浏览代码

Updated glslang.

Бранимир Караџић 4 年之前
父节点
当前提交
5d7814c334

+ 14 - 0
3rdparty/glslang/CHANGES.md

@@ -3,6 +3,20 @@
 All notable changes to this project will be documented in this file.
 This project adheres to [Semantic Versioning](https://semver.org/).
 
+## 11.4.0 2021-04-22
+
+### Other changes
+* Fix to keep source compatible with CMake 3.10.2
+
+## 11.3.0 2021-04-21
+
+### Other changes
+* Added --depfile
+* Added --auto-sampled-textures
+* Now supports InterpolateAt-based functions
+* Supports cross-stage automatic IO mapping
+* Supports GL_EXT_vulkan_glsl_relaxed (-R option)
+
 ## 11.2.0 2021-02-18
 
 ### Other changes

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

@@ -4236,6 +4236,8 @@ spv::Id TGlslangToSpvTraverser::makeArraySizeId(const glslang::TArraySizes& arra
     glslang::TIntermTyped* specNode = arraySizes.getDimNode(dim);
     if (specNode != nullptr) {
         builder.clearAccessChain();
+        SpecConstantOpModeGuard spec_constant_op_mode_setter(&builder);
+        spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
         specNode->traverse(this);
         return accessChainLoad(specNode->getAsTyped()->getType());
     }

+ 8 - 0
3rdparty/glslang/StandAlone/DirStackFileIncluder.h

@@ -40,6 +40,7 @@
 #include <string>
 #include <fstream>
 #include <algorithm>
+#include <set>
 
 #include "./../glslang/Public/ShaderLang.h"
 
@@ -84,12 +85,18 @@ public:
         }
     }
 
+    virtual std::set<std::string> getIncludedFiles()
+    {
+        return includedFiles;
+    }
+
     virtual ~DirStackFileIncluder() override { }
 
 protected:
     typedef char tUserDataElement;
     std::vector<std::string> directoryStack;
     int externalLocalDirectoryCount;
+    std::set<std::string> includedFiles;
 
     // Search for a valid "local" path based on combining the stack of include
     // directories and the nominal name of the header.
@@ -108,6 +115,7 @@ protected:
             std::ifstream file(path, std::ios_base::binary | std::ios_base::ate);
             if (file) {
                 directoryStack.push_back(getDirectory(path));
+                includedFiles.insert(path);
                 return newIncludeResult(path, file, (int)file.tellg());
             }
         }

+ 53 - 3
3rdparty/glslang/StandAlone/StandAlone.cpp

@@ -58,6 +58,7 @@
 #include <map>
 #include <memory>
 #include <thread>
+#include <set>
 
 #include "../glslang/OSDependent/osinclude.h"
 
@@ -111,6 +112,7 @@ bool NaNClamp = false;
 bool stripDebugInfo = false;
 bool beQuiet = false;
 bool VulkanRulesRelaxed = false;
+bool autoSampledTextures = false;
 
 //
 // Return codes from main/exit().
@@ -165,6 +167,7 @@ int ReflectOptions = EShReflectionDefault;
 int Options = 0;
 const char* ExecutableName = nullptr;
 const char* binaryFileName = nullptr;
+const char* depencyFileName = nullptr;
 const char* entryPointName = nullptr;
 const char* sourceEntryPointName = nullptr;
 const char* shaderStageName = nullptr;
@@ -655,6 +658,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                         HlslEnable16BitTypes = true;
                     } else if (lowerword == "hlsl-dx9-compatible") {
                         HlslDX9compatible = true;
+                    } else if (lowerword == "auto-sampled-textures") { 
+                        autoSampledTextures = true;
                     } else if (lowerword == "invert-y" ||  // synonyms
                                lowerword == "iy") {
                         Options |= EOptionInvertY;
@@ -798,6 +803,11 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
                         break;
                     } else if (lowerword == "quiet") {
                         beQuiet = true;
+                    } else if (lowerword == "depfile") {
+                        if (argc <= 1)
+                            Error("no <depfile-name> provided", lowerword.c_str());
+                        depencyFileName = argv[1];
+                        bumpArg();
                     } else if (lowerword == "version") {
                         Options |= EOptionDumpVersions;
                     } else if (lowerword == "help") {
@@ -1135,6 +1145,23 @@ struct ShaderCompUnit {
     }
 };
 
+// Writes a depfile similar to gcc -MMD foo.c
+bool writeDepFile(std::string depfile, std::vector<std::string>& binaryFiles, const std::vector<std::string>& sources)
+{
+    std::ofstream file(depfile);
+    if (file.fail())
+        return false;
+
+    for (auto it = binaryFiles.begin(); it != binaryFiles.end(); it++) {
+        file << *it << ":";
+        for (auto it = sources.begin(); it != sources.end(); it++) {
+            file << " " << *it;
+        }
+        file << std::endl;
+    }
+    return true;
+}
+
 //
 // For linking mode: Will independently parse each compilation unit, but then put them
 // in the same program and link them together, making at most one linked module per
@@ -1151,6 +1178,12 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
     EShMessages messages = EShMsgDefault;
     SetMessageOptions(messages);
 
+    DirStackFileIncluder includer;
+    std::for_each(IncludeDirectoryList.rbegin(), IncludeDirectoryList.rend(), [&includer](const std::string& dir) {
+        includer.pushExternalLocalDirectory(dir); });
+
+    std::vector<std::string> sources;
+
     //
     // Per-shader processing...
     //
@@ -1158,6 +1191,9 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
     glslang::TProgram& program = *new glslang::TProgram;
     for (auto it = compUnits.cbegin(); it != compUnits.cend(); ++it) {
         const auto &compUnit = *it;
+        for (int i = 0; i < compUnit.count; i++) {
+            sources.push_back(compUnit.fileNameList[i]);
+        }
         glslang::TShader* shader = new glslang::TShader(compUnit.stage);
         shader->setStringsWithLengthsAndNames(compUnit.text, NULL, compUnit.fileNameList, compUnit.count);
         if (entryPointName)
@@ -1189,6 +1225,9 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
         shader->setNoStorageFormat((Options & EOptionNoStorageFormat) != 0);
         shader->setResourceSetBinding(baseResourceSetBinding[compUnit.stage]);
 
+        if (autoSampledTextures)
+            shader->setTextureSamplerTransformMode(EShTexSampTransUpgradeTextureRemoveSampler);
+
         if (Options & EOptionAutoMapBindings)
             shader->setAutoMapBindings(true);
 
@@ -1252,9 +1291,6 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
 
         const int defaultVersion = Options & EOptionDefaultDesktop ? 110 : 100;
 
-        DirStackFileIncluder includer;
-        std::for_each(IncludeDirectoryList.rbegin(), IncludeDirectoryList.rend(), [&includer](const std::string& dir) {
-            includer.pushExternalLocalDirectory(dir); });
 #ifndef GLSLANG_WEB
         if (Options & EOptionOutputPreprocessed) {
             std::string str;
@@ -1314,6 +1350,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
     }
 #endif
 
+    std::vector<std::string> outputFiles;
+
     // Dump SPIR-V
     if (Options & EOptionSpv) {
         if (CompileFailed || LinkFailed)
@@ -1343,6 +1381,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
                         } else {
                             glslang::OutputSpvBin(spirv, GetBinaryName((EShLanguage)stage));
                         }
+
+                        outputFiles.push_back(GetBinaryName((EShLanguage)stage));
 #ifndef GLSLANG_WEB
                         if (!SpvToolsDisassembler && (Options & EOptionHumanReadableSpv))
                             spv::Disassemble(std::cout, spirv);
@@ -1353,6 +1393,13 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
         }
     }
 
+    if (depencyFileName && !(CompileFailed || LinkFailed)) {
+        std::set<std::string> includedFiles = includer.getIncludedFiles();
+        sources.insert(sources.end(), includedFiles.begin(), includedFiles.end());
+
+        writeDepFile(depencyFileName, outputFiles, sources);
+    }
+
     // Free everything up, program has to go before the shaders
     // because it might have merged stuff from the shaders, and
     // the stuff from the shaders has to have its destructors called
@@ -1772,7 +1819,10 @@ void usage()
            "                                    without explicit bindings\n"
            "  --auto-map-locations | --aml      automatically locate input/output lacking\n"
            "                                    'location' (fragile, not cross stage)\n"
+           "  --auto-sampled-textures           Removes sampler variables and converts\n" 
+           "                                    existing textures to sampled textures\n"
            "  --client {vulkan<ver>|opengl<ver>} see -V and -G\n"
+           "  --depfile <file>                  writes depfile for build systems\n"
            "  --dump-builtin-symbols            prints builtin symbol table prior each compile\n"
            "  -dumpfullversion | -dumpversion   print bare major.minor.patchlevel\n"
            "  --flatten-uniform-arrays | --fua  flatten uniform texture/sampler arrays to\n"

+ 1 - 1
3rdparty/glslang/build_info.h

@@ -35,7 +35,7 @@
 #define GLSLANG_BUILD_INFO
 
 #define GLSLANG_VERSION_MAJOR 11
-#define GLSLANG_VERSION_MINOR 2
+#define GLSLANG_VERSION_MINOR 4
 #define GLSLANG_VERSION_PATCH 0
 #define GLSLANG_VERSION_FLAVOR ""
 

+ 1 - 1
3rdparty/glslang/glslang/HLSL/hlslGrammar.cpp

@@ -3244,7 +3244,7 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node)
         }
 
         // hook it up
-        node = parseContext.handleFunctionCall(arguments->getLoc(), constructorFunction, arguments);
+        node = parseContext.handleFunctionCall(token.loc, constructorFunction, arguments);
 
         return node != nullptr;
     }

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

@@ -115,6 +115,7 @@ struct TSampler {   // misnomer now; includes images, textures without sampler,
 #endif
 
     bool is1D()          const { return dim == Esd1D; }
+    bool is2D()          const { return dim == Esd2D; }
     bool isBuffer()      const { return dim == EsdBuffer; }
     bool isRect()        const { return dim == EsdRect; }
     bool isSubpass()     const { return dim == EsdSubpass; }

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

@@ -1261,6 +1261,16 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "bvec3 notEqual(u64vec3, u64vec3);"
             "bvec4 notEqual(u64vec4, u64vec4);"
 
+            "int64_t bitCount(int64_t);"
+            "i64vec2 bitCount(i64vec2);"
+            "i64vec3 bitCount(i64vec3);"
+            "i64vec4 bitCount(i64vec4);"
+
+            "int64_t bitCount(uint64_t);"
+            "i64vec2 bitCount(u64vec2);"
+            "i64vec3 bitCount(u64vec3);"
+            "i64vec4 bitCount(u64vec4);"
+
             "int64_t findLSB(int64_t);"
             "i64vec2 findLSB(i64vec2);"
             "i64vec3 findLSB(i64vec3);"

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

@@ -2191,6 +2191,16 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
                               "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]");
                 }
             }
+
+            if (callNode.getOp() == EOpTextureOffset) {
+                TSampler s = arg0->getType().getSampler();
+                if (s.is2D() && s.isArrayed() && s.isShadow()) {
+                    if (isEsProfile())
+                        error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "ES Profile");
+                    else if (version <= 420)
+                        error(loc, "TextureOffset does not support sampler2DArrayShadow : ", "sampler", "version <= 420");
+                }
+            }
         }
 
         break;

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

@@ -508,7 +508,7 @@ public:
     //
     // setEnvInput:    The input source language and stage. If generating code for a
     //                 specific client, the input client semantics to use and the
-    //                 version of the that client's input semantics to use, otherwise
+    //                 version of that client's input semantics to use, otherwise
     //                 use EShClientNone and version of 0, e.g. for validation mode.
     //                 Note 'version' does not describe the target environment,
     //                 just the version of the source dialect to compile under.
@@ -722,7 +722,7 @@ class TObjectReflection {
 public:
     GLSLANG_EXPORT TObjectReflection(const std::string& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex);
 
-    GLSLANG_EXPORT const TType* getType() const { return type; }
+    const TType* getType() const { return type; }
     GLSLANG_EXPORT int getBinding() const;
     GLSLANG_EXPORT void dump() const;
     static TObjectReflection badReflection() { return TObjectReflection(); }