Browse Source

Updated glslang.

Бранимир Караџић 5 years ago
parent
commit
a9e1d1a8ce
31 changed files with 813 additions and 558 deletions
  1. 0 1
      3rdparty/glslang/OGLCompilersDLL/CMakeLists.txt
  2. 128 0
      3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp
  3. 4 4
      3rdparty/glslang/OGLCompilersDLL/InitializeDll.h
  4. 5 4
      3rdparty/glslang/SPIRV/CMakeLists.txt
  5. 5 2
      3rdparty/glslang/SPIRV/GlslangToSpv.cpp
  6. 2 2
      3rdparty/glslang/SPIRV/SpvTools.cpp
  7. 4 0
      3rdparty/glslang/StandAlone/StandAlone.cpp
  8. 1 3
      3rdparty/glslang/glslang/CMakeLists.txt
  9. 1 1
      3rdparty/glslang/glslang/Include/InitializeGlobals.h
  10. 118 52
      3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp
  11. 144 178
      3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp
  12. 14 1
      3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp
  13. 1 0
      3rdparty/glslang/glslang/MachineIndependent/ParseHelper.h
  14. 17 11
      3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp
  15. 29 14
      3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp
  16. 1 1
      3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp
  17. 6 6
      3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h
  18. 33 4
      3rdparty/glslang/glslang/MachineIndependent/Versions.cpp
  19. 1 1
      3rdparty/glslang/glslang/MachineIndependent/glslang.m4
  20. 1 2
      3rdparty/glslang/glslang/MachineIndependent/glslang.y
  21. 191 191
      3rdparty/glslang/glslang/MachineIndependent/glslang_tab.cpp
  22. 5 5
      3rdparty/glslang/glslang/MachineIndependent/glslang_tab.cpp.h
  23. 3 3
      3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp
  24. 2 2
      3rdparty/glslang/glslang/MachineIndependent/iomapper.cpp
  25. 3 3
      3rdparty/glslang/glslang/MachineIndependent/iomapper.h
  26. 3 3
      3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
  27. 75 53
      3rdparty/glslang/glslang/MachineIndependent/localintermediate.h
  28. 7 2
      3rdparty/glslang/glslang/MachineIndependent/parseVersions.h
  29. 2 2
      3rdparty/glslang/glslang/MachineIndependent/reflection.cpp
  30. 2 2
      3rdparty/glslang/glslang/MachineIndependent/reflection.h
  31. 5 5
      3rdparty/glslang/glslang/Public/ShaderLang.h

+ 0 - 1
3rdparty/glslang/OGLCompilersDLL/CMakeLists.txt

@@ -36,7 +36,6 @@ set(SOURCES InitializeDll.cpp InitializeDll.h)
 add_library(OGLCompiler STATIC ${SOURCES})
 add_library(OGLCompiler STATIC ${SOURCES})
 set_property(TARGET OGLCompiler PROPERTY FOLDER glslang)
 set_property(TARGET OGLCompiler PROPERTY FOLDER glslang)
 set_property(TARGET OGLCompiler PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET OGLCompiler PROPERTY POSITION_INDEPENDENT_CODE ON)
-glslang_default_to_hidden_visibility(OGLCompiler)
 
 
 if(WIN32)
 if(WIN32)
     source_group("Source" FILES ${SOURCES})
     source_group("Source" FILES ${SOURCES})

+ 128 - 0
3rdparty/glslang/OGLCompilersDLL/InitializeDll.cpp

@@ -32,6 +32,134 @@
 // POSSIBILITY OF SUCH DAMAGE.
 // POSSIBILITY OF SUCH DAMAGE.
 //
 //
 
 
+#define SH_EXPORTING
+
+#include <cassert>
+
+#include "InitializeDll.h"
+#include "../glslang/Include/InitializeGlobals.h"
+#include "../glslang/Public/ShaderLang.h"
+#include "../glslang/Include/PoolAlloc.h"
+
 namespace glslang {
 namespace glslang {
 
 
+OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
+
+// Per-process initialization.
+// Needs to be called at least once before parsing, etc. is done.
+// Will also do thread initialization for the calling thread; other
+// threads will need to do that explicitly.
+bool InitProcess()
+{
+    glslang::GetGlobalLock();
+
+    if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
+        //
+        // Function is re-entrant.
+        //
+
+        glslang::ReleaseGlobalLock();
+        return true;
+    }
+
+    ThreadInitializeIndex = OS_AllocTLSIndex();
+
+    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
+        assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
+
+        glslang::ReleaseGlobalLock();
+        return false;
+    }
+
+    if (! InitializePoolIndex()) {
+        assert(0 && "InitProcess(): Failed to initialize global pool");
+
+        glslang::ReleaseGlobalLock();
+        return false;
+    }
+
+    if (! InitThread()) {
+        assert(0 && "InitProcess(): Failed to initialize thread");
+
+        glslang::ReleaseGlobalLock();
+        return false;
+    }
+
+    glslang::ReleaseGlobalLock();
+    return true;
+}
+
+// Per-thread scoped initialization.
+// Must be called at least once by each new thread sharing the
+// symbol tables, etc., needed to parse.
+bool InitThread()
+{
+    //
+    // This function is re-entrant
+    //
+    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
+        assert(0 && "InitThread(): Process hasn't been initalised.");
+        return false;
+    }
+
+    if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
+        return true;
+
+    if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
+        assert(0 && "InitThread(): Unable to set init flag.");
+        return false;
+    }
+
+    glslang::SetThreadPoolAllocator(nullptr);
+
+    return true;
+}
+
+// Not necessary to call this: InitThread() is reentrant, and the need
+// to do per thread tear down has been removed.
+//
+// This is kept, with memory management removed, to satisfy any exiting
+// calls to it that rely on it.
+bool DetachThread()
+{
+    bool success = true;
+
+    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
+        return true;
+
+    //
+    // Function is re-entrant and this thread may not have been initialized.
+    //
+    if (OS_GetTLSValue(ThreadInitializeIndex) != 0) {
+        if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) {
+            assert(0 && "DetachThread(): Unable to clear init flag.");
+            success = false;
+        }
+    }
+
+    return success;
+}
+
+// Not necessary to call this: InitProcess() is reentrant.
+//
+// This is kept, with memory management removed, to satisfy any exiting
+// calls to it that rely on it.
+//
+// Users of glslang should call shFinalize() or glslang::FinalizeProcess() for
+// process-scoped memory tear down.
+bool DetachProcess()
+{
+    bool success = true;
+
+    if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
+        return true;
+
+    success = DetachThread();
+
+    OS_FreeTLSIndex(ThreadInitializeIndex);
+    ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
+
+    return success;
+}
+
 } // end namespace glslang
 } // end namespace glslang

+ 4 - 4
3rdparty/glslang/OGLCompilersDLL/InitializeDll.h

@@ -38,10 +38,10 @@
 
 
 namespace glslang {
 namespace glslang {
 
 
-inline bool InitProcess()   { return true; } // DEPRECATED
-inline bool InitThread()    { return true; } // DEPRECATED
-inline bool DetachThread()  { return true; } // DEPRECATED
-inline bool DetachProcess() { return true; } // DEPRECATED
+bool InitProcess();
+bool InitThread();
+bool DetachThread();  // not called from standalone, perhaps other tools rely on parts of it
+bool DetachProcess(); // not called from standalone, perhaps other tools rely on parts of it
 
 
 } // end namespace glslang
 } // end namespace glslang
 
 

+ 5 - 4
3rdparty/glslang/SPIRV/CMakeLists.txt

@@ -43,7 +43,8 @@ set(SOURCES
     CInterface/spirv_c_interface.cpp)
     CInterface/spirv_c_interface.cpp)
 
 
 set(SPVREMAP_SOURCES
 set(SPVREMAP_SOURCES
-    SPVRemapper.cpp)
+    SPVRemapper.cpp
+    doc.cpp)
 
 
 set(HEADERS
 set(HEADERS
     bitutils.h
     bitutils.h
@@ -68,7 +69,6 @@ set(SPVREMAP_HEADERS
     doc.h)
     doc.h)
 
 
 add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS})
 add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS})
-target_link_libraries(SPIRV PRIVATE MachineIndependent)
 set_property(TARGET SPIRV PROPERTY FOLDER glslang)
 set_property(TARGET SPIRV PROPERTY FOLDER glslang)
 set_property(TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON)
 target_include_directories(SPIRV PUBLIC
 target_include_directories(SPIRV PUBLIC
@@ -79,7 +79,6 @@ glslang_add_build_info_dependency(SPIRV)
 
 
 if (ENABLE_SPVREMAPPER)
 if (ENABLE_SPVREMAPPER)
     add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
     add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
-    target_link_libraries(SPVRemapper PRIVATE SPIRV)
     set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
     set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
     set_property(TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON)
     set_property(TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON)
 endif()
 endif()
@@ -96,10 +95,12 @@ if(ENABLE_OPT)
         PRIVATE ${spirv-tools_SOURCE_DIR}/include
         PRIVATE ${spirv-tools_SOURCE_DIR}/include
         PRIVATE ${spirv-tools_SOURCE_DIR}/source
         PRIVATE ${spirv-tools_SOURCE_DIR}/source
     )
     )
-    target_link_libraries(SPIRV PRIVATE SPIRV-Tools-opt)
+    target_link_libraries(SPIRV PRIVATE MachineIndependent SPIRV-Tools-opt)
     target_include_directories(SPIRV PUBLIC
     target_include_directories(SPIRV PUBLIC
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
         $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
+else()
+    target_link_libraries(SPIRV PRIVATE MachineIndependent)
 endif(ENABLE_OPT)
 endif(ENABLE_OPT)
 
 
 if(WIN32)
 if(WIN32)

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

@@ -283,6 +283,8 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
 {
 {
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     return spv::SourceLanguageESSL;
     return spv::SourceLanguageESSL;
+#elif defined(GLSLANG_ANGLE)
+    return spv::SourceLanguageGLSL;
 #endif
 #endif
 
 
     switch (source) {
     switch (source) {
@@ -1442,7 +1444,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
     // Add the source extensions
     // Add the source extensions
     const auto& sourceExtensions = glslangIntermediate->getRequestedExtensions();
     const auto& sourceExtensions = glslangIntermediate->getRequestedExtensions();
     for (auto it = sourceExtensions.begin(); it != sourceExtensions.end(); ++it)
     for (auto it = sourceExtensions.begin(); it != sourceExtensions.end(); ++it)
-        builder.addSourceExtension(it->first.c_str());
+        builder.addSourceExtension(it->c_str());
 
 
     // Add the top-level modes for this shader.
     // Add the top-level modes for this shader.
 
 
@@ -8694,7 +8696,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
 // Write SPIR-V out to a text file with 32-bit hexadecimal words
 // Write SPIR-V out to a text file with 32-bit hexadecimal words
 void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
 void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
 {
 {
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     std::ofstream out;
     std::ofstream out;
     out.open(baseName, std::ios::binary | std::ios::out);
     out.open(baseName, std::ios::binary | std::ios::out);
     if (out.fail())
     if (out.fail())
@@ -8721,6 +8723,7 @@ void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName,
     }
     }
     if (varName != nullptr) {
     if (varName != nullptr) {
         out << "};";
         out << "};";
+        out << std::endl;
     }
     }
     out.close();
     out.close();
 #endif
 #endif

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

@@ -165,7 +165,7 @@ void SpirvToolsValidate(const glslang::TIntermediate& intermediate, std::vector<
 void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
 void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
                          spv::SpvBuildLogger* logger, const SpvOptions* options)
                          spv::SpvBuildLogger* logger, const SpvOptions* options)
 {
 {
-    spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2;
+    spv_target_env target_env = MapToSpirvToolsEnv(intermediate.getSpv(), logger);
 
 
     spvtools::Optimizer optimizer(target_env);
     spvtools::Optimizer optimizer(target_env);
     optimizer.SetMessageConsumer(OptimizerMesssageConsumer);
     optimizer.SetMessageConsumer(OptimizerMesssageConsumer);
@@ -223,7 +223,7 @@ void SpirvToolsTransform(const glslang::TIntermediate& intermediate, std::vector
 void SpirvToolsStripDebugInfo(const glslang::TIntermediate& intermediate,
 void SpirvToolsStripDebugInfo(const glslang::TIntermediate& intermediate,
         std::vector<unsigned int>& spirv, spv::SpvBuildLogger* logger)
         std::vector<unsigned int>& spirv, spv::SpvBuildLogger* logger)
 {
 {
-    spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2;
+    spv_target_env target_env = MapToSpirvToolsEnv(intermediate.getSpv(), logger);
 
 
     spvtools::Optimizer optimizer(target_env);
     spvtools::Optimizer optimizer(target_env);
     optimizer.SetMessageConsumer(OptimizerMesssageConsumer);
     optimizer.SetMessageConsumer(OptimizerMesssageConsumer);

+ 4 - 0
3rdparty/glslang/StandAlone/StandAlone.cpp

@@ -696,6 +696,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                 setOpenGlSpv();
                 setOpenGlSpv();
                 if (argv[0][2] != 0)
                 if (argv[0][2] != 0)
                     ClientInputSemanticsVersion = getAttachedNumber("-G<num> client input semantics");
                     ClientInputSemanticsVersion = getAttachedNumber("-G<num> client input semantics");
+                if (ClientInputSemanticsVersion != 100)
+                    Error("unknown client version for -G, should be 100");
                 break;
                 break;
             case 'H':
             case 'H':
                 Options |= EOptionHumanReadableSpv;
                 Options |= EOptionHumanReadableSpv;
@@ -732,6 +734,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                 setVulkanSpv();
                 setVulkanSpv();
                 if (argv[0][2] != 0)
                 if (argv[0][2] != 0)
                     ClientInputSemanticsVersion = getAttachedNumber("-V<num> client input semantics");
                     ClientInputSemanticsVersion = getAttachedNumber("-V<num> client input semantics");
+                if (ClientInputSemanticsVersion != 100)
+                    Error("unknown client version for -V, should be 100");
                 break;
                 break;
             case 'c':
             case 'c':
                 Options |= EOptionDumpConfig;
                 Options |= EOptionDumpConfig;

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

@@ -52,7 +52,6 @@ add_library(GenericCodeGen STATIC
     GenericCodeGen/Link.cpp)
     GenericCodeGen/Link.cpp)
 set_property(TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET GenericCodeGen PROPERTY FOLDER glslang)
 set_property(TARGET GenericCodeGen PROPERTY FOLDER glslang)
-glslang_default_to_hidden_visibility(GenericCodeGen)
 
 
 ################################################################################
 ################################################################################
 # MachineIndependent
 # MachineIndependent
@@ -134,7 +133,6 @@ endif(ENABLE_HLSL)
 add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
 add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
 set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
 set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
 set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
-glslang_only_export_explicit_symbols(MachineIndependent)
 
 
 glslang_add_build_info_dependency(MachineIndependent)
 glslang_add_build_info_dependency(MachineIndependent)
 
 
@@ -170,7 +168,7 @@ set_target_properties(glslang PROPERTIES
     POSITION_INDEPENDENT_CODE ON
     POSITION_INDEPENDENT_CODE ON
     VERSION   "${GLSLANG_VERSION}"
     VERSION   "${GLSLANG_VERSION}"
     SOVERSION "${GLSLANG_VERSION_MAJOR}")
     SOVERSION "${GLSLANG_VERSION_MAJOR}")
-target_link_libraries(glslang PRIVATE OGLCompiler MachineIndependent)
+target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent)
 target_include_directories(glslang PUBLIC
 target_include_directories(glslang PUBLIC
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
     $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
     $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

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

@@ -37,7 +37,7 @@
 
 
 namespace glslang {
 namespace glslang {
 
 
-inline bool InitializePoolIndex() { return true; } // DEPRECATED: No need to call
+bool InitializePoolIndex();
 
 
 } // end namespace glslang
 } // end namespace glslang
 
 

+ 118 - 52
3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp

@@ -147,6 +147,10 @@ EProfile EDesktopProfile = static_cast<EProfile>(ENoProfile | ECoreProfile | ECo
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     const Versioning* Es300Desktop130 = nullptr;
     const Versioning* Es300Desktop130 = nullptr;
     const Versioning* Es310Desktop420 = nullptr;
     const Versioning* Es310Desktop420 = nullptr;
+#elif defined(GLSLANG_ANGLE)
+    const Versioning* Es300Desktop130 = nullptr;
+    const Versioning* Es310Desktop420 = nullptr;
+    const Versioning* Es310Desktop450 = nullptr;
 #else
 #else
     const Versioning Es300Desktop130Version[] = { { EEsProfile,      0, 300, 0, nullptr },
     const Versioning Es300Desktop130Version[] = { { EEsProfile,      0, 300, 0, nullptr },
                                                   { EDesktopProfile, 0, 130, 0, nullptr },
                                                   { EDesktopProfile, 0, 130, 0, nullptr },
@@ -415,7 +419,7 @@ void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
 // See if the tabled versioning information allows the current version.
 // See if the tabled versioning information allows the current version.
 bool ValidVersion(const BuiltInFunction& function, int version, EProfile profile, const SpvVersion& /* spVersion */)
 bool ValidVersion(const BuiltInFunction& function, int version, EProfile profile, const SpvVersion& /* spVersion */)
 {
 {
-#ifdef GLSLANG_WEB
+#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
     // all entries in table are valid
     // all entries in table are valid
     return true;
     return true;
 #endif
 #endif
@@ -499,7 +503,7 @@ TBuiltIns::TBuiltIns()
     prefixes[EbtFloat] =  "";
     prefixes[EbtFloat] =  "";
     prefixes[EbtInt]   = "i";
     prefixes[EbtInt]   = "i";
     prefixes[EbtUint]  = "u";
     prefixes[EbtUint]  = "u";
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     prefixes[EbtFloat16] = "f16";
     prefixes[EbtFloat16] = "f16";
     prefixes[EbtInt8]  = "i8";
     prefixes[EbtInt8]  = "i8";
     prefixes[EbtUint8] = "u8";
     prefixes[EbtUint8] = "u8";
@@ -516,7 +520,9 @@ TBuiltIns::TBuiltIns()
     dimMap[Esd3D] = 3;
     dimMap[Esd3D] = 3;
     dimMap[EsdCube] = 3;
     dimMap[EsdCube] = 3;
 #ifndef GLSLANG_WEB
 #ifndef GLSLANG_WEB
+#ifndef GLSLANG_ANGLE
     dimMap[Esd1D] = 1;
     dimMap[Esd1D] = 1;
+#endif
     dimMap[EsdRect] = 2;
     dimMap[EsdRect] = 2;
     dimMap[EsdBuffer] = 1;
     dimMap[EsdBuffer] = 1;
     dimMap[EsdSubpass] = 2;  // potentially unused for now
     dimMap[EsdSubpass] = 2;  // potentially unused for now
@@ -541,6 +547,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     version = 310;
     version = 310;
     profile = EEsProfile;
     profile = EEsProfile;
+#elif defined(GLSLANG_ANGLE)
+    version = 450;
+    profile = ECoreProfile;
 #endif
 #endif
     addTabledBuiltins(version, profile, spvVersion);
     addTabledBuiltins(version, profile, spvVersion);
 
 
@@ -586,6 +595,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         "vec4  fwidthCoarse(vec4  p);"
         "vec4  fwidthCoarse(vec4  p);"
     );
     );
 
 
+#ifndef GLSLANG_ANGLE
     TString derivativesAndControl16bits (
     TString derivativesAndControl16bits (
         "float16_t dFdx(float16_t);"
         "float16_t dFdx(float16_t);"
         "f16vec2   dFdx(f16vec2);"
         "f16vec2   dFdx(f16vec2);"
@@ -1173,6 +1183,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n"
             "\n"
         );
         );
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     if ((profile == EEsProfile && version >= 310) ||
     if ((profile == EEsProfile && version >= 310) ||
         (profile != EEsProfile && version >= 430)) {
         (profile != EEsProfile && version >= 430)) {
@@ -1210,6 +1221,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
             "\n");
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     if (profile != EEsProfile && version >= 440) {
     if (profile != EEsProfile && version >= 440) {
         commonBuiltins.append(
         commonBuiltins.append(
             "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
             "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
@@ -1271,7 +1283,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "void atomicStore(coherent volatile out double, double, int, int, int);"
             "void atomicStore(coherent volatile out double, double, int, int, int);"
             "\n");
             "\n");
     }
     }
-#endif
+#endif // !GLSLANG_ANGLE
+#endif // !GLSLANG_WEB
 
 
     if ((profile == EEsProfile && version >= 300) ||
     if ((profile == EEsProfile && version >= 300) ||
         (profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding
         (profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding
@@ -1311,6 +1324,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
             "\n");
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     if (profile != EEsProfile && version >= 150) {  // ARB_gpu_shader_fp64
     if (profile != EEsProfile && version >= 150) {  // ARB_gpu_shader_fp64
             commonBuiltins.append(
             commonBuiltins.append(
                 "double fma(double, double, double);"
                 "double fma(double, double, double);"
@@ -1319,6 +1333,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 "dvec4  fma(dvec4,  dvec4,  dvec4 );"
                 "dvec4  fma(dvec4,  dvec4,  dvec4 );"
                 "\n");
                 "\n");
     }
     }
+#endif
 
 
     if ((profile == EEsProfile && version >= 310) ||
     if ((profile == EEsProfile && version >= 310) ||
         (profile != EEsProfile && version >= 400)) {
         (profile != EEsProfile && version >= 400)) {
@@ -1336,6 +1351,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
             "\n");
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
     if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
         commonBuiltins.append(
         commonBuiltins.append(
             "double frexp(double, out int);"
             "double frexp(double, out int);"
@@ -1353,6 +1369,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 
 
             "\n");
             "\n");
     }
     }
+#endif
 #endif
 #endif
 
 
     if ((profile == EEsProfile && version >= 300) ||
     if ((profile == EEsProfile && version >= 300) ||
@@ -1462,6 +1479,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     }
     }
 
 
 #ifndef GLSLANG_WEB
 #ifndef GLSLANG_WEB
+#ifndef GLSLANG_ANGLE
     //
     //
     // Original-style texture functions existing in all stages.
     // Original-style texture functions existing in all stages.
     // (Per-stage functions below.)
     // (Per-stage functions below.)
@@ -1610,6 +1628,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 "\n");
                 "\n");
         }
         }
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     // Bitfield
     // Bitfield
     if ((profile == EEsProfile && version >= 310) ||
     if ((profile == EEsProfile && version >= 310) ||
@@ -1752,6 +1771,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
             "\n");
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     // GL_ARB_shader_ballot
     // GL_ARB_shader_ballot
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         commonBuiltins.append(
         commonBuiltins.append(
@@ -3072,6 +3092,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "bool textureFootprintGradClampNV(sampler2D, vec2, vec2, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
             "bool textureFootprintGradClampNV(sampler2D, vec2, vec2, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
             "\n");
             "\n");
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     if ((profile == EEsProfile && version >= 300 && version < 310) ||
     if ((profile == EEsProfile && version >= 300 && version < 310) ||
         (profile != EEsProfile && version >= 150 && version < 450)) { // GL_EXT_shader_integer_mix
         (profile != EEsProfile && version >= 150 && version < 450)) { // GL_EXT_shader_integer_mix
@@ -3091,6 +3112,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                               "\n");
                               "\n");
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     // GL_AMD_gpu_shader_half_float/Explicit types
     // GL_AMD_gpu_shader_half_float/Explicit types
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         commonBuiltins.append(
         commonBuiltins.append(
@@ -3941,28 +3963,30 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "f64vec3   log2(f64vec3);"
             "f64vec3   log2(f64vec3);"
             "f64vec4   log2(f64vec4);"
             "f64vec4   log2(f64vec4);"
             "\n");
             "\n");
-        }
-        if (profile != EEsProfile && version >= 450) {
-            stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
-            stageBuiltins[EShLangFragment].append(
-                "float64_t interpolateAtCentroid(float64_t);"
-                "f64vec2   interpolateAtCentroid(f64vec2);"
-                "f64vec3   interpolateAtCentroid(f64vec3);"
-                "f64vec4   interpolateAtCentroid(f64vec4);"
+    }
+
+    if (profile != EEsProfile && version >= 450) {
+        stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
+        stageBuiltins[EShLangFragment].append(
+            "float64_t interpolateAtCentroid(float64_t);"
+            "f64vec2   interpolateAtCentroid(f64vec2);"
+            "f64vec3   interpolateAtCentroid(f64vec3);"
+            "f64vec4   interpolateAtCentroid(f64vec4);"
 
 
-                "float64_t interpolateAtSample(float64_t, int);"
-                "f64vec2   interpolateAtSample(f64vec2,   int);"
-                "f64vec3   interpolateAtSample(f64vec3,   int);"
-                "f64vec4   interpolateAtSample(f64vec4,   int);"
+            "float64_t interpolateAtSample(float64_t, int);"
+            "f64vec2   interpolateAtSample(f64vec2,   int);"
+            "f64vec3   interpolateAtSample(f64vec3,   int);"
+            "f64vec4   interpolateAtSample(f64vec4,   int);"
 
 
-                "float64_t interpolateAtOffset(float64_t, f64vec2);"
-                "f64vec2   interpolateAtOffset(f64vec2,   f64vec2);"
-                "f64vec3   interpolateAtOffset(f64vec3,   f64vec2);"
-                "f64vec4   interpolateAtOffset(f64vec4,   f64vec2);"
+            "float64_t interpolateAtOffset(float64_t, f64vec2);"
+            "f64vec2   interpolateAtOffset(f64vec2,   f64vec2);"
+            "f64vec3   interpolateAtOffset(f64vec3,   f64vec2);"
+            "f64vec4   interpolateAtOffset(f64vec4,   f64vec2);"
 
 
-                "\n");
+            "\n");
 
 
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     //============================================================================
     //============================================================================
     //
     //
@@ -3978,6 +4002,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     if (spvVersion.vulkan == 0 && IncludeLegacy(version, profile, spvVersion))
     if (spvVersion.vulkan == 0 && IncludeLegacy(version, profile, spvVersion))
         stageBuiltins[EShLangVertex].append("vec4 ftransform();");
         stageBuiltins[EShLangVertex].append("vec4 ftransform();");
 
 
+#ifndef GLSLANG_ANGLE
     //
     //
     // Original-style texture Functions with lod.
     // Original-style texture Functions with lod.
     //
     //
@@ -4037,6 +4062,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 "\n");
                 "\n");
         }
         }
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     if ((profile != EEsProfile && version >= 150) ||
     if ((profile != EEsProfile && version >= 150) ||
         (profile == EEsProfile && version >= 310)) {
         (profile == EEsProfile && version >= 310)) {
@@ -4057,7 +4083,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "void EndPrimitive();"
             "void EndPrimitive();"
             "\n");
             "\n");
     }
     }
-#endif
+#endif // !GLSLANG_WEB
 
 
     //============================================================================
     //============================================================================
     //
     //
@@ -4117,6 +4143,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 
 
     commonBuiltins.append("void debugPrintfEXT();\n");
     commonBuiltins.append("void debugPrintfEXT();\n");
 
 
+#ifndef GLSLANG_ANGLE
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         // coopMatStoreNV perhaps ought to have "out" on the buf parameter, but
         // coopMatStoreNV perhaps ought to have "out" on the buf parameter, but
         // adding it introduces undesirable tempArgs on the stack. What we want
         // adding it introduces undesirable tempArgs on the stack. What we want
@@ -4240,6 +4267,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 
 
             "\n");
             "\n");
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     // GL_ARB_derivative_control
     // GL_ARB_derivative_control
     if (profile != EEsProfile && version >= 400) {
     if (profile != EEsProfile && version >= 400) {
@@ -4277,6 +4305,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         "bool helperInvocationEXT();"
         "bool helperInvocationEXT();"
         "\n");
         "\n");
 
 
+#ifndef GLSLANG_ANGLE
     // GL_AMD_shader_explicit_vertex_parameter
     // GL_AMD_shader_explicit_vertex_parameter
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         stageBuiltins[EShLangFragment].append(
         stageBuiltins[EShLangFragment].append(
@@ -4411,12 +4440,14 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "void executeCallableEXT(uint, int);"
             "void executeCallableEXT(uint, int);"
             "\n");
             "\n");
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     //E_SPV_NV_compute_shader_derivatives
     //E_SPV_NV_compute_shader_derivatives
     if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) {
     if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) {
         stageBuiltins[EShLangCompute].append(derivativeControls);
         stageBuiltins[EShLangCompute].append(derivativeControls);
         stageBuiltins[EShLangCompute].append("\n");
         stageBuiltins[EShLangCompute].append("\n");
     }
     }
+#ifndef GLSLANG_ANGLE
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
         stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
         stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
         stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
@@ -4429,7 +4460,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "void writePackedPrimitiveIndices4x8NV(uint, uint);"
             "void writePackedPrimitiveIndices4x8NV(uint, uint);"
             "\n");
             "\n");
     }
     }
-#endif
+#endif // !GLSLANG_ANGLE
+#endif // !GLSLANG_WEB
 
 
     //============================================================================
     //============================================================================
     //
     //
@@ -4466,7 +4498,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
             "\n");
     }
     }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
     if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
         //
         //
         // Matrix state. p. 31, 32, 37, 39, 40.
         // Matrix state. p. 31, 32, 37, 39, 40.
@@ -4584,7 +4616,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 
 
             "\n");
             "\n");
     }
     }
-#endif
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
 
 
     //============================================================================
     //============================================================================
     //
     //
@@ -4615,6 +4647,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
     }
     }
 
 
 #ifndef GLSLANG_WEB
 #ifndef GLSLANG_WEB
+#ifndef GLSLANG_ANGLE
     //============================================================================
     //============================================================================
     //
     //
     // Define the interface to the mesh/task shader.
     // Define the interface to the mesh/task shader.
@@ -4702,6 +4735,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 "\n");
                 "\n");
         }
         }
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     //============================================================================
     //============================================================================
     //
     //
@@ -5372,6 +5406,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 
 
 #ifndef GLSLANG_WEB
 #ifndef GLSLANG_WEB
 
 
+    if ((profile != EEsProfile && version >= 140) ||
+        (profile == EEsProfile && version >= 310)) {
+        stageBuiltins[EShLangFragment].append(
+            "flat in highp int gl_DeviceIndex;"     // GL_EXT_device_group
+            "flat in highp int gl_ViewIndex;"       // GL_EXT_multiview
+            "\n");
+    }
+
+#ifndef GLSLANG_ANGLE
     // GL_ARB_shader_ballot
     // GL_ARB_shader_ballot
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         const char* ballotDecls =
         const char* ballotDecls =
@@ -5402,14 +5445,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         stageBuiltins[EShLangTaskNV]        .append(ballotDecls);
         stageBuiltins[EShLangTaskNV]        .append(ballotDecls);
     }
     }
 
 
-    if ((profile != EEsProfile && version >= 140) ||
-        (profile == EEsProfile && version >= 310)) {
-        stageBuiltins[EShLangFragment].append(
-            "flat in highp int gl_DeviceIndex;"     // GL_EXT_device_group
-            "flat in highp int gl_ViewIndex;"       // GL_EXT_multiview
-            "\n");
-    }
-
     // GL_KHR_shader_subgroup
     // GL_KHR_shader_subgroup
     if ((profile == EEsProfile && version >= 310) ||
     if ((profile == EEsProfile && version >= 310) ||
         (profile != EEsProfile && version >= 140)) {
         (profile != EEsProfile && version >= 140)) {
@@ -5613,6 +5648,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         stageBuiltins[EShLangCallable].append(callableDecls);
         stageBuiltins[EShLangCallable].append(callableDecls);
 
 
     }
     }
+
     if ((profile != EEsProfile && version >= 140)) {
     if ((profile != EEsProfile && version >= 140)) {
         const char *deviceIndex =
         const char *deviceIndex =
             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
@@ -5625,12 +5661,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         stageBuiltins[EShLangMiss].append(deviceIndex);
         stageBuiltins[EShLangMiss].append(deviceIndex);
     }
     }
 
 
-    if (version >= 300 /* both ES and non-ES */) {
-        stageBuiltins[EShLangFragment].append(
-            "flat in highp uint gl_ViewID_OVR;"     // GL_OVR_multiview, GL_OVR_multiview2
-            "\n");
-    }
-
     if ((profile != EEsProfile && version >= 420) ||
     if ((profile != EEsProfile && version >= 420) ||
         (profile == EEsProfile && version >= 310)) {
         (profile == EEsProfile && version >= 310)) {
         commonBuiltins.append("const int gl_ScopeDevice      = 1;\n");
         commonBuiltins.append("const int gl_ScopeDevice      = 1;\n");
@@ -5654,7 +5684,15 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         commonBuiltins.append("const int gl_StorageSemanticsImage    = 0x800;\n");
         commonBuiltins.append("const int gl_StorageSemanticsImage    = 0x800;\n");
         commonBuiltins.append("const int gl_StorageSemanticsOutput   = 0x1000;\n");
         commonBuiltins.append("const int gl_StorageSemanticsOutput   = 0x1000;\n");
     }
     }
-#endif
+
+#endif // !GLSLANG_ANGLE
+
+    if (version >= 300 /* both ES and non-ES */) {
+        stageBuiltins[EShLangFragment].append(
+            "flat in highp uint gl_ViewID_OVR;"     // GL_OVR_multiview, GL_OVR_multiview2
+            "\n");
+    }
+#endif // !GLSLANG_WEB
 
 
     // printf("%s\n", commonBuiltins.c_str());
     // printf("%s\n", commonBuiltins.c_str());
     // printf("%s\n", stageBuiltins[EShLangFragment].c_str());
     // printf("%s\n", stageBuiltins[EShLangFragment].c_str());
@@ -5672,13 +5710,16 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
     //
     //
 
 
     // enumerate all the types
     // enumerate all the types
+    const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint,
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
+        EbtFloat16
+#endif
+    };
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
-    const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint };
     bool skipBuffer = true;
     bool skipBuffer = true;
     bool skipCubeArrayed = true;
     bool skipCubeArrayed = true;
     const int image = 0;
     const int image = 0;
 #else
 #else
-    const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint, EbtFloat16 };
     bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
     bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
     bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
     bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
     for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
     for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
@@ -5703,8 +5744,13 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c
                 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
                 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
                     for (int dim = Esd2D; dim <= EsdCube; ++dim) { // 2D, 3D, and Cube
                     for (int dim = Esd2D; dim <= EsdCube; ++dim) { // 2D, 3D, and Cube
+#else
+#if defined(GLSLANG_ANGLE)
+                    // TODO: what is subpass?
+                    for (int dim = Esd2D; dim < EsdSubpass; ++dim) { // 2D, ..., buffer
 #else
 #else
                     for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, ..., buffer, subpass
                     for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, ..., buffer, subpass
+#endif
                         if (dim == EsdSubpass && spvVersion.vulkan == 0)
                         if (dim == EsdSubpass && spvVersion.vulkan == 0)
                             continue;
                             continue;
                         if (dim == EsdSubpass && (image || shadow || arrayed))
                         if (dim == EsdSubpass && (image || shadow || arrayed))
@@ -6125,6 +6171,9 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     profile = EEsProfile;
     profile = EEsProfile;
     version = 310;
     version = 310;
+#elif defined(GLSLANG_ANGLE)
+    profile = ECoreProfile;
+    version = 450;
 #endif
 #endif
 
 
     //
     //
@@ -6201,7 +6250,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
                                     continue;
                                     continue;
 
 
                                 // loop over 16-bit floating-point texel addressing
                                 // loop over 16-bit floating-point texel addressing
-#ifdef GLSLANG_WEB
+#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
                                 const int f16TexAddr = 0;
                                 const int f16TexAddr = 0;
 #else
 #else
                                 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr)
                                 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr)
@@ -6214,7 +6263,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
                                         totalDims--;
                                         totalDims--;
                                     }
                                     }
                                     // loop over "bool" lod clamp
                                     // loop over "bool" lod clamp
-#ifdef GLSLANG_WEB
+#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
                                     const int lodClamp = 0;
                                     const int lodClamp = 0;
 #else
 #else
                                     for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp)
                                     for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp)
@@ -6226,7 +6275,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
                                             continue;
                                             continue;
 
 
                                         // loop over "bool" sparse or not
                                         // loop over "bool" sparse or not
-#ifdef GLSLANG_WEB
+#if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
                                         const int sparse = 0;
                                         const int sparse = 0;
 #else
 #else
                                         for (int sparse = 0; sparse <= 1; ++sparse)
                                         for (int sparse = 0; sparse <= 1; ++sparse)
@@ -6281,7 +6330,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
                                                 s.append("Offset");
                                                 s.append("Offset");
                                             if (lodClamp)
                                             if (lodClamp)
                                                 s.append("Clamp");
                                                 s.append("Clamp");
-                                            if (lodClamp || sparse)
+                                            if (lodClamp != 0 || sparse)
                                                 s.append("ARB");
                                                 s.append("ARB");
                                             s.append("(");
                                             s.append("(");
 
 
@@ -6381,7 +6430,7 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName,
                                             s.append(");\n");
                                             s.append(");\n");
 
 
                                             // Add to the per-language set of built-ins
                                             // Add to the per-language set of built-ins
-                                            if (bias || lodClamp) {
+                                            if (bias || lodClamp != 0) {
                                                 stageBuiltins[EShLangFragment].append(s);
                                                 stageBuiltins[EShLangFragment].append(s);
                                                 stageBuiltins[EShLangCompute].append(s);
                                                 stageBuiltins[EShLangCompute].append(s);
                                             } else
                                             } else
@@ -6410,6 +6459,9 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, in
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     profile = EEsProfile;
     profile = EEsProfile;
     version = 310;
     version = 310;
+#elif defined(GLSLANG_ANGLE)
+    profile = ECoreProfile;
+    version = 450;
 #endif
 #endif
 
 
     switch (sampler.dim) {
     switch (sampler.dim) {
@@ -6653,6 +6705,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     version = 310;
     version = 310;
     profile = EEsProfile;
     profile = EEsProfile;
+#elif defined(GLSLANG_ANGLE)
+    version = 450;
+    profile = ECoreProfile;
 #endif
 #endif
 
 
     //
     //
@@ -7081,6 +7136,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
         s.append("\n");
         s.append("\n");
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     // atomic counters (some in compute below)
     // atomic counters (some in compute below)
     if ((profile == EEsProfile && version >= 310) ||
     if ((profile == EEsProfile && version >= 310) ||
         (profile != EEsProfile && version >= 420)) {
         (profile != EEsProfile && version >= 420)) {
@@ -7117,6 +7173,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
 
 
         s.append("\n");
         s.append("\n");
     }
     }
+#endif // !GLSLANG_ANGLE
 
 
     // GL_ARB_cull_distance
     // GL_ARB_cull_distance
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
@@ -7133,6 +7190,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
         s.append(builtInConstant);
         s.append(builtInConstant);
     }
     }
 
 
+#ifndef GLSLANG_ANGLE
     // SPV_NV_mesh_shader
     // SPV_NV_mesh_shader
     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
         snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
         snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
@@ -7155,6 +7213,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
 
 
         s.append("\n");
         s.append("\n");
     }
     }
+#endif
 #endif
 #endif
 
 
     s.append("\n");
     s.append("\n");
@@ -7239,6 +7298,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     version = 310;
     version = 310;
     profile = EEsProfile;
     profile = EEsProfile;
+#elif defined(GLSLANG_ANGLE)
+    version = 450;
+    profile = ECoreProfile;
 #endif
 #endif
 
 
     //
     //
@@ -7428,7 +7490,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
 
 
     case EShLangTessEvaluation:
     case EShLangTessEvaluation:
     case EShLangGeometry:
     case EShLangGeometry:
-#endif
+#endif // !GLSLANG_WEB
         SpecialQualifier("gl_Position",   EvqPosition,   EbvPosition,   symbolTable);
         SpecialQualifier("gl_Position",   EvqPosition,   EbvPosition,   symbolTable);
         SpecialQualifier("gl_PointSize",  EvqPointSize,  EbvPointSize,  symbolTable);
         SpecialQualifier("gl_PointSize",  EvqPointSize,  EbvPointSize,  symbolTable);
 
 
@@ -7589,7 +7651,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
             BuiltInVariable("gl_WarpIDNV",              EbvWarpID,          symbolTable);
             BuiltInVariable("gl_WarpIDNV",              EbvWarpID,          symbolTable);
             BuiltInVariable("gl_SMIDNV",                EbvSMID,            symbolTable);
             BuiltInVariable("gl_SMIDNV",                EbvSMID,            symbolTable);
         }
         }
-#endif
+#endif // !GLSLANG_WEB
         break;
         break;
 
 
     case EShLangFragment:
     case EShLangFragment:
@@ -8095,7 +8157,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
         }
         }
 
 
         symbolTable.setFunctionExtensions("helperInvocationEXT",            1, &E_GL_EXT_demote_to_helper_invocation);
         symbolTable.setFunctionExtensions("helperInvocationEXT",            1, &E_GL_EXT_demote_to_helper_invocation);
-#endif
+#endif // !GLSLANG_WEB
         break;
         break;
 
 
     case EShLangCompute:
     case EShLangCompute:
@@ -8227,10 +8289,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
             symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
             symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
             symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
             symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
         }
         }
-#endif
+#endif // !GLSLANG_WEB
         break;
         break;
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     case EShLangRayGen:
     case EShLangRayGen:
     case EShLangIntersect:
     case EShLangIntersect:
     case EShLangAnyHit:
     case EShLangAnyHit:
@@ -9133,7 +9195,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
     default:
     default:
         assert(false && "Language not supported");
         assert(false && "Language not supported");
     }
     }
-#endif
+#endif // !GLSLANG_WEB
 }
 }
 
 
 //
 //
@@ -9148,6 +9210,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
 {
 {
 #ifndef GLSLANG_WEB
 #ifndef GLSLANG_WEB
+#if defined(GLSLANG_ANGLE)
+    profile = ECoreProfile;
+    version = 450;
+#endif
     if (profile != EEsProfile && version >= 430 && version < 440) {
     if (profile != EEsProfile && version >= 430 && version < 440) {
         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts);
         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts);
         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts);
         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts);

+ 144 - 178
3rdparty/glslang/glslang/MachineIndependent/Intermediate.cpp

@@ -113,14 +113,14 @@ TIntermSymbol* TIntermediate::addSymbol(const TType& type, const TSourceLoc& loc
 //
 //
 // Returns nullptr if the working conversions and promotions could not be found.
 // Returns nullptr if the working conversions and promotions could not be found.
 //
 //
-TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc)
+TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& loc)
 {
 {
     // No operations work on blocks
     // No operations work on blocks
     if (left->getType().getBasicType() == EbtBlock || right->getType().getBasicType() == EbtBlock)
     if (left->getType().getBasicType() == EbtBlock || right->getType().getBasicType() == EbtBlock)
         return nullptr;
         return nullptr;
 
 
     // Convert "reference +/- int" and "reference - reference" to integer math
     // Convert "reference +/- int" and "reference - reference" to integer math
-    if ((op == EOpAdd || op == EOpSub) && extensionRequested(E_GL_EXT_buffer_reference2)) {
+    if (op == EOpAdd || op == EOpSub) {
 
 
         // No addressing math on struct with unsized array.
         // No addressing math on struct with unsized array.
         if ((left->isReference() && left->getType().getReferentType()->containsUnsizedArray()) ||
         if ((left->isReference() && left->getType().getReferentType()->containsUnsizedArray()) ||
@@ -140,43 +140,44 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
             node = addBuiltInFunctionCall(loc, EOpConvUint64ToPtr, true, node, referenceType);
             node = addBuiltInFunctionCall(loc, EOpConvUint64ToPtr, true, node, referenceType);
             return node;
             return node;
         }
         }
+    }
 
 
-        if (op == EOpAdd && right->isReference() && isTypeInt(left->getBasicType())) {
-            const TType& referenceType = right->getType();
-            TIntermConstantUnion* size = addConstantUnion((unsigned long long)computeBufferReferenceTypeSize(right->getType()), loc, true);
-            right = addBuiltInFunctionCall(loc, EOpConvPtrToUint64, true, right, TType(EbtUint64));
-
-            left  = createConversion(EbtInt64, left);
-            left  = addBinaryMath(EOpMul, left, size, loc);
+    if (op == EOpAdd && right->isReference() && isTypeInt(left->getBasicType())) {
+        const TType& referenceType = right->getType();
+        TIntermConstantUnion* size =
+            addConstantUnion((unsigned long long)computeBufferReferenceTypeSize(right->getType()), loc, true);
+        right = addBuiltInFunctionCall(loc, EOpConvPtrToUint64, true, right, TType(EbtUint64));
 
 
-            TIntermTyped *node = addBinaryMath(op, left, right, loc);
-            node = addBuiltInFunctionCall(loc, EOpConvUint64ToPtr, true, node, referenceType);
-            return node;
-        }
+        left  = createConversion(EbtInt64, left);
+        left  = addBinaryMath(EOpMul, left, size, loc);
 
 
-        if (op == EOpSub && left->isReference() && right->isReference()) {
-            TIntermConstantUnion* size = addConstantUnion((long long)computeBufferReferenceTypeSize(left->getType()), loc, true);
+        TIntermTyped *node = addBinaryMath(op, left, right, loc);
+        node = addBuiltInFunctionCall(loc, EOpConvUint64ToPtr, true, node, referenceType);
+        return node;
+    }
 
 
-            left = addBuiltInFunctionCall(loc, EOpConvPtrToUint64, true, left, TType(EbtUint64));
-            right = addBuiltInFunctionCall(loc, EOpConvPtrToUint64, true, right, TType(EbtUint64));
+    if (op == EOpSub && left->isReference() && right->isReference()) {
+        TIntermConstantUnion* size =
+            addConstantUnion((long long)computeBufferReferenceTypeSize(left->getType()), loc, true);
 
 
-            left = addBuiltInFunctionCall(loc, EOpConvUint64ToInt64, true, left, TType(EbtInt64));
-            right = addBuiltInFunctionCall(loc, EOpConvUint64ToInt64, true, right, TType(EbtInt64));
+        left = addBuiltInFunctionCall(loc, EOpConvPtrToUint64, true, left, TType(EbtUint64));
+        right = addBuiltInFunctionCall(loc, EOpConvPtrToUint64, true, right, TType(EbtUint64));
 
 
-            left = addBinaryMath(EOpSub, left, right, loc);
+        left = addBuiltInFunctionCall(loc, EOpConvUint64ToInt64, true, left, TType(EbtInt64));
+        right = addBuiltInFunctionCall(loc, EOpConvUint64ToInt64, true, right, TType(EbtInt64));
 
 
-            TIntermTyped *node = addBinaryMath(EOpDiv, left, size, loc);
-            return node;
-        }
+        left = addBinaryMath(EOpSub, left, right, loc);
 
 
-        // No other math operators supported on references
-        if (left->isReference() || right->isReference()) {
-            return nullptr;
-        }
+        TIntermTyped *node = addBinaryMath(EOpDiv, left, size, loc);
+        return node;
     }
     }
 
 
+    // No other math operators supported on references
+    if (left->isReference() || right->isReference())
+        return nullptr;
+
     // Try converting the children's base types to compatible types.
     // Try converting the children's base types to compatible types.
-    auto children = addConversion(op, left, right);
+    auto children = addPairConversion(op, left, right);
     left = std::get<0>(children);
     left = std::get<0>(children);
     right = std::get<1>(children);
     right = std::get<1>(children);
 
 
@@ -226,13 +227,12 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
 //
 //
 // Low level: add binary node (no promotions or other argument modifications)
 // Low level: add binary node (no promotions or other argument modifications)
 //
 //
-TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc) const
+TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right,
+    const TSourceLoc& loc) const
 {
 {
     // build the node
     // build the node
     TIntermBinary* node = new TIntermBinary(op);
     TIntermBinary* node = new TIntermBinary(op);
-    if (loc.line == 0)
-        loc = left->getLoc();
-    node->setLoc(loc);
+    node->setLoc(loc.line != 0 ? loc : left->getLoc());
     node->setLeft(left);
     node->setLeft(left);
     node->setRight(right);
     node->setRight(right);
 
 
@@ -242,7 +242,8 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
 //
 //
 // like non-type form, but sets node's type.
 // like non-type form, but sets node's type.
 //
 //
-TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc, const TType& type) const
+TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right,
+    const TSourceLoc& loc, const TType& type) const
 {
 {
     TIntermBinary* node = addBinaryNode(op, left, right, loc);
     TIntermBinary* node = addBinaryNode(op, left, right, loc);
     node->setType(type);
     node->setType(type);
@@ -252,12 +253,10 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
 //
 //
 // Low level: add unary node (no promotions or other argument modifications)
 // Low level: add unary node (no promotions or other argument modifications)
 //
 //
-TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc loc) const
+TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc& loc) const
 {
 {
     TIntermUnary* node = new TIntermUnary(op);
     TIntermUnary* node = new TIntermUnary(op);
-    if (loc.line == 0)
-        loc = child->getLoc();
-    node->setLoc(loc);
+    node->setLoc(loc.line != 0 ? loc : child->getLoc());
     node->setOperand(child);
     node->setOperand(child);
 
 
     return node;
     return node;
@@ -266,7 +265,8 @@ TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSo
 //
 //
 // like non-type form, but sets node's type.
 // like non-type form, but sets node's type.
 //
 //
-TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc loc, const TType& type) const
+TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc& loc, const TType& type)
+    const
 {
 {
     TIntermUnary* node = addUnaryNode(op, child, loc);
     TIntermUnary* node = addUnaryNode(op, child, loc);
     node->setType(type);
     node->setType(type);
@@ -281,7 +281,8 @@ TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSo
 // Returns nullptr if the 'right' type could not be converted to match the 'left' type,
 // Returns nullptr if the 'right' type could not be converted to match the 'left' type,
 // or the resulting operation cannot be properly promoted.
 // or the resulting operation cannot be properly promoted.
 //
 //
-TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc)
+TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right,
+    const TSourceLoc& loc)
 {
 {
     // No block assignment
     // No block assignment
     if (left->getType().getBasicType() == EbtBlock || right->getType().getBasicType() == EbtBlock)
     if (left->getType().getBasicType() == EbtBlock || right->getType().getBasicType() == EbtBlock)
@@ -290,9 +291,7 @@ TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TInterm
     // Convert "reference += int" to "reference = reference + int". We need this because the
     // Convert "reference += int" to "reference = reference + int". We need this because the
     // "reference + int" calculation involves a cast back to the original type, which makes it
     // "reference + int" calculation involves a cast back to the original type, which makes it
     // not an lvalue.
     // not an lvalue.
-    if ((op == EOpAddAssign || op == EOpSubAssign) && left->isReference() &&
-        extensionRequested(E_GL_EXT_buffer_reference2)) {
-
+    if ((op == EOpAddAssign || op == EOpSubAssign) && left->isReference()) {
         if (!(right->getType().isScalar() && right->getType().isIntegerDomain()))
         if (!(right->getType().isScalar() && right->getType().isIntegerDomain()))
             return nullptr;
             return nullptr;
 
 
@@ -338,7 +337,8 @@ TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TInterm
 // Returns the added node.
 // Returns the added node.
 // The caller should set the type of the returned node.
 // The caller should set the type of the returned node.
 //
 //
-TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc loc)
+TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index,
+    const TSourceLoc& loc)
 {
 {
     // caller should set the type
     // caller should set the type
     return addBinaryNode(op, base, index, loc);
     return addBinaryNode(op, base, index, loc);
@@ -349,7 +349,8 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
 //
 //
 // Returns the added node.
 // Returns the added node.
 //
 //
-TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSourceLoc loc)
+TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
+    const TSourceLoc& loc)
 {
 {
     if (child == 0)
     if (child == 0)
         return nullptr;
         return nullptr;
@@ -495,7 +496,8 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(const TSourceLoc& loc, TOper
 // Returns an aggregate node, which could be the one passed in if
 // Returns an aggregate node, which could be the one passed in if
 // it was already an aggregate.
 // it was already an aggregate.
 //
 //
-TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator op, const TType& type, TSourceLoc loc)
+TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator op, const TType& type,
+    const TSourceLoc& loc)
 {
 {
     TIntermAggregate* aggNode;
     TIntermAggregate* aggNode;
 
 
@@ -510,8 +512,6 @@ TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator o
             //
             //
             aggNode = new TIntermAggregate();
             aggNode = new TIntermAggregate();
             aggNode->getSequence().push_back(node);
             aggNode->getSequence().push_back(node);
-            if (loc.line == 0)
-                loc = node->getLoc();
         }
         }
     } else
     } else
         aggNode = new TIntermAggregate();
         aggNode = new TIntermAggregate();
@@ -520,8 +520,8 @@ TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator o
     // Set the operator.
     // Set the operator.
     //
     //
     aggNode->setOperator(op);
     aggNode->setOperator(op);
-    if (loc.line != 0)
-        aggNode->setLoc(loc);
+    if (loc.line != 0 || node != nullptr)
+        aggNode->setLoc(loc.line != 0 ? loc : node->getLoc());
 
 
     aggNode->setType(type);
     aggNode->setType(type);
 
 
@@ -819,22 +819,25 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
                                   node->getBasicType() == EbtFloat ||
                                   node->getBasicType() == EbtFloat ||
                                   node->getBasicType() == EbtDouble);
                                   node->getBasicType() == EbtDouble);
 
 
-    if (! getArithemeticInt8Enabled()) {
-        if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
-            ((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes))
+    if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
+        ((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes)) {
+        if (! getArithemeticInt8Enabled()) {
             return nullptr;
             return nullptr;
+        }
     }
     }
 
 
-    if (! getArithemeticInt16Enabled()) {
-        if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
-            ((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes))
+    if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
+        ((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes)) {
+        if (! getArithemeticInt16Enabled()) {
             return nullptr;
             return nullptr;
+        }
     }
     }
 
 
-    if (! getArithemeticFloat16Enabled()) {
-        if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
-            (node->getBasicType() == EbtFloat16 && ! convertToFloatTypes))
+    if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
+        (node->getBasicType() == EbtFloat16 && ! convertToFloatTypes)) {
+        if (! getArithemeticFloat16Enabled()) {
             return nullptr;
             return nullptr;
+        }
     }
     }
 #endif
 #endif
 
 
@@ -887,7 +890,7 @@ TIntermTyped* TIntermediate::addConversion(TBasicType convertTo, TIntermTyped* n
 // Returns the converted pair of nodes.
 // Returns the converted pair of nodes.
 // Returns <nullptr, nullptr> when there is no conversion.
 // Returns <nullptr, nullptr> when there is no conversion.
 std::tuple<TIntermTyped*, TIntermTyped*>
 std::tuple<TIntermTyped*, TIntermTyped*>
-TIntermediate::addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1)
+TIntermediate::addPairConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1)
 {
 {
     if (!isConversionAllowed(op, node0) || !isConversionAllowed(op, node1))
     if (!isConversionAllowed(op, node0) || !isConversionAllowed(op, node1))
         return std::make_tuple(nullptr, nullptr);
         return std::make_tuple(nullptr, nullptr);
@@ -940,7 +943,7 @@ TIntermediate::addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* no
         if (node0->getBasicType() == node1->getBasicType())
         if (node0->getBasicType() == node1->getBasicType())
             return std::make_tuple(node0, node1);
             return std::make_tuple(node0, node1);
 
 
-        promoteTo = getConversionDestinatonType(node0->getBasicType(), node1->getBasicType(), op);
+        promoteTo = getConversionDestinationType(node0->getBasicType(), node1->getBasicType(), op);
         if (std::get<0>(promoteTo) == EbtNumTypes || std::get<1>(promoteTo) == EbtNumTypes)
         if (std::get<0>(promoteTo) == EbtNumTypes || std::get<1>(promoteTo) == EbtNumTypes)
             return std::make_tuple(nullptr, nullptr);
             return std::make_tuple(nullptr, nullptr);
 
 
@@ -1040,64 +1043,30 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
     // Note: callers are responsible for other aspects of shape,
     // Note: callers are responsible for other aspects of shape,
     // like vector and matrix sizes.
     // like vector and matrix sizes.
 
 
-    TBasicType promoteTo;
-    // GL_EXT_shader_16bit_storage can't do OpConstantComposite with
-    // 16-bit types, so disable promotion for those types.
-    bool canPromoteConstant = true;
-
     switch (op) {
     switch (op) {
     //
     //
     // Explicit conversions (unary operations)
     // Explicit conversions (unary operations)
     //
     //
     case EOpConstructBool:
     case EOpConstructBool:
-        promoteTo = EbtBool;
-        break;
     case EOpConstructFloat:
     case EOpConstructFloat:
-        promoteTo = EbtFloat;
-        break;
     case EOpConstructInt:
     case EOpConstructInt:
-        promoteTo = EbtInt;
-        break;
     case EOpConstructUint:
     case EOpConstructUint:
-        promoteTo = EbtUint;
-        break;
 #ifndef GLSLANG_WEB
 #ifndef GLSLANG_WEB
     case EOpConstructDouble:
     case EOpConstructDouble:
-        promoteTo = EbtDouble;
-        break;
     case EOpConstructFloat16:
     case EOpConstructFloat16:
-        promoteTo = EbtFloat16;
-        canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-                             extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16);
-        break;
     case EOpConstructInt8:
     case EOpConstructInt8:
-        promoteTo = EbtInt8;
-        canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-                             extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
-        break;
     case EOpConstructUint8:
     case EOpConstructUint8:
-        promoteTo = EbtUint8;
-        canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-                             extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
-        break;
     case EOpConstructInt16:
     case EOpConstructInt16:
-        promoteTo = EbtInt16;
-        canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-                             extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
-        break;
     case EOpConstructUint16:
     case EOpConstructUint16:
-        promoteTo = EbtUint16;
-        canPromoteConstant = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-                             extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
-        break;
     case EOpConstructInt64:
     case EOpConstructInt64:
-        promoteTo = EbtInt64;
-        break;
     case EOpConstructUint64:
     case EOpConstructUint64:
-        promoteTo = EbtUint64;
         break;
         break;
+
 #endif
 #endif
 
 
+    //
+    // Implicit conversions
+    //
     case EOpLogicalNot:
     case EOpLogicalNot:
 
 
     case EOpFunctionCall:
     case EOpFunctionCall:
@@ -1152,9 +1121,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
         if (type.getBasicType() == node->getType().getBasicType())
         if (type.getBasicType() == node->getType().getBasicType())
             return node;
             return node;
 
 
-        if (canImplicitlyPromote(node->getBasicType(), type.getBasicType(), op))
-            promoteTo = type.getBasicType();
-        else
+        if (! canImplicitlyPromote(node->getBasicType(), type.getBasicType(), op))
             return nullptr;
             return nullptr;
         break;
         break;
 
 
@@ -1164,9 +1131,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
     case EOpLeftShiftAssign:
     case EOpLeftShiftAssign:
     case EOpRightShiftAssign:
     case EOpRightShiftAssign:
     {
     {
-        if (getSource() == EShSourceHlsl && node->getType().getBasicType() == EbtBool)
-            promoteTo = type.getBasicType();
-        else {
+        if (!(getSource() == EShSourceHlsl && node->getType().getBasicType() == EbtBool)) {
             if (isTypeInt(type.getBasicType()) && isTypeInt(node->getBasicType()))
             if (isTypeInt(type.getBasicType()) && isTypeInt(node->getBasicType()))
                 return node;
                 return node;
             else
             else
@@ -1184,13 +1149,44 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
             return nullptr;
             return nullptr;
     }
     }
 
 
+    bool canPromoteConstant = true;
+#ifndef GLSLANG_WEB
+    // GL_EXT_shader_16bit_storage can't do OpConstantComposite with
+    // 16-bit types, so disable promotion for those types.
+    // Many issues with this, from JohnK:
+    //  - this isn't really right to discuss SPIR-V here
+    //  - this could easily be entirely about scalars, so is overstepping
+    //  - we should be looking at what the shader asked for, and saying whether or
+    //    not it can be done, in the parser, by calling requireExtensions(), not
+    //    changing language sementics on the fly by asking what extensions are in use
+    //  - at the time of this writing (14-Aug-2020), no test results are changed by this.
+    switch (op) {
+    case EOpConstructFloat16:
+        canPromoteConstant = numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+                             numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_float16);
+        break;
+    case EOpConstructInt8:
+    case EOpConstructUint8:
+        canPromoteConstant = numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+                             numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int8);
+        break;
+    case EOpConstructInt16:
+    case EOpConstructUint16:
+        canPromoteConstant = numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+                             numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int16);
+        break;
+    default:
+        break;
+    }
+#endif
+
     if (canPromoteConstant && node->getAsConstantUnion())
     if (canPromoteConstant && node->getAsConstantUnion())
-        return promoteConstantUnion(promoteTo, node->getAsConstantUnion());
+        return promoteConstantUnion(type.getBasicType(), node->getAsConstantUnion());
 
 
     //
     //
     // Add a new newNode for the conversion.
     // Add a new newNode for the conversion.
     //
     //
-    TIntermTyped* newNode = createConversion(promoteTo, node);
+    TIntermTyped* newNode = createConversion(type.getBasicType(), node);
 
 
     return newNode;
     return newNode;
 }
 }
@@ -1659,64 +1655,45 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
         }
         }
     }
     }
 
 
-    bool explicitTypesEnabled = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int32) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int64) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float32) ||
-                                extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float64);
-    
-    if (explicitTypesEnabled) {
-        // integral promotions
-        if (isIntegralPromotion(from, to)) {
-            return true;
-        }
-
-        // floating-point promotions
-        if (isFPPromotion(from, to)) {
-            return true;
-        }
-
-        // integral conversions
-        if (isIntegralConversion(from, to)) {
+    if (getSource() == EShSourceHlsl) {
+        // HLSL
+        if (from == EbtBool && (to == EbtInt || to == EbtUint || to == EbtFloat))
             return true;
             return true;
-        }
-
-        // floating-point conversions
-        if (isFPConversion(from, to)) {
-           return true;
-        }
-
-        // floating-integral conversions
-        if (isFPIntegralConversion(from, to)) {
-           return true;
-        }
-
-        // hlsl supported conversions
-        if (getSource() == EShSourceHlsl) {
-            if (from == EbtBool && (to == EbtInt || to == EbtUint || to == EbtFloat))
+    } else {
+        // GLSL
+        if (isIntegralPromotion(from, to) ||
+            isFPPromotion(from, to) ||
+            isIntegralConversion(from, to) ||
+            isFPConversion(from, to) ||
+            isFPIntegralConversion(from, to)) {
+
+            if (numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int8) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int16) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int32) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int64) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_float16) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_float32) ||
+                numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_float64)) {
                 return true;
                 return true;
+            }
         }
         }
-    } else if (isEsProfile()) {
+    }
+
+    if (isEsProfile()) {
         switch (to) {
         switch (to) {
             case EbtFloat:
             case EbtFloat:
                 switch (from) {
                 switch (from) {
                 case EbtInt:
                 case EbtInt:
                 case EbtUint:
                 case EbtUint:
-                    return extensionRequested(E_GL_EXT_shader_implicit_conversions);
-                case EbtFloat:
-                    return true;
+                    return numericFeatures.contains(TNumericFeatures::shader_implicit_conversions);
                 default:
                 default:
                     return false;
                     return false;
                 }
                 }
             case EbtUint:
             case EbtUint:
                 switch (from) {
                 switch (from) {
                 case EbtInt:
                 case EbtInt:
-                    return extensionRequested(E_GL_EXT_shader_implicit_conversions);
-                case EbtUint:
-                    return true;
+                    return numericFeatures.contains(TNumericFeatures::shader_implicit_conversions);
                 default:
                 default:
                     return false;
                     return false;
                 }
                 }
@@ -1732,15 +1709,14 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
             case EbtInt64:
             case EbtInt64:
             case EbtUint64:
             case EbtUint64:
             case EbtFloat:
             case EbtFloat:
-            case EbtDouble:
-                return version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64);
+                return version >= 400 || numericFeatures.contains(TNumericFeatures::gpu_shader_fp64);
             case EbtInt16:
             case EbtInt16:
             case EbtUint16:
             case EbtUint16:
-                return (version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64)) &&
-                       extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return (version >= 400 || numericFeatures.contains(TNumericFeatures::gpu_shader_fp64)) &&
+                                          numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             case EbtFloat16:
             case EbtFloat16:
-                return (version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64)) &&
-                       extensionRequested(E_GL_AMD_gpu_shader_half_float);
+                return (version >= 400 || numericFeatures.contains(TNumericFeatures::gpu_shader_fp64)) &&
+                                          numericFeatures.contains(TNumericFeatures::gpu_shader_half_float);
             default:
             default:
                 return false;
                 return false;
            }
            }
@@ -1748,16 +1724,15 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
             switch (from) {
             switch (from) {
             case EbtInt:
             case EbtInt:
             case EbtUint:
             case EbtUint:
-            case EbtFloat:
                  return true;
                  return true;
             case EbtBool:
             case EbtBool:
                  return getSource() == EShSourceHlsl;
                  return getSource() == EShSourceHlsl;
             case EbtInt16:
             case EbtInt16:
             case EbtUint16:
             case EbtUint16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             case EbtFloat16:
             case EbtFloat16:
-                return 
-                    extensionRequested(E_GL_AMD_gpu_shader_half_float) || getSource() == EShSourceHlsl;
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_half_float) ||
+                    getSource() == EShSourceHlsl;
             default:
             default:
                  return false;
                  return false;
             }
             }
@@ -1765,24 +1740,20 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
             switch (from) {
             switch (from) {
             case EbtInt:
             case EbtInt:
                 return version >= 400 || getSource() == EShSourceHlsl;
                 return version >= 400 || getSource() == EShSourceHlsl;
-            case EbtUint:
-                return true;
             case EbtBool:
             case EbtBool:
                 return getSource() == EShSourceHlsl;
                 return getSource() == EShSourceHlsl;
             case EbtInt16:
             case EbtInt16:
             case EbtUint16:
             case EbtUint16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             default:
             default:
                 return false;
                 return false;
             }
             }
         case EbtInt:
         case EbtInt:
             switch (from) {
             switch (from) {
-            case EbtInt:
-                return true;
             case EbtBool:
             case EbtBool:
                 return getSource() == EShSourceHlsl;
                 return getSource() == EShSourceHlsl;
             case EbtInt16:
             case EbtInt16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             default:
             default:
                 return false;
                 return false;
             }
             }
@@ -1791,21 +1762,19 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
             case EbtInt:
             case EbtInt:
             case EbtUint:
             case EbtUint:
             case EbtInt64:
             case EbtInt64:
-            case EbtUint64:
                 return true;
                 return true;
             case EbtInt16:
             case EbtInt16:
             case EbtUint16:
             case EbtUint16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             default:
             default:
                 return false;
                 return false;
             }
             }
         case EbtInt64:
         case EbtInt64:
             switch (from) {
             switch (from) {
             case EbtInt:
             case EbtInt:
-            case EbtInt64:
                 return true;
                 return true;
             case EbtInt16:
             case EbtInt16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             default:
             default:
                 return false;
                 return false;
             }
             }
@@ -1813,9 +1782,7 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
             switch (from) {
             switch (from) {
             case EbtInt16:
             case EbtInt16:
             case EbtUint16:
             case EbtUint16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
-            case EbtFloat16:
-                return extensionRequested(E_GL_AMD_gpu_shader_half_float);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             default:
             default:
                 break;
                 break;
             }
             }
@@ -1823,8 +1790,7 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
         case EbtUint16:
         case EbtUint16:
             switch (from) {
             switch (from) {
             case EbtInt16:
             case EbtInt16:
-            case EbtUint16:
-                return extensionRequested(E_GL_AMD_gpu_shader_int16);
+                return numericFeatures.contains(TNumericFeatures::gpu_shader_int16);
             default:
             default:
                 break;
                 break;
             }
             }
@@ -1951,13 +1917,13 @@ static TBasicType getCorrespondingUnsignedType(TBasicType type)
 //        integer type corresponding to the type of the operand with signed
 //        integer type corresponding to the type of the operand with signed
 //        integer type.
 //        integer type.
 
 
-std::tuple<TBasicType, TBasicType> TIntermediate::getConversionDestinatonType(TBasicType type0, TBasicType type1, TOperator op) const
+std::tuple<TBasicType, TBasicType> TIntermediate::getConversionDestinationType(TBasicType type0, TBasicType type1, TOperator op) const
 {
 {
     TBasicType res0 = EbtNumTypes;
     TBasicType res0 = EbtNumTypes;
     TBasicType res1 = EbtNumTypes;
     TBasicType res1 = EbtNumTypes;
 
 
     if ((isEsProfile() && 
     if ((isEsProfile() && 
-        (version < 310 || !extensionRequested(E_GL_EXT_shader_implicit_conversions))) || 
+        (version < 310 || !numericFeatures.contains(TNumericFeatures::shader_implicit_conversions))) || 
         version == 110)
         version == 110)
         return std::make_tuple(res0, res1);
         return std::make_tuple(res0, res1);
 
 
@@ -2490,7 +2456,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
     //
     //
     // Get compatible types.
     // Get compatible types.
     //
     //
-    auto children = addConversion(EOpSequence, trueBlock, falseBlock);
+    auto children = addPairConversion(EOpSequence, trueBlock, falseBlock);
     trueBlock = std::get<0>(children);
     trueBlock = std::get<0>(children);
     falseBlock = std::get<1>(children);
     falseBlock = std::get<1>(children);
 
 

+ 14 - 1
3rdparty/glslang/glslang/MachineIndependent/ParseHelper.cpp

@@ -751,8 +751,11 @@ TIntermTyped* TParseContext::handleBinaryMath(const TSourceLoc& loc, const char*
     }
     }
 
 
     TIntermTyped* result = nullptr;
     TIntermTyped* result = nullptr;
-    if (allowed)
+    if (allowed) {
+        if ((left->isReference() || right->isReference()))
+            requireExtensions(loc, 1, &E_GL_EXT_buffer_reference2, "buffer reference math");
         result = intermediate.addBinaryMath(op, left, right, loc);
         result = intermediate.addBinaryMath(op, left, right, loc);
+    }
 
 
     if (result == nullptr)
     if (result == nullptr)
         binaryOpError(loc, str, left->getCompleteString(), right->getCompleteString());
         binaryOpError(loc, str, left->getCompleteString(), right->getCompleteString());
@@ -1680,6 +1683,14 @@ TIntermTyped* TParseContext::addOutputArgumentConversions(const TFunction& funct
 #endif
 #endif
 }
 }
 
 
+TIntermTyped* TParseContext::addAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
+{
+    if ((op == EOpAddAssign || op == EOpSubAssign) && left->isReference())
+        requireExtensions(loc, 1, &E_GL_EXT_buffer_reference2, "+= and -= on a buffer reference");
+
+    return intermediate.addAssign(op, left, right, loc);
+}
+
 void TParseContext::memorySemanticsCheck(const TSourceLoc& loc, const TFunction& fnCandidate, const TIntermOperator& callNode)
 void TParseContext::memorySemanticsCheck(const TSourceLoc& loc, const TFunction& fnCandidate, const TIntermOperator& callNode)
 {
 {
     const TIntermSequence* argp = &callNode.getAsAggregate()->getSequence();
     const TIntermSequence* argp = &callNode.getAsAggregate()->getSequence();
@@ -7305,6 +7316,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
         if (!node->getType().isCoopMat()) {
         if (!node->getType().isCoopMat()) {
             if (type.getBasicType() != node->getType().getBasicType()) {
             if (type.getBasicType() != node->getType().getBasicType()) {
                 node = intermediate.addConversion(type.getBasicType(), node);
                 node = intermediate.addConversion(type.getBasicType(), node);
+                if (node == nullptr)
+                    return nullptr;
             }
             }
             node = intermediate.setAggregateOperator(node, EOpConstructCooperativeMatrix, type, node->getLoc());
             node = intermediate.setAggregateOperator(node, EOpConstructCooperativeMatrix, type, node->getLoc());
         } else {
         } else {

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

@@ -328,6 +328,7 @@ public:
     TIntermTyped* handleLengthMethod(const TSourceLoc&, TFunction*, TIntermNode*);
     TIntermTyped* handleLengthMethod(const TSourceLoc&, TFunction*, TIntermNode*);
     void addInputArgumentConversions(const TFunction&, TIntermNode*&) const;
     void addInputArgumentConversions(const TFunction&, TIntermNode*&) const;
     TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
     TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
+    TIntermTyped* addAssign(const TSourceLoc&, TOperator op, TIntermTyped* left, TIntermTyped* right);
     void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
     void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
     void nonOpBuiltInCheck(const TSourceLoc&, const TFunction&, TIntermAggregate&);
     void nonOpBuiltInCheck(const TSourceLoc&, const TFunction&, TIntermAggregate&);
     void userFunctionCallCheck(const TSourceLoc&, TIntermAggregate&);
     void userFunctionCallCheck(const TSourceLoc&, TIntermAggregate&);

+ 17 - 11
3rdparty/glslang/glslang/MachineIndependent/PoolAlloc.cpp

@@ -35,28 +35,34 @@
 #include "../Include/Common.h"
 #include "../Include/Common.h"
 #include "../Include/PoolAlloc.h"
 #include "../Include/PoolAlloc.h"
 
 
-namespace glslang {
+#include "../Include/InitializeGlobals.h"
+#include "../OSDependent/osinclude.h"
 
 
-namespace {
-thread_local TPoolAllocator* threadPoolAllocator = nullptr;
+namespace glslang {
 
 
-TPoolAllocator* GetDefaultThreadPoolAllocator()
-{
-    thread_local TPoolAllocator defaultAllocator;
-    return &defaultAllocator;
-}
-} // anonymous namespace
+// Process-wide TLS index
+OS_TLSIndex PoolIndex;
 
 
 // Return the thread-specific current pool.
 // Return the thread-specific current pool.
 TPoolAllocator& GetThreadPoolAllocator()
 TPoolAllocator& GetThreadPoolAllocator()
 {
 {
-    return *(threadPoolAllocator ? threadPoolAllocator : GetDefaultThreadPoolAllocator());
+    return *static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex));
 }
 }
 
 
 // Set the thread-specific current pool.
 // Set the thread-specific current pool.
 void SetThreadPoolAllocator(TPoolAllocator* poolAllocator)
 void SetThreadPoolAllocator(TPoolAllocator* poolAllocator)
 {
 {
-    threadPoolAllocator = poolAllocator;
+    OS_SetTLSValue(PoolIndex, poolAllocator);
+}
+
+// Process-wide set up of the TLS pool storage.
+bool InitializePoolIndex()
+{
+    // Allocate a TLS index.
+    if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
+        return false;
+
+    return true;
 }
 }
 
 
 //
 //

+ 29 - 14
3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp

@@ -294,6 +294,9 @@ void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int versi
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     profile = EEsProfile;
     profile = EEsProfile;
     version = 310;
     version = 310;
+#elif defined(GLSLANG_ANGLE)
+    profile = ECoreProfile;
+    version = 450;
 #endif
 #endif
 
 
     (*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]);
     (*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]);
@@ -315,6 +318,9 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable,  TS
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     profile = EEsProfile;
     profile = EEsProfile;
     version = 310;
     version = 310;
+#elif defined(GLSLANG_ANGLE)
+    profile = ECoreProfile;
+    version = 450;
 #endif
 #endif
 
 
     std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
     std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
@@ -354,7 +360,6 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable,  TS
         (profile == EEsProfile && version >= 310))
         (profile == EEsProfile && version >= 310))
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangGeometry, source,
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangGeometry, source,
                                    infoSink, commonTable, symbolTables);
                                    infoSink, commonTable, symbolTables);
-#endif
 
 
     // check for compute
     // check for compute
     if ((profile != EEsProfile && version >= 420) ||
     if ((profile != EEsProfile && version >= 420) ||
@@ -362,6 +367,7 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable,  TS
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
                                    infoSink, commonTable, symbolTables);
                                    infoSink, commonTable, symbolTables);
 
 
+#ifndef GLSLANG_ANGLE
     // check for ray tracing stages
     // check for ray tracing stages
     if (profile != EEsProfile && version >= 450) {
     if (profile != EEsProfile && version >= 450) {
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangRayGen, source,
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangRayGen, source,
@@ -389,6 +395,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable,  TS
         (profile == EEsProfile && version >= 320))
         (profile == EEsProfile && version >= 320))
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
         InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
                                    infoSink, commonTable, symbolTables);
                                    infoSink, commonTable, symbolTables);
+#endif // !GLSLANG_ANGLE
+#endif // !GLSLANG_WEB
 
 
     return true;
     return true;
 }
 }
@@ -490,7 +498,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
 // Function to Print all builtins
 // Function to Print all builtins
 void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
 void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
 {
 {
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     infoSink.debug << "BuiltinSymbolTable {\n";
     infoSink.debug << "BuiltinSymbolTable {\n";
 
 
     symbolTable.dump(infoSink, true);
     symbolTable.dump(infoSink, true);
@@ -594,7 +602,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
         break;
         break;
     }
     }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     // Correct for stage type...
     // Correct for stage type...
     switch (stage) {
     switch (stage) {
     case EShLangGeometry:
     case EShLangGeometry:
@@ -870,7 +878,7 @@ bool ProcessDeferred(
                                 : userInput.scanVersion(version, profile, versionNotFirstToken);
                                 : userInput.scanVersion(version, profile, versionNotFirstToken);
     bool versionNotFound = version == 0;
     bool versionNotFound = version == 0;
     if (forceDefaultVersionAndProfile && source == EShSourceGlsl) {
     if (forceDefaultVersionAndProfile && source == EShSourceGlsl) {
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
         if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound &&
         if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound &&
             (version != defaultVersion || profile != defaultProfile)) {
             (version != defaultVersion || profile != defaultProfile)) {
             compiler->infoSink.info << "Warning, (version, profile) forced to be ("
             compiler->infoSink.info << "Warning, (version, profile) forced to be ("
@@ -893,10 +901,13 @@ bool ProcessDeferred(
 #ifdef GLSLANG_WEB
 #ifdef GLSLANG_WEB
     profile = EEsProfile;
     profile = EEsProfile;
     version = 310;
     version = 310;
+#elif defined(GLSLANG_ANGLE)
+    profile = ECoreProfile;
+    version = 450;
 #endif
 #endif
 
 
     bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
     bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     bool warnVersionNotFirst = false;
     bool warnVersionNotFirst = false;
     if (! versionWillBeError && versionNotFirstToken) {
     if (! versionWillBeError && versionNotFirstToken) {
         if (messages & EShMsgRelaxedErrors)
         if (messages & EShMsgRelaxedErrors)
@@ -966,7 +977,7 @@ bool ProcessDeferred(
     parseContext->setLimits(*resources);
     parseContext->setLimits(*resources);
     if (! goodVersion)
     if (! goodVersion)
         parseContext->addError();
         parseContext->addError();
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     if (warnVersionNotFirst) {
     if (warnVersionNotFirst) {
         TSourceLoc loc;
         TSourceLoc loc;
         loc.init();
         loc.init();
@@ -1003,7 +1014,7 @@ bool ProcessDeferred(
     return success;
     return success;
 }
 }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 // Responsible for keeping track of the most recent source string and line in
 // Responsible for keeping track of the most recent source string and line in
 // the preprocessor and outputting newlines appropriately if the source string
 // the preprocessor and outputting newlines appropriately if the source string
@@ -1226,14 +1237,16 @@ struct DoFullParse{
             parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors.  No code generated.\n\n";
             parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors.  No code generated.\n\n";
         }
         }
 
 
+#ifndef GLSLANG_ANGLE
         if (messages & EShMsgAST)
         if (messages & EShMsgAST)
             intermediate.output(parseContext.infoSink, true);
             intermediate.output(parseContext.infoSink, true);
+#endif
 
 
         return success;
         return success;
     }
     }
 };
 };
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 // Take a single compilation unit, and run the preprocessor on it.
 // Take a single compilation unit, and run the preprocessor on it.
 // Return: True if there were no issues found in preprocessing,
 // Return: True if there were no issues found in preprocessing,
 //         False if during preprocessing any unknown version, pragmas or
 //         False if during preprocessing any unknown version, pragmas or
@@ -1873,7 +1886,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
                            &environment);
                            &environment);
 }
 }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 // Fill in a string with the result of preprocessing ShaderStrings
 // Fill in a string with the result of preprocessing ShaderStrings
 // Returns true if all extensions, pragmas and version strings were valid.
 // Returns true if all extensions, pragmas and version strings were valid.
 //
 //
@@ -1911,7 +1924,7 @@ const char* TShader::getInfoDebugLog()
 }
 }
 
 
 TProgram::TProgram() :
 TProgram::TProgram() :
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     reflection(0),
     reflection(0),
 #endif
 #endif
     linked(false)
     linked(false)
@@ -1927,7 +1940,7 @@ TProgram::TProgram() :
 TProgram::~TProgram()
 TProgram::~TProgram()
 {
 {
     delete infoSink;
     delete infoSink;
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     delete reflection;
     delete reflection;
 #endif
 #endif
 
 
@@ -1974,7 +1987,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
     if (stages[stage].size() == 0)
     if (stages[stage].size() == 0)
         return true;
         return true;
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     int numEsShaders = 0, numNonEsShaders = 0;
     int numEsShaders = 0, numNonEsShaders = 0;
     for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) {
     for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) {
         if ((*it)->intermediate->getProfile() == EEsProfile) {
         if ((*it)->intermediate->getProfile() == EEsProfile) {
@@ -2028,8 +2041,10 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
 #endif
 #endif
     intermediate[stage]->finalCheck(*infoSink, (messages & EShMsgKeepUncalled) != 0);
     intermediate[stage]->finalCheck(*infoSink, (messages & EShMsgKeepUncalled) != 0);
 
 
+#ifndef GLSLANG_ANGLE
     if (messages & EShMsgAST)
     if (messages & EShMsgAST)
         intermediate[stage]->output(*infoSink, true);
         intermediate[stage]->output(*infoSink, true);
+#endif
 
 
     return intermediate[stage]->getNumErrors() == 0;
     return intermediate[stage]->getNumErrors() == 0;
 }
 }
@@ -2044,7 +2059,7 @@ const char* TProgram::getInfoDebugLog()
     return infoSink->debug.c_str();
     return infoSink->debug.c_str();
 }
 }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 //
 //
 // Reflection implementation.
 // Reflection implementation.
@@ -2126,6 +2141,6 @@ bool TProgram::mapIO(TIoMapResolver* pResolver, TIoMapper* pIoMapper)
     return ioMapper->doMap(pResolver, *infoSink);
     return ioMapper->doMap(pResolver, *infoSink);
 }
 }
 
 
-#endif // GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
 
 
 } // end namespace glslang
 } // end namespace glslang

+ 1 - 1
3rdparty/glslang/glslang/MachineIndependent/SymbolTable.cpp

@@ -178,7 +178,7 @@ void TType::buildMangledName(TString& mangledName) const
     }
     }
 }
 }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 //
 //
 // Dump functions.
 // Dump functions.

+ 6 - 6
3rdparty/glslang/glslang/MachineIndependent/SymbolTable.h

@@ -117,7 +117,7 @@ public:
     virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
     virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
     virtual const char** getExtensions() const { return extensions->data(); }
     virtual const char** getExtensions() const { return extensions->data(); }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
     virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
     void dumpExtensions(TInfoSink& infoSink) const;
     void dumpExtensions(TInfoSink& infoSink) const;
 #endif
 #endif
@@ -196,7 +196,7 @@ public:
     }
     }
     virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
     virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     virtual void dump(TInfoSink& infoSink, bool complete = false) const;
     virtual void dump(TInfoSink& infoSink, bool complete = false) const;
 #endif
 #endif
 
 
@@ -319,7 +319,7 @@ public:
     virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
     virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
     virtual const TParameter& operator[](int i) const { return parameters[i]; }
     virtual const TParameter& operator[](int i) const { return parameters[i]; }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
     virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
 #endif
 #endif
 
 
@@ -381,7 +381,7 @@ public:
     virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
     virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
 
 
     virtual int getAnonId() const { return anonId; }
     virtual int getAnonId() const { return anonId; }
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
     virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
 #endif
 #endif
 
 
@@ -551,7 +551,7 @@ public:
 
 
     void relateToOperator(const char* name, TOperator op);
     void relateToOperator(const char* name, TOperator op);
     void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
     void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     void dump(TInfoSink& infoSink, bool complete = false) const;
     void dump(TInfoSink& infoSink, bool complete = false) const;
 #endif
 #endif
     TSymbolTableLevel* clone() const;
     TSymbolTableLevel* clone() const;
@@ -854,7 +854,7 @@ public:
     }
     }
 
 
     int getMaxSymbolId() { return uniqueId; }
     int getMaxSymbolId() { return uniqueId; }
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     void dump(TInfoSink& infoSink, bool complete = false) const;
     void dump(TInfoSink& infoSink, bool complete = false) const;
 #endif
 #endif
     void copyTable(const TSymbolTable& copyOf);
     void copyTable(const TSymbolTable& copyOf);

+ 33 - 4
3rdparty/glslang/glslang/MachineIndependent/Versions.cpp

@@ -762,7 +762,8 @@ bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExte
 // Use when there are no profile/version to check, it's just an error if one of the
 // Use when there are no profile/version to check, it's just an error if one of the
 // extensions is not present.
 // extensions is not present.
 //
 //
-void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
+void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[],
+    const char* featureDesc)
 {
 {
     if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
     if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
         return;
         return;
@@ -781,7 +782,8 @@ void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions,
 // Use by preprocessor when there are no profile/version to check, it's just an error if one of the
 // Use by preprocessor when there are no profile/version to check, it's just an error if one of the
 // extensions is not present.
 // extensions is not present.
 //
 //
-void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
+void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[],
+    const char* featureDesc)
 {
 {
     if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
     if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
         return;
         return;
@@ -847,6 +849,7 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
         error(getCurrentLoc(), "behavior not supported:", "#extension", behaviorString);
         error(getCurrentLoc(), "behavior not supported:", "#extension", behaviorString);
         return;
         return;
     }
     }
+    bool on = behavior != EBhDisable;
 
 
     // check if extension is used with correct shader stage
     // check if extension is used with correct shader stage
     checkExtensionStage(getCurrentLoc(), extension);
     checkExtensionStage(getCurrentLoc(), extension);
@@ -916,6 +919,32 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
         updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_int64", behaviorString);
         updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_int64", behaviorString);
     else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_float16") == 0)
     else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_float16") == 0)
         updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_float16", behaviorString);
         updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_float16", behaviorString);
+
+    // see if we need to update the numeric features
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int8") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int8, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int16") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int16, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int32") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int32, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int64") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int64, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float16") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float16, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float32") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float32, on);
+    else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float64") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float64, on);
+    else if (strcmp(extension, "GL_EXT_shader_implicit_conversions") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::shader_implicit_conversions, on);
+    else if (strcmp(extension, "GL_ARB_gpu_shader_fp64") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_fp64, on);
+    else if (strcmp(extension, "GL_AMD_gpu_shader_int16") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_int16, on);
+    else if (strcmp(extension, "GL_AMD_gpu_shader_half_float") == 0)
+        intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_half_float, on);
 }
 }
 
 
 void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBehavior behavior)
 void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBehavior behavior)
@@ -951,8 +980,8 @@ void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBe
         } else {
         } else {
             if (iter->second == EBhDisablePartial)
             if (iter->second == EBhDisablePartial)
                 warn(getCurrentLoc(), "extension is only partially supported:", "#extension", extension);
                 warn(getCurrentLoc(), "extension is only partially supported:", "#extension", extension);
-            if (behavior == EBhEnable || behavior == EBhRequire || behavior == EBhDisable)
-                intermediate.updateRequestedExtension(extension, behavior);
+            if (behavior != EBhDisable)
+                intermediate.addRequestedExtension(extension);
             iter->second = behavior;
             iter->second = behavior;
         }
         }
     }
     }

+ 1 - 1
3rdparty/glslang/glslang/MachineIndependent/glslang.m4

@@ -778,7 +778,7 @@ assignment_expression
         parseContext.specializationCheck($2.loc, $1->getType(), "=");
         parseContext.specializationCheck($2.loc, $1->getType(), "=");
         parseContext.lValueErrorCheck($2.loc, "assign", $1);
         parseContext.lValueErrorCheck($2.loc, "assign", $1);
         parseContext.rValueErrorCheck($2.loc, "assign", $3);
         parseContext.rValueErrorCheck($2.loc, "assign", $3);
-        $$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.loc);
+        $$ = parseContext.addAssign($2.loc, $2.op, $1, $3);
         if ($$ == 0) {
         if ($$ == 0) {
             parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
             parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
             $$ = $1;
             $$ = $1;

+ 1 - 2
3rdparty/glslang/glslang/MachineIndependent/glslang.y

@@ -778,7 +778,7 @@ assignment_expression
         parseContext.specializationCheck($2.loc, $1->getType(), "=");
         parseContext.specializationCheck($2.loc, $1->getType(), "=");
         parseContext.lValueErrorCheck($2.loc, "assign", $1);
         parseContext.lValueErrorCheck($2.loc, "assign", $1);
         parseContext.rValueErrorCheck($2.loc, "assign", $3);
         parseContext.rValueErrorCheck($2.loc, "assign", $3);
-        $$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.loc);
+        $$ = parseContext.addAssign($2.loc, $2.op, $1, $3);
         if ($$ == 0) {
         if ($$ == 0) {
             parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
             parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
             $$ = $1;
             $$ = $1;
@@ -3885,4 +3885,3 @@ single_attribute
 
 
 
 
 %%
 %%
-

File diff suppressed because it is too large
+ 191 - 191
3rdparty/glslang/glslang/MachineIndependent/glslang_tab.cpp


+ 5 - 5
3rdparty/glslang/glslang/MachineIndependent/glslang_tab.cpp.h

@@ -30,8 +30,8 @@
    This special exception was added by the Free Software Foundation in
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
    version 2.2 of Bison.  */
 
 
-#ifndef YY_YY_GLSLANG_TAB_CPP_H_INCLUDED
-# define YY_YY_GLSLANG_TAB_CPP_H_INCLUDED
+#ifndef YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED
+# define YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED
 /* Debug traces.  */
 /* Debug traces.  */
 #ifndef YYDEBUG
 #ifndef YYDEBUG
 # define YYDEBUG 1
 # define YYDEBUG 1
@@ -470,7 +470,7 @@ extern int yydebug;
 
 
 union YYSTYPE
 union YYSTYPE
 {
 {
-#line 97 "glslang.y" /* yacc.c:1909  */
+#line 97 "MachineIndependent/glslang.y" /* yacc.c:1909  */
 
 
     struct {
     struct {
         glslang::TSourceLoc loc;
         glslang::TSourceLoc loc;
@@ -506,7 +506,7 @@ union YYSTYPE
         glslang::TArraySizes* typeParameters;
         glslang::TArraySizes* typeParameters;
     } interm;
     } interm;
 
 
-#line 510 "glslang_tab.cpp.h" /* yacc.c:1909  */
+#line 510 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909  */
 };
 };
 
 
 typedef union YYSTYPE YYSTYPE;
 typedef union YYSTYPE YYSTYPE;
@@ -518,4 +518,4 @@ typedef union YYSTYPE YYSTYPE;
 
 
 int yyparse (glslang::TParseContext* pParseContext);
 int yyparse (glslang::TParseContext* pParseContext);
 
 
-#endif /* !YY_YY_GLSLANG_TAB_CPP_H_INCLUDED  */
+#endif /* !YY_YY_MACHINEINDEPENDENT_GLSLANG_TAB_CPP_H_INCLUDED  */

+ 3 - 3
3rdparty/glslang/glslang/MachineIndependent/intermOut.cpp

@@ -36,7 +36,7 @@
 // POSSIBILITY OF SUCH DAMAGE.
 // POSSIBILITY OF SUCH DAMAGE.
 //
 //
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 #include "localintermediate.h"
 #include "localintermediate.h"
 #include "../Include/InfoSink.h"
 #include "../Include/InfoSink.h"
@@ -1466,7 +1466,7 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
     infoSink.debug << "Shader version: " << version << "\n";
     infoSink.debug << "Shader version: " << version << "\n";
     if (requestedExtensions.size() > 0) {
     if (requestedExtensions.size() > 0) {
         for (auto extIt = requestedExtensions.begin(); extIt != requestedExtensions.end(); ++extIt)
         for (auto extIt = requestedExtensions.begin(); extIt != requestedExtensions.end(); ++extIt)
-            infoSink.debug << "Requested " << extIt->first << "\n";
+            infoSink.debug << "Requested " << *extIt << "\n";
     }
     }
 
 
     if (xfbMode)
     if (xfbMode)
@@ -1562,4 +1562,4 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
 
 
 } // end namespace glslang
 } // end namespace glslang
 
 
-#endif // not GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

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

@@ -33,7 +33,7 @@
 // POSSIBILITY OF SUCH DAMAGE.
 // POSSIBILITY OF SUCH DAMAGE.
 //
 //
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 #include "../Include/Common.h"
 #include "../Include/Common.h"
 #include "../Include/InfoSink.h"
 #include "../Include/InfoSink.h"
@@ -1288,4 +1288,4 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
 
 
 } // end namespace glslang
 } // end namespace glslang
 
 
-#endif // GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

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

@@ -33,7 +33,7 @@
 // POSSIBILITY OF SUCH DAMAGE.
 // POSSIBILITY OF SUCH DAMAGE.
 //
 //
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 #ifndef _IOMAPPER_INCLUDED
 #ifndef _IOMAPPER_INCLUDED
 #define _IOMAPPER_INCLUDED
 #define _IOMAPPER_INCLUDED
@@ -186,7 +186,7 @@ protected:
     }
     }
 };
 };
 
 
-// Defaulf I/O resolver for OpenGL
+// Default I/O resolver for OpenGL
 struct TDefaultGlslIoResolver : public TDefaultIoResolverBase {
 struct TDefaultGlslIoResolver : public TDefaultIoResolverBase {
 public:
 public:
     typedef std::map<TString, int> TVarSlotMap;  // <resourceName, location/binding>
     typedef std::map<TString, int> TVarSlotMap;  // <resourceName, location/binding>
@@ -299,4 +299,4 @@ public:
 
 
 #endif // _IOMAPPER_INCLUDED
 #endif // _IOMAPPER_INCLUDED
 
 
-#endif //  GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

+ 3 - 3
3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp

@@ -82,7 +82,7 @@ void TIntermediate::warn(TInfoSink& infoSink, const char* message)
 //
 //
 void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
 void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
 {
 {
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     mergeCallGraphs(infoSink, unit);
     mergeCallGraphs(infoSink, unit);
     mergeModes(infoSink, unit);
     mergeModes(infoSink, unit);
     mergeTrees(infoSink, unit);
     mergeTrees(infoSink, unit);
@@ -104,7 +104,7 @@ void TIntermediate::mergeCallGraphs(TInfoSink& infoSink, TIntermediate& unit)
     callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
     callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
 }
 }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 #define MERGE_MAX(member) member = std::max(member, unit.member)
 #define MERGE_MAX(member) member = std::max(member, unit.member)
 #define MERGE_TRUE(member) if (unit.member) member = unit.member;
 #define MERGE_TRUE(member) if (unit.member) member = unit.member;
@@ -533,7 +533,7 @@ void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
 //
 //
 void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, bool crossStage)
 void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, bool crossStage)
 {
 {
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     bool writeTypeComparison = false;
     bool writeTypeComparison = false;
 
 
     // Types have to match
     // Types have to match

+ 75 - 53
3rdparty/glslang/glslang/MachineIndependent/localintermediate.h

@@ -233,6 +233,31 @@ private:
     TMap<TString, int> maps[EsiCount];
     TMap<TString, int> maps[EsiCount];
 };
 };
 
 
+class TNumericFeatures {
+public:
+    TNumericFeatures() : features(0) { }
+    TNumericFeatures(const TNumericFeatures&) = delete;
+    TNumericFeatures& operator=(const TNumericFeatures&) = delete;
+    typedef enum : unsigned int {
+        shader_explicit_arithmetic_types          = 1 << 0,
+        shader_explicit_arithmetic_types_int8     = 1 << 1,
+        shader_explicit_arithmetic_types_int16    = 1 << 2,
+        shader_explicit_arithmetic_types_int32    = 1 << 3,
+        shader_explicit_arithmetic_types_int64    = 1 << 4,
+        shader_explicit_arithmetic_types_float16  = 1 << 5,
+        shader_explicit_arithmetic_types_float32  = 1 << 6,
+        shader_explicit_arithmetic_types_float64  = 1 << 7,
+        shader_implicit_conversions               = 1 << 8,
+        gpu_shader_fp64                           = 1 << 9,
+        gpu_shader_int16                          = 1 << 10,
+        gpu_shader_half_float                     = 1 << 11,
+    } feature;
+    void insert(feature f) { features |= f; }
+    void erase(feature f) { features &= ~f; }
+    bool contains(feature f) const { return (features & f) != 0; }
+private:
+    unsigned int features;
+};
 
 
 //
 //
 // Set of helper functions to help parse and build the tree.
 // Set of helper functions to help parse and build the tree.
@@ -241,7 +266,10 @@ class TIntermediate {
 public:
 public:
     explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
     explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
         language(l),
         language(l),
-        profile(p), version(v), treeRoot(0),
+#ifndef GLSLANG_ANGLE
+        profile(p), version(v),
+#endif
+        treeRoot(0),
         numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
         numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
         invertY(false),
         invertY(false),
         useStorageBuffer(false),
         useStorageBuffer(false),
@@ -295,9 +323,20 @@ public:
 #endif
 #endif
     }
     }
 
 
-    void setVersion(int v) { version = v; }
+    void setVersion(int v)
+    {
+#ifndef GLSLANG_ANGLE
+        version = v;
+#endif
+    }
+    void setProfile(EProfile p)
+    {
+#ifndef GLSLANG_ANGLE
+        profile = p;
+#endif
+    }
+
     int getVersion() const { return version; }
     int getVersion() const { return version; }
-    void setProfile(EProfile p) { profile = p; }
     EProfile getProfile() const { return profile; }
     EProfile getProfile() const { return profile; }
     void setSpv(const SpvVersion& s)
     void setSpv(const SpvVersion& s)
     {
     {
@@ -357,15 +396,8 @@ public:
     }
     }
     const SpvVersion& getSpv() const { return spvVersion; }
     const SpvVersion& getSpv() const { return spvVersion; }
     EShLanguage getStage() const { return language; }
     EShLanguage getStage() const { return language; }
-    void updateRequestedExtension(const char* extension, TExtensionBehavior behavior) { 
-        if(requestedExtensions.find(extension) != requestedExtensions.end()) {
-            requestedExtensions[extension] = behavior; 
-        } else {
-            requestedExtensions.insert(std::make_pair(extension, behavior)); 
-        }
-    }
-
-    const std::map<std::string, TExtensionBehavior>& getRequestedExtensions() const { return requestedExtensions; }
+    void addRequestedExtension(const char* extension) { requestedExtensions.insert(extension); }
+    const std::set<std::string>& getRequestedExtensions() const { return requestedExtensions; }
 
 
     void setTreeRoot(TIntermNode* r) { treeRoot = r; }
     void setTreeRoot(TIntermNode* r) { treeRoot = r; }
     TIntermNode* getTreeRoot() const { return treeRoot; }
     TIntermNode* getTreeRoot() const { return treeRoot; }
@@ -411,15 +443,15 @@ public:
     TIntermSymbol* addSymbol(const TType&, const TSourceLoc&);
     TIntermSymbol* addSymbol(const TType&, const TSourceLoc&);
     TIntermSymbol* addSymbol(const TIntermSymbol&);
     TIntermSymbol* addSymbol(const TIntermSymbol&);
     TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
     TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
-    std::tuple<TIntermTyped*, TIntermTyped*> addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1);
+    std::tuple<TIntermTyped*, TIntermTyped*> addPairConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1);
     TIntermTyped* addUniShapeConversion(TOperator, const TType&, TIntermTyped*);
     TIntermTyped* addUniShapeConversion(TOperator, const TType&, TIntermTyped*);
     TIntermTyped* addConversion(TBasicType convertTo, TIntermTyped* node) const;
     TIntermTyped* addConversion(TBasicType convertTo, TIntermTyped* node) const;
     void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
     void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
     TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
     TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
-    TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
-    TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
-    TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
-    TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, TSourceLoc);
+    TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
+    TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
+    TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
+    TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, const TSourceLoc&);
     TIntermTyped* addBuiltInFunctionCall(const TSourceLoc& line, TOperator, bool unary, TIntermNode*, const TType& returnType);
     TIntermTyped* addBuiltInFunctionCall(const TSourceLoc& line, TOperator, bool unary, TIntermNode*, const TType& returnType);
     bool canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op = EOpNull) const;
     bool canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op = EOpNull) const;
     bool isIntegralPromotion(TBasicType from, TBasicType to) const;
     bool isIntegralPromotion(TBasicType from, TBasicType to) const;
@@ -433,7 +465,7 @@ public:
     TIntermAggregate* makeAggregate(TIntermNode* node);
     TIntermAggregate* makeAggregate(TIntermNode* node);
     TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
     TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
     TIntermAggregate* makeAggregate(const TSourceLoc&);
     TIntermAggregate* makeAggregate(const TSourceLoc&);
-    TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, TSourceLoc);
+    TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, const TSourceLoc&);
     bool areAllChildConst(TIntermAggregate* aggrNode);
     bool areAllChildConst(TIntermAggregate* aggrNode);
     TIntermSelection* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
     TIntermSelection* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
     TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
     TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
@@ -462,10 +494,11 @@ public:
 
 
     // Low level functions to add nodes (no conversions or other higher level transformations)
     // Low level functions to add nodes (no conversions or other higher level transformations)
     // If a type is provided, the node's type will be set to it.
     // If a type is provided, the node's type will be set to it.
-    TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc) const;
-    TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, const TType&) const;
-    TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc) const;
-    TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc, const TType&) const;
+    TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&) const;
+    TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&,
+        const TType&) const;
+    TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc&) const;
+    TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc&, const TType&) const;
 
 
     // Constant folding (in Constant.cpp)
     // Constant folding (in Constant.cpp)
     TIntermTyped* fold(TIntermAggregate* aggrNode);
     TIntermTyped* fold(TIntermAggregate* aggrNode);
@@ -480,11 +513,7 @@ public:
     void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&);
     void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&);
     void addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymbol&);
     void addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymbol&);
 
 
-    void setUseStorageBuffer()
-    {
-        useStorageBuffer = true;
-        processes.addProcess("use-storage-buffer");
-    }
+    void setUseStorageBuffer() { useStorageBuffer = true; }
     bool usingStorageBuffer() const { return useStorageBuffer; }
     bool usingStorageBuffer() const { return useStorageBuffer; }
     void setDepthReplacing() { depthReplacing = true; }
     void setDepthReplacing() { depthReplacing = true; }
     bool isDepthReplacing() const { return depthReplacing; }
     bool isDepthReplacing() const { return depthReplacing; }
@@ -856,22 +885,25 @@ public:
     bool getArithemeticInt8Enabled() const { return false; }
     bool getArithemeticInt8Enabled() const { return false; }
     bool getArithemeticInt16Enabled() const { return false; }
     bool getArithemeticInt16Enabled() const { return false; }
     bool getArithemeticFloat16Enabled() const { return false; }
     bool getArithemeticFloat16Enabled() const { return false; }
+    void updateNumericFeature(TNumericFeatures::feature f, bool on) { }
 #else
 #else
     bool getArithemeticInt8Enabled() const {
     bool getArithemeticInt8Enabled() const {
-        return extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-               extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
+        return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+               numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int8);
     }
     }
     bool getArithemeticInt16Enabled() const {
     bool getArithemeticInt16Enabled() const {
-        return extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-               extensionRequested(E_GL_AMD_gpu_shader_int16) ||
-               extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
+        return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+               numericFeatures.contains(TNumericFeatures::gpu_shader_int16) ||
+               numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int16);
     }
     }
 
 
     bool getArithemeticFloat16Enabled() const {
     bool getArithemeticFloat16Enabled() const {
-        return extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
-               extensionRequested(E_GL_AMD_gpu_shader_half_float) ||
-               extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16);
+        return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+               numericFeatures.contains(TNumericFeatures::gpu_shader_half_float) ||
+               numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_float16);
     }
     }
+    void updateNumericFeature(TNumericFeatures::feature f, bool on)
+        { on ? numericFeatures.insert(f) : numericFeatures.erase(f); }
 #endif
 #endif
 
 
 protected:
 protected:
@@ -903,23 +935,7 @@ protected:
     bool specConstantPropagates(const TIntermTyped&, const TIntermTyped&);
     bool specConstantPropagates(const TIntermTyped&, const TIntermTyped&);
     void performTextureUpgradeAndSamplerRemovalTransformation(TIntermNode* root);
     void performTextureUpgradeAndSamplerRemovalTransformation(TIntermNode* root);
     bool isConversionAllowed(TOperator op, TIntermTyped* node) const;
     bool isConversionAllowed(TOperator op, TIntermTyped* node) const;
-    std::tuple<TBasicType, TBasicType> getConversionDestinatonType(TBasicType type0, TBasicType type1, TOperator op) const;
-
-    // JohnK: I think this function should go away.
-    // This data structure is just a log to pass on to back ends.
-    // Versioning and extensions are handled in Version.cpp, with a rich
-    // set of functions for querying stages, versions, extension enable/disabled, etc.
-#ifdef GLSLANG_WEB
-    bool extensionRequested(const char *extension) const { return false; }
-#else
-    bool extensionRequested(const char *extension) const {
-        auto it = requestedExtensions.find(extension);
-        if (it != requestedExtensions.end()) {
-            return (it->second == EBhDisable) ? false : true;
-        }
-        return false;
-    }
-#endif
+    std::tuple<TBasicType, TBasicType> getConversionDestinationType(TBasicType type0, TBasicType type1, TOperator op) const;
 
 
     static const char* getResourceName(TResourceType);
     static const char* getResourceName(TResourceType);
 
 
@@ -929,11 +945,16 @@ protected:
     typedef std::list<TCall> TGraph;
     typedef std::list<TCall> TGraph;
     TGraph callGraph;
     TGraph callGraph;
 
 
+#ifdef GLSLANG_ANGLE
+    const EProfile profile = ECoreProfile;
+    const int version = 450;
+#else
     EProfile profile;                           // source profile
     EProfile profile;                           // source profile
     int version;                                // source version
     int version;                                // source version
+#endif
     SpvVersion spvVersion;
     SpvVersion spvVersion;
     TIntermNode* treeRoot;
     TIntermNode* treeRoot;
-    std::map<std::string, TExtensionBehavior> requestedExtensions;  // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
+    std::set<std::string> requestedExtensions;  // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
     TBuiltInResource resources;
     TBuiltInResource resources;
     int numEntryPoints;
     int numEntryPoints;
     int numErrors;
     int numErrors;
@@ -1004,6 +1025,7 @@ protected:
 
 
     std::unordered_map<std::string, int> uniformLocationOverrides;
     std::unordered_map<std::string, int> uniformLocationOverrides;
     int uniformLocationBase;
     int uniformLocationBase;
+    TNumericFeatures numericFeatures;
 #endif
 #endif
 
 
     std::unordered_set<int> usedConstantId; // specialization constant ids used
     std::unordered_set<int> usedConstantId; // specialization constant ids used

+ 7 - 2
3rdparty/glslang/glslang/MachineIndependent/parseVersions.h

@@ -58,7 +58,7 @@ public:
                    const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
                    const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
                    bool forwardCompatible, EShMessages messages)
                    bool forwardCompatible, EShMessages messages)
         :
         :
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
         forwardCompatible(forwardCompatible),
         forwardCompatible(forwardCompatible),
         profile(profile),
         profile(profile),
 #endif
 #endif
@@ -116,9 +116,14 @@ public:
     bool relaxedErrors()    const { return false; }
     bool relaxedErrors()    const { return false; }
     bool suppressWarnings() const { return true; }
     bool suppressWarnings() const { return true; }
     bool isForwardCompatible() const { return false; }
     bool isForwardCompatible() const { return false; }
+#else
+#ifdef GLSLANG_ANGLE
+    const bool forwardCompatible = true;
+    const EProfile profile = ECoreProfile;
 #else
 #else
     bool forwardCompatible;      // true if errors are to be given for use of deprecated features
     bool forwardCompatible;      // true if errors are to be given for use of deprecated features
     EProfile profile;            // the declared profile in the shader (core by default)
     EProfile profile;            // the declared profile in the shader (core by default)
+#endif
     bool isEsProfile() const { return profile == EEsProfile; }
     bool isEsProfile() const { return profile == EEsProfile; }
     void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc);
     void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc);
     void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
     void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
@@ -224,7 +229,7 @@ public:
     TIntermediate& intermediate; // helper for making and hooking up pieces of the parse tree
     TIntermediate& intermediate; // helper for making and hooking up pieces of the parse tree
 
 
 protected:
 protected:
-    TMap<TString, TExtensionBehavior> extensionBehavior;    // for each extension string, what its current behavior is set to
+    TMap<TString, TExtensionBehavior> extensionBehavior;    // for each extension string, what its current behavior is
     TMap<TString, unsigned int> extensionMinSpv;            // for each extension string, store minimum spirv required
     TMap<TString, unsigned int> extensionMinSpv;            // for each extension string, store minimum spirv required
     EShMessages messages;        // errors/warnings/rule-sets
     EShMessages messages;        // errors/warnings/rule-sets
     int numErrors;               // number of compile-time errors encountered
     int numErrors;               // number of compile-time errors encountered

+ 2 - 2
3rdparty/glslang/glslang/MachineIndependent/reflection.cpp

@@ -33,7 +33,7 @@
 // POSSIBILITY OF SUCH DAMAGE.
 // POSSIBILITY OF SUCH DAMAGE.
 //
 //
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 #include "../Include/Common.h"
 #include "../Include/Common.h"
 #include "reflection.h"
 #include "reflection.h"
@@ -1266,4 +1266,4 @@ void TReflection::dump()
 
 
 } // end namespace glslang
 } // end namespace glslang
 
 
-#endif // GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

+ 2 - 2
3rdparty/glslang/glslang/MachineIndependent/reflection.h

@@ -33,7 +33,7 @@
 // POSSIBILITY OF SUCH DAMAGE.
 // POSSIBILITY OF SUCH DAMAGE.
 //
 //
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 #ifndef _REFLECTION_INCLUDED
 #ifndef _REFLECTION_INCLUDED
 #define _REFLECTION_INCLUDED
 #define _REFLECTION_INCLUDED
@@ -220,4 +220,4 @@ protected:
 
 
 #endif // _REFLECTION_INCLUDED
 #endif // _REFLECTION_INCLUDED
 
 
-#endif // GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE

+ 5 - 5
3rdparty/glslang/glslang/Public/ShaderLang.h

@@ -690,7 +690,7 @@ private:
     TShader& operator=(TShader&);
     TShader& operator=(TShader&);
 };
 };
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
 //
 //
 // A reflection database and its interface, consistent with the OpenGL API reflection queries.
 // A reflection database and its interface, consistent with the OpenGL API reflection queries.
@@ -808,7 +808,7 @@ public:
     virtual void addStage(EShLanguage stage) = 0;
     virtual void addStage(EShLanguage stage) = 0;
 };
 };
 
 
-#endif // GLSLANG_WEB
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
 
 
 // Make one TProgram per set of shaders that will get linked together.  Add all
 // Make one TProgram per set of shaders that will get linked together.  Add all
 // the shaders that are to be linked together.  After calling shader.parse()
 // the shaders that are to be linked together.  After calling shader.parse()
@@ -829,7 +829,7 @@ public:
 
 
     TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
     TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
 
 
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
 
 
     // Reflection Interface
     // Reflection Interface
 
 
@@ -923,7 +923,7 @@ public:
     // If resolver is not provided it uses the previous approach
     // If resolver is not provided it uses the previous approach
     // and respects auto assignment and offsets.
     // and respects auto assignment and offsets.
     GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr);
     GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr);
-#endif
+#endif // !GLSLANG_WEB && !GLSLANG_ANGLE
 
 
 protected:
 protected:
     GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages);
     GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages);
@@ -933,7 +933,7 @@ protected:
     TIntermediate* intermediate[EShLangCount];
     TIntermediate* intermediate[EShLangCount];
     bool newedIntermediate[EShLangCount];      // track which intermediate were "new" versus reusing a singleton unit in a stage
     bool newedIntermediate[EShLangCount];      // track which intermediate were "new" versus reusing a singleton unit in a stage
     TInfoSink* infoSink;
     TInfoSink* infoSink;
-#ifndef GLSLANG_WEB
+#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
     TReflection* reflection;
     TReflection* reflection;
 #endif
 #endif
     bool linked;
     bool linked;

Some files were not shown because too many files changed in this diff