Przeglądaj źródła

Updated glslang.

Бранимир Караџић 6 lat temu
rodzic
commit
4284db32f9

+ 1 - 0
3rdparty/glslang/Test/150.frag

@@ -47,4 +47,5 @@ void barWxyz()
 int primitiveID()
 {
    return gl_PrimitiveID;
+   gl_PerFragment; // ERROR, block name can't get reused
 }

+ 4 - 1
3rdparty/glslang/Test/baseResults/150.frag.out

@@ -3,7 +3,9 @@ ERROR: 0:4: 'redeclaration' : cannot redeclare with different qualification: gl_
 ERROR: 0:5: 'redeclaration' : cannot redeclare with different qualification: gl_FragCoord
 ERROR: 0:6: 'layout qualifier' : can only apply origin_upper_left and pixel_center_origin to gl_FragCoord 
 ERROR: 0:14: 'gl_FragCoord' : cannot redeclare after use 
-ERROR: 4 compilation errors.  No code generated.
+ERROR: 0:50: 'gl_PerFragment' : cannot be used (maybe an instance name is needed) 
+ERROR: 0:50: 'gl_PerFragment' : undeclared identifier 
+ERROR: 6 compilation errors.  No code generated.
 
 
 Shader version: 150
@@ -106,6 +108,7 @@ ERROR: node is still EOpNull!
 0:49    Sequence
 0:49      Branch: Return with expression
 0:49        'gl_PrimitiveID' ( flat in int PrimitiveID)
+0:50      'gl_PerFragment' ( temp float)
 0:?   Linker Objects
 0:?     'gl_FragCoord' ( gl_FragCoord 4-component vector of float FragCoord)
 0:?     'foo' ( smooth in 4-component vector of float)

+ 2 - 0
3rdparty/glslang/glslang/Include/Types.h

@@ -1661,6 +1661,8 @@ public:
     virtual bool isImage()   const { return basicType == EbtSampler && getSampler().isImage(); }
     virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
     virtual bool isTexture() const { return basicType == EbtSampler && getSampler().isTexture(); }
+    // Check the block-name convention of creating a block without populating it's members:
+    virtual bool isUnusableName() const { return isStruct() && structure == nullptr; }
     virtual bool isParameterized()  const { return typeParameters != nullptr; }
 #ifdef GLSLANG_WEB
     bool isAtomic() const { return false; }

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

@@ -319,10 +319,15 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
         // If this is a variable or a block, check it and all it contains, but if this
         // is a member of an anonymous block, check the whole block, as the whole block
         // will need to be copied up if it contains an unsized array.
-        if (symbol->getType().containsUnsizedArray() ||
-            (symbol->getAsAnonMember() &&
-             symbol->getAsAnonMember()->getAnonContainer().getType().containsUnsizedArray()))
-            makeEditable(symbol);
+        //
+        // This check is being done before the block-name check further down, so guard
+        // for that too.
+        if (!symbol->getType().isUnusableName()) {
+            if (symbol->getType().containsUnsizedArray() ||
+                (symbol->getAsAnonMember() &&
+                 symbol->getAsAnonMember()->getAnonContainer().getType().containsUnsizedArray()))
+                makeEditable(symbol);
+        }
     }
 #endif
 
@@ -347,8 +352,7 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
         // See if it was a variable.
         variable = symbol ? symbol->getAsVariable() : nullptr;
         if (variable) {
-            if ((variable->getType().getBasicType() == EbtBlock ||
-                 variable->getType().getBasicType() == EbtStruct) && variable->getType().getStruct() == nullptr) {
+            if (variable->getType().isUnusableName()) {
                 error(loc, "cannot be used (maybe an instance name is needed)", string->c_str(), "");
                 variable = nullptr;
             }

+ 6 - 2
3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp

@@ -1035,7 +1035,9 @@ struct TDefaultHlslIoResolver : public TDefaultIoResolverBase {
 bool TIoMapper::addStage(EShLanguage stage, TIntermediate& intermediate, TInfoSink& infoSink, TIoMapResolver* resolver) {
     bool somethingToDo = ! intermediate.getResourceSetBinding().empty() || intermediate.getAutoMapBindings() ||
                          intermediate.getAutoMapLocations();
-    for (int res = 0; res < EResCount; ++res) {
+    // Restrict the stricter condition to further check 'somethingToDo' only if 'somethingToDo' has not been set, reduce
+    // unnecessary or insignificant for-loop operation after 'somethingToDo' have been true.
+    for (int res = 0; (res < EResCount && !somethingToDo); ++res) {
         somethingToDo = somethingToDo || (intermediate.getShiftBinding(TResourceType(res)) != 0) ||
                         intermediate.hasShiftBindingForSet(TResourceType(res));
     }
@@ -1134,7 +1136,9 @@ bool TGlslIoMapper::addStage(EShLanguage stage, TIntermediate& intermediate, TIn
 
     bool somethingToDo = ! intermediate.getResourceSetBinding().empty() || intermediate.getAutoMapBindings() ||
                          intermediate.getAutoMapLocations();
-    for (int res = 0; res < EResCount; ++res) {
+    // Restrict the stricter condition to further check 'somethingToDo' only if 'somethingToDo' has not been set, reduce
+    // unnecessary or insignificant for-loop operation after 'somethingToDo' have been true.
+    for (int res = 0; (res < EResCount && !somethingToDo); ++res) {
         somethingToDo = somethingToDo || (intermediate.getShiftBinding(TResourceType(res)) != 0) ||
                         intermediate.hasShiftBindingForSet(TResourceType(res));
     }

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

@@ -5,14 +5,14 @@
       "site" : "github",
       "subrepo" : "KhronosGroup/SPIRV-Tools",
       "subdir" : "External/spirv-tools",
-      "commit" : "aa9e8f538041db3055ea443080e0ccc315fa114f"
+      "commit" : "9b3cc3e05337358d0bd9fec1b7a51e3cbf55312b"
     },
     {
       "name" : "spirv-tools/external/spirv-headers",
       "site" : "github",
       "subrepo" : "KhronosGroup/SPIRV-Headers",
       "subdir" : "External/spirv-tools/external/spirv-headers",
-      "commit" : "45c2cc37276d69e5b257507d97fd90d2a5684ccc"
+      "commit" : "38cafab379e5d16137cb97a485b9385191039b92"
     }
   ]
 }