Fix T52591: OpenColorIO not working correct with OpenGL core profile on macOS.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 30 Aug 2017 16:28:33 +0000 (18:28 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 30 Aug 2017 17:59:07 +0000 (19:59 +0200)
Also remove textureSize() replacement code, is always supported now.

intern/opencolorio/gpu_shader_display_transform.glsl
intern/opencolorio/ocio_impl_glsl.cc

index ae0c524300dcf785cacc243d5e90e63175e85afa..f1dca04b823bfd0a56d75730dd38b0ec0a97142b 100644 (file)
@@ -5,11 +5,6 @@ uniform sampler3D lut3d_texture;
 uniform float dither;
 #endif
 
-#ifdef USE_TEXTURE_SIZE
-uniform float image_texture_width;
-uniform float image_texture_height;
-#endif
-
 in vec2 texCoord_interp;
 out vec4 fragColor;
 
@@ -122,11 +117,7 @@ float dither_random_value(vec2 co)
 vec2 round_to_pixel(vec2 st)
 {
        vec2 result;
-#ifdef USE_TEXTURE_SIZE
-       vec2 size = vec2(image_texture_width, image_texture_height);
-#else
        vec2 size = textureSize(image_texture, 0);
-#endif
        result.x = float(int(st.x * size.x)) / size.x;
        result.y = float(int(st.y * size.y)) / size.y;
        return result;
index c8b64f7244053c90efce214819321f55bb46b2e1..6d634da04773b60fe2bef36274ec49afccb93116 100644 (file)
@@ -85,8 +85,6 @@ typedef struct OCIO_GLSLDrawState {
 
        bool predivide_used;
 
-       bool texture_size_used;
-
        /* Cache */
        std::string lut3dcacheid;
        std::string shadercacheid;
@@ -240,17 +238,6 @@ bool OCIOImpl::supportGLSLDraw()
        return GLEW_VERSION_3_0 || GLEW_ARB_texture_float;
 }
 
-static bool supportGLSL13()
-{
-       const char *version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
-       int major = 1, minor = 0;
-
-       if (version && sscanf(version, "%d.%d", &major, &minor) == 2)
-               return (major > 1 || (major == 1 && minor >= 30));
-
-       return false;
-}
-
 /**
  * Setup OpenGL contexts for a transform defined by processor using GLSL
  * All LUT allocating baking and shader compilation happens here.
@@ -353,13 +340,7 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
                /* Vertex shader */
                std::ostringstream osv;
 
-               if (supportGLSL13()) {
-                       osv << "#version 330\n";
-               }
-               else {
-                       osv << "#version 120\n";
-               }
-
+               osv << "#version 330\n";
                osv << datatoc_gpu_shader_display_transform_vertex_glsl;
 
                state->vert_shader = compileShaderText(GL_VERTEX_SHADER, osv.str().c_str());
@@ -367,13 +348,11 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
                /* Fragment shader */
                std::ostringstream os;
 
-               if (supportGLSL13()) {
-                       os << "#version 330\n";
-               }
-               else {
-                       os << "#define USE_TEXTURE_SIZE\n";
-                       state->texture_size_used = use_dither;
-               }
+               os << "#version 330\n";
+
+               /* Work around OpenColorIO not supporting latest GLSL yet. */
+               os << "#define texture2D texture\n";
+               os << "#define texture3D texture\n";
 
                if (use_predivide) {
                        os << "#define USE_PREDIVIDE\n";
@@ -432,18 +411,6 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
                immUniform1i("image_texture", 0);
                immUniform1i("lut3d_texture", 1);
 
-               if (state->texture_size_used) {
-                       /* we use textureSize() if possible for best performance, if not
-                        * supported we query the size and pass it as uniform variables */
-                       GLint width, height;
-
-                       glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
-                       glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
-
-                       immUniform1f("image_texture_width", (float)width);
-                       immUniform1f("image_texture_height", (float)height);
-               }
-
                if (use_dither) {
                        immUniform1f("dither", dither);
                }