BGL deprecation #80730
For 2.91 we refactored the whole GPU module to be ready for vulkan. In this process we added a state tracking mechanism which removes unneeded state changes by only pushing the state before drawing commands.
The issue is that BGL does not make use of this and directly use the GL API which can lead to unsafe states.
The current workaround is to push the state to the GL before the callbacks loop starts and just force reset all states after the loop (see blender/blender@fe5efccd8f).
This is quite ugly since it does not prevent misusage of the BGL API with the pyGPU API (which is using our GPU module states).
So we have things to do here:
Polish the pyGPU API and force its usage everywhere: Impractical for 2.91 because there would be no transition period. But we do need to get started already since the API did change a little (see GPUOffscreen). A refactor is in the process here D8826. This is the long term plan.blender/blender@4430e8a008 Make wrappers inside the BGL module to make theblender/blender@f12b0373f3
GPUStateundefined if calling a function that modifies it: This would trigger a special path inside
gl_state.ccwhere the state would be ignored. This should fix some of the API mixing issues.
- ~~But we also need to push the state for commands that need it (like
glReadPixels, ...). ~~ blender/blender@f12b0373f3
The last remaining issue is our resource binding check that needs to be disable because incompatible with theblender/blender@f12b0373f3
glUniform + glBindTextureidiom (we now use internal fixed binding points).
We still have to figure how to mitigate:
Current framebuffer state: calling(Resolved with python's
glBindFramebuffer(GL_FRAMEBUFFER, id)will break the state tracking.
withstatement forcing a context specific block. See blender/blender@4430e8a008)
- Current bound program state: calling
glUseProgam(program)will break the state tracking.
- ... (any other?)
Other issues with pyGPU:
- There are still functions to get the raw GL handle for some object (Shader/Texture). Deprecate them.
- GPUOffscreen / GPUFramebuffer now always store/resets their own Viewport/Scissor bounds. Document the API change.
Addons and scripts using the bgl module:
- archimesh (
- curve_assign_shapekey.py (
- curve_tools (
- greasepencil_tools (
- io_mesh_uv_layout (
- magic_uv (
- measureit (
- node_wrangler.py (
- object_carver (
- object_collection_manager (
- object_scatter (
- power_sequencer (
- precision_drawing_tools (
- space_view3d_math_vis (
- sun_position (
- viewport_vr_preview.py (
- archimesh (
Changed status from 'Needs Triage' to: 'Confirmed'
So all the same abilities - (grab texture ID - replace with new Texture using py - will be abstracted now like the draw calls in order to be restored?)
Once D8826: Python: gpu module: add new submodules and types is committed, this task should be updated to reflect the current status.
Besides taking care of any remaining known API issues and documenting the new APIs, I think we should also involve the community. Once we are ready for it, I suggest to:
- Create a task with the list of add-ons that needs to be updated, and get the community to help with this
- Create a devtalk thread to gather feedback
This issue was referenced by blender/blender@4430e8a008
This issue was referenced by
This issue was referenced by blender/blender@1a627d528c
So, which release is BGL actually going to be removed for? And why was object_collection_manager removed from the list?
In #80730#1420991, @Imaginer wrote:
So, which release is BGL actually going to be removed for?
Probably in 3.4 (along with the Metal stand support)
And why was object_collection_manager removed from the list?
It doesn't look like this addon has ever used
bgl, it seems like it was a mistake to add it to the list.
It doesn't look like this addon has ever used bgl, it seems like it was a mistake to add it to the list.
No, it uses
bgl fairly extensively in
qcd_move_widget.py (I should know, I'm the author 😛 )
I've been waiting to update it to use the pyGPU API for a number of reasons, but if it's official that
bgl is being removed for 3.4 then I'll update it.
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?