[Bf-blender-cvs] [67c13974e38] cycles-x: Fix Cycles X crash when GPUDisplay OpenGL context is failed to be created

Sergey Sharybin noreply at git.blender.org
Thu Sep 9 18:26:07 CEST 2021


Commit: 67c13974e38cb74bf4d43d859f0e57defe73bafb
Author: Sergey Sharybin
Date:   Thu Sep 9 18:25:12 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB67c13974e38cb74bf4d43d859f0e57defe73bafb

Fix Cycles X crash when GPUDisplay OpenGL context is failed to be created

Better to display empty render result while rendering than to crash
and loose data.

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

M	intern/cycles/blender/blender_gpu_display.cpp

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

diff --git a/intern/cycles/blender/blender_gpu_display.cpp b/intern/cycles/blender/blender_gpu_display.cpp
index 3bcd44f2aa2..48c7f67087f 100644
--- a/intern/cycles/blender/blender_gpu_display.cpp
+++ b/intern/cycles/blender/blender_gpu_display.cpp
@@ -494,11 +494,18 @@ void BlenderGPUDisplay::gl_context_create()
   const bool drw_state = DRW_opengl_context_release();
 
   gl_context_ = WM_opengl_context_create_from_thread();
-  if (!gl_context_) {
+
+  if (gl_context_) {
+    /* Context creation leaves it active. Need to release it so that it can be bound from another
+     * thread. */
+    /* TODO(sergey): Need to look again into it: seems on Windoes this generates invalid handle
+     * error in `wglMakeCurrent()`. */
+    WM_opengl_context_release(gl_context_);
+  }
+  else {
     LOG(ERROR) << "Error creating OpenGL context.";
   }
 
-  WM_opengl_context_release(gl_context_);
   DRW_opengl_context_activate(drw_state);
 }



More information about the Bf-blender-cvs mailing list