Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2015-12-07 02:47:58 +0300
committerMike Erwin <significant.bit@gmail.com>2015-12-07 02:47:58 +0300
commita048d5f945be217c0c3e90cb716bf6bb7c267097 (patch)
tree53958fec97a9d842f77247f0461ee7ab82a00640
parent50df05c35cca2f26f613f3d44dd3175852da2f78 (diff)
OpenSubdiv: refine OpenGL version & extension checks
Use new GPU_legacy_support() function. Determine GLSL version once instead of per shader. For Texture Buffers, allow ARB or EXT version of the extension. Either one will do.
-rw-r--r--intern/opensubdiv/gpu_shader_opensubd_display.glsl3
-rw-r--r--intern/opensubdiv/opensubdiv_capi.cc7
-rw-r--r--intern/opensubdiv/opensubdiv_capi.h2
-rw-r--r--intern/opensubdiv/opensubdiv_gpu_capi.cc51
4 files changed, 39 insertions, 24 deletions
diff --git a/intern/opensubdiv/gpu_shader_opensubd_display.glsl b/intern/opensubdiv/gpu_shader_opensubd_display.glsl
index 57bbfa89714..51e8ed46c34 100644
--- a/intern/opensubdiv/gpu_shader_opensubd_display.glsl
+++ b/intern/opensubdiv/gpu_shader_opensubd_display.glsl
@@ -70,7 +70,8 @@ void main()
#if __VERSION__ < 140
#extension GL_ARB_uniform_buffer_object: require
- #extension GL_ARB_texture_buffer_object: require
+ #extension GL_ARB_texture_buffer_object: enable
+ #extension GL_EXT_texture_buffer_object: enable
#endif
uniform mat4 modelViewMatrix;
diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
index f715bf32565..6c226d6cf6b 100644
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ b/intern/opensubdiv/opensubdiv_capi.cc
@@ -296,8 +296,9 @@ const struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_getGLMeshTopologyRefine
int openSubdiv_supportGPUDisplay(void)
{
// TODO: simplify extension check once Blender adopts GL 3.2
- return (GLEW_VERSION_3_2 && GLEW_ARB_compatibility) ||
- (GLEW_VERSION_3_1 && GLEW_ARB_compatibility && GLEW_EXT_geometry_shader4) ||
- (GLEW_VERSION_3_0 && GLEW_EXT_geometry_shader4 && GLEW_ARB_uniform_buffer_object && GLEW_ARB_texture_buffer_object);
+ return 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)));
/* also ARB_explicit_attrib_location? */
}
diff --git a/intern/opensubdiv/opensubdiv_capi.h b/intern/opensubdiv/opensubdiv_capi.h
index 8010c39647d..9d1c1b3795c 100644
--- a/intern/opensubdiv/opensubdiv_capi.h
+++ b/intern/opensubdiv/opensubdiv_capi.h
@@ -144,6 +144,8 @@ int openSubdiv_getAvailableEvaluators(void);
void openSubdiv_init(void);
void openSubdiv_cleanup(void);
+extern bool GPU_legacy_support(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc b/intern/opensubdiv/opensubdiv_gpu_capi.cc
index fc46ad05f53..cbde06b9082 100644
--- a/intern/opensubdiv/opensubdiv_gpu_capi.cc
+++ b/intern/opensubdiv/opensubdiv_gpu_capi.cc
@@ -186,24 +186,12 @@ void transpose_m3(float mat[3][3])
GLuint compileShader(GLenum shaderType,
const char *section,
+ const char *version,
const char *define)
{
char sdefine[64];
sprintf(sdefine, "#define %s\n", section);
- const char *version;
- if (GLEW_VERSION_3_2 && GLEW_ARB_compatibility) {
- version = "#version 150 compatibility\n";
- }
- else if (GLEW_VERSION_3_1 && GLEW_ARB_compatibility) {
- version = "#version 140\n"
- "#extension GL_ARB_compatibility: enable\n";
- }
- else if (GLEW_VERSION_3_0) {
- version = "#version 130\n";
- /* minimum supported for OpenSubdiv */
- }
-
const char *sources[] = {
version,
define,
@@ -230,22 +218,25 @@ GLuint compileShader(GLenum shaderType,
return shader;
}
-GLuint linkProgram(const char *define)
+GLuint linkProgram(const char *version, const char *define)
{
GLuint vertexShader = compileShader(GL_VERTEX_SHADER,
"VERTEX_SHADER",
+ version,
define);
if (vertexShader == 0) {
return 0;
}
GLuint geometryShader = compileShader(GL_GEOMETRY_SHADER,
"GEOMETRY_SHADER",
+ version,
define);
if (geometryShader == 0) {
return 0;
}
GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER,
"FRAGMENT_SHADER",
+ version,
define);
if (fragmentShader == 0) {
return 0;
@@ -261,7 +252,7 @@ GLuint linkProgram(const char *define)
glBindAttribLocation(program, 1, "normal");
- if (!(GLEW_VERSION_3_2 && GLEW_ARB_compatibility)) {
+ if (!GLEW_VERSION_3_2) {
/* provide input/output layout info */
glProgramParameteriEXT(program,
GL_GEOMETRY_INPUT_TYPE_EXT,
@@ -381,11 +372,31 @@ bool openSubdiv_osdGLDisplayInit(void)
static bool need_init = true;
static bool init_success = false;
if (need_init) {
- g_flat_fill_solid_program = linkProgram("#define FLAT_SHADING\n");
- g_flat_fill_texture2d_program = linkProgram("#define USE_TEXTURE_2D\n#define FLAT_SHADING\n");
- g_smooth_fill_solid_program = linkProgram("#define SMOOTH_SHADING\n");
- g_smooth_fill_texture2d_program = linkProgram("#define USE_TEXTURE_2D\n#define SMOOTH_SHADING\n");
- g_wireframe_program = linkProgram("#define WIREFRAME\n");
+
+ if (!openSubdiv_supportGPUDisplay()) {
+ return false;
+ }
+
+ const char *version = "";
+ if (GLEW_VERSION_3_2) {
+ version = "#version 150 compatibility\n";
+ }
+ else if (GLEW_VERSION_3_1) {
+ version = "#version 140\n"
+ "#extension GL_ARB_compatibility: enable\n";
+ }
+ else {
+ version = "#version 130\n";
+ /* minimum supported for OpenSubdiv */
+ }
+
+ fprintf(stderr, version);
+
+ g_flat_fill_solid_program = linkProgram(version, "#define FLAT_SHADING\n");
+ g_flat_fill_texture2d_program = linkProgram(version, "#define USE_TEXTURE_2D\n#define FLAT_SHADING\n");
+ g_smooth_fill_solid_program = linkProgram(version, "#define SMOOTH_SHADING\n");
+ g_smooth_fill_texture2d_program = linkProgram(version, "#define USE_TEXTURE_2D\n#define SMOOTH_SHADING\n");
+ g_wireframe_program = linkProgram(version, "#define WIREFRAME\n");
glGenBuffers(1, &g_lighting_ub);
glBindBuffer(GL_UNIFORM_BUFFER, g_lighting_ub);