diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc index 997088ac1ff..80c8ecb9819 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc @@ -519,9 +519,16 @@ static void gizmo_draw_select_3d_loop(const bContext *C, const int visible_gizmos_len, bool *r_use_select_bias) { + /* WORKAROUND(#132196): `GPU_DEPTH_NONE` leads to issues with Intel GPU drivers on Windows + * where camera gizmos cannot be shifted. `glGetQueryObjectuiv` for `GL_SAMPLES_PASSED` + * seems to return zero in all cases. This might be due to undefined behavior of OpenGL + * when the depth test is disabled and rendering to a depth render target-only framebuffer. + * Using `GPU_DEPTH_ALWAYS` fixes the issue. */ + const bool use_intel_gpu_workaround = true; - /* TODO(@ideasman42): this depends on depth buffer being written to, - * currently broken for the 3D view. */ + /* Set default depth state. */ + GPU_depth_test(use_intel_gpu_workaround ? GPU_DEPTH_ALWAYS : GPU_DEPTH_NONE); + GPU_depth_mask(true); bool is_depth_prev = false; bool is_depth_skip_prev = false; @@ -540,12 +547,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C, GPU_depth_test(GPU_DEPTH_LESS_EQUAL); } else { - /* WORKAROUND(#132196): `GPU_DEPTH_NONE` leads to issues with Intel GPU drivers on Windows - * where camera gizmos cannot be shifted. `glGetQueryObjectuiv` for `GL_SAMPLES_PASSED` - * seems to return zero in all cases. This might be due to undefined behavior of OpenGL - * when the depth test is disabled and rendering to a depth render target-only framebuffer. - * Using `GPU_DEPTH_ALWAYS` fixes the issue. */ - GPU_depth_test(GPU_DEPTH_ALWAYS); + GPU_depth_test(use_intel_gpu_workaround ? GPU_DEPTH_ALWAYS : GPU_DEPTH_NONE); } is_depth_prev = is_depth; } @@ -567,7 +569,9 @@ static void gizmo_draw_select_3d_loop(const bContext *C, gz->type->draw_select(C, gz, select_id << 8); } - if (is_depth_prev) { + /* Reset depth state.*/ + + if (is_depth_prev || use_intel_gpu_workaround) { GPU_depth_test(GPU_DEPTH_NONE); } if (is_depth_skip_prev) {