[Bf-blender-cvs] [1788293] master: Fix T45381: Crash Blender 2.75 in Win7 x64 AMD card

Sergey Sharybin noreply at git.blender.org
Thu Jul 23 12:13:51 CEST 2015


Commit: 1788293a0125e178cf7cbea60113ae7d81749cbe
Author: Sergey Sharybin
Date:   Thu Jul 23 12:08:19 2015 +0200
Branches: master
https://developer.blender.org/rB1788293a0125e178cf7cbea60113ae7d81749cbe

Fix T45381: Crash Blender 2.75 in Win7 x64 AMD card

Previous fix didn't work well enough because on Windows Python has different
environment than Blender ans setting variables in there made no effect from
Blender point of view.

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

M	intern/cycles/blender/addon/engine.py
M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/device/device_opencl.cpp

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

diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index db81cbb..c936b90 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -44,9 +44,10 @@ def _is_using_buggy_driver():
 
 def _workaround_buggy_drivers():
     if _is_using_buggy_driver():
-        import os
-        print("Cycles: OpenGL driver known to be buggy, disabling OpenCL platform.")
-        os.environ["CYCLES_OPENCL_TEST"] = "NONE"
+        import _cycles
+        if hasattr(_cycles, "opencl_disable"):
+            print("Cycles: OpenGL driver known to be buggy, disabling OpenCL platform.")
+            _cycles.opencl_disable()
 
 def init():
     import bpy
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 200003f..5da018e 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -22,6 +22,7 @@
 #include "blender_session.h"
 
 #include "util_foreach.h"
+#include "util_logging.h"
 #include "util_md5.h"
 #include "util_opengl.h"
 #include "util_path.h"
@@ -486,6 +487,15 @@ static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
 	return PyUnicode_FromString(system_info.c_str());
 }
 
+#ifdef WITH_OPENCL
+static PyObject *opencl_disable_func(PyObject * /*self*/, PyObject * /*value*/)
+{
+	VLOG(2) << "Disabling OpenCL platform.";
+	setenv("CYCLES_OPENCL_TEST", "NONE", 1);
+	Py_RETURN_NONE;
+}
+#endif
+
 static PyMethodDef methods[] = {
 	{"init", init_func, METH_VARARGS, ""},
 	{"create", create_func, METH_VARARGS, ""},
@@ -501,6 +511,9 @@ static PyMethodDef methods[] = {
 #endif
 	{"available_devices", available_devices_func, METH_NOARGS, ""},
 	{"system_info", system_info_func, METH_NOARGS, ""},
+#ifdef WITH_OPENCL
+	{"opencl_disable", opencl_disable_func, METH_NOARGS, ""},
+#endif
 	{NULL, NULL, 0, NULL},
 };
 
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 2a596a2..0cc49e8 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -3610,16 +3610,22 @@ bool device_opencl_init(void)
 
 	initialized = true;
 
-	int clew_result = clewInit();
-	if(clew_result == CLEW_SUCCESS) {
-		VLOG(1) << "CLEW initialization succeeded.";
-		result = true;
+	if(opencl_device_type() != 0) {
+		int clew_result = clewInit();
+		if(clew_result == CLEW_SUCCESS) {
+			VLOG(1) << "CLEW initialization succeeded.";
+			result = true;
+		}
+		else {
+			VLOG(1) << "CLEW initialization failed: "
+			        << ((clew_result == CLEW_ERROR_ATEXIT_FAILED)
+			            ? "Error setting up atexit() handler"
+			            : "Error opening the library");
+		}
 	}
 	else {
-		VLOG(1) << "CLEW initialization failed: "
-		        << ((clew_result == CLEW_ERROR_ATEXIT_FAILED)
-		            ? "Error setting up atexit() handler"
-		            : "Error opening the library");
+		VLOG(1) << "Skip initializing CLEW, platform is force disabled.";
+		result = false;
 	}
 
 	return result;




More information about the Bf-blender-cvs mailing list