Jelajahi Sumber

Updated glslang.

Branimir Karadžić 7 tahun lalu
induk
melakukan
4fabcd1e8e

+ 9 - 8
3rdparty/glslang/Test/array.frag

@@ -102,11 +102,12 @@ void foo3()
 }
 }
 
 
 int[] i = int[]();    // ERROR, need constructor arguments
 int[] i = int[]();    // ERROR, need constructor arguments
-float emptyA[];
-float b = vec4(emptyA);    // ERROR, array can't be a constructor argument
-uniform sampler2D s2d[];
-
-void foo4()
-{
-    s2d[a];           // ERROR, can't variably index unsized array
-}
+float emptyA[];
+float b = vec4(emptyA);    // ERROR, array can't be a constructor argument
+uniform sampler2D s2d[];
+
+void foo4()
+{
+    s2d[a];                         // ERROR, can't variably index unsized array
+    float local[] = gUnusedUnsized; // ERROR, can initialize with runtime-sized array
+}

+ 6 - 1
3rdparty/glslang/Test/baseResults/array.frag.out

@@ -27,7 +27,8 @@ ERROR: 0:104: '=' :  cannot convert from ' const float' to ' global unsized 1-el
 ERROR: 0:106: 'constructor' : array argument must be sized 
 ERROR: 0:106: 'constructor' : array argument must be sized 
 ERROR: 0:111: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:111: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:111: 'variable indexing sampler array' : not supported with this profile: none
 ERROR: 0:111: 'variable indexing sampler array' : not supported with this profile: none
-ERROR: 28 compilation errors.  No code generated.
+ERROR: 0:112: '[]' : array initializer must be sized 
+ERROR: 29 compilation errors.  No code generated.
 
 
 
 
 Shader version: 130
 Shader version: 130
@@ -272,6 +273,10 @@ ERROR: node is still EOpNull!
 0:111      indirect index ( temp sampler2D)
 0:111      indirect index ( temp sampler2D)
 0:111        's2d' ( uniform runtime-sized array of sampler2D)
 0:111        's2d' ( uniform runtime-sized array of sampler2D)
 0:111        'a' ( uniform int)
 0:111        'a' ( uniform int)
+0:112      Sequence
+0:112        move second child to first child ( temp unsized 1-element array of float)
+0:112          'local' ( temp unsized 1-element array of float)
+0:112          'gUnusedUnsized' ( global unsized 1-element array of float)
 0:?   Linker Objects
 0:?   Linker Objects
 0:?     'gu' ( global runtime-sized array of float)
 0:?     'gu' ( global runtime-sized array of float)
 0:?     'g4' ( global 4-element array of float)
 0:?     'g4' ( global 4-element array of float)

+ 16 - 1
3rdparty/glslang/Test/baseResults/runtimeArray.vert.out

@@ -31,7 +31,8 @@ ERROR: 0:104: 'variable index' : required extension not requested: GL_EXT_nonuni
 ERROR: 0:105: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:105: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:106: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:106: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:107: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
 ERROR: 0:107: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
-ERROR: 26 compilation errors.  No code generated.
+ERROR: 0:109: '[]' : array initializer must be sized 
+ERROR: 27 compilation errors.  No code generated.
 
 
 
 
 Shader version: 450
 Shader version: 450
@@ -311,6 +312,13 @@ ERROR: node is still EOpNull!
 0:107      indirect index (layout( binding=9 r32f) temp imageBuffer)
 0:107      indirect index (layout( binding=9 r32f) temp imageBuffer)
 0:107        'storageTexelBuffer' (layout( binding=9 r32f) uniform runtime-sized array of imageBuffer)
 0:107        'storageTexelBuffer' (layout( binding=9 r32f) uniform runtime-sized array of imageBuffer)
 0:107        'i' ( global int)
 0:107        'i' ( global int)
+0:109      Sequence
+0:109        move second child to first child ( temp unsized 1-element array of float)
+0:109          'local' ( temp unsized 1-element array of float)
+0:109          b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
+0:109            'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
+0:109            Constant:
+0:109              1 (const int)
 0:?   Linker Objects
 0:?   Linker Objects
 0:?     'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
 0:?     'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
 0:?     'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
 0:?     'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
@@ -611,6 +619,13 @@ ERROR: node is still EOpNull!
 0:107      indirect index (layout( binding=9 r32f) temp imageBuffer)
 0:107      indirect index (layout( binding=9 r32f) temp imageBuffer)
 0:107        'storageTexelBuffer' (layout( binding=9 r32f) uniform runtime-sized array of imageBuffer)
 0:107        'storageTexelBuffer' (layout( binding=9 r32f) uniform runtime-sized array of imageBuffer)
 0:107        'i' ( global int)
 0:107        'i' ( global int)
+0:109      Sequence
+0:109        move second child to first child ( temp 1-element array of float)
+0:109          'local' ( temp 1-element array of float)
+0:109          b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
+0:109            'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
+0:109            Constant:
+0:109              1 (const int)
 0:?   Linker Objects
 0:?   Linker Objects
 0:?     'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
 0:?     'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
 0:?     'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
 0:?     'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})

+ 2 - 0
3rdparty/glslang/Test/baseResults/spv.AofA.frag.out

@@ -1,4 +1,6 @@
 spv.AofA.frag
 spv.AofA.frag
+WARNING: 0:6: '[][]' : Generating SPIR-V array-of-arrays, but Vulkan only supports single array level for this resource 
+
 // Module Version 10000
 // Module Version 10000
 // Generated by (magic number): 80006
 // Generated by (magic number): 80006
 // Id's are bound by 104
 // Id's are bound by 104

+ 2 - 0
3rdparty/glslang/Test/runtimeArray.vert

@@ -105,4 +105,6 @@ void main()
     storageImage[i];           // ERROR, need extension
     storageImage[i];           // ERROR, need extension
     uniformTexelBuffer[i];     // ERROR, need extension
     uniformTexelBuffer[i];     // ERROR, need extension
     storageTexelBuffer[i];     // ERROR, need extension
     storageTexelBuffer[i];     // ERROR, need extension
+
+    float local[] = ubuf.b;    // ERROR, can initialize with runtime-sized array
 }
 }

+ 1 - 1
3rdparty/glslang/Test/validate-shaders.sh

@@ -7,7 +7,7 @@
 declare -r EXE='../build/install/bin/glslangValidator'
 declare -r EXE='../build/install/bin/glslangValidator'
 
 
 # search common locations for spirv-tools: keep first one
 # search common locations for spirv-tools: keep first one
-for toolsdir in '../External/spirv-tools/build/tools' '../../SPIRV-Tools/build/tools' '/usr/local/bin'; do
+for toolsdir in '../External/spirv-tools/build/tools' '../../SPIRV-Tools/build/tools/bin' '/usr/local/bin'; do
     [[ -z "$VAL" && -x "${toolsdir}/spirv-val" ]] && declare -r VAL="${toolsdir}/spirv-val"
     [[ -z "$VAL" && -x "${toolsdir}/spirv-val" ]] && declare -r VAL="${toolsdir}/spirv-val"
     [[ -z "$DIS" && -x "${toolsdir}/spirv-dis" ]] && declare -r DIS="${toolsdir}/spirv-dis"
     [[ -z "$DIS" && -x "${toolsdir}/spirv-dis" ]] && declare -r DIS="${toolsdir}/spirv-dis"
 done
 done

+ 2 - 0
3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp

@@ -6569,6 +6569,7 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, in
                         break;
                         break;
                     case 2:
                     case 2:
                         s.append("Offsets");
                         s.append("Offsets");
+                        break;
                     default:
                     default:
                         break;
                         break;
                     }
                     }
@@ -6680,6 +6681,7 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, in
                                 break;
                                 break;
                             case 2:
                             case 2:
                                 s.append("Offsets");
                                 s.append("Offsets");
+                                break;
                             default:
                             default:
                                 break;
                                 break;
                             }
                             }

+ 19 - 6
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -3135,7 +3135,8 @@ void TParseContext::structArrayCheck(const TSourceLoc& /*loc*/, const TType& typ
     }
     }
 }
 }
 
 
-void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qualifier, TArraySizes* arraySizes, bool initializer, bool lastMember)
+void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qualifier, TArraySizes* arraySizes,
+    const TIntermTyped* initializer, bool lastMember)
 {
 {
     assert(arraySizes);
     assert(arraySizes);
 
 
@@ -3143,9 +3144,13 @@ void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qua
     if (parsingBuiltins)
     if (parsingBuiltins)
         return;
         return;
 
 
-    // always allow an initializer to set any unknown array sizes
-    if (initializer)
+    // initializer must be a sized array, in which case
+    // allow the initializer to set any unknown array sizes
+    if (initializer != nullptr) {
+        if (initializer->getType().isUnsizedArray())
+            error(loc, "array initializer must be sized", "[]", "");
         return;
         return;
+    }
 
 
     // No environment allows any non-outer-dimension to be implicitly sized
     // No environment allows any non-outer-dimension to be implicitly sized
     if (arraySizes->isInnerUnsized()) {
     if (arraySizes->isInnerUnsized()) {
@@ -4786,6 +4791,14 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
         }
         }
     }
     }
 
 
+    // some things can't have arrays of arrays
+    if (type.isArrayOfArrays()) {
+        if (spvVersion.vulkan > 0) {
+            if (type.isOpaque() || (type.getQualifier().isUniformOrBuffer() && type.getBasicType() == EbtBlock))
+                warn(loc, "Generating SPIR-V array-of-arrays, but Vulkan only supports single array level for this resource", "[][]", "");
+        }
+    }
+
     // "The offset qualifier can only be used on block members of blocks..."
     // "The offset qualifier can only be used on block members of blocks..."
     if (qualifier.hasOffset()) {
     if (qualifier.hasOffset()) {
         if (type.getBasicType() == EbtBlock)
         if (type.getBasicType() == EbtBlock)
@@ -5390,7 +5403,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
     // Declare the variable
     // Declare the variable
     if (type.isArray()) {
     if (type.isArray()) {
         // Check that implicit sizing is only where allowed.
         // Check that implicit sizing is only where allowed.
-        arraySizesCheck(loc, type.getQualifier(), type.getArraySizes(), initializer != nullptr, false);
+        arraySizesCheck(loc, type.getQualifier(), type.getArraySizes(), initializer, false);
 
 
         if (! arrayQualifierError(loc, type.getQualifier()) && ! arrayError(loc, type))
         if (! arrayQualifierError(loc, type.getQualifier()) && ! arrayError(loc, type))
             declareArray(loc, identifier, type, symbol);
             declareArray(loc, identifier, type, symbol);
@@ -5992,7 +6005,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
     blockStageIoCheck(loc, currentBlockQualifier);
     blockStageIoCheck(loc, currentBlockQualifier);
     blockQualifierCheck(loc, currentBlockQualifier, instanceName != nullptr);
     blockQualifierCheck(loc, currentBlockQualifier, instanceName != nullptr);
     if (arraySizes != nullptr) {
     if (arraySizes != nullptr) {
-        arraySizesCheck(loc, currentBlockQualifier, arraySizes, false, false);
+        arraySizesCheck(loc, currentBlockQualifier, arraySizes, nullptr, false);
         arrayOfArrayVersionCheck(loc, arraySizes);
         arrayOfArrayVersionCheck(loc, arraySizes);
         if (arraySizes->getNumDims() > 1)
         if (arraySizes->getNumDims() > 1)
             requireProfile(loc, ~EEsProfile, "array-of-array of block");
             requireProfile(loc, ~EEsProfile, "array-of-array of block");
@@ -6010,7 +6023,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
         if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
         if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
             error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
             error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
         if (memberType.isArray())
         if (memberType.isArray())
-            arraySizesCheck(memberLoc, currentBlockQualifier, memberType.getArraySizes(), false, member == typeList.size() - 1);
+            arraySizesCheck(memberLoc, currentBlockQualifier, memberType.getArraySizes(), nullptr, member == typeList.size() - 1);
         if (memberQualifier.hasOffset()) {
         if (memberQualifier.hasOffset()) {
             if (spvVersion.spv == 0) {
             if (spvVersion.spv == 0) {
                 requireProfile(memberLoc, ~EEsProfile, "offset on block member");
                 requireProfile(memberLoc, ~EEsProfile, "offset on block member");

+ 1 - 1
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h

@@ -340,7 +340,7 @@ public:
     bool arrayError(const TSourceLoc&, const TType&);
     bool arrayError(const TSourceLoc&, const TType&);
     void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
     void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
     void structArrayCheck(const TSourceLoc&, const TType& structure);
     void structArrayCheck(const TSourceLoc&, const TType& structure);
-    void arraySizesCheck(const TSourceLoc&, const TQualifier&, TArraySizes*, bool initializer, bool lastMember);
+    void arraySizesCheck(const TSourceLoc&, const TQualifier&, TArraySizes*, const TIntermTyped* initializer, bool lastMember);
     void arrayOfArrayVersionCheck(const TSourceLoc&, const TArraySizes*);
     void arrayOfArrayVersionCheck(const TSourceLoc&, const TArraySizes*);
     bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
     bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
     void boolCheck(const TSourceLoc&, const TIntermTyped*);
     void boolCheck(const TSourceLoc&, const TIntermTyped*);

+ 1 - 1
3rdparty/glslang/known_good.json

@@ -5,7 +5,7 @@
       "site" : "github",
       "site" : "github",
       "subrepo" : "KhronosGroup/SPIRV-Tools",
       "subrepo" : "KhronosGroup/SPIRV-Tools",
       "subdir" : "External/spirv-tools",
       "subdir" : "External/spirv-tools",
-      "commit" : "26a698c34788bb69123a1f3789970a16cf4d9641"
+      "commit" : "c20a718e00876a91c868858e367b8f150a8d595a"
     },
     },
     {
     {
       "name" : "spirv-tools/external/spirv-headers",
       "name" : "spirv-tools/external/spirv-headers",