[Bf-blender-cvs] [87328bd] master: Fix T45218: Crash when trying to open System in the User preferences Fix T45381: Crash Blender 2.75 in Win7 x64 AMD card

Sergey Sharybin noreply at git.blender.org
Mon Jul 20 12:50:52 CEST 2015


Commit: 87328bde478ba77db4387530c39d21c62c2c0d20
Author: Sergey Sharybin
Date:   Mon Jul 20 11:08:50 2015 +0200
Branches: master
https://developer.blender.org/rB87328bde478ba77db4387530c39d21c62c2c0d20

Fix T45218: Crash when trying to open System in the User preferences
Fix T45381: Crash Blender 2.75 in Win7 x64 AMD card

The issue is basically caused by graphics card driver which crashes when
querying OpenCL platforms. This isn't something we can really solve from
the CLEW side, because opencl.dll does exist in old driver and even has
all the needed symbols, but first ever call to clGetPlatformIDs crashes.

While rest of the blender works fine with those older ATI/AMD cards it's
really needed to solve crashes of OpenCL device enumeration.

Solution here is to force disable OpenCL platforms if we've detected that
display card is using old ATI/AMD driver. It's not really proper solution
so it's done in the python side where it's easy to do tweaks. Reasoning
behind this change is:

- If one uses really old driver it's likely because it's the latest one
  he/she can ever to install (because of discontinued support from AMD).

- If old card is used it's likely to not have dedicated GPUs for rendering.

- Even if there's a dedicated GPU device enumeration is likely to crash
  because of attempt to query OpenCL from the old card.

There are still some tweaks needed likely, but this commit should make
some of the configurations to work.

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

M	intern/cycles/blender/addon/engine.py

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

diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 4187e23..db81cbb 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -17,11 +17,55 @@
 # <pep8 compliant>
 
 
+def _is_using_buggy_driver():
+    import bgl
+    # We need to be conservative here because in multi-GPU systems display card
+    # might be quite old, but others one might be just good.
+    #
+    # So We shouldn't disable possible good dedicated cards just because display
+    # card seems weak. And instead we only blacklist configurations which are
+    # proven to cause problems.
+    if bgl.glGetString(bgl.GL_VENDOR) == "ATI Technologies Inc.":
+        import re
+        version = bgl.glGetString(bgl.GL_VERSION)
+        if version.endswith("Compatibility Profile Context"):
+            # Old HD 4xxx and 5xxx series drivers did not have driver version
+            # in the version string, but thsoe cards do not quite work and
+            # cusing crashes.
+            return True
+        regex = re.compile(".*Compatibility Profile Context ([0-9]+(\.[0-9]+)+)$")
+        if not regex.match(version):
+            # Skip cards like FireGL
+            return False
+        version = regex.sub("\\1", version).split('.')
+        return int(version[0]) == 8
+    return False
+
+
+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"
+
 def init():
     import bpy
     import _cycles
     import os.path
 
+    # Workaroud posibly buggy legacy drivers which crashes on the OpenCL
+    # device enumeration.
+    #
+    # This checks are not really correct because they might still fail
+    # in the case of multiple GPUs. However, currently buggy drivers
+    # are really old and likely to be used in single GPU systems only
+    # anyway.
+    #
+    # Can't do it in the background mode, so we hope OpenCL is no enabled
+    # in the user preferences.
+    if not bpy.app.background:
+        _workaround_buggy_drivers()
+
     path = os.path.dirname(__file__)
     user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))




More information about the Bf-blender-cvs mailing list