Implement GL_EXT_shader_texture_lod.
authorJohn Kessenich <cepheus@frii.com>
Fri, 22 Nov 2013 17:30:34 +0000 (17:30 +0000)
committerJohn Kessenich <cepheus@frii.com>
Fri, 22 Nov 2013 17:30:34 +0000 (17:30 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24177 e7fa87d3-cd2b-0410-9028-fcbf551c1848

Install/Windows/glslangValidator.exe
Test/100.frag
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/Versions.cpp
glslang/MachineIndependent/Versions.h

index 1d66f7a..905b9de 100644 (file)
Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ
index 9daa026..abe3ed1 100644 (file)
@@ -140,13 +140,27 @@ void foo246()
 }\r
 \r
 #extension GL_OES_EGL_image_external : disable\r
+uniform sampler2D s2Dg;\r
 \r
 int foo203940(int a, float b, float a)  // ERROR, a redefined\r
 {\r
+    texture2DProjGradEXT(s2Dg, vec3(f13), uv2, uv2);  // ERROR, extension not enabled\r
     return a;\r
 }\r
 \r
 float f123 = 4.0f;   // ERROR\r
 float f124 = 5e10F;  // ERROR\r
 \r
+#extension GL_EXT_shader_texture_lod : enable\r
+\r
+uniform samplerCube sCube;\r
+\r
+void foo323433()\r
+{\r
+    texture2DLodEXT(s2Dg, uv2, f13);\r
+    texture2DProjGradEXT(s2Dg, vec3(f13), uv2, uv2);\r
+    texture2DGradEXT(s2Dg, uv2, uv2, uv2);\r
+    textureCubeGradEXT(sCube, vec3(f13), vec3(f13), vec3(f13));\r
+}\r
+\r
 uniform samplerExternalOES badExt;  // syntax ERROR\r
index be3726f..d318239 100644 (file)
@@ -43,9 +43,9 @@
 //   TBuiltIns::initialize(version,profile)       context-independent textual built-ins; add them to the right string
 //   TBuiltIns::initialize(resources,...)         context-dependent textual built-ins; add them to the right string
 //   IdentifyBuiltIns(...,symbolTable)            context-independent programmatic additions/mappings to the symbol table,
-//                                                including identify what extensions are needed if a version does not allow a symbol
+//                                                including identifying what extensions are needed if a version does not allow a symbol
 //   IdentifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the symbol table,
-//                                                including identify what extensions are needed if a version does not allow a symbol
+//                                                including identifying what extensions are needed if a version does not allow a symbol
 //
 
 #include "../Include/intermediate.h"
@@ -648,7 +648,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
     }
 
     //
-    // Original-style texture functions existing in both stages.
+    // Original-style texture functions existing in all stages.
     // (Per-stage functions below.)
     //
     if ((profile == EEsProfile && version == 100) ||
@@ -686,12 +686,16 @@ void TBuiltIns::initialize(int version, EProfile profile)
             "\n");
     }
 
-    if (profile == EEsProfile) {
-        // GL_OES_EGL_image_external, caught by keyword check
+    if (profile == EEsProfile) {        
         commonBuiltins.append(
-            "vec4 texture2D(samplerExternalOES, vec2 coord);"
-            "vec4 texture2DProj(samplerExternalOES, vec3);"
-            "vec4 texture2DProj(samplerExternalOES, vec4);"
+            "vec4 texture2D(samplerExternalOES, vec2 coord);"  // GL_OES_EGL_image_external, caught by keyword check
+            "vec4 texture2DProj(samplerExternalOES, vec3);"    // GL_OES_EGL_image_external, caught by keyword check
+            "vec4 texture2DProj(samplerExternalOES, vec4);"    // GL_OES_EGL_image_external, caught by keyword check
+            "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);"      // GL_EXT_shader_texture_lod
+            "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);"  // GL_EXT_shader_texture_lod
+            "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);"  // GL_EXT_shader_texture_lod
+            "vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);"  // GL_EXT_shader_texture_lod
+
             "\n");
     }
 
@@ -857,6 +861,15 @@ void TBuiltIns::initialize(int version, EProfile profile)
             
             "\n");
     }
+    if (profile == EEsProfile) {
+        stageBuiltins[EShLangFragment].append(
+            "vec4 texture2DLodEXT(sampler2D, vec2, float);"      // GL_EXT_shader_texture_lod
+            "vec4 texture2DProjLodEXT(sampler2D, vec3, float);"  // GL_EXT_shader_texture_lod
+            "vec4 texture2DProjLodEXT(sampler2D, vec4, float);"  // GL_EXT_shader_texture_lod
+            "vec4 textureCubeLodEXT(samplerCube, vec3, float);"  // GL_EXT_shader_texture_lod
+            
+            "\n");
+    }
 
        stageBuiltins[EShLangFragment].append(
         "float dFdx(float p);"
@@ -2161,6 +2174,11 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
             symbolTable.setFunctionExtensions("dFdy",   1, &GL_OES_standard_derivatives);
             symbolTable.setFunctionExtensions("fwidth", 1, &GL_OES_standard_derivatives);
         }
+        if (profile == EEsProfile) {
+            symbolTable.setFunctionExtensions("texture2DLodEXT",     1, &GL_EXT_shader_texture_lod);
+            symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &GL_EXT_shader_texture_lod);
+            symbolTable.setFunctionExtensions("textureCubeLodEXT",   1, &GL_EXT_shader_texture_lod);
+        }
         symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &GL_EXT_frag_depth);
         break;
 
@@ -2173,9 +2191,15 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         break;
     }
 
+    if (profile == EEsProfile) {
+        symbolTable.setFunctionExtensions("texture2DGradEXT",     1, &GL_EXT_shader_texture_lod);
+        symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &GL_EXT_shader_texture_lod);
+        symbolTable.setFunctionExtensions("textureCubeGradEXT",   1, &GL_EXT_shader_texture_lod);
+    }
+
     //
-    // Next, identify which built-ins from the already loaded headers have
-    // a mapping to an operator.  Those that are not identified as such are
+    // Next, identify which built-ins have a mapping to an operator.
+    // Those that are not identified as such are
     // expected to be resolved through a library of functions, versus as
     // operations.
     //
index c86d4f3..36aa151 100644 (file)
@@ -153,6 +153,7 @@ void TParseContext::initializeExtensionBehavior()
     extensionBehavior[GL_OES_standard_derivatives]     = EBhDisable;
     extensionBehavior[GL_EXT_frag_depth]               = EBhDisable;
     extensionBehavior[GL_OES_EGL_image_external]       = EBhDisable;
+    extensionBehavior[GL_EXT_shader_texture_lod]       = EBhDisable;
 
     extensionBehavior[GL_ARB_texture_rectangle]        = EBhDisable;
     extensionBehavior[GL_3DL_array_objects]            = EBhDisable;
@@ -171,7 +172,8 @@ const char* TParseContext::getPreamble()
             "#define GL_OES_texture_3D 1\n"
             "#define GL_OES_standard_derivatives 1\n"
             "#define GL_EXT_frag_depth 1\n"
-            "#define GL_OES_EGL_image_external 1\n";
+            "#define GL_OES_EGL_image_external 1\n"
+            "#define GL_EXT_shader_texture_lod 1\n";
     } else {
         return
             "#define GL_FRAGMENT_PRECISION_HIGH 1\n"
index 0580cc9..3c8619d 100644 (file)
@@ -76,6 +76,7 @@ const char* const GL_OES_texture_3D               = "GL_OES_texture_3D";
 const char* const GL_OES_standard_derivatives     = "GL_OES_standard_derivatives";
 const char* const GL_EXT_frag_depth               = "GL_EXT_frag_depth";
 const char* const GL_OES_EGL_image_external       = "GL_OES_EGL_image_external";
+const char* const GL_EXT_shader_texture_lod       = "GL_EXT_shader_texture_lod";
 
 const char* const GL_ARB_texture_rectangle        = "GL_ARB_texture_rectangle";
 const char* const GL_3DL_array_objects            = "GL_3DL_array_objects";