Бранимир Караџић 5 лет назад
Родитель
Сommit
11137890f7
31 измененных файлов с 1202 добавлено и 189 удалено
  1. 24 10
      3rdparty/glslang/SPIRV/GlslangToSpv.cpp
  2. 1 1
      3rdparty/glslang/SPIRV/GlslangToSpv.h
  3. 1 1
      3rdparty/glslang/SPIRV/SpvBuilder.h
  4. 2 0
      3rdparty/glslang/SPIRV/SpvTools.cpp
  5. 1 1
      3rdparty/glslang/SPIRV/SpvTools.h
  6. 58 28
      3rdparty/glslang/StandAlone/StandAlone.cpp
  7. 451 0
      3rdparty/glslang/glslang/CInterface/glslang_c_interface.cpp
  8. 4 1
      3rdparty/glslang/glslang/CMakeLists.txt
  9. 1 1
      3rdparty/glslang/glslang/Include/ConstantUnion.h
  10. 8 8
      3rdparty/glslang/glslang/Include/Types.h
  11. 119 0
      3rdparty/glslang/glslang/Include/glslang_c_interface.h
  12. 182 0
      3rdparty/glslang/glslang/Include/glslang_c_shader_types.h
  13. 1 1
      3rdparty/glslang/glslang/Include/revision.h
  14. 65 21
      3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp
  15. 3 0
      3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp
  16. 11 5
      3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
  17. 41 43
      3rdparty/glslang/glslang/MachineIndependent/Scan.cpp
  18. 6 0
      3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp
  19. 2 0
      3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp
  20. 11 3
      3rdparty/glslang/glslang/MachineIndependent/Versions.cpp
  21. 8 1
      3rdparty/glslang/glslang/MachineIndependent/Versions.h
  22. 51 17
      3rdparty/glslang/glslang/MachineIndependent/glslang.m4
  23. 51 17
      3rdparty/glslang/glslang/MachineIndependent/glslang.y
  24. 51 17
      3rdparty/glslang/glslang/MachineIndependent/glslang_tab.cpp
  25. 9 6
      3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp
  26. 5 4
      3rdparty/glslang/glslang/MachineIndependent/iomapper.h
  27. 3 0
      3rdparty/glslang/glslang/MachineIndependent/localintermediate.h
  28. 12 1
      3rdparty/glslang/glslang/Public/ShaderLang.h
  29. 2 0
      3rdparty/glslang/hlsl/hlslGrammar.cpp
  30. 11 2
      3rdparty/glslang/hlsl/hlslParseHelper.cpp
  31. 7 0
      3rdparty/glslang/hlsl/hlslParseHelper.h

+ 24 - 10
3rdparty/glslang/SPIRV/GlslangToSpv.cpp

@@ -245,7 +245,9 @@ protected:
     std::unordered_map<std::string, spv::Function*> functionMap;
     std::unordered_map<const glslang::TTypeList*, spv::Id> structMap[glslang::ElpCount][glslang::ElmCount];
     // for mapping glslang block indices to spv indices (e.g., due to hidden members):
-    std::unordered_map<const glslang::TTypeList*, std::vector<int> > memberRemapper;
+    std::unordered_map<int, std::vector<int>> memberRemapper;
+    // for mapping glslang symbol struct to symbol Id
+    std::unordered_map<const glslang::TTypeList*, int> glslangTypeToIdMap;
     std::stack<bool> breakForLoop;  // false means break for switch
     std::unordered_map<std::string, const glslang::TIntermSymbol*> counterOriginator;
     // Map pointee types for EbtReference to their forward pointers
@@ -1661,6 +1663,9 @@ void TGlslangToSpvTraverser::dumpSpv(std::vector<unsigned int>& out)
 void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
 {
     SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
+    if (symbol->getType().isStruct())
+        glslangTypeToIdMap[symbol->getType().getStruct()] = symbol->getId();
+
     if (symbol->getType().getQualifier().isSpecConstant())
         spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
 
@@ -1753,6 +1758,12 @@ void TGlslangToSpvTraverser::visitSymbol(glslang::TIntermSymbol* symbol)
 bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::TIntermBinary* node)
 {
     builder.setLine(node->getLoc().line, node->getLoc().getFilename());
+    if (node->getLeft()->getAsSymbolNode() != nullptr && node->getLeft()->getType().isStruct()) {
+        glslangTypeToIdMap[node->getLeft()->getType().getStruct()] = node->getLeft()->getAsSymbolNode()->getId();
+    }
+    if (node->getRight()->getAsSymbolNode() != nullptr && node->getRight()->getType().isStruct()) {
+        glslangTypeToIdMap[node->getRight()->getType().getStruct()] = node->getRight()->getAsSymbolNode()->getId();
+    }
 
     SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
     if (node->getType().getQualifier().isSpecConstant())
@@ -1857,9 +1868,12 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
                 {
                     // This may be, e.g., an anonymous block-member selection, which generally need
                     // index remapping due to hidden members in anonymous blocks.
-                    std::vector<int>& remapper = memberRemapper[node->getLeft()->getType().getStruct()];
-                    assert(remapper.size() > 0);
-                    spvIndex = remapper[glslangIndex];
+                    int glslangId = glslangTypeToIdMap[node->getLeft()->getType().getStruct()];
+                    if (memberRemapper.find(glslangId) != memberRemapper.end()) {
+                        std::vector<int>& remapper = memberRemapper[glslangId];
+                        assert(remapper.size() > 0);
+                        spvIndex = remapper[glslangIndex];
+                    }
                 }
 
                 // normal case for indexing array or structure or block
@@ -3483,7 +3497,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
 
             // else, we haven't seen it...
             if (type.getBasicType() == glslang::EbtBlock)
-                memberRemapper[glslangMembers].resize(glslangMembers->size());
+                memberRemapper[glslangTypeToIdMap[glslangMembers]].resize(glslangMembers->size());
             spvType = convertGlslangStructToSpvType(type, glslangMembers, explicitLayout, qualifier);
         }
         break;
@@ -3619,15 +3633,15 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
         if (glslangMember.hiddenMember()) {
             ++memberDelta;
             if (type.getBasicType() == glslang::EbtBlock)
-                memberRemapper[glslangMembers][i] = -1;
+                memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = -1;
         } else {
             if (type.getBasicType() == glslang::EbtBlock) {
                 if (filterMember(glslangMember)) {
                     memberDelta++;
-                    memberRemapper[glslangMembers][i] = -1;
+                    memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = -1;
                     continue;
                 }
-                memberRemapper[glslangMembers][i] = i - memberDelta;
+                memberRemapper[glslangTypeToIdMap[glslangMembers]][i] = i - memberDelta;
             }
             // modify just this child's view of the qualifier
             glslang::TQualifier memberQualifier = glslangMember.getQualifier();
@@ -3685,7 +3699,7 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
         glslang::TType& glslangMember = *(*glslangMembers)[i].type;
         int member = i;
         if (type.getBasicType() == glslang::EbtBlock) {
-            member = memberRemapper[glslangMembers][i];
+            member = memberRemapper[glslangTypeToIdMap[glslangMembers]][i];
             if (filterMember(glslangMember))
                 continue;
         }
@@ -7482,7 +7496,7 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
         id = builder.createCompositeExtract(mulOp, typeId, 0);
         for (int i = 1; i < componentCount; ++i) {
             builder.setPrecision(id, precision);
-            id = builder.createBinOp(spv::OpIAdd, typeId, id, builder.createCompositeExtract(operands[0], typeId, i));
+            id = builder.createBinOp(spv::OpIAdd, typeId, id, builder.createCompositeExtract(mulOp, typeId, i));
         }
     } else {
         switch (consumedOperands) {

+ 1 - 1
3rdparty/glslang/SPIRV/GlslangToSpv.h

@@ -40,7 +40,7 @@
 #endif
 
 #include "SpvTools.h"
-#include "../glslang/Include/intermediate.h"
+#include "glslang/Include/intermediate.h"
 
 #include <string>
 #include <vector>

+ 1 - 1
3rdparty/glslang/SPIRV/SpvBuilder.h

@@ -512,7 +512,7 @@ public:
         Block &head, &body, &merge, &continue_target;
     private:
         LoopBlocks();
-        LoopBlocks& operator=(const LoopBlocks&);
+        LoopBlocks& operator=(const LoopBlocks&) = delete;
     };
 
     // Start a new loop and prepare the builder to generate code for it.  Until

+ 2 - 0
3rdparty/glslang/SPIRV/SpvTools.cpp

@@ -67,6 +67,8 @@ spv_target_env MapToSpirvToolsEnv(const SpvVersion& spvVersion, spv::SpvBuildLog
             logger->missingFunctionality("Target version for SPIRV-Tools validator");
             return spv_target_env::SPV_ENV_VULKAN_1_1;
         }
+    case glslang::EShTargetVulkan_1_2:
+        return spv_target_env::SPV_ENV_VULKAN_1_2;
     default:
         break;
     }

+ 1 - 1
3rdparty/glslang/SPIRV/SpvTools.h

@@ -46,7 +46,7 @@
 #include <ostream>
 #endif
 
-#include "../glslang/MachineIndependent/localintermediate.h"
+#include "glslang/MachineIndependent/localintermediate.h"
 #include "Logger.h"
 
 namespace glslang {

+ 58 - 28
3rdparty/glslang/StandAlone/StandAlone.cpp

@@ -204,7 +204,7 @@ public:
         text.append("#define ");
         fixLine(def);
 
-        Processes.push_back("D");
+        Processes.push_back("define-macro ");
         Processes.back().append(def);
 
         // The first "=" needs to turn into a space
@@ -222,7 +222,7 @@ public:
         text.append("#undef ");
         fixLine(undef);
 
-        Processes.push_back("U");
+        Processes.push_back("undef-macro ");
         Processes.back().append(undef);
 
         text.append(undef);
@@ -292,9 +292,12 @@ bool SetConfigFile(const std::string& name)
 //
 // Give error and exit with failure code.
 //
-void Error(const char* message)
+void Error(const char* message, const char* detail = nullptr)
 {
-    fprintf(stderr, "%s: Error %s (use -h for usage)\n", ExecutableName, message);
+    fprintf(stderr, "%s: Error: ", ExecutableName);
+    if (detail != nullptr)
+        fprintf(stderr, "%s: ", detail);
+    fprintf(stderr, "%s (use -h for usage)\n", message);
     exit(EFailUsage);
 }
 
@@ -482,7 +485,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                         Options |= EOptionAutoMapLocations;
                     } else if (lowerword == "uniform-base") {
                         if (argc <= 1)
-                            Error("no <base> provided for --uniform-base");
+                            Error("no <base> provided", lowerword.c_str());
                         uniformBase = ::strtol(argv[1], NULL, 10);
                         bumpArg();
                         break;
@@ -493,15 +496,23 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                             else if (strcmp(argv[1], "opengl100") == 0)
                                 setOpenGlSpv();
                             else
-                                Error("--client expects vulkan100 or opengl100");
-                        }
+                                Error("expects vulkan100 or opengl100", lowerword.c_str());
+                        } else
+                            Error("expects vulkan100 or opengl100", lowerword.c_str());
+                        bumpArg();
+                    } else if (lowerword == "define-macro" ||
+                               lowerword == "d") {
+                        if (argc > 1)
+                            UserPreamble.addDef(argv[1]);
+                        else
+                            Error("expects <name[=def]>", argv[0]);
                         bumpArg();
                     } else if (lowerword == "dump-builtin-symbols") {
                         DumpBuiltinSymbols = true;
                     } else if (lowerword == "entry-point") {
                         entryPointName = argv[1];
                         if (argc <= 1)
-                            Error("no <name> provided for --entry-point");
+                            Error("no <name> provided", lowerword.c_str());
                         bumpArg();
                     } else if (lowerword == "flatten-uniform-arrays" || // synonyms
                                lowerword == "flatten-uniform-array"  ||
@@ -576,7 +587,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                     } else if (lowerword == "source-entrypoint" || // synonyms
                                lowerword == "sep") {
                         if (argc <= 1)
-                            Error("no <entry-point> provided for --source-entrypoint");
+                            Error("no <entry-point> provided", lowerword.c_str());
                         sourceEntryPointName = argv[1];
                         bumpArg();
                         break;
@@ -597,6 +608,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                             } else if (strcmp(argv[1], "vulkan1.1") == 0) {
                                 setVulkanSpv();
                                 ClientVersion = glslang::EShTargetVulkan_1_1;
+                            } else if (strcmp(argv[1], "vulkan1.2") == 0) {
+                                setVulkanSpv();
+                                ClientVersion = glslang::EShTargetVulkan_1_2;
                             } else if (strcmp(argv[1], "opengl") == 0) {
                                 setOpenGlSpv();
                                 ClientVersion = glslang::EShTargetOpenGL_450;
@@ -619,22 +633,32 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                                 TargetLanguage = glslang::EShTargetSpv;
                                 TargetVersion = glslang::EShTargetSpv_1_5;
                             } else
-                                Error("--target-env expected one of: vulkan1.0, vulkan1.1, opengl,\n"
+                                Error("--target-env expected one of: vulkan1.0, vulkan1.1, vulkan1.2, opengl,\n"
                                       "spirv1.0, spirv1.1, spirv1.2, spirv1.3, spirv1.4, or spirv1.5");
                         }
                         bumpArg();
+                    } else if (lowerword == "undef-macro" ||
+                               lowerword == "u") {
+                        if (argc > 1)
+                            UserPreamble.addUndef(argv[1]);
+                        else
+                            Error("expects <name>", argv[0]);
+                        bumpArg();
                     } else if (lowerword == "variable-name" || // synonyms
                                lowerword == "vn") {
                         Options |= EOptionOutputHexadecimal;
                         if (argc <= 1)
-                            Error("no <C-variable-name> provided for --variable-name");
+                            Error("no <C-variable-name> provided", lowerword.c_str());
                         variableName = argv[1];
                         bumpArg();
                         break;
                     } else if (lowerword == "version") {
                         Options |= EOptionDumpVersions;
-                    } else {
+                    } else if (lowerword == "help") {
                         usage();
+                        break;
+                    } else {
+                        Error("unrecognized command-line option", argv[0]);
                     }
                 }
                 break;
@@ -645,7 +669,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                 if (argv[0][2] == 0)
                     Options |= EOptionReadHlsl;
                 else
-                    UserPreamble.addDef(getStringOperand("-D<macro> macro name"));
+                    UserPreamble.addDef(getStringOperand("-D<name[=def]>"));
                 break;
             case 'u':
                 uniformLocationOverrides.push_back(getUniformOverride());
@@ -688,7 +712,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                 bumpArg();
                 break;
             case 'U':
-                UserPreamble.addUndef(getStringOperand("-U<macro>: macro name"));
+                UserPreamble.addUndef(getStringOperand("-U<name>"));
                 break;
             case 'V':
                 setVulkanSpv();
@@ -760,7 +784,7 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                 Options |= EOptionOutputHexadecimal;
                 break;
             default:
-                usage();
+                Error("unrecognized command-line option", argv[0]);
                 break;
             }
         } else {
@@ -807,6 +831,10 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
             TargetLanguage = glslang::EShTargetSpv;
             TargetVersion = glslang::EShTargetSpv_1_3;
             break;
+        case glslang::EShTargetVulkan_1_2:
+            TargetLanguage = glslang::EShTargetSpv;
+            TargetVersion = glslang::EShTargetSpv_1_5;
+            break;
         case glslang::EShTargetOpenGL_450:
             TargetLanguage = glslang::EShTargetSpv;
             TargetVersion = glslang::EShTargetSpv_1_0;
@@ -1263,7 +1291,7 @@ int singleMain()
     ProcessConfigFile();
 
     if ((Options & EOptionReadHlsl) && !((Options & EOptionOutputPreprocessed) || (Options & EOptionSpv)))
-        Error("ERROR: HLSL requires SPIR-V code generation (or preprocessing only)");
+        Error("HLSL requires SPIR-V code generation (or preprocessing only)");
 
     //
     // Two modes:
@@ -1498,8 +1526,8 @@ void usage()
            "Options:\n"
            "  -C          cascading errors; risk crash from accumulation of error recoveries\n"
            "  -D          input is HLSL (this is the default when any suffix is .hlsl)\n"
-           "  -D<macro=def>\n"
-           "  -D<macro>   define a pre-processor macro\n"
+           "  -D<name[=def]> | --define-macro <name[=def]> | --D <name[=def]>\n"
+           "              define a pre-processor macro\n"
            "  -E          print pre-processed GLSL; cannot be used with -l;\n"
            "              errors will appear on stderr\n"
            "  -G[ver]     create SPIR-V binary, under OpenGL semantics; turns on -l;\n"
@@ -1515,7 +1543,8 @@ void usage()
            "  -Os         optimizes SPIR-V to minimize size\n"
            "  -S <stage>  uses specified stage rather than parsing the file extension\n"
            "              choices for <stage> are vert, tesc, tese, geom, frag, or comp\n"
-           "  -U<macro>   undefine a pre-processor macro\n"
+           "  -U<name> | --undef-macro <name> | --U <name>\n"
+           "              undefine a pre-processor macro\n"
            "  -V[ver]     create SPIR-V binary, under Vulkan semantics; turns on -l;\n"
            "              default file name is <stage>.spv (-o overrides this)\n"
            "              'ver', when present, is the version of the input semantics,\n"
@@ -1621,16 +1650,17 @@ void usage()
            "  --sep                             synonym for --source-entrypoint\n"
            "  --stdin                           read from stdin instead of from a file;\n"
            "                                    requires providing the shader stage using -S\n"
-           "  --target-env {vulkan1.0 | vulkan1.1 | opengl | \n"
+           "  --target-env {vulkan1.0 | vulkan1.1 | vulkan1.2 | opengl | \n"
            "                spirv1.0 | spirv1.1 | spirv1.2 | spirv1.3 | spirv1.4 | spirv1.5}\n"
-           "                                    set execution environment that emitted code\n"
-           "                                    will execute in (versus source language\n"
-           "                                    semantics selected by --client) defaults:\n"
-           "                                     * 'vulkan1.0' under '--client vulkan<ver>'\n"
-           "                                     * 'opengl' under '--client opengl<ver>'\n"
-           "                                     * 'spirv1.0' under --target-env vulkan1.0\n"
-           "                                     * 'spirv1.3' under --target-env vulkan1.1\n"
-           "                                    multiple --targen-env can be specified.\n"
+           "                                    Set the execution environment that the\n"
+           "                                    generated code will be executed in.\n"
+           "                                    Defaults to:\n"
+           "                                     * vulkan1.0 under --client vulkan<ver>\n"
+           "                                     * opengl    under --client opengl<ver>\n"
+           "                                     * spirv1.0  under --target-env vulkan1.0\n"
+           "                                     * spirv1.3  under --target-env vulkan1.1\n"
+           "                                     * spirv1.5  under --target-env vulkan1.2\n"
+           "                                    Multiple --target-env can be specified.\n"
            "  --variable-name <name>\n"
            "  --vn <name>                       creates a C header file that contains a\n"
            "                                    uint32_t array named <name>\n"

+ 451 - 0
3rdparty/glslang/glslang/CInterface/glslang_c_interface.cpp

@@ -0,0 +1,451 @@
+/**
+    This code is based on the glslang_c_interface implementation by Viktor Latypov
+**/
+
+/**
+BSD 2-Clause License
+
+Copyright (c) 2019, Viktor Latypov
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**/
+
+#include "glslang/Include/glslang_c_interface.h"
+
+#include "SPIRV/GlslangToSpv.h"
+#include "SPIRV/Logger.h"
+#include "SPIRV/SpvTools.h"
+#include "StandAlone/DirStackFileIncluder.h"
+#include "StandAlone/ResourceLimits.h"
+#include "glslang/Include/ShHandle.h"
+
+#include "glslang/Include/ResourceLimits.h"
+#include "glslang/MachineIndependent/Versions.h"
+
+static_assert(GLSLANG_STAGE_COUNT == EShLangCount, "");
+static_assert(GLSLANG_STAGE_MASK_COUNT == EShLanguageMaskCount, "");
+static_assert(GLSLANG_SOURCE_COUNT == glslang::EShSourceCount, "");
+static_assert(GLSLANG_CLIENT_COUNT == glslang::EShClientCount, "");
+static_assert(GLSLANG_TARGET_COUNT == glslang::EShTargetCount, "");
+static_assert(GLSLANG_TARGET_CLIENT_VERSION_COUNT == glslang::EShTargetClientVersionCount, "");
+static_assert(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT == glslang::EShTargetLanguageVersionCount, "");
+static_assert(GLSLANG_OPT_LEVEL_COUNT == EshOptLevelCount, "");
+static_assert(GLSLANG_TEX_SAMP_TRANS_COUNT == EShTexSampTransCount, "");
+static_assert(GLSLANG_MSG_COUNT == EShMsgCount, "");
+static_assert(GLSLANG_REFLECTION_COUNT == EShReflectionCount, "");
+static_assert(GLSLANG_PROFILE_COUNT == EProfileCount, "");
+
+typedef struct glslang_shader_s {
+    glslang::TShader* shader;
+    std::string preprocessedGLSL;
+} glslang_shader_t;
+
+typedef struct glslang_program_s {
+    glslang::TProgram* program;
+    std::vector<unsigned int> spirv;
+    std::string loggerMessages;
+} glslang_program_t;
+
+/* Wrapper/Adapter for C glsl_include_callbacks_t functions
+
+   This class contains a 'glsl_include_callbacks_t' structure
+   with C include_local/include_system callback pointers.
+
+   This class implement TShader::Includer interface
+   by redirecting C++ virtual methods to C callbacks.
+
+   The 'IncludeResult' instances produced by this Includer
+   contain a reference to glsl_include_result_t C structure
+   to allow its lifetime management by another C callback
+   (CallbackIncluder::callbacks::free_include_result)
+*/
+class CallbackIncluder : public glslang::TShader::Includer {
+public:
+    /* Wrapper of IncludeResult which stores a glsl_include_result object internally */
+    class CallbackIncludeResult : public glslang::TShader::Includer::IncludeResult {
+    public:
+        CallbackIncludeResult(const std::string& headerName, const char* const headerData, const size_t headerLength,
+                              void* userData, glsl_include_result_t* includeResult)
+            : glslang::TShader::Includer::IncludeResult(headerName, headerData, headerLength, userData),
+              includeResult(includeResult)
+        {
+        }
+
+        virtual ~CallbackIncludeResult() {}
+
+    protected:
+        friend class CallbackIncluder;
+
+        glsl_include_result_t* includeResult;
+    };
+
+public:
+    CallbackIncluder(glsl_include_callbacks_t _callbacks, void* _context) : callbacks(_callbacks), context(_context) {}
+
+    virtual ~CallbackIncluder() {}
+
+    virtual IncludeResult* includeSystem(const char* headerName, const char* includerName,
+                                         size_t inclusionDepth) override
+    {
+        if (this->callbacks.include_system) {
+            glsl_include_result_t* result =
+                this->callbacks.include_system(this->context, headerName, includerName, inclusionDepth);
+
+            return new CallbackIncludeResult(std::string(headerName), result->header_data, result->header_length,
+                                             nullptr, result);
+        }
+
+        return glslang::TShader::Includer::includeSystem(headerName, includerName, inclusionDepth);
+    }
+
+    virtual IncludeResult* includeLocal(const char* headerName, const char* includerName,
+                                        size_t inclusionDepth) override
+    {
+        if (this->callbacks.include_local) {
+            glsl_include_result_t* result =
+                this->callbacks.include_local(this->context, headerName, includerName, inclusionDepth);
+
+            return new CallbackIncludeResult(std::string(headerName), result->header_data, result->header_length,
+                                             nullptr, result);
+        }
+
+        return glslang::TShader::Includer::includeLocal(headerName, includerName, inclusionDepth);
+    }
+
+    /* This function only calls free_include_result callback
+       when the IncludeResult instance is allocated by a C function */
+    virtual void releaseInclude(IncludeResult* result) override
+    {
+        if (result == nullptr)
+            return;
+
+        if (this->callbacks.free_include_result && (result->userData == nullptr)) {
+            CallbackIncludeResult* innerResult = static_cast<CallbackIncludeResult*>(result);
+            /* use internal free() function */
+            this->callbacks.free_include_result(this->context, innerResult->includeResult);
+            /* ignore internal fields of TShader::Includer::IncludeResult */
+            delete result;
+            return;
+        }
+
+        delete[] static_cast<char*>(result->userData);
+        delete result;
+    }
+
+private:
+    CallbackIncluder() {}
+
+    /* C callback pointers */
+    glsl_include_callbacks_t callbacks;
+    /* User-defined context */
+    void* context;
+};
+
+int glslang_initialize_process() { return static_cast<int>(glslang::InitializeProcess()); }
+
+void glslang_finalize_process() { glslang::FinalizeProcess(); }
+
+static EShLanguage c_shader_stage(glslang_stage_t stage)
+{
+    switch (stage) {
+    case GLSLANG_STAGE_VERTEX:
+        return EShLangVertex;
+    case GLSLANG_STAGE_TESSCONTROL:
+        return EShLangTessControl;
+    case GLSLANG_STAGE_TESSEVALUATION:
+        return EShLangTessEvaluation;
+    case GLSLANG_STAGE_GEOMETRY:
+        return EShLangGeometry;
+    case GLSLANG_STAGE_FRAGMENT:
+        return EShLangFragment;
+    case GLSLANG_STAGE_COMPUTE:
+        return EShLangCompute;
+    case GLSLANG_STAGE_RAYGEN_NV:
+        return EShLangRayGenNV;
+    case GLSLANG_STAGE_INTERSECT_NV:
+        return EShLangIntersectNV;
+    case GLSLANG_STAGE_ANYHIT_NV:
+        return EShLangAnyHitNV;
+    case GLSLANG_STAGE_CLOSESTHIT_NV:
+        return EShLangClosestHitNV;
+    case GLSLANG_STAGE_MISS_NV:
+        return EShLangMissNV;
+    case GLSLANG_STAGE_CALLABLE_NV:
+        return EShLangCallableNV;
+    case GLSLANG_STAGE_TASK_NV:
+        return EShLangTaskNV;
+    case GLSLANG_STAGE_MESH_NV:
+        return EShLangMeshNV;
+    default:
+        break;
+    }
+    return EShLangCount;
+}
+
+static int c_shader_messages(glslang_messages_t messages)
+{
+#define CONVERT_MSG(in, out)                                                                                           \
+    if ((messages & in) == in)                                                                                         \
+        res |= out;
+
+    int res = 0;
+
+    CONVERT_MSG(GLSLANG_MSG_RELAXED_ERRORS_BIT, EShMsgRelaxedErrors);
+    CONVERT_MSG(GLSLANG_MSG_SUPPRESS_WARNINGS_BIT, EShMsgSuppressWarnings);
+    CONVERT_MSG(GLSLANG_MSG_AST_BIT, EShMsgAST);
+    CONVERT_MSG(GLSLANG_MSG_SPV_RULES_BIT, EShMsgSpvRules);
+    CONVERT_MSG(GLSLANG_MSG_VULKAN_RULES_BIT, EShMsgVulkanRules);
+    CONVERT_MSG(GLSLANG_MSG_ONLY_PREPROCESSOR_BIT, EShMsgOnlyPreprocessor);
+    CONVERT_MSG(GLSLANG_MSG_READ_HLSL_BIT, EShMsgReadHlsl);
+    CONVERT_MSG(GLSLANG_MSG_CASCADING_ERRORS_BIT, EShMsgCascadingErrors);
+    CONVERT_MSG(GLSLANG_MSG_KEEP_UNCALLED_BIT, EShMsgKeepUncalled);
+    CONVERT_MSG(GLSLANG_MSG_HLSL_OFFSETS_BIT, EShMsgHlslOffsets);
+    CONVERT_MSG(GLSLANG_MSG_DEBUG_INFO_BIT, EShMsgDebugInfo);
+    CONVERT_MSG(GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT, EShMsgHlslEnable16BitTypes);
+    CONVERT_MSG(GLSLANG_MSG_HLSL_LEGALIZATION_BIT, EShMsgHlslLegalization);
+    CONVERT_MSG(GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT, EShMsgHlslDX9Compatible);
+    CONVERT_MSG(GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT, EShMsgBuiltinSymbolTable);
+    return res;
+#undef CONVERT_MSG
+}
+
+static glslang::EShTargetLanguageVersion
+c_shader_target_language_version(glslang_target_language_version_t target_language_version)
+{
+    switch (target_language_version) {
+    case GLSLANG_TARGET_SPV_1_0:
+        return glslang::EShTargetSpv_1_0;
+    case GLSLANG_TARGET_SPV_1_1:
+        return glslang::EShTargetSpv_1_1;
+    case GLSLANG_TARGET_SPV_1_2:
+        return glslang::EShTargetSpv_1_2;
+    case GLSLANG_TARGET_SPV_1_3:
+        return glslang::EShTargetSpv_1_3;
+    case GLSLANG_TARGET_SPV_1_4:
+        return glslang::EShTargetSpv_1_4;
+    case GLSLANG_TARGET_SPV_1_5:
+        return glslang::EShTargetSpv_1_5;
+    default:
+        break;
+    }
+    return glslang::EShTargetSpv_1_0;
+}
+
+static glslang::EShClient c_shader_client(glslang_client_t client)
+{
+    switch (client) {
+    case GLSLANG_CLIENT_VULKAN:
+        return glslang::EShClientVulkan;
+    case GLSLANG_CLIENT_OPENGL:
+        return glslang::EShClientOpenGL;
+    default:
+        break;
+    }
+
+    return glslang::EShClientNone;
+}
+
+static glslang::EShTargetClientVersion c_shader_client_version(glslang_target_client_version_t client_version)
+{
+    switch (client_version) {
+    case GLSLANG_TARGET_VULKAN_1_1:
+        return glslang::EShTargetVulkan_1_1;
+    case GLSLANG_TARGET_OPENGL_450:
+        return glslang::EShTargetOpenGL_450;
+    default:
+        break;
+    }
+
+    return glslang::EShTargetVulkan_1_0;
+}
+
+static glslang::EShTargetLanguage c_shader_target_language(glslang_target_language_t target_language)
+{
+    if (target_language == GLSLANG_TARGET_NONE)
+        return glslang::EShTargetNone;
+
+    return glslang::EShTargetSpv;
+}
+
+static glslang::EShSource c_shader_source(glslang_source_t source)
+{
+    switch (source) {
+    case GLSLANG_SOURCE_GLSL:
+        return glslang::EShSourceGlsl;
+    case GLSLANG_SOURCE_HLSL:
+        return glslang::EShSourceHlsl;
+    default:
+        break;
+    }
+
+    return glslang::EShSourceNone;
+}
+
+static EProfile c_shader_profile(glslang_profile_t profile)
+{
+    switch (profile) {
+    case GLSLANG_BAD_PROFILE:
+        return EBadProfile;
+    case GLSLANG_NO_PROFILE:
+        return ENoProfile;
+    case GLSLANG_CORE_PROFILE:
+        return ECoreProfile;
+    case GLSLANG_COMPATIBILITY_PROFILE:
+        return ECompatibilityProfile;
+    case GLSLANG_ES_PROFILE:
+        return EEsProfile;
+    }
+
+    return EProfile();
+}
+
+glslang_shader_t* glslang_shader_create(const glslang_input_t* input)
+{
+    if (!input || !input->code) {
+        printf("Error creating shader: null input(%p)/input->code\n", input);
+
+        if (input)
+            printf("input->code = %p\n", input->code);
+
+        return nullptr;
+    }
+
+    glslang_shader_t* shader = new glslang_shader_t();
+
+    shader->shader = new glslang::TShader(c_shader_stage(input->stage));
+    shader->shader->setStrings(&input->code, 1);
+    shader->shader->setEnvInput(c_shader_source(input->language), c_shader_stage(input->stage),
+                                c_shader_client(input->client), input->default_version);
+    shader->shader->setEnvClient(c_shader_client(input->client), c_shader_client_version(input->client_version));
+    shader->shader->setEnvTarget(c_shader_target_language(input->target_language),
+                                 c_shader_target_language_version(input->target_language_version));
+
+    return shader;
+}
+
+const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader)
+{
+    return shader->preprocessedGLSL.c_str();
+}
+
+int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* i)
+{
+    DirStackFileIncluder Includer;
+    /* TODO: use custom callbacks if they are available in 'i->callbacks' */
+    return shader->shader->preprocess(
+        /* No user-defined resources limit */
+        &glslang::DefaultTBuiltInResource, i->default_version, c_shader_profile(i->default_profile),
+        i->force_default_version_and_profile != 0, i->forward_compatible != 0,
+        (EShMessages)c_shader_messages(i->messages), &shader->preprocessedGLSL, Includer
+    );
+}
+
+int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input)
+{
+    const char* preprocessedCStr = shader->preprocessedGLSL.c_str();
+    shader->shader->setStrings(&preprocessedCStr, 1);
+
+    return shader->shader->parse(
+        /* No user-defined resource limits for now */
+        &glslang::DefaultTBuiltInResource, input->default_version, input->forward_compatible != 0,
+        (EShMessages)c_shader_messages(input->messages));
+}
+
+const char* glslang_shader_get_info_log(glslang_shader_t* shader) { return shader->shader->getInfoLog(); }
+
+const char* glslang_shader_get_info_debug_log(glslang_shader_t* shader) { return shader->shader->getInfoDebugLog(); }
+
+void glslang_shader_delete(glslang_shader_t* shader)
+{
+    if (!shader)
+        return;
+
+    delete (shader->shader);
+    delete (shader);
+}
+
+glslang_program_t* glslang_program_create()
+{
+    glslang_program_t* p = new glslang_program_t();
+    p->program = new glslang::TProgram();
+    return p;
+}
+
+void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage)
+{
+    spv::SpvBuildLogger logger;
+    glslang::SpvOptions spvOptions;
+    spvOptions.validate = true;
+
+    const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage));
+
+    glslang::GlslangToSpv(*intermediate, program->spirv, &logger, &spvOptions);
+
+    program->loggerMessages = logger.getAllMessages();
+}
+
+size_t glslang_program_SPIRV_get_size(glslang_program_t* program) { return program->spirv.size(); }
+
+void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int* out)
+{
+    memcpy(out, program->spirv.data(), program->spirv.size() * sizeof(unsigned int));
+}
+
+unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program)
+{
+    return program->spirv.data();
+}
+
+const char* glslang_program_SPIRV_get_messages(glslang_program_t* program)
+{
+    return program->loggerMessages.empty() ? nullptr : program->loggerMessages.c_str();
+}
+
+void glslang_program_delete(glslang_program_t* program)
+{
+    if (!program)
+        return;
+
+    delete (program->program);
+    delete (program);
+}
+
+void glslang_program_add_shader(glslang_program_t* program, glslang_shader_t* shader)
+{
+    program->program->addShader(shader->shader);
+}
+
+int glslang_program_link(glslang_program_t* program, int messages)
+{
+    return (int)program->program->link((EShMessages)messages);
+}
+
+const char* glslang_program_get_info_log(glslang_program_t* program)
+{
+    return program->program->getInfoLog();
+}
+
+const char* glslang_program_get_info_debug_log(glslang_program_t* program)
+{
+    return program->program->getInfoDebugLog();
+}

+ 4 - 1
3rdparty/glslang/glslang/CMakeLists.txt

@@ -41,7 +41,8 @@ set(SOURCES
     MachineIndependent/preprocessor/PpTokens.cpp
     MachineIndependent/propagateNoContraction.cpp
     GenericCodeGen/CodeGen.cpp
-    GenericCodeGen/Link.cpp)
+    GenericCodeGen/Link.cpp
+    CInterface/glslang_c_interface.cpp)
 
 set(HEADERS
     Public/ShaderLang.h
@@ -49,6 +50,8 @@ set(HEADERS
     Include/BaseTypes.h
     Include/Common.h
     Include/ConstantUnion.h
+    Include/glslang_c_interface.h
+    Include/glslang_c_shader_types.h
     Include/InfoSink.h
     Include/InitializeGlobals.h
     Include/intermediate.h

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

@@ -921,7 +921,7 @@ public:
         else
             unionArray =  new TConstUnionVector(size);
     }
-    TConstUnionArray(const TConstUnionArray& a) : unionArray(a.unionArray) { }
+    TConstUnionArray(const TConstUnionArray& a) = default;
     TConstUnionArray(const TConstUnionArray& a, int start, int size)
     {
         unionArray = new TConstUnionVector(size);

+ 8 - 8
3rdparty/glslang/glslang/Include/Types.h

@@ -82,11 +82,6 @@ struct TSampler {   // misnomer now; includes images, textures without sampler,
     bool    sampler : 1;  // true means a pure sampler, other fields should be clear()
 
 #ifdef GLSLANG_WEB
-    unsigned int getVectorSize() const { return 4; }
-    void clearReturnStruct() const { }
-    bool hasReturnStruct() const { return false; }
-    unsigned getStructReturnIndex() const { return 0; }
-
     bool is1D()          const { return false; }
     bool isBuffer()      const { return false; }
     bool isRect()        const { return false; }
@@ -111,10 +106,12 @@ struct TSampler {   // misnomer now; includes images, textures without sampler,
     bool   external : 1;  // GL_OES_EGL_image_external
     bool        yuv : 1;  // GL_EXT_YUV_target
 
+#ifdef ENABLE_HLSL
     unsigned int getVectorSize() const { return vectorSize; }
     void clearReturnStruct() { structReturnIndex = noReturnStruct; }
     bool hasReturnStruct() const { return structReturnIndex != noReturnStruct; }
     unsigned getStructReturnIndex() const { return structReturnIndex; }
+#endif
 
     bool is1D()          const { return dim == Esd1D; }
     bool isBuffer()      const { return dim == EsdBuffer; }
@@ -225,9 +222,12 @@ struct TSampler {   // misnomer now; includes images, textures without sampler,
             isCombined() == right.isCombined() &&
          isPureSampler() == right.isPureSampler() &&
             isExternal() == right.isExternal() &&
-                 isYuv() == right.isYuv() &&
-         getVectorSize() == right.getVectorSize() &&
-  getStructReturnIndex() == right.getStructReturnIndex();
+                 isYuv() == right.isYuv()
+#ifdef ENABLE_HLSL
+      && getVectorSize() == right.getVectorSize() &&
+  getStructReturnIndex() == right.getStructReturnIndex()
+#endif
+        ;
     }
 
     bool operator!=(const TSampler& right) const

+ 119 - 0
3rdparty/glslang/glslang/Include/glslang_c_interface.h

@@ -0,0 +1,119 @@
+/**
+    This code is based on the glslang_c_interface implementation by Viktor Latypov
+**/
+
+/**
+BSD 2-Clause License
+
+Copyright (c) 2019, Viktor Latypov
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**/
+
+#ifndef GLSLANG_C_IFACE_H_INCLUDED
+#define GLSLANG_C_IFACE_H_INCLUDED
+
+#include <stdlib.h>
+
+#include "glslang_c_shader_types.h"
+
+typedef struct glslang_shader_s glslang_shader_t;
+typedef struct glslang_program_s glslang_program_t;
+
+typedef struct glslang_input_s {
+    glslang_source_t language;
+    glslang_stage_t stage;
+    glslang_client_t client;
+    glslang_target_client_version_t client_version;
+    glslang_target_language_t target_language;
+    glslang_target_language_version_t target_language_version;
+    /** Shader source code */
+    const char* code;
+    int default_version;
+    glslang_profile_t default_profile;
+    int force_default_version_and_profile;
+    int forward_compatible;
+    glslang_messages_t messages;
+} glslang_input_t;
+
+/* Inclusion result structure allocated by C include_local/include_system callbacks */
+typedef struct glsl_include_result_s {
+    /* Header file name or NULL if inclusion failed */
+    const char* header_name;
+
+    /* Header contents or NULL */
+    const char* header_data;
+    size_t header_length;
+
+} glsl_include_result_t;
+
+/* Callback for local file inclusion */
+typedef glsl_include_result_t* (*glsl_include_local_func)(void* ctx, const char* header_name, const char* includer_name,
+                                                          size_t include_depth);
+
+/* Callback for system file inclusion */
+typedef glsl_include_result_t* (*glsl_include_system_func)(void* ctx, const char* header_name,
+                                                           const char* includer_name, size_t include_depth);
+
+/* Callback for include result destruction */
+typedef int (*glsl_free_include_result_func)(void* ctx, glsl_include_result_t* result);
+
+/* Collection of callbacks for GLSL preprocessor */
+typedef struct glsl_include_callbacks_s {
+    glsl_include_system_func include_system;
+    glsl_include_local_func include_local;
+    glsl_free_include_result_func free_include_result;
+} glsl_include_callbacks_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int glslang_initialize_process();
+void glslang_finalize_process();
+
+glslang_shader_t* glslang_shader_create(const glslang_input_t* input);
+void glslang_shader_delete(glslang_shader_t* shader);
+int glslang_shader_preprocess(glslang_shader_t* shader, const glslang_input_t* input);
+int glslang_shader_parse(glslang_shader_t* shader, const glslang_input_t* input);
+const char* glslang_shader_get_preprocessed_code(glslang_shader_t* shader);
+const char* glslang_shader_get_info_log(glslang_shader_t* shader);
+const char* glslang_shader_get_info_debug_log(glslang_shader_t* shader);
+
+glslang_program_t* glslang_program_create();
+void glslang_program_delete(glslang_program_t* program);
+void glslang_program_add_shader(glslang_program_t* program, glslang_shader_t* shader);
+int glslang_program_link(glslang_program_t* program, int messages); // glslang_messages_t
+void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage);
+size_t glslang_program_SPIRV_get_size(glslang_program_t* program);
+void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int*);
+unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program);
+const char* glslang_program_SPIRV_get_messages(glslang_program_t* program);
+const char* glslang_program_get_info_log(glslang_program_t* program);
+const char* glslang_program_get_info_debug_log(glslang_program_t* program);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifdef GLSLANG_C_IFACE_INCLUDED */

+ 182 - 0
3rdparty/glslang/glslang/Include/glslang_c_shader_types.h

@@ -0,0 +1,182 @@
+/**
+    This code is based on the glslang_c_interface implementation by Viktor Latypov
+**/
+
+/**
+BSD 2-Clause License
+
+Copyright (c) 2019, Viktor Latypov
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**/
+
+#ifndef C_SHADER_TYPES_H_INCLUDED
+#define C_SHADER_TYPES_H_INCLUDED
+
+#define LAST_ELEMENT_MARKER(x) x
+
+/* EShLanguage counterpart */
+typedef enum {
+    GLSLANG_STAGE_VERTEX,
+    GLSLANG_STAGE_TESSCONTROL,
+    GLSLANG_STAGE_TESSEVALUATION,
+    GLSLANG_STAGE_GEOMETRY,
+    GLSLANG_STAGE_FRAGMENT,
+    GLSLANG_STAGE_COMPUTE,
+    GLSLANG_STAGE_RAYGEN_NV,
+    GLSLANG_STAGE_INTERSECT_NV,
+    GLSLANG_STAGE_ANYHIT_NV,
+    GLSLANG_STAGE_CLOSESTHIT_NV,
+    GLSLANG_STAGE_MISS_NV,
+    GLSLANG_STAGE_CALLABLE_NV,
+    GLSLANG_STAGE_TASK_NV,
+    GLSLANG_STAGE_MESH_NV,
+    LAST_ELEMENT_MARKER(GLSLANG_STAGE_COUNT),
+} glslang_stage_t; // would be better as stage, but this is ancient now
+
+/* EShLanguageMask counterpart */
+typedef enum {
+    GLSLANG_STAGE_VERTEX_MASK = (1 << GLSLANG_STAGE_VERTEX),
+    GLSLANG_STAGE_TESSCONTROL_MASK = (1 << GLSLANG_STAGE_TESSCONTROL),
+    GLSLANG_STAGE_TESSEVALUATION_MASK = (1 << GLSLANG_STAGE_TESSEVALUATION),
+    GLSLANG_STAGE_GEOMETRY_MASK = (1 << GLSLANG_STAGE_GEOMETRY),
+    GLSLANG_STAGE_FRAGMENT_MASK = (1 << GLSLANG_STAGE_FRAGMENT),
+    GLSLANG_STAGE_COMPUTE_MASK = (1 << GLSLANG_STAGE_COMPUTE),
+    GLSLANG_STAGE_RAYGEN_NV_MASK = (1 << GLSLANG_STAGE_RAYGEN_NV),
+    GLSLANG_STAGE_INTERSECT_NV_MASK = (1 << GLSLANG_STAGE_INTERSECT_NV),
+    GLSLANG_STAGE_ANYHIT_NV_MASK = (1 << GLSLANG_STAGE_ANYHIT_NV),
+    GLSLANG_STAGE_CLOSESTHIT_NV_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT_NV),
+    GLSLANG_STAGE_MISS_NV_MASK = (1 << GLSLANG_STAGE_MISS_NV),
+    GLSLANG_STAGE_CALLABLE_NV_MASK = (1 << GLSLANG_STAGE_CALLABLE_NV),
+    GLSLANG_STAGE_TASK_NV_MASK = (1 << GLSLANG_STAGE_TASK_NV),
+    GLSLANG_STAGE_MESH_NV_MASK = (1 << GLSLANG_STAGE_MESH_NV),
+    LAST_ELEMENT_MARKER(GLSLANG_STAGE_MASK_COUNT),
+} glslang_stage_mask_t;
+
+/* EShSource counterpart */
+typedef enum {
+    GLSLANG_SOURCE_NONE,
+    GLSLANG_SOURCE_GLSL,
+    GLSLANG_SOURCE_HLSL,
+    LAST_ELEMENT_MARKER(GLSLANG_SOURCE_COUNT),
+} glslang_source_t;
+
+/* EShClient counterpart */
+typedef enum {
+    GLSLANG_CLIENT_NONE,
+    GLSLANG_CLIENT_VULKAN,
+    GLSLANG_CLIENT_OPENGL,
+    LAST_ELEMENT_MARKER(GLSLANG_CLIENT_COUNT),
+} glslang_client_t;
+
+/* EShTargetLanguage counterpart */
+typedef enum {
+    GLSLANG_TARGET_NONE,
+    GLSLANG_TARGET_SPV,
+    LAST_ELEMENT_MARKER(GLSLANG_TARGET_COUNT),
+} glslang_target_language_t;
+
+/* SH_TARGET_ClientVersion counterpart */
+typedef enum {
+    GLSLANG_TARGET_VULKAN_1_0 = (1 << 22),
+    GLSLANG_TARGET_VULKAN_1_1 = (1 << 22) | (1 << 12),
+    GLSLANG_TARGET_OPENGL_450 = 450,
+    LAST_ELEMENT_MARKER(GLSLANG_TARGET_CLIENT_VERSION_COUNT),
+} glslang_target_client_version_t;
+
+/* SH_TARGET_LanguageVersion counterpart */
+typedef enum {
+    GLSLANG_TARGET_SPV_1_0 = (1 << 16),
+    GLSLANG_TARGET_SPV_1_1 = (1 << 16) | (1 << 8),
+    GLSLANG_TARGET_SPV_1_2 = (1 << 16) | (2 << 8),
+    GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
+    GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
+    GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
+    LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT),
+} glslang_target_language_version_t;
+
+/* EShExecutable counterpart */
+typedef enum { GLSLANG_EX_VERTEX_FRAGMENT, GLSLANG_EX_FRAGMENT } glslang_executable_t;
+
+/* EShOptimizationLevel counterpart  */
+typedef enum {
+    GLSLANG_OPT_NO_GENERATION,
+    GLSLANG_OPT_NONE,
+    GLSLANG_OPT_SIMPLE,
+    GLSLANG_OPT_FULL,
+    LAST_ELEMENT_MARKER(GLSLANG_OPT_LEVEL_COUNT),
+} glslang_optimization_level_t;
+
+/* EShTextureSamplerTransformMode counterpart */
+typedef enum {
+    GLSLANG_TEX_SAMP_TRANS_KEEP,
+    GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER,
+    LAST_ELEMENT_MARKER(GLSLANG_TEX_SAMP_TRANS_COUNT),
+} glslang_texture_sampler_transform_mode_t;
+
+/* EShMessages counterpart */
+typedef enum {
+    GLSLANG_MSG_DEFAULT_BIT = 0,
+    GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
+    GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
+    GLSLANG_MSG_AST_BIT = (1 << 2),
+    GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
+    GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
+    GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
+    GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
+    GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
+    GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
+    GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
+    GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
+    GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
+    GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
+    GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
+    GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
+    LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
+} glslang_messages_t;
+
+/* EShReflectionOptions counterpart */
+typedef enum {
+    GLSLANG_REFLECTION_DEFAULT_BIT = 0,
+    GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 << 0),
+    GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 << 1),
+    GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 << 2),
+    GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3),
+    GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4),
+    GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5),
+    LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT),
+} glslang_reflection_options_t;
+
+/* EProfile counterpart (from Versions.h) */
+typedef enum {
+    GLSLANG_BAD_PROFILE = 0,
+    GLSLANG_NO_PROFILE = (1 << 0),
+    GLSLANG_CORE_PROFILE = (1 << 1),
+    GLSLANG_COMPATIBILITY_PROFILE = (1 << 2),
+    GLSLANG_ES_PROFILE = (1 << 3),
+    LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
+} glslang_profile_t;
+
+#undef LAST_ELEMENT_MARKER
+
+#endif

+ 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 3500
+#define GLSLANG_PATCH_LEVEL 3559

+ 65 - 21
3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp

@@ -690,7 +690,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     //
     // double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack
     //
-    if (profile != EEsProfile && version >= 400) {
+    if (profile != EEsProfile && version >= 150) {  // ARB_gpu_shader_fp64
         commonBuiltins.append(
 
             "double sqrt(double);"
@@ -1298,15 +1298,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "vec3   fma(vec3,   vec3,   vec3  );"
             "vec4   fma(vec4,   vec4,   vec4  );"
             "\n");
+    }
 
-        if (profile != EEsProfile) {
+    if (profile != EEsProfile && version >= 150) {  // ARB_gpu_shader_fp64
             commonBuiltins.append(
                 "double fma(double, double, double);"
                 "dvec2  fma(dvec2,  dvec2,  dvec2 );"
                 "dvec3  fma(dvec3,  dvec3,  dvec3 );"
                 "dvec4  fma(dvec4,  dvec4,  dvec4 );"
                 "\n");
-        }
     }
 
     if ((profile == EEsProfile && version >= 310) ||
@@ -1325,7 +1325,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
     }
 
-    if (profile != EEsProfile && version >= 400) {
+    if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
         commonBuiltins.append(
             "double frexp(double, out int);"
             "dvec2  frexp( dvec2, out ivec2);"
@@ -3946,7 +3946,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     //
     // Geometric Functions.
     //
-    if (IncludeLegacy(version, profile, spvVersion))
+    if (spvVersion.vulkan == 0 && IncludeLegacy(version, profile, spvVersion))
         stageBuiltins[EShLangVertex].append("vec4 ftransform();");
 
     //
@@ -5178,19 +5178,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 "flat in int gl_PrimitiveID;"
                 );
 
-        if (version >= 400) {
+        if (version >= 130) { // ARB_sample_shading
             stageBuiltins[EShLangFragment].append(
                 "flat in  int  gl_SampleID;"
                 "     in  vec2 gl_SamplePosition;"
-                "flat in  int  gl_SampleMaskIn[];"
                 "     out int  gl_SampleMask[];"
                 );
-            if (spvVersion.spv == 0)
+
+            if (spvVersion.spv == 0) {
                 stageBuiltins[EShLangFragment].append(
                     "uniform int gl_NumSamples;"
-                    );
+                );
+            }
         }
 
+        if (version >= 400)
+            stageBuiltins[EShLangFragment].append(
+                "flat in  int  gl_SampleMaskIn[];"
+            );
+
         if (version >= 430)
             stageBuiltins[EShLangFragment].append(
                 "flat in int gl_Layer;"
@@ -6618,9 +6624,34 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
             }
         }
 
+        if (version >= 320) {
+            // tessellation
+
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources.maxTessControlAtomicCounters);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources.maxTessEvaluationAtomicCounters);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources.maxTessControlAtomicCounterBuffers);
+            s.append(builtInConstant);
+            snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources.maxTessEvaluationAtomicCounterBuffers);
+            s.append(builtInConstant);
+        }
+
     } else {
         // non-ES profile
 
+        if (version > 400) {
+            snprintf(builtInConstant, maxSize, "const int  gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors);
+            s.append(builtInConstant);
+
+            snprintf(builtInConstant, maxSize, "const int  gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
+            s.append(builtInConstant);
+        }
+
         snprintf(builtInConstant, maxSize, "const int  gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
         s.append(builtInConstant);
 
@@ -7422,18 +7453,29 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
             BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable);
         }
 
-        if ((profile != EEsProfile && version >= 400) ||
+        if ((profile != EEsProfile && version >= 130) ||
             (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 && version < 320) {
-                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_SampleID",           EbvSampleId,       symbolTable);
+            BuiltInVariable("gl_SamplePosition",     EbvSamplePosition, symbolTable);
+            BuiltInVariable("gl_SampleMask",         EbvSampleMask,     symbolTable);
+
+            if (profile != EEsProfile && version < 400) {
+                BuiltInVariable("gl_NumSamples",     EbvSampleMask,     symbolTable);
+
+                symbolTable.setVariableExtensions("gl_SampleMask",     1, &E_GL_ARB_sample_shading);
+                symbolTable.setVariableExtensions("gl_SampleID",       1, &E_GL_ARB_sample_shading);
+                symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_ARB_sample_shading);
+                symbolTable.setVariableExtensions("gl_NumSamples",     1, &E_GL_ARB_sample_shading);
+            } else {
+                BuiltInVariable("gl_SampleMaskIn",    EbvSampleMask,     symbolTable);
+
+                if (profile == EEsProfile && version < 320) {
+                    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);
+                }
             }
         }
 
@@ -8444,9 +8486,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
         symbolTable.relateToOperator("textureFootprintGradNV",      EOpImageSampleFootprintGradNV);
         symbolTable.relateToOperator("textureFootprintGradClampNV", EOpImageSampleFootprintGradClampNV);
 
+        if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion))
+            symbolTable.relateToOperator("ftransform", EOpFtransform);
+
         if (spvVersion.spv == 0 && (IncludeLegacy(version, profile, spvVersion) ||
             (profile == EEsProfile && version == 100))) {
-            symbolTable.relateToOperator("ftransform",               EOpFtransform);
 
             symbolTable.relateToOperator("texture1D",                EOpTexture);
             symbolTable.relateToOperator("texture1DGradARB",         EOpTextureGrad);

+ 3 - 0
3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp

@@ -2774,6 +2774,9 @@ bool TIntermediate::postProcess(TIntermNode* root, EShLanguage /*language*/)
     case EShTexSampTransUpgradeTextureRemoveSampler:
         performTextureUpgradeAndSamplerRemovalTransformation(root);
         break;
+    case EShTexSampTransCount:
+        assert(0);
+        break;
     }
 #endif
 

+ 11 - 5
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -6035,6 +6035,10 @@ void TParseContext::fixOffset(const TSourceLoc& loc, TSymbol& symbol)
                 offset = qualifier.layoutOffset;
             else
                 offset = atomicUintOffsets[qualifier.layoutBinding];
+
+            if (offset % 4 != 0)
+                error(loc, "atomic counters offset should align based on 4:", "offset", "%d", offset);
+
             symbol.getWritableType().getQualifier().layoutOffset = offset;
 
             // Check for overlap
@@ -6087,7 +6091,7 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& loc, const TFunct
     if (isEsProfile() || version < 120)
         function = findFunctionExact(loc, call, builtIn);
     else if (version < 400)
-        function = findFunction120(loc, call, builtIn);
+        function = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn);
     else if (explicitTypesEnabled)
         function = findFunctionExplicitTypes(loc, call, builtIn);
     else
@@ -6380,13 +6384,15 @@ const TFunction* TParseContext::findFunctionExplicitTypes(const TSourceLoc& loc,
 void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType& publicType)
 {
 #ifndef GLSLANG_WEB
-    if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding() &&
-        publicType.qualifier.hasOffset()) {
+    if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding()) {
         if (publicType.qualifier.layoutBinding >= (unsigned int)resources.maxAtomicCounterBindings) {
             error(loc, "atomic_uint binding is too large", "binding", "");
             return;
         }
-        atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset;
+
+        if(publicType.qualifier.hasOffset()) {
+            atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset;
+        }
         return;
     }
 
@@ -7609,7 +7615,7 @@ void TParseContext::blockStageIoCheck(const TSourceLoc& loc, const TQualifier& q
     switch (qualifier.storage) {
     case EvqUniform:
         profileRequires(loc, EEsProfile, 300, nullptr, "uniform block");
-        profileRequires(loc, ENoProfile, 140, nullptr, "uniform block");
+        profileRequires(loc, ENoProfile, 140, E_GL_ARB_uniform_buffer_object, "uniform block");
         if (currentBlockQualifier.layoutPacking == ElpStd430 && ! currentBlockQualifier.isPushConstant())
             requireExtensions(loc, 1, &E_GL_EXT_scalar_block_layout, "std430 requires the buffer storage qualifier");
         break;

+ 41 - 43
3rdparty/glslang/glslang/MachineIndependent/Scan.cpp

@@ -990,8 +990,7 @@ int TScanContext::tokenizeIdentifier()
 
 #ifndef GLSLANG_WEB
     case NOPERSPECTIVE:
-        if (parseContext.isEsProfile() && parseContext.version >= 300 &&
-            parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
+        if (parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
             return keyword;
         return es30ReservedFromGLSL(130);
 
@@ -1012,8 +1011,7 @@ int TScanContext::tokenizeIdentifier()
     case CALLDATAINNV:
     case ACCSTRUCTNV:
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            (!parseContext.isEsProfile() && parseContext.version >= 460
-                 && parseContext.extensionTurnedOn(E_GL_NV_ray_tracing)))
+            parseContext.extensionTurnedOn(E_GL_NV_ray_tracing))
             return keyword;
         return identifierOrType();
     case ATOMIC_UINT:
@@ -1168,7 +1166,10 @@ int TScanContext::tokenizeIdentifier()
     case DVEC3:
     case DVEC4:
         afterType = true;
-        if (parseContext.isEsProfile() || parseContext.version < 400)
+        if (parseContext.isEsProfile() || parseContext.version < 150 ||
+            (!parseContext.symbolTable.atBuiltInLevel() &&
+              parseContext.version < 400 &&
+             !parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64)))
             reservedWord();
         return keyword;
 
@@ -1182,10 +1183,9 @@ int TScanContext::tokenizeIdentifier()
     case U64VEC4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            (!parseContext.isEsProfile() && parseContext.version >= 450 &&
-             (parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int64))))
+            parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int64))
             return keyword;
         return identifierOrType();
 
@@ -1199,10 +1199,9 @@ int TScanContext::tokenizeIdentifier()
     case U8VEC4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            ((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_8bit_storage) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int8)) &&
-              !parseContext.isEsProfile() && parseContext.version >= 450))
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_8bit_storage) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int8))
             return keyword;
         return identifierOrType();
 
@@ -1216,11 +1215,10 @@ int TScanContext::tokenizeIdentifier()
     case U16VEC4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            (!parseContext.isEsProfile() && parseContext.version >= 450 &&
-             (parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_16bit_storage) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int16))))
+            parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_16bit_storage) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int16))
             return keyword;
         return identifierOrType();
     case INT32_T:
@@ -1233,9 +1231,8 @@ int TScanContext::tokenizeIdentifier()
     case U32VEC4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-           ((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-             parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int32)) &&
-             !parseContext.isEsProfile() && parseContext.version >= 450))
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_int32))
             return keyword;
         return identifierOrType();
     case FLOAT32_T:
@@ -1256,9 +1253,8 @@ int TScanContext::tokenizeIdentifier()
     case F32MAT4X4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            ((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float32)) &&
-              !parseContext.isEsProfile() && parseContext.version >= 450))
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float32))
             return keyword;
         return identifierOrType();
 
@@ -1280,9 +1276,8 @@ int TScanContext::tokenizeIdentifier()
     case F64MAT4X4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            ((parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float64)) &&
-              !parseContext.isEsProfile() && parseContext.version >= 450))
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float64))
             return keyword;
         return identifierOrType();
 
@@ -1292,11 +1287,10 @@ int TScanContext::tokenizeIdentifier()
     case F16VEC4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            (!parseContext.isEsProfile() && parseContext.version >= 450 &&
-             (parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_16bit_storage) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float16))))
+            parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_16bit_storage) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float16))
             return keyword;
 
         return identifierOrType();
@@ -1315,10 +1309,9 @@ int TScanContext::tokenizeIdentifier()
     case F16MAT4X4:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            (!parseContext.isEsProfile() && parseContext.version >= 450 &&
-             (parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
-              parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float16))))
+            parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types) ||
+            parseContext.extensionTurnedOn(E_GL_EXT_shader_explicit_arithmetic_types_float16))
             return keyword;
 
         return identifierOrType();
@@ -1431,6 +1424,9 @@ int TScanContext::tokenizeIdentifier()
         afterType = true;
         if (parseContext.isEsProfile() && parseContext.version >= 310)
             return keyword;
+        if (!parseContext.isEsProfile() && (parseContext.version > 140 ||
+            (parseContext.version == 140 && parseContext.extensionsTurnedOn(1, &E_GL_ARB_texture_multisample))))
+            return keyword;
         return es30ReservedFromGLSL(150);
 
     case SAMPLER2DMSARRAY:
@@ -1440,6 +1436,9 @@ int TScanContext::tokenizeIdentifier()
         if ((parseContext.isEsProfile() && parseContext.version >= 320) ||
             parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array))
             return keyword;
+        if (!parseContext.isEsProfile() && (parseContext.version > 140 ||
+            (parseContext.version == 140 && parseContext.extensionsTurnedOn(1, &E_GL_ARB_texture_multisample))))
+            return keyword;
         return es30ReservedFromGLSL(150);
 
     case SAMPLER1D:
@@ -1567,20 +1566,17 @@ int TScanContext::tokenizeIdentifier()
     case F16SUBPASSINPUTMS:
         afterType = true;
         if (parseContext.symbolTable.atBuiltInLevel() ||
-            (parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float_fetch) &&
-             !parseContext.isEsProfile() && parseContext.version >= 450))
+            parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float_fetch))
             return keyword;
         return identifierOrType();
 
     case EXPLICITINTERPAMD:
-        if (!parseContext.isEsProfile() && parseContext.version >= 450 &&
-            parseContext.extensionTurnedOn(E_GL_AMD_shader_explicit_vertex_parameter))
+        if (parseContext.extensionTurnedOn(E_GL_AMD_shader_explicit_vertex_parameter))
             return keyword;
         return identifierOrType();
 
     case PERVERTEXNV:
-        if (((!parseContext.isEsProfile() && parseContext.version >= 450) ||
-            (parseContext.isEsProfile() && parseContext.version >= 320)) &&
+        if ((!parseContext.isEsProfile() && parseContext.version >= 450) ||
             parseContext.extensionTurnedOn(E_GL_NV_fragment_shader_barycentric))
             return keyword;
         return identifierOrType();
@@ -1748,7 +1744,9 @@ int TScanContext::dMat()
         return keyword;
     }
 
-    if (!parseContext.isEsProfile() && parseContext.version >= 400)
+    if (!parseContext.isEsProfile() && (parseContext.version >= 400 ||
+        parseContext.symbolTable.atBuiltInLevel() ||
+        (parseContext.version >= 150 && parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64))))
         return keyword;
 
     if (parseContext.isForwardCompatible())

+ 6 - 0
3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp

@@ -716,6 +716,9 @@ void TranslateEnvironment(const TEnvironment* environment, EShMessages& messages
             case EShClientOpenGL:
                 spvVersion.openGl = environment->input.dialectVersion;
                 break;
+            case EShClientCount:
+                assert(0);
+                break;
             }
             switch (environment->input.languageFamily) {
             case EShSourceNone:
@@ -728,6 +731,9 @@ void TranslateEnvironment(const TEnvironment* environment, EShMessages& messages
                 source = EShSourceHlsl;
                 messages = static_cast<EShMessages>(messages | EShMsgReadHlsl);
                 break;
+            case EShSourceCount:
+                assert(0);
+                break;
             }
         }
 

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

@@ -114,6 +114,7 @@ void TType::buildMangledName(TString& mangledName) const
         default: break; // some compilers want this
         }
 
+#ifdef ENABLE_HLSL
         if (sampler.hasReturnStruct()) {
             // Name mangle for sampler return struct uses struct table index.
             mangledName += "-tx-struct";
@@ -129,6 +130,7 @@ void TType::buildMangledName(TString& mangledName) const
             case 4: break; // default to prior name mangle behavior
             }
         }
+#endif
 
         if (sampler.isMultiSample())
             mangledName += "M";

+ 11 - 3
3rdparty/glslang/glslang/MachineIndependent/Versions.cpp

@@ -172,6 +172,7 @@ void TParseVersions::initializeExtensionBehavior()
     extensionBehavior[E_GL_ARB_tessellation_shader]          = EBhDisable;
     extensionBehavior[E_GL_ARB_enhanced_layouts]             = EBhDisable;
     extensionBehavior[E_GL_ARB_texture_cube_map_array]       = EBhDisable;
+    extensionBehavior[E_GL_ARB_texture_multisample]          = EBhDisable;
     extensionBehavior[E_GL_ARB_shader_texture_lod]           = EBhDisable;
     extensionBehavior[E_GL_ARB_explicit_attrib_location]     = EBhDisable;
     extensionBehavior[E_GL_ARB_explicit_uniform_location]    = EBhDisable;
@@ -183,6 +184,7 @@ void TParseVersions::initializeExtensionBehavior()
     extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable;
     extensionBehavior[E_GL_ARB_viewport_array]               = EBhDisable;
     extensionBehavior[E_GL_ARB_gpu_shader_int64]             = EBhDisable;
+    extensionBehavior[E_GL_ARB_gpu_shader_fp64]              = EBhDisable;
     extensionBehavior[E_GL_ARB_shader_ballot]                = EBhDisable;
     extensionBehavior[E_GL_ARB_sparse_texture2]              = EBhDisable;
     extensionBehavior[E_GL_ARB_sparse_texture_clamp]         = EBhDisable;
@@ -192,6 +194,8 @@ void TParseVersions::initializeExtensionBehavior()
     extensionBehavior[E_GL_ARB_shader_viewport_layer_array]  = EBhDisable;
     extensionBehavior[E_GL_ARB_fragment_shader_interlock]    = EBhDisable;
     extensionBehavior[E_GL_ARB_shader_clock]                 = EBhDisable;
+    extensionBehavior[E_GL_ARB_uniform_buffer_object]        = EBhDisable;
+    extensionBehavior[E_GL_ARB_sample_shading]               = EBhDisable;
 
     extensionBehavior[E_GL_KHR_shader_subgroup_basic]            = EBhDisable;
     extensionBehavior[E_GL_KHR_shader_subgroup_vote]             = EBhDisable;
@@ -335,7 +339,6 @@ void TParseVersions::getPreamble(std::string& preamble)
 
             // AEP
             "#define GL_ANDROID_extension_pack_es31a 1\n"
-            "#define GL_KHR_blend_equation_advanced 1\n"
             "#define GL_OES_sample_variables 1\n"
             "#define GL_OES_shader_image_atomic 1\n"
             "#define GL_OES_shader_multisample_interpolation 1\n"
@@ -379,6 +382,7 @@ void TParseVersions::getPreamble(std::string& preamble)
             "#define GL_ARB_tessellation_shader 1\n"
             "#define GL_ARB_enhanced_layouts 1\n"
             "#define GL_ARB_texture_cube_map_array 1\n"
+            "#define GL_ARB_texture_multisample 1\n"
             "#define GL_ARB_shader_texture_lod 1\n"
             "#define GL_ARB_explicit_attrib_location 1\n"
             "#define GL_ARB_explicit_uniform_location 1\n"
@@ -390,13 +394,16 @@ void TParseVersions::getPreamble(std::string& preamble)
             "#define GL_ARB_shader_texture_image_samples 1\n"
             "#define GL_ARB_viewport_array 1\n"
             "#define GL_ARB_gpu_shader_int64 1\n"
+            "#define GL_ARB_gpu_shader_fp64 1\n"
             "#define GL_ARB_shader_ballot 1\n"
             "#define GL_ARB_sparse_texture2 1\n"
             "#define GL_ARB_sparse_texture_clamp 1\n"
             "#define GL_ARB_shader_stencil_export 1\n"
+            "#define GL_ARB_sample_shading 1\n"
 //            "#define GL_ARB_cull_distance 1\n"    // present for 4.5, but need extension control over block members
             "#define GL_ARB_post_depth_coverage 1\n"
             "#define GL_ARB_fragment_shader_interlock 1\n"
+            "#define GL_ARB_uniform_buffer_object 1\n"
             "#define GL_EXT_shader_non_constant_global_initializers 1\n"
             "#define GL_EXT_shader_image_load_formatted 1\n"
             "#define GL_EXT_post_depth_coverage 1\n"
@@ -499,6 +506,7 @@ void TParseVersions::getPreamble(std::string& preamble)
     preamble +=
             "#define GL_GOOGLE_cpp_style_line_directive 1\n"
             "#define GL_GOOGLE_include_directive 1\n"
+            "#define GL_KHR_blend_equation_advanced 1\n"
             ;
 #endif
 
@@ -919,8 +927,8 @@ void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
 // Call for any operation needing GLSL double data-type support.
 void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op)
 {
-    requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
-    profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op);
+    //requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
+    profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op);
 }
 
 // Call for any operation needing GLSL float16 data-type support.

+ 8 - 1
3rdparty/glslang/glslang/MachineIndependent/Versions.h

@@ -38,6 +38,8 @@
 #ifndef _VERSIONS_INCLUDED_
 #define _VERSIONS_INCLUDED_
 
+#define LAST_ELEMENT_MARKER(x) x
+
 //
 // Help manage multiple profiles, versions, extensions etc.
 //
@@ -54,7 +56,8 @@ typedef enum {
     ENoProfile            = (1 << 0), // only for desktop, before profiles showed up
     ECoreProfile          = (1 << 1),
     ECompatibilityProfile = (1 << 2),
-    EEsProfile            = (1 << 3)
+    EEsProfile            = (1 << 3),
+    LAST_ELEMENT_MARKER(EProfileCount),
 } EProfile;
 
 namespace glslang {
@@ -124,6 +127,7 @@ const char* const E_GL_ARB_compute_shader               = "GL_ARB_compute_shader
 const char* const E_GL_ARB_tessellation_shader          = "GL_ARB_tessellation_shader";
 const char* const E_GL_ARB_enhanced_layouts             = "GL_ARB_enhanced_layouts";
 const char* const E_GL_ARB_texture_cube_map_array       = "GL_ARB_texture_cube_map_array";
+const char* const E_GL_ARB_texture_multisample          = "GL_ARB_texture_multisample";
 const char* const E_GL_ARB_shader_texture_lod           = "GL_ARB_shader_texture_lod";
 const char* const E_GL_ARB_explicit_attrib_location     = "GL_ARB_explicit_attrib_location";
 const char* const E_GL_ARB_explicit_uniform_location    = "GL_ARB_explicit_uniform_location";
@@ -135,6 +139,7 @@ const char* const E_GL_ARB_derivative_control           = "GL_ARB_derivative_con
 const char* const E_GL_ARB_shader_texture_image_samples = "GL_ARB_shader_texture_image_samples";
 const char* const E_GL_ARB_viewport_array               = "GL_ARB_viewport_array";
 const char* const E_GL_ARB_gpu_shader_int64             = "GL_ARB_gpu_shader_int64";
+const char* const E_GL_ARB_gpu_shader_fp64              = "GL_ARB_gpu_shader_fp64";
 const char* const E_GL_ARB_shader_ballot                = "GL_ARB_shader_ballot";
 const char* const E_GL_ARB_sparse_texture2              = "GL_ARB_sparse_texture2";
 const char* const E_GL_ARB_sparse_texture_clamp         = "GL_ARB_sparse_texture_clamp";
@@ -144,6 +149,8 @@ const char* const E_GL_ARB_post_depth_coverage          = "GL_ARB_post_depth_cov
 const char* const E_GL_ARB_shader_viewport_layer_array  = "GL_ARB_shader_viewport_layer_array";
 const char* const E_GL_ARB_fragment_shader_interlock    = "GL_ARB_fragment_shader_interlock";
 const char* const E_GL_ARB_shader_clock                 = "GL_ARB_shader_clock";
+const char* const E_GL_ARB_uniform_buffer_object        = "GL_ARB_uniform_buffer_object";
+const char* const E_GL_ARB_sample_shading               = "GL_ARB_sample_shading";
 
 const char* const E_GL_KHR_shader_subgroup_basic            = "GL_KHR_shader_subgroup_basic";
 const char* const E_GL_KHR_shader_subgroup_vote             = "GL_KHR_shader_subgroup_vote";

+ 51 - 17
3rdparty/glslang/glslang/MachineIndependent/glslang.m4

@@ -402,7 +402,9 @@ GLSLANG_WEB_EXCLUDE_ON
         $$ = parseContext.intermediate.addConstantUnion((unsigned short)$1.u, $1.loc, true);
     }
     | DOUBLECONSTANT {
-        parseContext.doubleCheck($1.loc, "double literal");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double literal");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double literal");
         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtDouble, $1.loc, true);
     }
     | FLOAT16CONSTANT {
@@ -1751,7 +1753,9 @@ type_specifier_nonarray
     }
 GLSLANG_WEB_EXCLUDE_ON
     | DOUBLE {
-        parseContext.doubleCheck($1.loc, "double");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
     }
@@ -1811,19 +1815,25 @@ GLSLANG_WEB_EXCLUDE_ON
         $$.basicType = EbtUint64;
     }
     | DVEC2 {
-        parseContext.doubleCheck($1.loc, "double vector");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double vector");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setVector(2);
     }
     | DVEC3 {
-        parseContext.doubleCheck($1.loc, "double vector");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double vector");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setVector(3);
     }
     | DVEC4 {
-        parseContext.doubleCheck($1.loc, "double vector");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double vector");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setVector(4);
@@ -2027,73 +2037,97 @@ GLSLANG_WEB_EXCLUDE_ON
         $$.setVector(4);
     }
     | DMAT2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 2);
     }
     | DMAT3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 3);
     }
     | DMAT4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 4);
     }
     | DMAT2X2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 2);
     }
     | DMAT2X3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 3);
     }
     | DMAT2X4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 4);
     }
     | DMAT3X2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 2);
     }
     | DMAT3X3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 3);
     }
     | DMAT3X4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 4);
     }
     | DMAT4X2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 2);
     }
     | DMAT4X3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 3);
     }
     | DMAT4X4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 4);

+ 51 - 17
3rdparty/glslang/glslang/MachineIndependent/glslang.y

@@ -402,7 +402,9 @@ primary_expression
         $$ = parseContext.intermediate.addConstantUnion((unsigned short)$1.u, $1.loc, true);
     }
     | DOUBLECONSTANT {
-        parseContext.doubleCheck($1.loc, "double literal");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double literal");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double literal");
         $$ = parseContext.intermediate.addConstantUnion($1.d, EbtDouble, $1.loc, true);
     }
     | FLOAT16CONSTANT {
@@ -1751,7 +1753,9 @@ type_specifier_nonarray
     }
 
     | DOUBLE {
-        parseContext.doubleCheck($1.loc, "double");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
     }
@@ -1811,19 +1815,25 @@ type_specifier_nonarray
         $$.basicType = EbtUint64;
     }
     | DVEC2 {
-        parseContext.doubleCheck($1.loc, "double vector");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double vector");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setVector(2);
     }
     | DVEC3 {
-        parseContext.doubleCheck($1.loc, "double vector");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double vector");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setVector(3);
     }
     | DVEC4 {
-        parseContext.doubleCheck($1.loc, "double vector");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double vector");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setVector(4);
@@ -2027,73 +2037,97 @@ type_specifier_nonarray
         $$.setVector(4);
     }
     | DMAT2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 2);
     }
     | DMAT3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 3);
     }
     | DMAT4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 4);
     }
     | DMAT2X2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 2);
     }
     | DMAT2X3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 3);
     }
     | DMAT2X4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(2, 4);
     }
     | DMAT3X2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 2);
     }
     | DMAT3X3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 3);
     }
     | DMAT3X4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(3, 4);
     }
     | DMAT4X2 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 2);
     }
     | DMAT4X3 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 3);
     }
     | DMAT4X4 {
-        parseContext.doubleCheck($1.loc, "double matrix");
+        parseContext.requireProfile($1.loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck($1.loc, "double matrix");
         $$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
         $$.basicType = EbtDouble;
         $$.setMatrix(4, 4);

+ 51 - 17
3rdparty/glslang/glslang/MachineIndependent/glslang_tab.cpp

@@ -4279,7 +4279,9 @@ yyreduce:
   case 15:
 #line 404 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double literal");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double literal");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double literal");
         (yyval.interm.intermTypedNode) = parseContext.intermediate.addConstantUnion((yyvsp[0].lex).d, EbtDouble, (yyvsp[0].lex).loc, true);
     }
 #line 4286 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646  */
@@ -6498,7 +6500,9 @@ yyreduce:
   case 228:
 #line 1753 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
     }
@@ -6618,7 +6622,9 @@ yyreduce:
   case 240:
 #line 1813 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setVector(2);
@@ -6629,7 +6635,9 @@ yyreduce:
   case 241:
 #line 1819 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setVector(3);
@@ -6640,7 +6648,9 @@ yyreduce:
   case 242:
 #line 1825 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double vector");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double vector");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setVector(4);
@@ -7014,7 +7024,9 @@ yyreduce:
   case 276:
 #line 2029 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(2, 2);
@@ -7025,7 +7037,9 @@ yyreduce:
   case 277:
 #line 2035 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(3, 3);
@@ -7036,7 +7050,9 @@ yyreduce:
   case 278:
 #line 2041 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(4, 4);
@@ -7047,7 +7063,9 @@ yyreduce:
   case 279:
 #line 2047 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(2, 2);
@@ -7058,7 +7076,9 @@ yyreduce:
   case 280:
 #line 2053 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(2, 3);
@@ -7069,7 +7089,9 @@ yyreduce:
   case 281:
 #line 2059 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(2, 4);
@@ -7080,7 +7102,9 @@ yyreduce:
   case 282:
 #line 2065 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(3, 2);
@@ -7091,7 +7115,9 @@ yyreduce:
   case 283:
 #line 2071 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(3, 3);
@@ -7102,7 +7128,9 @@ yyreduce:
   case 284:
 #line 2077 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(3, 4);
@@ -7113,7 +7141,9 @@ yyreduce:
   case 285:
 #line 2083 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(4, 2);
@@ -7124,7 +7154,9 @@ yyreduce:
   case 286:
 #line 2089 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(4, 3);
@@ -7135,7 +7167,9 @@ yyreduce:
   case 287:
 #line 2095 "MachineIndependent/glslang.y" /* yacc.c:1646  */
     {
-        parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
+        parseContext.requireProfile((yyvsp[0].lex).loc, ECoreProfile | ECompatibilityProfile, "double matrix");
+        if (! parseContext.symbolTable.atBuiltInLevel())
+            parseContext.doubleCheck((yyvsp[0].lex).loc, "double matrix");
         (yyval.interm.type).init((yyvsp[0].lex).loc, parseContext.symbolTable.atGlobalLevel());
         (yyval.interm.type).basicType = EbtDouble;
         (yyval.interm.type).setMatrix(4, 4);

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

@@ -161,7 +161,7 @@ struct TNotifyUniformAdaptor
     }
 
 private:
-    TNotifyUniformAdaptor& operator=(TNotifyUniformAdaptor&);
+    TNotifyUniformAdaptor& operator=(TNotifyUniformAdaptor&) = delete;
 };
 
 struct TNotifyInOutAdaptor
@@ -180,7 +180,7 @@ struct TNotifyInOutAdaptor
     }
 
 private:
-    TNotifyInOutAdaptor& operator=(TNotifyInOutAdaptor&);
+    TNotifyInOutAdaptor& operator=(TNotifyInOutAdaptor&) = delete;
 };
 
 struct TResolverUniformAdaptor {
@@ -236,7 +236,7 @@ struct TResolverUniformAdaptor {
     bool&           error;
 
 private:
-    TResolverUniformAdaptor& operator=(TResolverUniformAdaptor&);
+    TResolverUniformAdaptor& operator=(TResolverUniformAdaptor&) = delete;
 };
 
 struct TResolverInOutAdaptor {
@@ -283,7 +283,7 @@ struct TResolverInOutAdaptor {
     bool&           error;
 
 private:
-    TResolverInOutAdaptor& operator=(TResolverInOutAdaptor&);
+    TResolverInOutAdaptor& operator=(TResolverInOutAdaptor&) = delete;
 };
 
 // The class is used for reserving explicit uniform locations and ubo/ssbo/opaque bindings
@@ -384,7 +384,7 @@ struct TSymbolValidater
     bool& hadError;
 
 private:
-    TSymbolValidater& operator=(TSymbolValidater&);
+    TSymbolValidater& operator=(TSymbolValidater&) = delete;
 };
 
 struct TSlotCollector {
@@ -398,7 +398,7 @@ struct TSlotCollector {
     TInfoSink& infoSink;
 
 private:
-    TSlotCollector& operator=(TSlotCollector&);
+    TSlotCollector& operator=(TSlotCollector&) = delete;
 };
 
 TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate)
@@ -831,6 +831,7 @@ void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink&
                 if (iter->second != location) {
                     TString errorMsg = "Invalid location: " + name;
                     infoSink.info.message(EPrefixInternalError, errorMsg.c_str());
+                    hasError = true;
                 }
             }
         }
@@ -856,6 +857,7 @@ void TDefaultGlslIoResolver::reserverStorageSlot(TVarEntryInfo& ent, TInfoSink&
                 if (iter->second != location) {
                     TString errorMsg = "Invalid location: " + name;
                     infoSink.info.message(EPrefixInternalError, errorMsg.c_str());
+                    hasError = true;
                 }
             }
         }
@@ -884,6 +886,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
             if (iter->second != binding) {
                 TString errorMsg = "Invalid binding: " + name;
                 infoSink.info.message(EPrefixInternalError, errorMsg.c_str());
+                hasError = true;
             }
         }
     }

+ 5 - 4
3rdparty/glslang/glslang/MachineIndependent/iomapper.h

@@ -129,6 +129,7 @@ public:
     uint32_t computeTypeLocationSize(const TType& type, EShLanguage stage);
 
     TSlotSetMap slots;
+    bool hasError = false;
 
 protected:
     TDefaultIoResolverBase(TDefaultIoResolverBase&);
@@ -260,10 +261,10 @@ public:
 class TGlslIoMapper : public TIoMapper {
 public:
     TGlslIoMapper() {
-        memset(inVarMaps,     0, sizeof(TVarLiveMap*)   * (EShLangCount + 1));
-        memset(outVarMaps,    0, sizeof(TVarLiveMap*)   * (EShLangCount + 1));
-        memset(uniformVarMap, 0, sizeof(TVarLiveMap*)   * (EShLangCount + 1));
-        memset(intermediates, 0, sizeof(TIntermediate*) * (EShLangCount + 1));
+        memset(inVarMaps,     0, sizeof(TVarLiveMap*)   * EShLangCount);
+        memset(outVarMaps,    0, sizeof(TVarLiveMap*)   * EShLangCount);
+        memset(uniformVarMap, 0, sizeof(TVarLiveMap*)   * EShLangCount);
+        memset(intermediates, 0, sizeof(TIntermediate*) * EShLangCount);
     }
     virtual ~TGlslIoMapper() {
         for (size_t stage = 0; stage < EShLangCount; stage++) {

+ 3 - 0
3rdparty/glslang/glslang/MachineIndependent/localintermediate.h

@@ -332,6 +332,9 @@ public:
         case EShTargetVulkan_1_1:
             processes.addProcess("target-env vulkan1.1");
             break;
+        case EShTargetVulkan_1_2:
+            processes.addProcess("target-env vulkan1.2");
+            break;
         default:
             processes.addProcess("target-env vulkanUnknown");
             break;

+ 12 - 1
3rdparty/glslang/glslang/Public/ShaderLang.h

@@ -100,7 +100,7 @@ typedef enum {
     EShLangCallableNV,
     EShLangTaskNV,
     EShLangMeshNV,
-    EShLangCount,
+    LAST_ELEMENT_MARKER(EShLangCount),
 } EShLanguage;         // would be better as stage, but this is ancient now
 
 typedef enum {
@@ -118,6 +118,7 @@ typedef enum {
     EShLangCallableNVMask     = (1 << EShLangCallableNV),
     EShLangTaskNVMask         = (1 << EShLangTaskNV),
     EShLangMeshNVMask         = (1 << EShLangMeshNV),
+    LAST_ELEMENT_MARKER(EShLanguageMaskCount),
 } EShLanguageMask;
 
 namespace glslang {
@@ -128,24 +129,29 @@ typedef enum {
     EShSourceNone,
     EShSourceGlsl,               // GLSL, includes ESSL (OpenGL ES GLSL)
     EShSourceHlsl,               // HLSL
+    LAST_ELEMENT_MARKER(EShSourceCount),
 } EShSource;                     // if EShLanguage were EShStage, this could be EShLanguage instead
 
 typedef enum {
     EShClientNone,               // use when there is no client, e.g. for validation
     EShClientVulkan,
     EShClientOpenGL,
+    LAST_ELEMENT_MARKER(EShClientCount),
 } EShClient;
 
 typedef enum {
     EShTargetNone,
     EShTargetSpv,                 // SPIR-V (preferred spelling)
     EshTargetSpv = EShTargetSpv,  // legacy spelling
+    LAST_ELEMENT_MARKER(EShTargetCount),
 } EShTargetLanguage;
 
 typedef enum {
     EShTargetVulkan_1_0 = (1 << 22),                  // Vulkan 1.0
     EShTargetVulkan_1_1 = (1 << 22) | (1 << 12),      // Vulkan 1.1
+    EShTargetVulkan_1_2 = (1 << 22) | (2 << 12),      // Vulkan 1.2
     EShTargetOpenGL_450 = 450,                        // OpenGL
+    LAST_ELEMENT_MARKER(EShTargetClientVersionCount),
 } EShTargetClientVersion;
 
 typedef EShTargetClientVersion EshTargetClientVersion;
@@ -157,6 +163,7 @@ typedef enum {
     EShTargetSpv_1_3 = (1 << 16) | (3 << 8),          // SPIR-V 1.3
     EShTargetSpv_1_4 = (1 << 16) | (4 << 8),          // SPIR-V 1.4
     EShTargetSpv_1_5 = (1 << 16) | (5 << 8),          // SPIR-V 1.5
+    LAST_ELEMENT_MARKER(EShTargetLanguageVersionCount),
 } EShTargetLanguageVersion;
 
 struct TInputLanguage {
@@ -206,6 +213,7 @@ typedef enum {
     EShOptNone,
     EShOptSimple,       // Optimizations that can be done quickly
     EShOptFull,         // Optimizations that will take more time
+    LAST_ELEMENT_MARKER(EshOptLevelCount),
 } EShOptimizationLevel;
 
 //
@@ -214,6 +222,7 @@ typedef enum {
 typedef enum {
     EShTexSampTransKeep,   // keep textures and samplers as is (default)
     EShTexSampTransUpgradeTextureRemoveSampler,  // change texture w/o embeded sampler into sampled texture and throw away all samplers
+    LAST_ELEMENT_MARKER(EShTexSampTransCount),
 } EShTextureSamplerTransformMode;
 
 //
@@ -236,6 +245,7 @@ enum EShMessages {
     EShMsgHlslLegalization  = (1 << 12), // enable HLSL Legalization messages
     EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (right now only for samplers)
     EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
+    LAST_ELEMENT_MARKER(EShMsgCount),
 };
 
 //
@@ -249,6 +259,7 @@ typedef enum {
     EShReflectionSeparateBuffers   = (1 << 3), // buffer variables and buffer blocks are reflected separately
     EShReflectionAllBlockVariables = (1 << 4), // reflect all variables in blocks, even if they are inactive
     EShReflectionUnwrapIOBlocks    = (1 << 5), // unwrap input/output blocks the same as with uniform blocks
+    LAST_ELEMENT_MARKER(EShReflectionCount),
 } EShReflectionOptions;
 
 //

+ 2 - 0
3rdparty/glslang/hlsl/hlslGrammar.cpp

@@ -2516,6 +2516,8 @@ bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const T
 //
 bool HlslGrammar::acceptFunctionParameters(TFunction& function)
 {
+    parseContext.beginParameterParsing(function);
+
     // LEFT_PAREN
     if (! acceptTokenClass(EHTokLeftParen))
         return false;

+ 11 - 2
3rdparty/glslang/hlsl/hlslParseHelper.cpp

@@ -69,7 +69,8 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
     clipDistanceOutput(nullptr),
     cullDistanceOutput(nullptr),
     clipDistanceInput(nullptr),
-    cullDistanceInput(nullptr)
+    cullDistanceInput(nullptr),
+    parsingEntrypointParameters(false)
 {
     globalUniformDefaults.clear();
     globalUniformDefaults.layoutMatrix = ElmRowMajor;
@@ -2049,7 +2050,7 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
     };
 
     // if we aren't in the entry point, fix the IO as such and exit
-    if (userFunction.getName().compare(intermediate.getEntryPointName().c_str()) != 0) {
+    if (! isEntrypointName(userFunction.getName())) {
         remapNonEntryPointIO(userFunction);
         return nullptr;
     }
@@ -8884,6 +8885,10 @@ void HlslParseContext::addQualifierToExisting(const TSourceLoc& loc, TQualifier
 //
 bool HlslParseContext::handleInputGeometry(const TSourceLoc& loc, const TLayoutGeometry& geometry)
 {
+    // these can be declared on non-entry-points, in which case they lose their meaning
+    if (! parsingEntrypointParameters)
+        return true;
+
     switch (geometry) {
     case ElgPoints:             // fall through
     case ElgLines:              // ...
@@ -8914,6 +8919,10 @@ bool HlslParseContext::handleOutputGeometry(const TSourceLoc& loc, const TLayout
     if (language != EShLangGeometry)
         return true;
 
+    // these can be declared on non-entry-points, in which case they lose their meaning
+    if (! parsingEntrypointParameters)
+        return true;
+
     switch (geometry) {
     case ElgPoints:
     case ElgLineStrip:

+ 7 - 0
3rdparty/glslang/hlsl/hlslParseHelper.h

@@ -183,6 +183,11 @@ public:
     void getFullNamespaceName(TString*&) const;
     void addScopeMangler(TString&);
 
+    void beginParameterParsing(TFunction& function)
+    {
+        parsingEntrypointParameters = isEntrypointName(function.getName());
+    }
+
     void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
     void popSwitchSequence() { switchSequenceStack.pop_back(); }
 
@@ -241,6 +246,7 @@ protected:
     TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit);
     bool isScalarConstructor(const TIntermNode*);
     TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage);
+    bool isEntrypointName(const TString& name) { return name.compare(intermediate.getEntryPointName().c_str()) == 0; }
 
     // Return true if this node requires L-value conversion (e.g, to an imageStore).
     bool shouldConvertLValue(const TIntermNode*) const;
@@ -494,6 +500,7 @@ protected:
     };
 
     TMap<int, tShadowTextureSymbols*> textureShadowVariant;
+    bool parsingEntrypointParameters;
 };
 
 // This is the prefix we use for built-in methods to avoid namespace collisions with