OpenSubdiv: Remove redundant section define from shader compilation
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 16 Sep 2016 10:28:06 +0000 (12:28 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 16 Sep 2016 10:28:35 +0000 (12:28 +0200)
intern/opensubdiv/opensubdiv_gpu_capi.cc

index da4a937540dc1e6b9f33e5080aff255bafc78ace..c36eaae1c6e5cd2927788353e20f04479359e8ce 100644 (file)
@@ -208,26 +208,23 @@ struct OpenSubdiv_GLMeshFVarData
 namespace {
 
 GLuint compileShader(GLenum shaderType,
-                     const char *section,
                      const char *version,
                      const char *define,
                      const char *source)
 {
-       char sdefine[64];
-       sprintf(sdefine, "#define %s\n", section);
-
        const char *sources[] = {
                version,
                define,
-               sdefine,
 #ifdef SUPPORT_COLOR_MATERIAL
                "#define SUPPORT_COLOR_MATERIAL\n",
+#else
+               "",
 #endif
                source,
        };
 
        GLuint shader = glCreateShader(shaderType);
-       glShaderSource(shader, 5, sources, NULL);
+       glShaderSource(shader, 4, sources, NULL);
        glCompileShader(shader);
 
        GLint status;
@@ -235,7 +232,7 @@ GLuint compileShader(GLenum shaderType,
        if (status == GL_FALSE) {
                GLchar emsg[1024];
                glGetShaderInfoLog(shader, sizeof(emsg), 0, emsg);
-               fprintf(stderr, "Error compiling GLSL %s: %s\n", section, emsg);
+               fprintf(stderr, "Error compiling GLSL: %s\n", emsg);
                fprintf(stderr, "Version: %s\n", version);
                fprintf(stderr, "Defines: %s\n", define);
                fprintf(stderr, "Source: %s\n", source);
@@ -248,7 +245,6 @@ GLuint compileShader(GLenum shaderType,
 GLuint linkProgram(const char *version, const char *define)
 {
        GLuint vertexShader = compileShader(GL_VERTEX_SHADER,
-                                           "VERTEX_SHADER",
                                            version,
                                            define,
                                            datatoc_gpu_shader_opensubdiv_vertex_glsl);
@@ -256,7 +252,6 @@ GLuint linkProgram(const char *version, const char *define)
                return 0;
        }
        GLuint geometryShader = compileShader(GL_GEOMETRY_SHADER,
-                                             "GEOMETRY_SHADER",
                                              version,
                                              define,
                                              datatoc_gpu_shader_opensubdiv_geometry_glsl);
@@ -264,7 +259,6 @@ GLuint linkProgram(const char *version, const char *define)
                return 0;
        }
        GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER,
-                                             "FRAGMENT_SHADER",
                                              version,
                                              define,
                                              datatoc_gpu_shader_opensubdiv_fragment_glsl );