Бранимир Караџић 6 лет назад
Родитель
Сommit
9b28bc89c5
23 измененных файлов с 288 добавлено и 67 удалено
  1. 2 0
      3rdparty/glslang/CMakeLists.txt
  2. 4 2
      3rdparty/glslang/SPIRV/GlslangToSpv.cpp
  3. 1 0
      3rdparty/glslang/SPIRV/disassemble.cpp
  4. 1 0
      3rdparty/glslang/SPIRV/doc.cpp
  5. 1 1
      3rdparty/glslang/Test/310.frag
  6. 12 0
      3rdparty/glslang/Test/320.comp
  7. 10 0
      3rdparty/glslang/Test/baseResults/310.frag.out
  8. 60 6
      3rdparty/glslang/Test/baseResults/320.comp.out
  9. 48 2
      3rdparty/glslang/Test/baseResults/spv.meshShaderPerViewUserDefined.mesh.out
  10. 11 0
      3rdparty/glslang/Test/baseResults/spv.meshShaderPerView_Errors.mesh.out
  11. 1 1
      3rdparty/glslang/Test/baseResults/spv.sampleMaskOverrideCoverage.frag.out
  12. 6 0
      3rdparty/glslang/Test/baseResults/spv.specConstArrayCheck.vert.out
  13. 16 4
      3rdparty/glslang/Test/spv.meshShaderPerViewUserDefined.mesh
  14. 32 0
      3rdparty/glslang/Test/spv.meshShaderPerView_Errors.mesh
  15. 14 0
      3rdparty/glslang/Test/spv.specConstArrayCheck.vert
  16. 1 1
      3rdparty/glslang/glslang/Include/revision.h
  17. 17 14
      3rdparty/glslang/glslang/MachineIndependent/Constant.cpp
  18. 19 20
      3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp
  19. 7 1
      3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp
  20. 21 13
      3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
  21. 1 1
      3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h
  22. 2 0
      3rdparty/glslang/gtests/Spv.FromFile.cpp
  23. 1 1
      3rdparty/glslang/known_good.json

+ 2 - 0
3rdparty/glslang/CMakeLists.txt

@@ -105,6 +105,8 @@ else()
     set(CMAKE_CXX_EXTENSIONS OFF)
 endif()
 
+add_compile_options(-fno-rtti)
+
 function(glslang_set_link_args TARGET)
     # For MinGW compiles, statically link against the GCC and C++ runtimes.
     # This avoids the need to ship those runtimes as DLLs.

+ 4 - 2
3rdparty/glslang/SPIRV/GlslangToSpv.cpp

@@ -7619,8 +7619,9 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv:
     case glslang::EOpIsHelperInvocation:
     {
         std::vector<spv::Id> args; // Dummy arguments
-        spv::Id id = builder.createOp(spv::OpIsHelperInvocationEXT, typeId, args);
-        return id;
+        builder.addExtension(spv::E_SPV_EXT_demote_to_helper_invocation);
+        builder.addCapability(spv::CapabilityDemoteToHelperInvocationEXT);
+        return builder.createOp(spv::OpIsHelperInvocationEXT, typeId, args);
     }
 
     case glslang::EOpReadClockSubgroupKHR: {
@@ -7738,6 +7739,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
               decoration = (spv::Decoration)spv::DecorationMax;
         builder.addDecoration(id, decoration);
         if (decoration != spv::DecorationMax) {
+            builder.addCapability(spv::CapabilitySampleMaskOverrideCoverageNV);
             builder.addExtension(spv::E_SPV_NV_sample_mask_override_coverage);
         }
     }

+ 1 - 0
3rdparty/glslang/SPIRV/disassemble.cpp

@@ -734,6 +734,7 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
         case CapabilityFragmentBarycentricNV:       return "FragmentBarycentricNV";
         case CapabilityMeshShadingNV:               return "MeshShadingNV";
         case CapabilityImageFootprintNV:            return "ImageFootprintNV";
+        case CapabilitySampleMaskOverrideCoverageNV:return "SampleMaskOverrideCoverageNV";
 
         // NV Decorations
         case DecorationOverrideCoverageNV:          return "OverrideCoverageNV";

+ 1 - 0
3rdparty/glslang/SPIRV/doc.cpp

@@ -926,6 +926,7 @@ const char* CapabilityString(int info)
     case CapabilityMeshShadingNV:                   return "MeshShadingNV";
     case CapabilityImageFootprintNV:                return "ImageFootprintNV";
 //    case CapabilityShadingRateNV:                   return "ShadingRateNV";  // superseded by FragmentDensityEXT
+    case CapabilitySampleMaskOverrideCoverageNV:    return "SampleMaskOverrideCoverageNV";
 #endif
     case CapabilityFragmentDensityEXT:              return "FragmentDensityEXT";
 

+ 1 - 1
3rdparty/glslang/Test/310.frag

@@ -58,8 +58,8 @@ void foo23()
     b1 = mix(b2, b3, b);
     uvec3 um3 = mix(uvec3(i), uvec3(i), bvec3(b));
     ivec4 im4 = mix(ivec4(i), ivec4(i), bvec4(b));
+    1 << mix(1u, 1u, false);  // does not require folding
 }
-
 layout(binding=3) uniform sampler2D s1;
 layout(binding=3) uniform sampler2D s2; // ERROR: overlapping bindings?  Don't see that in the 310 spec.
 highp layout(binding=2) uniform writeonly image2D      i2D;

+ 12 - 0
3rdparty/glslang/Test/320.comp

@@ -1,5 +1,17 @@
 #version 320 es
+
+float fX;
+float fY;
 
 void main()
 {
+    dFdx(fX);
+    dFdy(fY);
+    fwidth(fX);
+    dFdxCoarse(fX);
+    dFdyCoarse(fY);
+    fwidthCoarse(fX);
+    dFdxFine(fX);
+    dFdyFine(fY);
+    fwidthFine(fX);
 }

+ 10 - 0
3rdparty/glslang/Test/baseResults/310.frag.out

@@ -337,6 +337,16 @@ ERROR: node is still EOpNull!
 0:60              'i' ( uniform mediump int)
 0:60            Construct bvec4 ( temp 4-component vector of bool)
 0:60              'b' ( temp bool)
+0:61      left-shift ( temp int)
+0:61        Constant:
+0:61          1 (const int)
+0:61        mix ( global uint)
+0:61          Constant:
+0:61            1 (const uint)
+0:61          Constant:
+0:61            1 (const uint)
+0:61          Constant:
+0:61            false (const bool)
 0:98  Function Definition: foots( ( global void)
 0:98    Function Parameters: 
 0:100    Sequence

+ 60 - 6
3rdparty/glslang/Test/baseResults/320.comp.out

@@ -1,10 +1,43 @@
 320.comp
+ERROR: 0:8: 'dFdx' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:9: 'dFdy' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:10: 'fwidth' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:11: 'dFdxCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:12: 'dFdyCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:13: 'fwidthCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:14: 'dFdxFine' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:15: 'dFdyFine' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:16: 'fwidthFine' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 9 compilation errors.  No code generated.
+
+
 Shader version: 320
 local_size = (1, 1, 1)
-0:? Sequence
-0:3  Function Definition: main( ( global void)
-0:3    Function Parameters: 
+ERROR: node is still EOpNull!
+0:6  Function Definition: main( ( global void)
+0:6    Function Parameters: 
+0:8    Sequence
+0:8      dPdx ( global highp float)
+0:8        'fX' ( global highp float)
+0:9      dPdy ( global highp float)
+0:9        'fY' ( global highp float)
+0:10      fwidth ( global highp float)
+0:10        'fX' ( global highp float)
+0:11      dPdxCoarse ( global highp float)
+0:11        'fX' ( global highp float)
+0:12      dPdyCoarse ( global highp float)
+0:12        'fY' ( global highp float)
+0:13      fwidthCoarse ( global highp float)
+0:13        'fX' ( global highp float)
+0:14      dPdxFine ( global highp float)
+0:14        'fX' ( global highp float)
+0:15      dPdyFine ( global highp float)
+0:15        'fY' ( global highp float)
+0:16      fwidthFine ( global highp float)
+0:16        'fX' ( global highp float)
 0:?   Linker Objects
+0:?     'fX' ( global highp float)
+0:?     'fY' ( global highp float)
 
 
 Linked compute stage:
@@ -12,8 +45,29 @@ Linked compute stage:
 
 Shader version: 320
 local_size = (1, 1, 1)
-0:? Sequence
-0:3  Function Definition: main( ( global void)
-0:3    Function Parameters: 
+ERROR: node is still EOpNull!
+0:6  Function Definition: main( ( global void)
+0:6    Function Parameters: 
+0:8    Sequence
+0:8      dPdx ( global highp float)
+0:8        'fX' ( global highp float)
+0:9      dPdy ( global highp float)
+0:9        'fY' ( global highp float)
+0:10      fwidth ( global highp float)
+0:10        'fX' ( global highp float)
+0:11      dPdxCoarse ( global highp float)
+0:11        'fX' ( global highp float)
+0:12      dPdyCoarse ( global highp float)
+0:12        'fY' ( global highp float)
+0:13      fwidthCoarse ( global highp float)
+0:13        'fX' ( global highp float)
+0:14      dPdxFine ( global highp float)
+0:14        'fX' ( global highp float)
+0:15      dPdyFine ( global highp float)
+0:15        'fY' ( global highp float)
+0:16      fwidthFine ( global highp float)
+0:16        'fX' ( global highp float)
 0:?   Linker Objects
+0:?     'fX' ( global highp float)
+0:?     'fY' ( global highp float)
 

+ 48 - 2
3rdparty/glslang/Test/baseResults/spv.meshShaderPerViewUserDefined.mesh.out

@@ -1,13 +1,13 @@
 spv.meshShaderPerViewUserDefined.mesh
 // Module Version 10000
 // Generated by (magic number): 80007
-// Id's are bound by 90
+// Id's are bound by 108
 
                               Capability MeshShadingNV
                               Extension  "SPV_NV_mesh_shader"
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
-                              EntryPoint MeshNV 4  "main" 11 20 21 35 67
+                              EntryPoint MeshNV 4  "main" 11 20 21 35 67 92 95 96 97 102 105 106 107
                               ExecutionMode 4 LocalSize 32 1 1
                               ExecutionMode 4 OutputVertices 81
                               ExecutionMode 4 OutputPrimitivesNV 32
@@ -32,6 +32,14 @@ spv.meshShaderPerViewUserDefined.mesh
                               MemberName 64(perviewBlock) 2  "color7"
                               MemberName 64(perviewBlock) 3  "color8"
                               Name 67  "b2"
+                              Name 92  "nonBlk1"
+                              Name 95  "nonBlk2"
+                              Name 96  "nonBlk3"
+                              Name 97  "nonBlk4"
+                              Name 102  "nonBlkArr1"
+                              Name 105  "nonBlkArr2"
+                              Name 106  "nonBlkArr3"
+                              Name 107  "nonBlkArr4"
                               Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
                               Decorate 20(gl_MeshViewIndicesNV) BuiltIn MeshViewIndicesNV
                               Decorate 21(gl_MeshViewCountNV) BuiltIn MeshViewCountNV
@@ -50,6 +58,26 @@ spv.meshShaderPerViewUserDefined.mesh
                               Decorate 64(perviewBlock) Block
                               Decorate 67(b2) Location 10
                               Decorate 89 BuiltIn WorkgroupSize
+                              Decorate 92(nonBlk1) PerViewNV
+                              Decorate 92(nonBlk1) Location 18
+                              Decorate 95(nonBlk2) PerPrimitiveNV
+                              Decorate 95(nonBlk2) PerViewNV
+                              Decorate 95(nonBlk2) Location 19
+                              Decorate 96(nonBlk3) PerViewNV
+                              Decorate 96(nonBlk3) Location 20
+                              Decorate 97(nonBlk4) PerPrimitiveNV
+                              Decorate 97(nonBlk4) PerViewNV
+                              Decorate 97(nonBlk4) Location 21
+                              Decorate 102(nonBlkArr1) PerViewNV
+                              Decorate 102(nonBlkArr1) Location 22
+                              Decorate 105(nonBlkArr2) PerPrimitiveNV
+                              Decorate 105(nonBlkArr2) PerViewNV
+                              Decorate 105(nonBlkArr2) Location 24
+                              Decorate 106(nonBlkArr3) PerViewNV
+                              Decorate 106(nonBlkArr3) Location 26
+                              Decorate 107(nonBlkArr4) PerPrimitiveNV
+                              Decorate 107(nonBlkArr4) PerViewNV
+                              Decorate 107(nonBlkArr4) Location 28
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeInt 32 0
@@ -106,6 +134,24 @@ spv.meshShaderPerViewUserDefined.mesh
               86:   27(fvec4) ConstantComposite 85 85 85 85
               88:      6(int) Constant 32
               89:    9(ivec3) ConstantComposite 88 60 60
+              90:             TypeArray 63 32
+              91:             TypePointer Output 90
+     92(nonBlk1):     91(ptr) Variable Output
+              93:             TypeArray 63 88
+              94:             TypePointer Output 93
+     95(nonBlk2):     94(ptr) Variable Output
+     96(nonBlk3):     91(ptr) Variable Output
+     97(nonBlk4):     94(ptr) Variable Output
+              98:             TypeArray 27(fvec4) 62
+              99:             TypeArray 98 17
+             100:             TypeArray 99 32
+             101:             TypePointer Output 100
+ 102(nonBlkArr1):    101(ptr) Variable Output
+             103:             TypeArray 99 88
+             104:             TypePointer Output 103
+ 105(nonBlkArr2):    104(ptr) Variable Output
+ 106(nonBlkArr3):    101(ptr) Variable Output
+ 107(nonBlkArr4):    104(ptr) Variable Output
          4(main):           2 Function None 3
                5:             Label
           8(iid):      7(ptr) Variable Function

+ 11 - 0
3rdparty/glslang/Test/baseResults/spv.meshShaderPerView_Errors.mesh.out

@@ -0,0 +1,11 @@
+spv.meshShaderPerView_Errors.mesh
+ERROR: 0:19: '[]' : only outermost dimension of an array of arrays can be implicitly sized 
+ERROR: 0:20: '[]' : mesh view output array size must be gl_MaxMeshViewCountNV or implicitly sized 
+ERROR: 0:21: 'perviewNV' : requires a view array dimension 
+ERROR: 0:25: '[]' : only outermost dimension of an array of arrays can be implicitly sized 
+ERROR: 0:26: '[]' : mesh view output array size must be gl_MaxMeshViewCountNV or implicitly sized 
+ERROR: 0:27: 'perviewNV' : requires a view array dimension 
+ERROR: 6 compilation errors.  No code generated.
+
+
+SPIR-V is not generated for failed compile or link

+ 1 - 1
3rdparty/glslang/Test/baseResults/spv.sampleMaskOverrideCoverage.frag.out

@@ -1,10 +1,10 @@
 spv.sampleMaskOverrideCoverage.frag
-Validation failed
 // Module Version 10000
 // Generated by (magic number): 80007
 // Id's are bound by 20
 
                               Capability Shader
+                              Capability SampleMaskOverrideCoverageNV
                               Extension  "SPV_NV_sample_mask_override_coverage"
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450

+ 6 - 0
3rdparty/glslang/Test/baseResults/spv.specConstArrayCheck.vert.out

@@ -0,0 +1,6 @@
+spv.specConstArrayCheck.vert
+ERROR: 0:13: '[' :  array index out of range '6'
+ERROR: 1 compilation errors.  No code generated.
+
+
+SPIR-V is not generated for failed compile or link

+ 16 - 4
3rdparty/glslang/Test/spv.meshShaderPerViewUserDefined.mesh

@@ -22,18 +22,30 @@ layout(triangles) out;
 layout(location=0) out block {
     perprimitiveNV perviewNV vec4 color1[][3];  // Implicitly sized
     perprimitiveNV vec4 color2[3];
-    perviewNV vec4 color3[MAX_VIEWS][3];          // Explicitly sized
+    perviewNV vec4 color3[MAX_VIEWS][3];        // Explicitly sized
     vec4 color4;
 } b[];
 
-// per-view block
+// per-view block attributes
 perviewNV layout(location=10) out perviewBlock {
     perprimitiveNV vec4 color5[];              // Implicitly sized
     perprimitiveNV vec4 color6[MAX_VIEWS][3];  // Explicitly sized
-    vec4 color7[][3];                            // Implicitly sized
-    vec4 color8[MAX_VIEWS];                      // Explicitly sized
+    vec4 color7[][3];                          // Implicitly sized
+    vec4 color8[MAX_VIEWS];                    // Explicitly sized
 } b2[];
 
+// per-view non-block attributes
+perviewNV                layout(location=18) out vec4 nonBlk1[MAX_VER][MAX_VIEWS]; // Explicit+Explicit
+perviewNV perprimitiveNV layout(location=19) out vec4 nonBlk2[MAX_PRIM][];         // Explicit+Implicit
+perviewNV                layout(location=20) out vec4 nonBlk3[][MAX_VIEWS];        // Implicit+Explicit
+perviewNV perprimitiveNV layout(location=21) out vec4 nonBlk4[][];                 // Implicit+Implicit
+
+// per-view non-block array attributes
+perviewNV                layout(location=22) out vec4 nonBlkArr1[MAX_VER][MAX_VIEWS][2]; // Explicit+Explicit
+perviewNV perprimitiveNV layout(location=24) out vec4 nonBlkArr2[MAX_PRIM][][2];         // Explicit+Implicit
+perviewNV                layout(location=26) out vec4 nonBlkArr3[][MAX_VIEWS][2];        // Implicit+Explicit
+perviewNV perprimitiveNV layout(location=28) out vec4 nonBlkArr4[][][2];                 // Implicit+Implicit
+
 void main()
 {
     uint iid = gl_LocalInvocationID.x;

+ 32 - 0
3rdparty/glslang/Test/spv.meshShaderPerView_Errors.mesh

@@ -0,0 +1,32 @@
+#version 450
+
+#define MAX_VER  81
+#define MAX_PRIM 32
+#define MAX_VIEWS gl_MaxMeshViewCountNV
+
+#extension GL_NV_mesh_shader : enable
+
+layout(local_size_x = 32) in;
+
+layout(max_vertices=MAX_VER) out;
+layout(max_primitives=MAX_PRIM) out;
+layout(triangles) out;
+
+// test error checks for use of incorrect per-view attributes
+
+// per-view block attributes
+perviewNV layout(location=0) out perviewBlock {
+    vec4 missingInnermostDimSize1[][];
+    vec4 incorrectViewDimSize1[MAX_VIEWS+1];
+    vec4 missingViewDim1;
+} b2[];
+
+// per-view non-block attributes
+perviewNV layout(location=10) out vec4 missingInnermostDimSize2[][][];
+perviewNV layout(location=11) out vec4 incorrectViewDimSize2[][MAX_VIEWS-1];
+perviewNV layout(location=12) out vec4 missingViewDim2[];
+
+void main()
+{
+}
+

+ 14 - 0
3rdparty/glslang/Test/spv.specConstArrayCheck.vert

@@ -0,0 +1,14 @@
+#version 450
+
+layout(constant_id = 0) const uint a = 1;
+layout(constant_id = 1) const uint b = 2;
+layout(location = 0) out uint o;
+
+void main() {
+  uint arr1[a+a];
+  uint arr2[b];
+  o = arr1[1];
+  o = arr2[1];
+  o = arr1[6];
+  o = arr2[6];
+}

+ 1 - 1
3rdparty/glslang/glslang/Include/revision.h

@@ -1,3 +1,3 @@
 // This header is generated by the make-revision script.
 
-#define GLSLANG_PATCH_LEVEL 3276
+#define GLSLANG_PATCH_LEVEL 3294

+ 17 - 14
3rdparty/glslang/glslang/MachineIndependent/Constant.cpp

@@ -415,8 +415,8 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
 
     case EOpEmitStreamVertex:
     case EOpEndStreamPrimitive:
-        // These don't actually fold
-        return 0;
+        // These don't fold
+        return nullptr;
 
     case EOpPackSnorm2x16:
     case EOpPackUnorm2x16:
@@ -491,8 +491,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
         break;
     }
 
-    // TODO: 3.0 Functionality: unary constant folding: the rest of the ops have to be fleshed out
-
     case EOpPackSnorm2x16:
     case EOpPackUnorm2x16:
     case EOpPackHalf2x16:
@@ -510,7 +508,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
     case EOpDeterminant:
     case EOpMatrixInverse:
     case EOpTranspose:
-        return 0;
+        return nullptr;
 
     default:
         assert(componentWise);
@@ -538,7 +536,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
             case EbtInt64: newConstArray[i].setI64Const(-unionArray[i].getI64Const()); break;
             case EbtUint64: newConstArray[i].setU64Const(static_cast<unsigned long long>(-static_cast<long long>(unionArray[i].getU64Const())));  break;
             default:
-                return 0;
+                return nullptr;
             }
             break;
         case EOpLogicalNot:
@@ -546,7 +544,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
             switch (getType().getBasicType()) {
             case EbtBool:  newConstArray[i].setBConst(!unionArray[i].getBConst()); break;
             default:
-                return 0;
+                return nullptr;
             }
             break;
         case EOpBitwiseNot:
@@ -970,7 +968,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
         case EOpInt16BitsToFloat16:
         case EOpUint16BitsToFloat16:
         default:
-            return 0;
+            return nullptr;
         }
     }
 
@@ -1201,12 +1199,17 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
                 newConstArray[comp].setBConst(childConstUnions[0][arg0comp] != childConstUnions[1][arg1comp]);
                 break;
             case EOpMix:
-                if (children[2]->getAsTyped()->getBasicType() == EbtBool)
-                    newConstArray[comp].setDConst(childConstUnions[2][arg2comp].getBConst() ? childConstUnions[1][arg1comp].getDConst() :
-                                                                                              childConstUnions[0][arg0comp].getDConst());
-                else
-                    newConstArray[comp].setDConst(childConstUnions[0][arg0comp].getDConst() * (1.0 - childConstUnions[2][arg2comp].getDConst()) +
-                                                  childConstUnions[1][arg1comp].getDConst() *        childConstUnions[2][arg2comp].getDConst());
+                if (!children[0]->getAsTyped()->isFloatingDomain())
+                    return aggrNode;
+                if (children[2]->getAsTyped()->getBasicType() == EbtBool) {
+                    newConstArray[comp].setDConst(childConstUnions[2][arg2comp].getBConst()
+                        ? childConstUnions[1][arg1comp].getDConst()
+                        : childConstUnions[0][arg0comp].getDConst());
+                } else {
+                    newConstArray[comp].setDConst(
+                        childConstUnions[0][arg0comp].getDConst() * (1.0 - childConstUnions[2][arg2comp].getDConst()) +
+                        childConstUnions[1][arg1comp].getDConst() *        childConstUnions[2][arg2comp].getDConst());
+                }
                 break;
             case EOpStep:
                 newConstArray[comp].setDConst(childConstUnions[1][arg1comp].getDConst() < childConstUnions[0][arg0comp].getDConst() ? 0.0 : 1.0);

+ 19 - 20
3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp

@@ -5144,14 +5144,12 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     }
 
     //E_SPV_NV_compute_shader_derivatives
-    
-    stageBuiltins[EShLangCompute].append(derivatives);
-    stageBuiltins[EShLangCompute].append(derivativeControls);
-    stageBuiltins[EShLangCompute].append("\n");
-    
-
+    if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) {
+        stageBuiltins[EShLangCompute].append(derivatives);
+        stageBuiltins[EShLangCompute].append(derivativeControls);
+        stageBuiltins[EShLangCompute].append("\n");
+    }
     if (profile != EEsProfile && version >= 450) {
-
         stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
         stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
         stageBuiltins[EShLangCompute].append("\n");
@@ -8443,19 +8441,6 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
             BuiltInVariable("gl_BaryCoordNV",        EbvBaryCoordNV,        symbolTable);
             BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
         }
-        if (((profile != EEsProfile && version >= 450) ||
-            (profile == EEsProfile && version >= 320)) &&
-            language == EShLangCompute) {
-            symbolTable.setFunctionExtensions("dFdx",                   1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdy",                   1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("fwidth",                 1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdxFine",               1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdyFine",               1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("fwidthFine",             1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdxCoarse",             1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
-        }
 #endif
 
         if ((profile != EEsProfile && version >= 450) ||
@@ -8774,6 +8759,20 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
         symbolTable.setFunctionExtensions("coopMatStoreNV",             1, &E_GL_NV_cooperative_matrix);
         symbolTable.setFunctionExtensions("coopMatMulAddNV",            1, &E_GL_NV_cooperative_matrix);
 
+#ifdef NV_EXTENSIONS
+        if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
+            symbolTable.setFunctionExtensions("dFdx",                   1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdy",                   1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("fwidth",                 1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdxFine",               1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdyFine",               1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("fwidthFine",             1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdxCoarse",             1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
+        }
+#endif
+
         break;
 #ifdef NV_EXTENSIONS
     case EShLangRayGenNV:

+ 7 - 1
3rdparty/glslang/glslang/MachineIndependent/ParseContextBase.cpp

@@ -254,11 +254,17 @@ void TParseContextBase::trackLinkage(TSymbol& symbol)
 // Give an error if not.
 void TParseContextBase::checkIndex(const TSourceLoc& loc, const TType& type, int& index)
 {
+    const auto sizeIsSpecializationExpression = [&type]() {
+        return type.containsSpecializationSize() &&
+               type.getArraySizes()->getOuterNode() != nullptr &&
+               type.getArraySizes()->getOuterNode()->getAsSymbolNode() == nullptr; };
+
     if (index < 0) {
         error(loc, "", "[", "index out of range '%d'", index);
         index = 0;
     } else if (type.isArray()) {
-        if (type.isSizedArray() && index >= type.getOuterArraySize()) {
+        if (type.isSizedArray() && !sizeIsSpecializationExpression() &&
+            index >= type.getOuterArraySize()) {
             error(loc, "", "[", "array index out of range '%d'", index);
             index = type.getOuterArraySize() - 1;
         }

+ 21 - 13
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -3976,23 +3976,30 @@ bool TParseContext::isRuntimeLength(const TIntermTyped& base) const
 }
 
 #ifdef NV_EXTENSIONS
-// Fix mesh view output array dimension
-void TParseContext::resizeMeshViewDimension(const TSourceLoc& loc, TType& type)
+// Check if mesh perviewNV attributes have a view dimension
+// and resize it to gl_MaxMeshViewCountNV when implicitly sized.
+void TParseContext::checkAndResizeMeshViewDim(const TSourceLoc& loc, TType& type, bool isBlockMember)
 {
     // see if member is a per-view attribute
-    if (type.getQualifier().isPerView()) {
-        // since we don't have the maxMeshViewCountNV set during parsing builtins, we hardcode the value
+    if (!type.getQualifier().isPerView())
+        return;
+
+    if ((isBlockMember && type.isArray()) || (!isBlockMember && type.isArrayOfArrays())) {
+        // since we don't have the maxMeshViewCountNV set during parsing builtins, we hardcode the value.
         int maxViewCount = parsingBuiltins ? 4 : resources.maxMeshViewCountNV;
+        // For block members, outermost array dimension is the view dimension.
+        // For non-block members, outermost array dimension is the vertex/primitive dimension
+        // and 2nd outermost is the view dimension.
+        int viewDim = isBlockMember ? 0 : 1;
+        int viewDimSize = type.getArraySizes()->getDimSize(viewDim);
 
-        if (! type.isArray()) {
-            error(loc, "requires an view array dimension", "perviewNV", "");
-        }
-        else if (!type.isUnsizedArray() && type.getOuterArraySize() != maxViewCount) {
+        if (viewDimSize != UnsizedArraySize && viewDimSize != maxViewCount)
             error(loc, "mesh view output array size must be gl_MaxMeshViewCountNV or implicitly sized", "[]", "");
-        }
-        else if (type.isUnsizedArray()) {
-            type.changeOuterArraySize(maxViewCount);
-        }
+        else if (viewDimSize == UnsizedArraySize)
+            type.getArraySizes()->setDimSize(viewDim, maxViewCount);
+    }
+    else {
+        error(loc, "requires a view array dimension", "perviewNV", "");
     }
 }
 #endif
@@ -6427,6 +6434,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
     transparentOpaqueCheck(loc, type, identifier);
 #ifdef NV_EXTENSIONS
     accStructNVCheck(loc, type, identifier);
+    checkAndResizeMeshViewDim(loc, type, /*isBlockMember*/ false);
 #endif
     if (type.getQualifier().storage == EvqConst && type.containsBasicType(EbtReference)) {
         error(loc, "variables with reference type can't have qualifier 'const'", "qualifier", "");
@@ -7342,7 +7350,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
 #ifdef NV_EXTENSIONS
     if (memberWithPerViewQualifier) {
         for (unsigned int member = 0; member < typeList.size(); ++member) {
-            resizeMeshViewDimension(typeList[member].loc, *typeList[member].type);
+            checkAndResizeMeshViewDim(typeList[member].loc, *typeList[member].type, /*isBlockMember*/ true);
         }
     }
 #endif

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

@@ -429,7 +429,7 @@ public:
     // Determine loop control from attributes
     void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
 
-    void resizeMeshViewDimension(const TSourceLoc&, TType&);
+    void checkAndResizeMeshViewDim(const TSourceLoc&, TType&, bool isBlockMember);
 
 protected:
     void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type);

+ 2 - 0
3rdparty/glslang/gtests/Spv.FromFile.cpp

@@ -545,6 +545,7 @@ INSTANTIATE_TEST_CASE_P(
         "vulkan.vert",
         "vulkan.comp",
         "samplerlessTextureFunctions.frag",
+        "spv.specConstArrayCheck.vert",
     })),
     FileNameAsCustomTestSuffix
 );
@@ -624,6 +625,7 @@ INSTANTIATE_TEST_CASE_P(
     "spv.meshShaderUserDefined.mesh",
     "spv.meshShaderPerViewBuiltins.mesh",
     "spv.meshShaderPerViewUserDefined.mesh",
+    "spv.meshShaderPerView_Errors.mesh",
     "spv.meshShaderSharedMem.mesh",
     "spv.meshShaderTaskMem.mesh",
     "spv.320.meshShaderUserDefined.mesh",

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

@@ -5,7 +5,7 @@
       "site" : "github",
       "subrepo" : "KhronosGroup/SPIRV-Tools",
       "subdir" : "External/spirv-tools",
-      "commit" : "456cc598afb6d7c264f20cd3a183d85e369bed9a"
+      "commit" : "1fedf72e500b7cf72098a3f800c8ef4b9d9dc84f"
     },
     {
       "name" : "spirv-tools/external/spirv-headers",