OpenSubdiv: Avoid having bad-level call
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 18 Dec 2015 18:16:52 +0000 (23:16 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 18 Dec 2015 18:16:52 +0000 (23:16 +0500)
This is always asking for problems. Additionally, that call was leading
to OpenGL calls happening from threads.

intern/opensubdiv/opensubdiv_capi.cc
intern/opensubdiv/opensubdiv_capi.h
intern/opensubdiv/opensubdiv_utils_capi.cc
source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c

index 6c226d6cf6b263c9196f2ef3749b9b858f99b914..9b9f4baa39e7ffca523931ed3141b6aacaee763c 100644 (file)
@@ -296,7 +296,7 @@ const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefine
 int openSubdiv_supportGPUDisplay(void)
 {
        // TODO: simplify extension check once Blender adopts GL 3.2
-       return GPU_legacy_support() &&
+       return openSubdiv_gpu_legacy_support() &&
               (GLEW_VERSION_3_2 ||
               (GLEW_VERSION_3_1 && GLEW_EXT_geometry_shader4) ||
               (GLEW_VERSION_3_0 && GLEW_EXT_geometry_shader4 && GLEW_ARB_uniform_buffer_object && (GLEW_ARB_texture_buffer_object || GLEW_EXT_texture_buffer_object)));
index 9d1c1b3795cb8725da3bc027658700034c5b9107..b40505b197d074326432f2ef42a85f383f93ff50 100644 (file)
@@ -141,10 +141,9 @@ void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh,
 /* ** Utility functions ** */
 int openSubdiv_supportGPUDisplay(void);
 int openSubdiv_getAvailableEvaluators(void);
-void openSubdiv_init(void);
+void openSubdiv_init(bool gpu_legacy_support);
 void openSubdiv_cleanup(void);
-
-extern bool GPU_legacy_support(void);
+bool openSubdiv_gpu_legacy_support(void);
 
 #ifdef __cplusplus
 }
index c993e347587810b8836c8cd7ec826543c91cba8c..ae5592367dd96d037050382f7d2f3f0098df4440 100644 (file)
@@ -41,6 +41,8 @@
 #  include "opensubdiv_device_context_cuda.h"
 #endif  /* OPENSUBDIV_HAS_CUDA */
 
+static bool gpu_legacy_support_global = false;
+
 int openSubdiv_getAvailableEvaluators(void)
 {
        if (!openSubdiv_supportGPUDisplay()) {
@@ -80,13 +82,19 @@ int openSubdiv_getAvailableEvaluators(void)
        return flags;
 }
 
-void openSubdiv_init(void)
+void openSubdiv_init(bool gpu_legacy_support)
 {
        /* Ensure all OpenGL strings are cached. */
        (void)openSubdiv_getAvailableEvaluators();
+       gpu_legacy_support_global = gpu_legacy_support;
 }
 
 void openSubdiv_cleanup(void)
 {
        openSubdiv_osdGLDisplayDeinit();
 }
+
+bool openSubdiv_gpu_legacy_support(void)
+{
+       return gpu_legacy_support_global;
+}
index 0f61a50ed13966ea4187dc4525b087bae4b3ec75..2bb55c2d1ed36b3360ed54eb24b000512b88fa56 100644 (file)
@@ -44,6 +44,7 @@
 #include "opensubdiv_converter_capi.h"
 
 #include "GL/glew.h"
+#include "GPU_extensions.h"
 
 #define OSD_LOG if (false) printf
 
@@ -987,7 +988,7 @@ void ccgSubSurf__delete_pending(void)
 
 void BKE_subsurf_osd_init(void)
 {
-       openSubdiv_init();
+       openSubdiv_init(GPU_legacy_support());
        BLI_spin_init(&delete_spin);
 }