Browse Source

Updated glslang.

Бранимир Караџић 4 years ago
parent
commit
74d4920a17

+ 49 - 59
3rdparty/glslang/SPIRV/GlslangToSpv.cpp

@@ -1830,10 +1830,10 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
             std::vector<spv::Id> operandIds;
             assert(!modeId.second.empty());
             for (auto extraOperand : modeId.second) {
-                int nextConst = 0;
-                spv::Id operandId = createSpvConstantFromConstUnionArray(
-                    extraOperand->getType(), extraOperand->getConstArray(), nextConst, false);
-                operandIds.push_back(operandId);
+                if (extraOperand->getType().getQualifier().isSpecConstant())
+                    operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode()));
+                else
+                    operandIds.push_back(createSpvConstant(*extraOperand));
             }
             builder.addExecutionModeId(shaderEntry, static_cast<spv::ExecutionMode>(modeId.first), operandIds);
         }
@@ -4150,58 +4150,48 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
 
         std::vector<spv::Id> operands;
         for (const auto& typeParam : spirvType.typeParams) {
-            if (typeParam.isConstant) {
-                // Constant expression
-                if (typeParam.constant->isLiteral()) {
-                    if (typeParam.constant->getBasicType() == glslang::EbtFloat) {
-                        float floatValue = static_cast<float>(typeParam.constant->getConstArray()[0].getDConst());
-                        unsigned literal = *reinterpret_cast<unsigned*>(&floatValue);
-                        operands.push_back(literal);
-                    } else if (typeParam.constant->getBasicType() == glslang::EbtInt) {
-                        unsigned literal = typeParam.constant->getConstArray()[0].getIConst();
-                        operands.push_back(literal);
-                    } else if (typeParam.constant->getBasicType() == glslang::EbtUint) {
-                        unsigned literal = typeParam.constant->getConstArray()[0].getUConst();
-                        operands.push_back(literal);
-                    } else if (typeParam.constant->getBasicType() == glslang::EbtBool) {
-                        unsigned literal = typeParam.constant->getConstArray()[0].getBConst();
-                        operands.push_back(literal);
-                    } else if (typeParam.constant->getBasicType() == glslang::EbtString) {
-                        auto str = typeParam.constant->getConstArray()[0].getSConst()->c_str();
-                        unsigned literal = 0;
-                        char* literalPtr = reinterpret_cast<char*>(&literal);
-                        unsigned charCount = 0;
-                        char ch = 0;
-                        do {
-                            ch = *(str++);
-                            *(literalPtr++) = ch;
-                            ++charCount;
-                            if (charCount == 4) {
-                                operands.push_back(literal);
-                                literalPtr = reinterpret_cast<char*>(&literal);
-                                charCount = 0;
-                            }
-                        } while (ch != 0);
-
-                        // Partial literal is padded with 0
-                        if (charCount > 0) {
-                            for (; charCount < 4; ++charCount)
-                                *(literalPtr++) = 0;
+            // Constant expression
+            if (typeParam.constant->isLiteral()) {
+                if (typeParam.constant->getBasicType() == glslang::EbtFloat) {
+                    float floatValue = static_cast<float>(typeParam.constant->getConstArray()[0].getDConst());
+                    unsigned literal = *reinterpret_cast<unsigned*>(&floatValue);
+                    operands.push_back(literal);
+                } else if (typeParam.constant->getBasicType() == glslang::EbtInt) {
+                    unsigned literal = typeParam.constant->getConstArray()[0].getIConst();
+                    operands.push_back(literal);
+                } else if (typeParam.constant->getBasicType() == glslang::EbtUint) {
+                    unsigned literal = typeParam.constant->getConstArray()[0].getUConst();
+                    operands.push_back(literal);
+                } else if (typeParam.constant->getBasicType() == glslang::EbtBool) {
+                    unsigned literal = typeParam.constant->getConstArray()[0].getBConst();
+                    operands.push_back(literal);
+                } else if (typeParam.constant->getBasicType() == glslang::EbtString) {
+                    auto str = typeParam.constant->getConstArray()[0].getSConst()->c_str();
+                    unsigned literal = 0;
+                    char* literalPtr = reinterpret_cast<char*>(&literal);
+                    unsigned charCount = 0;
+                    char ch = 0;
+                    do {
+                        ch = *(str++);
+                        *(literalPtr++) = ch;
+                        ++charCount;
+                        if (charCount == 4) {
                             operands.push_back(literal);
+                            literalPtr = reinterpret_cast<char*>(&literal);
+                            charCount = 0;
                         }
-                    } else
-                        assert(0); // Unexpected type
-                } else {
-                    int nextConst = 0;
-                    spv::Id constant = createSpvConstantFromConstUnionArray(
-                        typeParam.constant->getType(), typeParam.constant->getConstArray(), nextConst, false);
-                    operands.push_back(constant);
-                }
-            } else {
-                // Type specifier
-                spv::Id typeId = convertGlslangToSpvType(*typeParam.type);
-                operands.push_back(typeId);
-            }
+                    } while (ch != 0);
+
+                    // Partial literal is padded with 0
+                    if (charCount > 0) {
+                        for (; charCount < 4; ++charCount)
+                            *(literalPtr++) = 0;
+                        operands.push_back(literal);
+                    }
+                } else
+                    assert(0); // Unexpected type
+            } else
+                operands.push_back(createSpvConstant(*typeParam.constant));
         }
 
         if (spirvInst.set == "")
@@ -8847,12 +8837,12 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
             std::vector<spv::Id> operandIds;
             assert(!decorateId.second.empty());
             for (auto extraOperand : decorateId.second) {
-                int nextConst = 0;
-                spv::Id operandId = createSpvConstantFromConstUnionArray(
-                    extraOperand->getType(), extraOperand->getConstArray(), nextConst, false);
-                operandIds.push_back(operandId);
+                if (extraOperand->getQualifier().isSpecConstant())
+                    operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode()));
+                else
+                    operandIds.push_back(createSpvConstant(*extraOperand));
             }
-            builder.addDecoration(id, static_cast<spv::Decoration>(decorateId.first), operandIds);
+            builder.addDecorationId(id, static_cast<spv::Decoration>(decorateId.first), operandIds);
         }
 
         // Add spirv_decorate_string

+ 26 - 13
3rdparty/glslang/SPIRV/SpvPostProcess.cpp

@@ -44,10 +44,8 @@
 #include <algorithm>
 
 #include "SpvBuilder.h"
-
 #include "spirv.hpp"
-#include "GlslangToSpv.h"
-#include "SpvBuilder.h"
+
 namespace spv {
     #include "GLSL.std.450.h"
     #include "GLSL.ext.KHR.h"
@@ -113,8 +111,6 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
             }
         }
         break;
-    case OpAccessChain:
-    case OpPtrAccessChain:
     case OpCopyObject:
         break;
     case OpFConvert:
@@ -161,26 +157,43 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
         switch (inst.getImmediateOperand(1)) {
         case GLSLstd450Frexp:
         case GLSLstd450FrexpStruct:
-            if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeInt, 16))
+            if (getSpvVersion() < spv::Spv_1_3 && containsType(typeId, OpTypeInt, 16))
                 addExtension(spv::E_SPV_AMD_gpu_shader_int16);
             break;
         case GLSLstd450InterpolateAtCentroid:
         case GLSLstd450InterpolateAtSample:
         case GLSLstd450InterpolateAtOffset:
-            if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeFloat, 16))
+            if (getSpvVersion() < spv::Spv_1_3 && containsType(typeId, OpTypeFloat, 16))
                 addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
             break;
         default:
             break;
         }
         break;
+    case OpAccessChain:
+    case OpPtrAccessChain:
+        if (isPointerType(typeId))
+            break;
+        if (basicTypeOp == OpTypeInt) {
+            if (width == 16)
+                addCapability(CapabilityInt16);
+            else if (width == 8)
+                addCapability(CapabilityInt8);
+        }
     default:
-        if (basicTypeOp == OpTypeFloat && width == 16)
-            addCapability(CapabilityFloat16);
-        if (basicTypeOp == OpTypeInt && width == 16)
-            addCapability(CapabilityInt16);
-        if (basicTypeOp == OpTypeInt && width == 8)
-            addCapability(CapabilityInt8);
+        if (basicTypeOp == OpTypeInt) {
+            if (width == 16)
+                addCapability(CapabilityInt16);
+            else if (width == 8)
+                addCapability(CapabilityInt8);
+            else if (width == 64)
+                addCapability(CapabilityInt64);
+        } else if (basicTypeOp == OpTypeFloat) {
+            if (width == 16)
+                addCapability(CapabilityFloat16);
+            else if (width == 64)
+                addCapability(CapabilityFloat64);
+        }
         break;
     }
 }

+ 14 - 1
3rdparty/glslang/StandAlone/StandAlone.cpp

@@ -2,6 +2,7 @@
 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
 // Copyright (C) 2013-2016 LunarG, Inc.
 // Copyright (C) 2016-2020 Google, Inc.
+// Modifications Copyright(C) 2021 Advanced Micro Devices, Inc.All rights reserved.
 //
 // All rights reserved.
 //
@@ -65,6 +66,8 @@
 // Build-time generated includes
 #include "glslang/build_info.h"
 
+#include "glslang/glsl_intrinsic_header.h"
+
 extern "C" {
     GLSLANG_EXPORT void ShOutputHtml();
 }
@@ -263,6 +266,7 @@ protected:
 
 // Track the user's #define and #undef from the command line.
 TPreamble UserPreamble;
+std::string PreambleString;
 
 //
 // Create the default name for saving a binary if -o is not provided.
@@ -1204,8 +1208,17 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
                        "Use '-e <name>'.\n");
             shader->setSourceEntryPoint(sourceEntryPointName);
         }
+
+        std::string intrinsicString = getIntrinsic(compUnit.text, compUnit.count);
+
+        PreambleString = "";
         if (UserPreamble.isSet())
-            shader->setPreamble(UserPreamble.get());
+            PreambleString.append(UserPreamble.get());
+
+        if (!intrinsicString.empty())
+            PreambleString.append(intrinsicString);
+
+        shader->setPreamble(PreambleString.c_str());
         shader->addProcesses(Processes);
 
 #ifndef GLSLANG_WEB

+ 98 - 0
3rdparty/glslang/gen_extension_headers.py

@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2020 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import glob
+import sys
+import os
+
+def generate_main(glsl_files, output_header_file):
+    # Write commit ID to output header file
+    with open(output_header_file, "w") as header_file:
+        # Copyright Notice
+        header_string =  '/***************************************************************************\n'
+        header_string += ' *\n'
+        header_string += ' * Copyright (c) 2015-2021 The Khronos Group Inc.\n'
+        header_string += ' * Copyright (c) 2015-2021 Valve Corporation\n'
+        header_string += ' * Copyright (c) 2015-2021 LunarG, Inc.\n'
+        header_string += ' * Copyright (c) 2015-2021 Google Inc.\n'
+        header_string += ' * Copyright (c) 2021 Advanced Micro Devices, Inc.All rights reserved.\n'
+        header_string += ' *\n'
+        header_string += ' ****************************************************************************/\n'
+        header_string += '#pragma once\n\n'
+        header_string += '#ifndef _INTRINSIC_EXTENSION_HEADER_H_\n'
+        header_string += '#define _INTRINSIC_EXTENSION_HEADER_H_\n\n'
+        header_file.write(header_string)
+
+        symbol_name_list = []
+
+        for i in glsl_files:
+            glsl_contents = open(i,"r").read()
+
+            filename = os.path.basename(i)
+            symbol_name = filename.split(".")[0]
+            symbol_name_list.append(symbol_name)
+            header_name = symbol_name + ".h"
+            header_str = 'std::string %s_GLSL = R"(\n%s\n)";\n' % (symbol_name, glsl_contents)
+            header_str += '\n'
+            header_file.write(header_str)
+
+        contents = ''
+        contents += '\n'
+        contents += 'std::string getIntrinsic(const char* const* shaders, int n) {\n'
+        contents += '\tstd::string shaderString = "";\n';
+
+        contents += '\tfor (int i = 0; i < n; i++) {\n'
+
+        for symbol_name in symbol_name_list:
+            contents += '\t\tif (strstr(shaders[i], "%s") != NULL) {\n'   % (symbol_name)
+            contents += '\t\t    shaderString.append(%s_GLSL);\n' % (symbol_name)
+            contents += '\t\t}\n'
+
+        contents += '\t}\n'
+        contents += '\treturn shaderString;\n';
+        contents += '}\n'
+
+        contents += '\n#endif\n'
+        header_file.write(contents)
+
+def main():
+    if len(sys.argv) < 2:
+        raise Exception("Invalid number of arguments")
+
+    i = 0
+    while i < len(sys.argv):
+        opt = sys.argv[i]
+        i = i + 1
+
+        if opt == "-i" or opt == "-o":
+            if i == len(sys.argv):
+                raise Exception("Expected path after {}".format(opt))
+            val = sys.argv[i]
+            i = i + 1
+            if (opt == "-i"):
+                input_dir = val
+            elif (opt == "-o"):
+                output_file = val
+            else:
+                raise Exception("Unknown flag {}".format(opt))
+
+    glsl_files = glob.glob(input_dir + '/*.glsl')
+
+    # Generate main header
+    generate_main(glsl_files, output_file)
+
+if __name__ == '__main__':
+    main()

+ 54 - 0
3rdparty/glslang/glslang/ExtensionHeaders/GL_EXT_shader_realtime_clock.glsl

@@ -0,0 +1,54 @@
+//
+// Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
+// Copyright (C) 2013-2016 LunarG, Inc.
+// Copyright (C) 2016-2020 Google, Inc.
+// Modifications Copyright(C) 2021 Advanced Micro Devices, Inc.All rights reserved.
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+
+#extension GL_EXT_spirv_intrinsics : enable
+#extension GL_ARB_gpu_shader_int64 : enable
+
+uvec2 clockRealtime2x32EXT(void) {
+    spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
+    uvec2 clockRealtime2x32EXT_internal(uint scope);
+    
+    return clockRealtime2x32EXT_internal(1 /*Device scope*/);
+}
+
+uint64_t clockRealtimeEXT(void) {
+    spirv_instruction (extensions = ["SPV_KHR_shader_clock"], capabilities = [5055], id = 5056)
+    uint64_t clockRealtimeEXT_internal(uint scope);
+    
+    return clockRealtimeEXT_internal(1 /*Device scope*/);
+}

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

@@ -306,6 +306,8 @@ public:
 
     TPoolAllocator& getAllocator() const { return allocator; }
 
+    pool_allocator select_on_container_copy_construction() const { return pool_allocator{}; }
+
 protected:
     pool_allocator& operator=(const pool_allocator&) { return *this; }
     TPoolAllocator& allocator;

+ 5 - 13
3rdparty/glslang/glslang/Include/SpirvIntrinsics.h

@@ -65,7 +65,7 @@ struct TSpirvExecutionMode {
     // spirv_execution_mode
     TMap<int, TVector<const TIntermConstantUnion*>> modes;
     // spirv_execution_mode_id
-    TMap<int, TVector<const TIntermConstantUnion*> > modeIds;
+    TMap<int, TVector<const TIntermTyped*> > modeIds;
 };
 
 // SPIR-V decorations
@@ -75,7 +75,7 @@ struct TSpirvDecorate {
     // spirv_decorate
     TMap<int, TVector<const TIntermConstantUnion*> > decorates;
     // spirv_decorate_id
-    TMap<int, TVector<const TIntermConstantUnion*> > decorateIds;
+    TMap<int, TVector<const TIntermTyped*>> decorateIds;
     // spirv_decorate_string
     TMap<int, TVector<const TIntermConstantUnion*> > decorateStrings;
 };
@@ -98,20 +98,12 @@ struct TSpirvInstruction {
 struct TSpirvTypeParameter {
     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
 
-    TSpirvTypeParameter(const TIntermConstantUnion* arg) { isConstant = true; constant = arg; }
-    TSpirvTypeParameter(const TType* arg) { isConstant = false; type = arg; }
+    TSpirvTypeParameter(const TIntermConstantUnion* arg) { constant = arg; }
 
-    bool operator==(const TSpirvTypeParameter& rhs) const
-    {
-        return isConstant == rhs.isConstant && ((isConstant && constant == rhs.constant) || (!isConstant && type == rhs.type));
-    }
+    bool operator==(const TSpirvTypeParameter& rhs) const { return constant == rhs.constant; }
     bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
 
-    bool isConstant;
-    union {
-        const TIntermConstantUnion* constant;
-        const TType* type;
-    };
+    const TIntermConstantUnion* constant;
 };
 
 typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;

+ 23 - 110
3rdparty/glslang/glslang/MachineIndependent/Initialize.cpp

@@ -3,7 +3,7 @@
 // Copyright (C) 2012-2016 LunarG, Inc.
 // Copyright (C) 2015-2020 Google, Inc.
 // Copyright (C) 2017 ARM Limited.
-// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
+// Modifications Copyright (C) 2020-2021 Advanced Micro Devices, Inc. All rights reserved.
 //
 // All rights reserved.
 //
@@ -4159,106 +4159,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "u16vec4  unpack16(uint64_t);"
             "i32vec2  unpack32(int64_t);"
             "u32vec2  unpack32(uint64_t);"
-
-            "float64_t radians(float64_t);"
-            "f64vec2   radians(f64vec2);"
-            "f64vec3   radians(f64vec3);"
-            "f64vec4   radians(f64vec4);"
-
-            "float64_t degrees(float64_t);"
-            "f64vec2   degrees(f64vec2);"
-            "f64vec3   degrees(f64vec3);"
-            "f64vec4   degrees(f64vec4);"
-
-            "float64_t sin(float64_t);"
-            "f64vec2   sin(f64vec2);"
-            "f64vec3   sin(f64vec3);"
-            "f64vec4   sin(f64vec4);"
-
-            "float64_t cos(float64_t);"
-            "f64vec2   cos(f64vec2);"
-            "f64vec3   cos(f64vec3);"
-            "f64vec4   cos(f64vec4);"
-
-            "float64_t tan(float64_t);"
-            "f64vec2   tan(f64vec2);"
-            "f64vec3   tan(f64vec3);"
-            "f64vec4   tan(f64vec4);"
-
-            "float64_t asin(float64_t);"
-            "f64vec2   asin(f64vec2);"
-            "f64vec3   asin(f64vec3);"
-            "f64vec4   asin(f64vec4);"
-
-            "float64_t acos(float64_t);"
-            "f64vec2   acos(f64vec2);"
-            "f64vec3   acos(f64vec3);"
-            "f64vec4   acos(f64vec4);"
-
-            "float64_t atan(float64_t, float64_t);"
-            "f64vec2   atan(f64vec2,   f64vec2);"
-            "f64vec3   atan(f64vec3,   f64vec3);"
-            "f64vec4   atan(f64vec4,   f64vec4);"
-
-            "float64_t atan(float64_t);"
-            "f64vec2   atan(f64vec2);"
-            "f64vec3   atan(f64vec3);"
-            "f64vec4   atan(f64vec4);"
-
-            "float64_t sinh(float64_t);"
-            "f64vec2   sinh(f64vec2);"
-            "f64vec3   sinh(f64vec3);"
-            "f64vec4   sinh(f64vec4);"
-
-            "float64_t cosh(float64_t);"
-            "f64vec2   cosh(f64vec2);"
-            "f64vec3   cosh(f64vec3);"
-            "f64vec4   cosh(f64vec4);"
-
-            "float64_t tanh(float64_t);"
-            "f64vec2   tanh(f64vec2);"
-            "f64vec3   tanh(f64vec3);"
-            "f64vec4   tanh(f64vec4);"
-
-            "float64_t asinh(float64_t);"
-            "f64vec2   asinh(f64vec2);"
-            "f64vec3   asinh(f64vec3);"
-            "f64vec4   asinh(f64vec4);"
-
-            "float64_t acosh(float64_t);"
-            "f64vec2   acosh(f64vec2);"
-            "f64vec3   acosh(f64vec3);"
-            "f64vec4   acosh(f64vec4);"
-
-            "float64_t atanh(float64_t);"
-            "f64vec2   atanh(f64vec2);"
-            "f64vec3   atanh(f64vec3);"
-            "f64vec4   atanh(f64vec4);"
-
-            "float64_t pow(float64_t, float64_t);"
-            "f64vec2   pow(f64vec2,   f64vec2);"
-            "f64vec3   pow(f64vec3,   f64vec3);"
-            "f64vec4   pow(f64vec4,   f64vec4);"
-
-            "float64_t exp(float64_t);"
-            "f64vec2   exp(f64vec2);"
-            "f64vec3   exp(f64vec3);"
-            "f64vec4   exp(f64vec4);"
-
-            "float64_t log(float64_t);"
-            "f64vec2   log(f64vec2);"
-            "f64vec3   log(f64vec3);"
-            "f64vec4   log(f64vec4);"
-
-            "float64_t exp2(float64_t);"
-            "f64vec2   exp2(f64vec2);"
-            "f64vec3   exp2(f64vec3);"
-            "f64vec4   exp2(f64vec4);"
-
-            "float64_t log2(float64_t);"
-            "f64vec2   log2(f64vec2);"
-            "f64vec3   log2(f64vec3);"
-            "f64vec4   log2(f64vec4);"
             "\n");
     }
 
@@ -4653,13 +4553,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "\n");
     }
 
-    // GL_ARB_shader_clock & GL_EXT_shader_realtime_clock
+    // GL_ARB_shader_clock
     if (profile != EEsProfile && version >= 450) {
         commonBuiltins.append(
             "uvec2 clock2x32ARB();"
             "uint64_t clockARB();"
-            "uvec2 clockRealtime2x32EXT();"
-            "uint64_t clockRealtimeEXT();"
             "\n");
     }
 
@@ -5174,9 +5072,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 );
         }
 
-        if (version >= 450)
+        if (version >= 430)
             stageBuiltins[EShLangVertex].append(
                 "out int gl_ViewportMask[];"             // GL_NV_viewport_array2
+                );
+
+        if (version >= 450)
+            stageBuiltins[EShLangVertex].append(
                 "out int gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
                 "out vec4 gl_SecondaryPositionNV;"       // GL_NV_stereo_view_rendering
                 "out vec4 gl_PositionPerViewNV[];"       // GL_NVX_multiview_per_view_attributes
@@ -5312,9 +5214,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
             "in int gl_InvocationID;"
             );
 
-        if (version >= 450)
+        if (version >= 430)
             stageBuiltins[EShLangGeometry].append(
                 "out int gl_ViewportMask[];"               // GL_NV_viewport_array2
+            );
+
+        if (version >= 450)
+            stageBuiltins[EShLangGeometry].append(
                 "out int gl_SecondaryViewportMaskNV[];"    // GL_NV_stereo_view_rendering
                 "out vec4 gl_SecondaryPositionNV;"         // GL_NV_stereo_view_rendering
                 "out vec4 gl_PositionPerViewNV[];"         // GL_NVX_multiview_per_view_attributes
@@ -5390,7 +5296,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
         if (version >= 450)
             stageBuiltins[EShLangTessControl].append(
                 "float gl_CullDistance[];"
+            );
+        if (version >= 430)
+            stageBuiltins[EShLangTessControl].append(
                 "int  gl_ViewportMask[];"             // GL_NV_viewport_array2
+            );
+        if (version >= 450)
+            stageBuiltins[EShLangTessControl].append(
                 "vec4 gl_SecondaryPositionNV;"        // GL_NV_stereo_view_rendering
                 "int  gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
                 "vec4 gl_PositionPerViewNV[];"        // GL_NVX_multiview_per_view_attributes
@@ -5493,9 +5405,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
                 "out int gl_Layer;"
                 "\n");
 
-        if (version >= 450)
+        if (version >= 430)
             stageBuiltins[EShLangTessEvaluation].append(
                 "out int  gl_ViewportMask[];"             // GL_NV_viewport_array2
+            );
+
+        if (version >= 450)
+            stageBuiltins[EShLangTessEvaluation].append(
                 "out vec4 gl_SecondaryPositionNV;"        // GL_NV_stereo_view_rendering
                 "out int  gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
                 "out vec4 gl_PositionPerViewNV[];"        // GL_NVX_multiview_per_view_attributes
@@ -8408,9 +8324,6 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
         symbolTable.setFunctionExtensions("clockARB",     1, &E_GL_ARB_shader_clock);
         symbolTable.setFunctionExtensions("clock2x32ARB", 1, &E_GL_ARB_shader_clock);
 
-        symbolTable.setFunctionExtensions("clockRealtimeEXT",     1, &E_GL_EXT_shader_realtime_clock);
-        symbolTable.setFunctionExtensions("clockRealtime2x32EXT", 1, &E_GL_EXT_shader_realtime_clock);
-
         if (profile == EEsProfile && version < 320) {
             symbolTable.setVariableExtensions("gl_PrimitiveID",  Num_AEP_geometry_shader, AEP_geometry_shader);
             symbolTable.setVariableExtensions("gl_Layer",        Num_AEP_geometry_shader, AEP_geometry_shader);

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

@@ -3029,11 +3029,14 @@ void TParseContext::constantValueCheck(TIntermTyped* node, const char* token)
 
 //
 // Both test, and if necessary spit out an error, to see if the node is really
-// an integer.
+// a 32-bit integer or can implicitly convert to one.
 //
 void TParseContext::integerCheck(const TIntermTyped* node, const char* token)
 {
-    if ((node->getBasicType() == EbtInt || node->getBasicType() == EbtUint) && node->isScalar())
+    auto from_type = node->getBasicType();
+    if ((from_type == EbtInt || from_type == EbtUint ||
+         intermediate.canImplicitlyPromote(from_type, EbtInt, EOpNull) ||
+         intermediate.canImplicitlyPromote(from_type, EbtUint, EOpNull)) && node->isScalar())
         return;
 
     error(node->getLoc(), "scalar integer expression required", token, "");

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

@@ -480,7 +480,6 @@ public:
     TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
                                                 TSpirvRequirement* spirvReq2);
     TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant);
-    TSpirvTypeParameters* makeSpirvTypeParameters(const TPublicType& type);
     TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1,
                                                    TSpirvTypeParameters* spirvTypeParams2);
     TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value);

+ 14 - 19
3rdparty/glslang/glslang/MachineIndependent/SpirvIntrinsics.cpp

@@ -130,11 +130,11 @@ void TIntermediate::insertSpirvExecutionModeId(int executionMode, const TIntermA
         spirvExecutionMode = new TSpirvExecutionMode;
 
     assert(args);
-    TVector<const TIntermConstantUnion*> extraOperands;
+    TVector<const TIntermTyped*> extraOperands;
 
     for (auto arg : args->getSequence()) {
-        auto extraOperand = arg->getAsConstantUnion();
-        assert(extraOperand != nullptr);
+        auto extraOperand = arg->getAsTyped();
+        assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant());
         extraOperands.push_back(extraOperand);
     }
     spirvExecutionMode->modeIds[executionMode] = extraOperands;
@@ -165,10 +165,10 @@ void TQualifier::setSpirvDecorateId(int decoration, const TIntermAggregate* args
         spirvDecorate = new TSpirvDecorate;
 
     assert(args);
-    TVector<const TIntermConstantUnion*> extraOperands;
+    TVector<const TIntermTyped*> extraOperands;
     for (auto arg : args->getSequence()) {
-        auto extraOperand = arg->getAsConstantUnion();
-        assert(extraOperand != nullptr);
+        auto extraOperand = arg->getAsTyped();
+        assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant());
         extraOperands.push_back(extraOperand);
     }
     spirvDecorate->decorateIds[decoration] = extraOperands;
@@ -201,25 +201,27 @@ TString TQualifier::getSpirvDecorateQualifierString() const
     const auto appendBool = [&](bool b) { qualifierString.append(std::to_string(b).c_str()); };
     const auto appendStr = [&](const char* s) { qualifierString.append(s); };
 
-    const auto appendDecorate = [&](const TIntermConstantUnion* constant) {
+    const auto appendDecorate = [&](const TIntermTyped* constant) {
+        auto& constArray = constant->getAsConstantUnion() != nullptr ? constant->getAsConstantUnion()->getConstArray()
+                                                                     : constant->getAsSymbolNode()->getConstArray();
         if (constant->getBasicType() == EbtFloat) {
-            float value = static_cast<float>(constant->getConstArray()[0].getDConst());
+            float value = static_cast<float>(constArray[0].getDConst());
             appendFloat(value);
         }
         else if (constant->getBasicType() == EbtInt) {
-            int value = constant->getConstArray()[0].getIConst();
+            int value = constArray[0].getIConst();
             appendInt(value);
         }
         else if (constant->getBasicType() == EbtUint) {
-            unsigned value = constant->getConstArray()[0].getUConst();
+            unsigned value = constArray[0].getUConst();
             appendUint(value);
         }
         else if (constant->getBasicType() == EbtBool) {
-            bool value = constant->getConstArray()[0].getBConst();
+            bool value = constArray[0].getBConst();
             appendBool(value);
         }
         else if (constant->getBasicType() == EbtString) {
-            const TString* value = constant->getConstArray()[0].getSConst();
+            const TString* value = constArray[0].getSConst();
             appendStr(value->c_str());
         }
         else
@@ -290,13 +292,6 @@ TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& l
     return spirvTypeParams;
 }
 
-TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TPublicType& type)
-{
-    TSpirvTypeParameters* spirvTypeParams = new TSpirvTypeParameters;
-    spirvTypeParams->push_back(TSpirvTypeParameter(new TType(type)));
-    return spirvTypeParams;
-}
-
 TSpirvTypeParameters* TParseContext::mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* spirvTypeParams2)
 {
     // Merge SPIR-V type parameters of the second one to the first one

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

@@ -4367,9 +4367,6 @@ spirv_type_parameter
     : constant_expression {
         $$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
     }
-    | type_specifier {
-        $$ = parseContext.makeSpirvTypeParameters($1);
-    }
 
 spirv_instruction_qualifier
     : SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {

+ 0 - 3
3rdparty/glslang/glslang/MachineIndependent/glslang.y

@@ -4367,9 +4367,6 @@ spirv_type_parameter
     : constant_expression {
         $$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
     }
-    | type_specifier {
-        $$ = parseContext.makeSpirvTypeParameters($1);
-    }
 
 spirv_instruction_qualifier
     : SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {

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


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

@@ -79,7 +79,7 @@ public:
             target = &inputList;
         else if (base->getQualifier().storage == EvqVaryingOut)
             target = &outputList;
-        else if (base->getQualifier().isUniformOrBuffer() && !base->getQualifier().isPushConstant())
+        else if (base->getQualifier().isUniformOrBuffer() && !base->getQualifier().isPushConstant() && !base->getQualifier().isShaderRecord())
             target = &uniformList;
         // If a global is being visited, then we should also traverse it incase it's evaluation
         // ends up visiting inputs we want to tag as live
@@ -748,7 +748,7 @@ private:
 };
 
 TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate)
-    : intermediate(intermediate)
+    : referenceIntermediate(intermediate)
     , nextUniformLocation(intermediate.getUniformLocationBase())
     , nextInputLocation(0)
     , nextOutputLocation(0)
@@ -760,17 +760,17 @@ TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate
 
 int TDefaultIoResolverBase::getBaseBinding(EShLanguage stage, TResourceType res, unsigned int set) const {
     return stageIntermediates[stage] ? selectBaseBinding(stageIntermediates[stage]->getShiftBinding(res), stageIntermediates[stage]->getShiftBindingForSet(res, set))
-                                     : selectBaseBinding(intermediate.getShiftBinding(res), intermediate.getShiftBindingForSet(res, set));
+                                     : selectBaseBinding(referenceIntermediate.getShiftBinding(res), referenceIntermediate.getShiftBindingForSet(res, set));
 }
 
 const std::vector<std::string>& TDefaultIoResolverBase::getResourceSetBinding(EShLanguage stage) const {
     return stageIntermediates[stage] ? stageIntermediates[stage]->getResourceSetBinding()
-                                     : intermediate.getResourceSetBinding();
+                                     : referenceIntermediate.getResourceSetBinding();
 }
 
-bool TDefaultIoResolverBase::doAutoBindingMapping() const { return intermediate.getAutoMapBindings(); }
+bool TDefaultIoResolverBase::doAutoBindingMapping() const { return referenceIntermediate.getAutoMapBindings(); }
 
-bool TDefaultIoResolverBase::doAutoLocationMapping() const { return intermediate.getAutoMapLocations(); }
+bool TDefaultIoResolverBase::doAutoLocationMapping() const { return referenceIntermediate.getAutoMapLocations(); }
 
 TDefaultIoResolverBase::TSlotSet::iterator TDefaultIoResolverBase::findSlot(int set, int slot) {
     return std::lower_bound(slots[set].begin(), slots[set].end(), slot);
@@ -827,7 +827,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
     }
     // no locations added if already present, a built-in variable, a block, or an opaque
     if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
-        type.isAtomic() || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) {
+        type.isAtomic() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
         return ent.newLocation = -1;
     }
     // no locations on blocks of built-in variables
@@ -839,7 +839,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
             return ent.newLocation = -1;
         }
     }
-    int location = intermediate.getUniformLocationOverride(name);
+    int location = referenceIntermediate.getUniformLocationOverride(name);
     if (location != -1) {
         return ent.newLocation = location;
     }
@@ -1024,7 +1024,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
     } else {
         // no locations added if already present, a built-in variable, a block, or an opaque
         if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
-            type.isAtomic() || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) {
+            type.isAtomic() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
             return ent.newLocation = -1;
         }
         // no locations on blocks of built-in variables
@@ -1037,7 +1037,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
             }
         }
     }
-    int location = intermediate.getUniformLocationOverride(name.c_str());
+    int location = referenceIntermediate.getUniformLocationOverride(name.c_str());
     if (location != -1) {
         return ent.newLocation = location;
     }
@@ -1086,7 +1086,7 @@ int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent
     const TType& type = ent.symbol->getType();
     const TString& name = ent.symbol->getAccessName();
     // On OpenGL arrays of opaque types take a separate binding for each element
-    int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
+    int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
     TResourceType resource = getResourceType(type);
     // don't need to handle uniform symbol, it will be handled in resolveUniformLocation
     if (resource == EResUbo && type.getBasicType() != EbtBlock) {
@@ -1095,7 +1095,7 @@ int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent
     // There is no 'set' qualifier in OpenGL shading language, each resource has its own
     // binding name space, so remap the 'set' to resource type which make each resource
     // binding is valid from 0 to MAX_XXRESOURCE_BINDINGS
-    int set = intermediate.getSpv().openGl != 0 ? resource : ent.newSet;
+    int set = referenceIntermediate.getSpv().openGl != 0 ? resource : ent.newSet;
     int resourceKey = set;
     if (resource < EResCount) {
         if (type.getQualifier().hasBinding()) {
@@ -1223,7 +1223,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
     const TType& type = ent.symbol->getType();
     const TString& name = ent.symbol->getAccessName();
     TResourceType resource = getResourceType(type);
-    int set = intermediate.getSpv().openGl != 0 ? resource : resolveSet(ent.stage, ent);
+    int set = referenceIntermediate.getSpv().openGl != 0 ? resource : resolveSet(ent.stage, ent);
     int resourceKey = set;
 
     if (type.getQualifier().hasBinding()) {
@@ -1233,7 +1233,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
 
         if (iter == varSlotMap.end()) {
             // Reserve the slots for the ubo, ssbo and opaques who has explicit binding
-            int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
+            int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
             varSlotMap[name] = binding;
             reserveSlot(resourceKey, binding, numBindings);
         } else {
@@ -1288,7 +1288,7 @@ struct TDefaultIoResolver : public TDefaultIoResolverBase {
         const TType& type = ent.symbol->getType();
         const int set = getLayoutSet(type);
         // On OpenGL arrays of opaque types take a seperate binding for each element
-        int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
+        int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
         TResourceType resource = getResourceType(type);
         if (resource < EResCount) {
             if (type.getQualifier().hasBinding()) {

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

@@ -165,7 +165,7 @@ public:
 protected:
     TDefaultIoResolverBase(TDefaultIoResolverBase&);
     TDefaultIoResolverBase& operator=(TDefaultIoResolverBase&);
-    const TIntermediate& intermediate;
+    const TIntermediate& referenceIntermediate;
     int nextUniformLocation;
     int nextInputLocation;
     int nextOutputLocation;
@@ -322,8 +322,8 @@ public:
                 intermediates[stage] = nullptr;
         }
     }
-	// If set, the uniform block with the given name will be changed to be backed by
-	// push_constant if it's size is <= maxSize
+    // If set, the uniform block with the given name will be changed to be backed by
+    // push_constant if it's size is <= maxSize
     void setAutoPushConstantBlock(const char* name, unsigned int maxSize, TLayoutPacking packing) {
         autoPushConstantBlockName = name;
         autoPushConstantMaxSize = maxSize;

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

@@ -954,10 +954,10 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
     //       current implementation only has one offset.
     if (symbol.getQualifier().layoutMatrix    != unitSymbol.getQualifier().layoutMatrix ||
         symbol.getQualifier().layoutPacking   != unitSymbol.getQualifier().layoutPacking ||
-        symbol.getQualifier().layoutLocation  != unitSymbol.getQualifier().layoutLocation ||
+        (symbol.getQualifier().hasLocation() && unitSymbol.getQualifier().hasLocation() && symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation) ||
         symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent ||
         symbol.getQualifier().layoutIndex     != unitSymbol.getQualifier().layoutIndex ||
-        symbol.getQualifier().layoutBinding   != unitSymbol.getQualifier().layoutBinding ||
+        (symbol.getQualifier().hasBinding() && unitSymbol.getQualifier().hasBinding() && symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding) ||
         (symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset))) {
         error(infoSink, "Layout qualification must match:");
         writeTypeComparison = true;

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