Add GL_OES_EGL_image_external. Includes new keyword, type, name mangling, built...
authorJohn Kessenich <cepheus@frii.com>
Mon, 11 Nov 2013 23:29:59 +0000 (23:29 +0000)
committerJohn Kessenich <cepheus@frii.com>
Mon, 11 Nov 2013 23:29:59 +0000 (23:29 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24007 e7fa87d3-cd2b-0410-9028-fcbf551c1848

12 files changed:
Install/Windows/glslangValidator.exe
Test/100.frag
Test/baseResults/100.frag.out
glslang/Include/Types.h
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.h
glslang/MachineIndependent/Scan.cpp
glslang/MachineIndependent/SymbolTable.cpp
glslang/MachineIndependent/Versions.cpp
glslang/MachineIndependent/Versions.h
glslang/MachineIndependent/glslang.y

index 792c066..b647163 100644 (file)
Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ
index 57c5c88..a4dc798 100644 (file)
@@ -110,4 +110,31 @@ void foo239()
 {\r
     gl_FragDepth = f13;    // ERROR\r
     gl_FragDepthEXT = f13;\r
-}
\ No newline at end of file
+}\r
+\r
+#extension GL_OES_EGL_image_external : enable\r
+\r
+uniform samplerExternalOES sExt;\r
+\r
+void foo245()\r
+{\r
+    texture2D(sExt, vec2(0.2));\r
+    texture2DProj(sExt, vec3(f13));\r
+    texture2DProj(sExt, v[2]);\r
+}\r
+\r
+precision mediump samplerExternalOES;\r
+uniform samplerExternalOES mediumExt;\r
+uniform highp samplerExternalOES highExt;\r
+\r
+void foo246()\r
+{\r
+    texture2D(mediumExt, vec2(0.2));\r
+    texture2DProj(highExt, v[2]);\r
+    texture3D(sExt, vec3(f13));   // ERROR\r
+    texture2DProjLod(sExt, vec3(f13), f13);  // ERROR\r
+}\r
+\r
+#extension GL_OES_EGL_image_external : disable\r
+\r
+uniform samplerExternalOES badExt;  // syntax ERROR\r
index db43e6a..07dc987 100644 (file)
@@ -48,7 +48,10 @@ ERROR: 0:93: 'fwidth' : required extension not requested: GL_OES_standard_deriva
 ERROR: 0:103: 'gl_FragDepth' : undeclared identifier \r
 ERROR: 0:104: 'gl_FragDepthEXT' : required extension not requested: GL_EXT_frag_depth\r
 ERROR: 0:111: 'gl_FragDepth' : undeclared identifier \r
-ERROR: 43 compilation errors.  No code generated.\r
+ERROR: 0:134: 'texture3D' : no matching overloaded function found \r
+ERROR: 0:135: 'texture2DProjLod' : no matching overloaded function found \r
+ERROR: 0:140: '' :  syntax error\r
+ERROR: 46 compilation errors.  No code generated.\r
 \r
 ERROR: node is still EOpNull!\r
 0:3  Sequence\r
@@ -184,6 +187,42 @@ ERROR: node is still EOpNull!
 0:112      move second child to first child (highp float)\r
 0:112        'gl_FragDepthEXT' (gl_FragDepth highp float)\r
 0:112        'f13' (invariant mediump float)\r
+0:119  Function Definition: foo245( (void)\r
+0:119    Function Parameters: \r
+0:121    Sequence\r
+0:121      Function Call: texture2D(sE21;vf2; (lowp 4-component vector of float)\r
+0:121        'sExt' (uniform lowp samplerExternalOES)\r
+0:121        Constant:\r
+0:121          0.200000\r
+0:121          0.200000\r
+0:122      Function Call: texture2DProj(sE21;vf3; (lowp 4-component vector of float)\r
+0:122        'sExt' (uniform lowp samplerExternalOES)\r
+0:122        Construct vec3 (3-component vector of float)\r
+0:122          'f13' (invariant mediump float)\r
+0:123      Function Call: texture2DProj(sE21;vf4; (lowp 4-component vector of float)\r
+0:123        'sExt' (uniform lowp samplerExternalOES)\r
+0:123        direct index (smooth mediump 4-component vector of float)\r
+0:123          'v' (smooth in 3-element array of mediump 4-component vector of float)\r
+0:123          Constant:\r
+0:123            2 (const int)\r
+0:130  Function Definition: foo246( (void)\r
+0:130    Function Parameters: \r
+0:132    Sequence\r
+0:132      Function Call: texture2D(sE21;vf2; (mediump 4-component vector of float)\r
+0:132        'mediumExt' (uniform mediump samplerExternalOES)\r
+0:132        Constant:\r
+0:132          0.200000\r
+0:132          0.200000\r
+0:133      Function Call: texture2DProj(sE21;vf4; (highp 4-component vector of float)\r
+0:133        'highExt' (uniform highp samplerExternalOES)\r
+0:133        direct index (smooth mediump 4-component vector of float)\r
+0:133          'v' (smooth in 3-element array of mediump 4-component vector of float)\r
+0:133          Constant:\r
+0:133            2 (const int)\r
+0:134      Constant:\r
+0:134        0.000000\r
+0:135      Constant:\r
+0:135        0.000000\r
 0:?   Linker Objects\r
 0:?     'a' (3-element array of mediump int)\r
 0:?     'uint' (mediump int)\r
@@ -200,4 +239,7 @@ ERROR: node is still EOpNull!
 0:?     'vary2D' (smooth in lowp sampler2D)\r
 0:?     's3D' (uniform mediump sampler3D)\r
 0:?     's3D2' (uniform highp sampler3D)\r
+0:?     'sExt' (uniform lowp samplerExternalOES)\r
+0:?     'mediumExt' (uniform mediump samplerExternalOES)\r
+0:?     'highExt' (uniform highp samplerExternalOES)\r
 \r
index 330df77..1a74a4e 100644 (file)
@@ -65,6 +65,7 @@ struct TSampler {
     bool     shadow : 1;
     bool         ms : 1;
     bool      image : 1;
+    bool   external : 1;  // GL_OES_EGL_image_external
 
     void clear()
     {
@@ -74,6 +75,7 @@ struct TSampler {
         shadow = false;
         ms = false;
         image = false;
+        external = false;
     }
 
     void set(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
@@ -84,6 +86,7 @@ struct TSampler {
         shadow = s;
         ms = m;
         image = false;
+        external = false;
     }
 
     void setImage(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
@@ -94,6 +97,7 @@ struct TSampler {
         shadow = s;
         ms = m;
         image = true;
+        external = false;
     }
 
     bool operator==(const TSampler& right) const
@@ -103,7 +107,8 @@ struct TSampler {
             arrayed == right.arrayed &&
              shadow == right.shadow &&
                  ms == right.ms &&
-              image == right.image;
+              image == right.image &&
+           external == right.external;
     }
 
     TString getString() const
@@ -120,6 +125,10 @@ struct TSampler {
             s.append("image");
         else
             s.append("sampler");
+        if (external) {
+            s.append("ExternalOES");
+            return s;
+        }
         switch (dim) {
         case Esd1D:      s.append("1D");     break;
         case Esd2D:      s.append("2D");     break;
index 6c600b2..be3726f 100644 (file)
@@ -686,6 +686,15 @@ void TBuiltIns::initialize(int version, EProfile profile)
             "\n");
     }
 
+    if (profile == EEsProfile) {
+        // GL_OES_EGL_image_external, caught by keyword check
+        commonBuiltins.append(
+            "vec4 texture2D(samplerExternalOES, vec2 coord);"
+            "vec4 texture2DProj(samplerExternalOES, vec3);"
+            "vec4 texture2DProj(samplerExternalOES, vec4);"
+            "\n");
+    }
+
     //
     // Noise functions.
     //
index e9dc7b1..29c2112 100644 (file)
@@ -74,6 +74,9 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb,
         defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
         sampler.set(EbtFloat, EsdCube);
         defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
+        sampler.set(EbtFloat, Esd2D);
+        sampler.external = true;
+        defaultSamplerPrecision[computeSamplerTypeIndex(sampler)] = EpqLow;
 
         switch (language) {
         case EShLangFragment:
@@ -1715,10 +1718,11 @@ void TParseContext::setDefaultPrecision(TSourceLoc loc, TPublicType& publicType,
 // correlates with the declaration of defaultSamplerPrecision[]
 int TParseContext::computeSamplerTypeIndex(TSampler& sampler)
 {
-    int arrayIndex = sampler.arrayed ? 1 : 0;
-    int shadowIndex = sampler.shadow ? 1 : 0;
+    int arrayIndex   = sampler.arrayed   ? 1 : 0;
+    int shadowIndex   = sampler.shadow   ? 1 : 0;
+    int externalIndex = sampler.external ? 1 : 0;
 
-    return EsdNumDims * (EbtNumTypes * (2 * arrayIndex + shadowIndex) + sampler.type) + sampler.dim;
+    return EsdNumDims * (EbtNumTypes * (2 * (2 * arrayIndex + shadowIndex) + externalIndex) + sampler.type) + sampler.dim;
 }
 
 TPrecisionQualifier TParseContext::getDefaultPrecision(TPublicType& publicType)
index 9ff76e7..c7680ba 100644 (file)
@@ -238,7 +238,7 @@ protected:
     int numErrors;               // number of compile-time errors encountered
     bool parsingBuiltins;        // true if parsing built-in symbols/functions
     TMap<TString, TExtensionBehavior> extensionBehavior;    // for each extension string, what its current behavior is set to
-    static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2)); // see computeSamplerTypeIndex()
+    static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2)); // see computeSamplerTypeIndex()
     TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
     bool afterEOF;
     TQualifier globalBufferDefaults;
index c93099c..2f6fd24 100644 (file)
@@ -424,6 +424,7 @@ void TScanContext::fillInKeywordMap()
     (*KeywordMap)["sampler2DRect"] =           SAMPLER2DRECT;
     (*KeywordMap)["sampler2DRectShadow"] =     SAMPLER2DRECTSHADOW;
     (*KeywordMap)["sampler1DArray"] =          SAMPLER1DARRAY;
+    (*KeywordMap)["samplerExternalOES"] =      SAMPLEREXTERNALOES; // GL_OES_EGL_image_external
     (*KeywordMap)["noperspective"] =           NOPERSPECTIVE;
     (*KeywordMap)["smooth"] =                  SMOOTH;
     (*KeywordMap)["flat"] =                    FLAT;
@@ -811,6 +812,12 @@ int TScanContext::tokenizeIdentifier()
             return identifierOrType();
         return keyword;
 
+    case SAMPLEREXTERNALOES:
+        afterType = true;
+        if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionsTurnedOn(1, &GL_OES_EGL_image_external))
+            return keyword;
+        return identifierOrType();
+
     case NOPERSPECTIVE:
         return es30ReservedFromGLSL(130);
         
index e801a93..a801193 100644 (file)
@@ -77,6 +77,8 @@ void TType::buildMangledName(TString& mangledName)
             mangledName += "A";
         if (sampler.shadow)
             mangledName += "S";
+        if (sampler.external)
+            mangledName += "E";
         switch (sampler.dim) {
         case Esd1D:       mangledName += "1";  break;
         case Esd2D:       mangledName += "2";  break;
index 4574c4e..c86d4f3 100644 (file)
@@ -152,6 +152,7 @@ void TParseContext::initializeExtensionBehavior()
     extensionBehavior[GL_OES_texture_3D]               = EBhDisable;
     extensionBehavior[GL_OES_standard_derivatives]     = EBhDisable;
     extensionBehavior[GL_EXT_frag_depth]               = EBhDisable;
+    extensionBehavior[GL_OES_EGL_image_external]       = EBhDisable;
 
     extensionBehavior[GL_ARB_texture_rectangle]        = EBhDisable;
     extensionBehavior[GL_3DL_array_objects]            = EBhDisable;
@@ -169,7 +170,8 @@ const char* TParseContext::getPreamble()
             "#define GL_ES 1\n"
             "#define GL_OES_texture_3D 1\n"
             "#define GL_OES_standard_derivatives 1\n"
-            "#define GL_EXT_frag_depth 1\n";
+            "#define GL_EXT_frag_depth 1\n"
+            "#define GL_OES_EGL_image_external 1\n";
     } else {
         return
             "#define GL_FRAGMENT_PRECISION_HIGH 1\n"
index 8e2ffcc..0580cc9 100644 (file)
@@ -75,6 +75,7 @@ typedef enum {
 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_ARB_texture_rectangle        = "GL_ARB_texture_rectangle";
 const char* const GL_3DL_array_objects            = "GL_3DL_array_objects";
index df91311..de5438b 100644 (file)
@@ -139,6 +139,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
 %token <lex> ISAMPLERCUBEARRAY USAMPLERCUBEARRAY\r
 %token <lex> SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS\r
 %token <lex> SAMPLER2DMSARRAY ISAMPLER2DMSARRAY USAMPLER2DMSARRAY\r
+%token <lex> SAMPLEREXTERNALOES\r
 \r
 %token <lex> IMAGE1D IIMAGE1D UIMAGE1D IMAGE2D IIMAGE2D\r
 %token <lex> UIMAGE2D IMAGE3D IIMAGE3D UIMAGE3D\r
@@ -1951,6 +1952,12 @@ type_specifier_nonarray
         $$.basicType = EbtSampler;\r
         $$.sampler.setImage(EbtUint, Esd2D, true, false, true);\r
     }\r
+    | SAMPLEREXTERNALOES {  // GL_OES_EGL_image_external\r
+        $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());\r
+        $$.basicType = EbtSampler;\r
+        $$.sampler.set(EbtFloat, Esd2D);\r
+        $$.sampler.external = true;\r
+    }\r
     | struct_specifier {\r
         $$ = $1;\r
         $$.qualifier.storage = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;\r