OpenSubdiv: Avoid having bad-level call

This is always asking for problems. Additionally, that call was leading
to OpenGL calls happening from threads.
This commit is contained in:
Sergey Sharybin 2015-12-18 23:16:52 +05:00
parent 672f2efbe6
commit 82921ce420
4 changed files with 14 additions and 6 deletions

@ -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)));

@ -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
}

@ -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;
}

@ -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);
}