[Bf-blender-cvs] [cb986446e29] blender-v3.1-release: Fix Crash: Switching to wireframe mode.

Jeroen Bakker noreply at git.blender.org
Fri Feb 4 14:04:51 CET 2022


Commit: cb986446e29a51b07bdb73b999a0339df5ecdeb4
Author: Jeroen Bakker
Date:   Fri Feb 4 14:00:06 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBcb986446e29a51b07bdb73b999a0339df5ecdeb4

Fix Crash: Switching to wireframe mode.

Crash introduced by {rB0cb5eae}.

When switching to between drawing modes the region.draw_buffer could be
uninitialized when the gizmo depth test is performed. When the mouse is
placed on top of a gizmo part that could be highlighted would crash.

This fix adds a early exit when depth testing is requested, but there
isn't a draw_buffer. Not sure this is an root cause fix.

Reported by multiple animators in Blender Studio.

===================================================================

M	source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c

===================================================================

diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index e61de28d0a4..ab955a9e233 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -596,6 +596,14 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
                                    /* Fast-path (occlusion queries). */
                                    GPU_SELECT_ALL);
 
+  /* When switching between modes and the mouse pointer is over a gizmo, the highlight test is
+   * performed before the viewport is fully initialized (region->draw_buffer = NULL).
+   * When this is the case we should not use depth testing. */
+  GPUViewport *gpu_viewport = WM_draw_region_get_viewport(region);
+  if (use_depth_test && gpu_viewport == NULL) {
+    return -1;
+  }
+
   if (GPU_select_is_cached()) {
     GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, gpu_select_mode, 0);
     GPU_select_cache_load_id();
@@ -613,8 +621,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
      * because all future passes the will use the cached depths. */
     GPUFrameBuffer *depth_read_fb = NULL;
     if (use_depth_test) {
-      GPUViewport *viewport = WM_draw_region_get_viewport(CTX_wm_region(C));
-      GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport);
+      GPUTexture *depth_tx = GPU_viewport_depth_texture(gpu_viewport);
       GPU_framebuffer_ensure_config(&depth_read_fb,
                                     {
                                         GPU_ATTACHMENT_TEXTURE(depth_tx),



More information about the Bf-blender-cvs mailing list