Implement GL_OES_sample_variables.
authorJohn Kessenich <cepheus@frii.com>
Mon, 17 Aug 2015 03:55:59 +0000 (21:55 -0600)
committerJohn Kessenich <cepheus@frii.com>
Mon, 17 Aug 2015 03:55:59 +0000 (21:55 -0600)
Test/310.frag
Test/baseResults/310.frag.out
glslang/Include/revision.h
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/Versions.cpp

index f12d75f..6aa54a5 100644 (file)
@@ -251,3 +251,26 @@ void CAT()
     highp ivec4 b6 = texture(CA6, vec4(0.5), 0.26);\r
     highp uvec4 b7 = texture(CA7, vec4(0.5), 0.27);\r
 }\r
+\r
+void badSample()\r
+{\r
+    lowp     int  a1 = gl_SampleID;         // ERROR, need extension\r
+    mediump  vec2 a2 = gl_SamplePosition;   // ERROR, need extension\r
+    highp    int  a3 = gl_SampleMaskIn[0];  // ERROR, need extension\r
+    gl_SampleMask[0] = a3;                  // ERROR, need extension\r
+    mediump int n = gl_NumSamples;          // ERROR, need extension\r
+}\r
+\r
+#ifdef GL_OES_sample_variables\r
+#extension GL_OES_sample_variables : enable\r
+#endif\r
+\r
+void goodSample()\r
+{\r
+    lowp     int  a1 = gl_SampleID;       \r
+    mediump  vec2 a2 = gl_SamplePosition; \r
+    highp    int  a3 = gl_SampleMaskIn[0];\r
+    gl_SampleMask[0] = a3;\r
+    mediump int n1 = gl_MaxSamples;\r
+    mediump int n2 = gl_NumSamples;\r
+}\r
index b48460c..7cf8e48 100644 (file)
@@ -70,7 +70,12 @@ ERROR: 0:212: 'textureGatherOffsets' : required extension not requested: Possibl
 GL_EXT_gpu_shader5\r
 GL_OES_gpu_shader5\r
 ERROR: 0:223: 'textureGatherOffsets(...)' : must be a compile-time constant: offsets argument\r
-ERROR: 62 compilation errors.  No code generated.\r
+ERROR: 0:257: 'gl_SampleID' : required extension not requested: GL_OES_sample_variables\r
+ERROR: 0:258: 'gl_SamplePosition' : required extension not requested: GL_OES_sample_variables\r
+ERROR: 0:259: 'gl_SampleMaskIn' : required extension not requested: GL_OES_sample_variables\r
+ERROR: 0:260: 'gl_SampleMask' : required extension not requested: GL_OES_sample_variables\r
+ERROR: 0:261: 'gl_NumSamples' : required extension not requested: GL_OES_sample_variables\r
+ERROR: 67 compilation errors.  No code generated.\r
 \r
 \r
 Shader version: 310\r
@@ -78,6 +83,7 @@ Requested GL_EXT_shader_io_blocks
 Requested GL_EXT_texture_cube_map_array\r
 Requested GL_OES_geometry_shader\r
 Requested GL_OES_gpu_shader5\r
+Requested GL_OES_sample_variables\r
 Requested GL_OES_shader_io_blocks\r
 gl_FragCoord pixel center is integer\r
 gl_FragCoord origin is upper left\r
@@ -483,6 +489,67 @@ ERROR: node is still EOpNull!
 0:252              0.500000\r
 0:252            Constant:\r
 0:252              0.270000\r
+0:255  Function Definition: badSample( (global void)\r
+0:255    Function Parameters: \r
+0:257    Sequence\r
+0:257      Sequence\r
+0:257        move second child to first child (temp lowp int)\r
+0:257          'a1' (temp lowp int)\r
+0:257          'gl_SampleID' (flat in lowp int SampleId)\r
+0:258      Sequence\r
+0:258        move second child to first child (temp mediump 2-component vector of float)\r
+0:258          'a2' (temp mediump 2-component vector of float)\r
+0:258          'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition)\r
+0:259      Sequence\r
+0:259        move second child to first child (temp highp int)\r
+0:259          'a3' (temp highp int)\r
+0:259          direct index (flat temp highp int SampleMaskIn)\r
+0:259            'gl_SampleMaskIn' (flat in implicitly-sized array of highp int SampleMaskIn)\r
+0:259            Constant:\r
+0:259              0 (const int)\r
+0:260      move second child to first child (temp highp int)\r
+0:260        direct index (temp highp int SampleMaskIn)\r
+0:260          'gl_SampleMask' (out implicitly-sized array of highp int SampleMaskIn)\r
+0:260          Constant:\r
+0:260            0 (const int)\r
+0:260        'a3' (temp highp int)\r
+0:261      Sequence\r
+0:261        move second child to first child (temp mediump int)\r
+0:261          'n' (temp mediump int)\r
+0:261          'gl_NumSamples' (uniform lowp int)\r
+0:268  Function Definition: goodSample( (global void)\r
+0:268    Function Parameters: \r
+0:270    Sequence\r
+0:270      Sequence\r
+0:270        move second child to first child (temp lowp int)\r
+0:270          'a1' (temp lowp int)\r
+0:270          'gl_SampleID' (flat in lowp int SampleId)\r
+0:271      Sequence\r
+0:271        move second child to first child (temp mediump 2-component vector of float)\r
+0:271          'a2' (temp mediump 2-component vector of float)\r
+0:271          'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition)\r
+0:272      Sequence\r
+0:272        move second child to first child (temp highp int)\r
+0:272          'a3' (temp highp int)\r
+0:272          direct index (flat temp highp int SampleMaskIn)\r
+0:272            'gl_SampleMaskIn' (flat in implicitly-sized array of highp int SampleMaskIn)\r
+0:272            Constant:\r
+0:272              0 (const int)\r
+0:273      move second child to first child (temp highp int)\r
+0:273        direct index (temp highp int SampleMaskIn)\r
+0:273          'gl_SampleMask' (out implicitly-sized array of highp int SampleMaskIn)\r
+0:273          Constant:\r
+0:273            0 (const int)\r
+0:273        'a3' (temp highp int)\r
+0:274      Sequence\r
+0:274        move second child to first child (temp mediump int)\r
+0:274          'n1' (temp mediump int)\r
+0:274          Constant:\r
+0:274            4 (const int)\r
+0:275      Sequence\r
+0:275        move second child to first child (temp mediump int)\r
+0:275          'n2' (temp mediump int)\r
+0:275          'gl_NumSamples' (uniform lowp int)\r
 0:?   Linker Objects\r
 0:?     'gl_FragCoord' (smooth in mediump 4-component vector of float)\r
 0:?     'v3' (layout(location=2 ) smooth in mediump 3-component vector of float)\r
@@ -556,6 +623,8 @@ ERROR: node is still EOpNull!
 0:?     'CA5' (uniform highp samplerCubeArrayShadow)\r
 0:?     'CA6' (uniform highp isamplerCubeArray)\r
 0:?     'CA7' (uniform highp usamplerCubeArray)\r
+0:?     'gl_SampleMaskIn' (flat in implicitly-sized array of highp int SampleMaskIn)\r
+0:?     'gl_SampleMask' (out implicitly-sized array of highp int SampleMaskIn)\r
 \r
 \r
 Linked fragment stage:\r
@@ -567,6 +636,7 @@ Requested GL_EXT_shader_io_blocks
 Requested GL_EXT_texture_cube_map_array\r
 Requested GL_OES_geometry_shader\r
 Requested GL_OES_gpu_shader5\r
+Requested GL_OES_sample_variables\r
 Requested GL_OES_shader_io_blocks\r
 gl_FragCoord pixel center is integer\r
 gl_FragCoord origin is upper left\r
@@ -972,6 +1042,67 @@ ERROR: node is still EOpNull!
 0:252              0.500000\r
 0:252            Constant:\r
 0:252              0.270000\r
+0:255  Function Definition: badSample( (global void)\r
+0:255    Function Parameters: \r
+0:257    Sequence\r
+0:257      Sequence\r
+0:257        move second child to first child (temp lowp int)\r
+0:257          'a1' (temp lowp int)\r
+0:257          'gl_SampleID' (flat in lowp int SampleId)\r
+0:258      Sequence\r
+0:258        move second child to first child (temp mediump 2-component vector of float)\r
+0:258          'a2' (temp mediump 2-component vector of float)\r
+0:258          'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition)\r
+0:259      Sequence\r
+0:259        move second child to first child (temp highp int)\r
+0:259          'a3' (temp highp int)\r
+0:259          direct index (flat temp highp int SampleMaskIn)\r
+0:259            'gl_SampleMaskIn' (flat in 1-element array of highp int SampleMaskIn)\r
+0:259            Constant:\r
+0:259              0 (const int)\r
+0:260      move second child to first child (temp highp int)\r
+0:260        direct index (temp highp int SampleMaskIn)\r
+0:260          'gl_SampleMask' (out 1-element array of highp int SampleMaskIn)\r
+0:260          Constant:\r
+0:260            0 (const int)\r
+0:260        'a3' (temp highp int)\r
+0:261      Sequence\r
+0:261        move second child to first child (temp mediump int)\r
+0:261          'n' (temp mediump int)\r
+0:261          'gl_NumSamples' (uniform lowp int)\r
+0:268  Function Definition: goodSample( (global void)\r
+0:268    Function Parameters: \r
+0:270    Sequence\r
+0:270      Sequence\r
+0:270        move second child to first child (temp lowp int)\r
+0:270          'a1' (temp lowp int)\r
+0:270          'gl_SampleID' (flat in lowp int SampleId)\r
+0:271      Sequence\r
+0:271        move second child to first child (temp mediump 2-component vector of float)\r
+0:271          'a2' (temp mediump 2-component vector of float)\r
+0:271          'gl_SamplePosition' (smooth in mediump 2-component vector of float SamplePosition)\r
+0:272      Sequence\r
+0:272        move second child to first child (temp highp int)\r
+0:272          'a3' (temp highp int)\r
+0:272          direct index (flat temp highp int SampleMaskIn)\r
+0:272            'gl_SampleMaskIn' (flat in 1-element array of highp int SampleMaskIn)\r
+0:272            Constant:\r
+0:272              0 (const int)\r
+0:273      move second child to first child (temp highp int)\r
+0:273        direct index (temp highp int SampleMaskIn)\r
+0:273          'gl_SampleMask' (out 1-element array of highp int SampleMaskIn)\r
+0:273          Constant:\r
+0:273            0 (const int)\r
+0:273        'a3' (temp highp int)\r
+0:274      Sequence\r
+0:274        move second child to first child (temp mediump int)\r
+0:274          'n1' (temp mediump int)\r
+0:274          Constant:\r
+0:274            4 (const int)\r
+0:275      Sequence\r
+0:275        move second child to first child (temp mediump int)\r
+0:275          'n2' (temp mediump int)\r
+0:275          'gl_NumSamples' (uniform lowp int)\r
 0:?   Linker Objects\r
 0:?     'gl_FragCoord' (smooth in mediump 4-component vector of float)\r
 0:?     'v3' (layout(location=2 ) smooth in mediump 3-component vector of float)\r
@@ -1045,4 +1176,6 @@ ERROR: node is still EOpNull!
 0:?     'CA5' (uniform highp samplerCubeArrayShadow)\r
 0:?     'CA6' (uniform highp isamplerCubeArray)\r
 0:?     'CA7' (uniform highp usamplerCubeArray)\r
+0:?     'gl_SampleMaskIn' (flat in 1-element array of highp int SampleMaskIn)\r
+0:?     'gl_SampleMask' (out 1-element array of highp int SampleMaskIn)\r
 \r
index d5dfc84..d2b8064 100644 (file)
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "2.3.718"
+#define GLSLANG_REVISION "2.3.719"
 #define GLSLANG_DATE "16-Aug-2015"
index 06e522e..354a1aa 100644 (file)
@@ -1766,6 +1766,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
                 "     in  vec2 gl_SamplePosition;"
                 "flat in  int  gl_SampleMaskIn[];"
                 "     out int  gl_SampleMask[];"
+                "uniform int gl_NumSamples;"
                 );
 
         if (version >= 430)
@@ -1782,26 +1783,36 @@ void TBuiltIns::initialize(int version, EProfile profile)
     } else {
         // ES profile
 
-        if (version == 100)
+        if (version == 100) {
             stageBuiltins[EShLangFragment].append(
                 "mediump vec4 gl_FragCoord;"    // needs qualifier fixed later
                 "        bool gl_FrontFacing;"  // needs qualifier fixed later
                 "mediump vec4 gl_FragColor;"    // needs qualifier fixed later
                 "mediump vec2 gl_PointCoord;"   // needs qualifier fixed later
                 );
-        else if (version >= 300) {
+        }
+        if (version >= 300) {
             stageBuiltins[EShLangFragment].append(
                 "highp   vec4  gl_FragCoord;"    // needs qualifier fixed later
                 "        bool  gl_FrontFacing;"  // needs qualifier fixed later
                 "mediump vec2  gl_PointCoord;"   // needs qualifier fixed later
                 "highp   float gl_FragDepth;"    // needs qualifier fixed later
                 );
-            if (version >= 310)
-                stageBuiltins[EShLangFragment].append(
-                    "bool gl_HelperInvocation;"    // needs qualifier fixed later
-                    "flat in highp int gl_PrimitiveID;"  // needs qualifier fixed later
-                    "flat in highp int gl_Layer;"        // needs qualifier fixed later
-                    );
+        }
+        if (version >= 310) {
+            stageBuiltins[EShLangFragment].append(
+                "bool gl_HelperInvocation;"          // needs qualifier fixed later
+                "flat in highp int gl_PrimitiveID;"  // needs qualifier fixed later
+                "flat in highp int gl_Layer;"        // needs qualifier fixed later
+                );
+
+            stageBuiltins[EShLangFragment].append(  // GL_OES_sample_variables
+                "flat lowp    in  int  gl_SampleID;"
+                "     mediump in  vec2 gl_SamplePosition;"
+                "flat highp   in  int  gl_SampleMaskIn[];"
+                "     highp   out int  gl_SampleMask[];"
+                "uniform lowp int gl_NumSamples;"
+                );
         }
         stageBuiltins[EShLangFragment].append(
             "highp float gl_FragDepthEXT;"       // GL_EXT_frag_depth
@@ -2719,7 +2730,8 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
     }
 
     // GL_ARB_ES3_1_compatibility
-    if (profile != EEsProfile && version >= 450) {
+    if ((profile != EEsProfile && version >= 450) ||
+        (profile == EEsProfile && version >= 310)) {
         snprintf(builtInConstant, maxSize, "const int gl_MaxSamples = %d;", resources.maxSamples);
         s.append(builtInConstant);
     }
@@ -2935,10 +2947,22 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         BuiltInVariable("gl_ClipDistance",    EbvClipDistance,   symbolTable);
         BuiltInVariable("gl_CullDistance",    EbvCullDistance,   symbolTable);
         BuiltInVariable("gl_PrimitiveID",     EbvPrimitiveId,    symbolTable);
-        BuiltInVariable("gl_SampleID",        EbvSampleId,       symbolTable);
-        BuiltInVariable("gl_SamplePosition",  EbvSamplePosition, symbolTable);
-        BuiltInVariable("gl_SampleMaskIn",    EbvSampleMask,     symbolTable);
-        BuiltInVariable("gl_SampleMask",      EbvSampleMask,     symbolTable);
+
+        if ((profile != EEsProfile && version >= 400) ||
+            (profile == EEsProfile && version >= 310)) {
+            BuiltInVariable("gl_SampleID",        EbvSampleId,       symbolTable);
+            BuiltInVariable("gl_SamplePosition",  EbvSamplePosition, symbolTable);
+            BuiltInVariable("gl_SampleMaskIn",    EbvSampleMask,     symbolTable);
+            BuiltInVariable("gl_SampleMask",      EbvSampleMask,     symbolTable);
+            if (profile == EEsProfile) {
+                symbolTable.setVariableExtensions("gl_SampleID",       1, &E_GL_OES_sample_variables);
+                symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables);
+                symbolTable.setVariableExtensions("gl_SampleMaskIn",   1, &E_GL_OES_sample_variables);
+                symbolTable.setVariableExtensions("gl_SampleMask",     1, &E_GL_OES_sample_variables);
+                symbolTable.setVariableExtensions("gl_NumSamples",     1, &E_GL_OES_sample_variables);
+            }
+        }
+        
         BuiltInVariable("gl_Layer",           EbvLayer,          symbolTable);
         BuiltInVariable("gl_ViewportIndex",   EbvViewportIndex,  symbolTable);
 
index dbd37cc..d5abaee 100644 (file)
@@ -181,7 +181,7 @@ void TParseContext::initializeExtensionBehavior()
     // AEP
     extensionBehavior[E_GL_ANDROID_extension_pack_es31a]             = EBhDisablePartial;
     extensionBehavior[E_GL_KHR_blend_equation_advanced]              = EBhDisablePartial;
-    extensionBehavior[E_GL_OES_sample_variables]                     = EBhDisablePartial;
+    extensionBehavior[E_GL_OES_sample_variables]                     = EBhDisable;
     extensionBehavior[E_GL_OES_shader_image_atomic]                  = EBhDisablePartial;
     extensionBehavior[E_GL_OES_shader_multisample_interpolation]     = EBhDisablePartial;
     extensionBehavior[E_GL_OES_texture_storage_multisample_2d_array] = EBhDisable;