[Bf-blender-cvs] [82921ce] master: OpenSubdiv: Avoid having bad-level call

Sergey Sharybin noreply at git.blender.org
Fri Dec 18 19:18:04 CET 2015


Commit: 82921ce42002901791d786890c232dc6768c8e62
Author: Sergey Sharybin
Date:   Fri Dec 18 23:16:52 2015 +0500
Branches: master
https://developer.blender.org/rB82921ce42002901791d786890c232dc6768c8e62

OpenSubdiv: Avoid having bad-level call

This is always asking for problems. Additionally, that call was leading
to OpenGL calls happening from threads.

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

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

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

diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
index 6c226d6..9b9f4ba 100644
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ b/intern/opensubdiv/opensubdiv_capi.cc
@@ -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)));
diff --git a/intern/opensubdiv/opensubdiv_capi.h b/intern/opensubdiv/opensubdiv_capi.h
index 9d1c1b3..b40505b 100644
--- a/intern/opensubdiv/opensubdiv_capi.h
+++ b/intern/opensubdiv/opensubdiv_capi.h
@@ -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
 }
diff --git a/intern/opensubdiv/opensubdiv_utils_capi.cc b/intern/opensubdiv/opensubdiv_utils_capi.cc
index c993e34..ae55923 100644
--- a/intern/opensubdiv/opensubdiv_utils_capi.cc
+++ b/intern/opensubdiv/opensubdiv_utils_capi.cc
@@ -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;
+}
diff --git a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
index 0f61a50..2bb55c2 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c
@@ -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);
 }




More information about the Bf-blender-cvs mailing list