diff options
author | Jakub Marcowski <01158831@pw.edu.pl> | 2024-02-05 20:39:02 +0100 |
---|---|---|
committer | Jakub Marcowski <01158831@pw.edu.pl> | 2024-02-06 13:46:56 +0100 |
commit | 8350c88718736978b41001084dda38d00d84ce33 (patch) | |
tree | 47559c286c9adc85a4b4068d41c05bd620597bf4 /thirdparty/glslang/SPIRV | |
parent | d3352813ea44447bfbf135efdec23acc4d1d3f89 (diff) | |
download | redot-engine-8350c88718736978b41001084dda38d00d84ce33.tar.gz |
vulkan: Update all components to Vulkan SDK 1.3.275.0
Diffstat (limited to 'thirdparty/glslang/SPIRV')
-rwxr-xr-x | thirdparty/glslang/SPIRV/GlslangToSpv.cpp | 165 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/GlslangToSpv.h | 20 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/SPVRemapper.h | 2 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/SpvBuilder.cpp | 136 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/SpvBuilder.h | 14 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/SpvTools.h | 13 | ||||
-rwxr-xr-x | thirdparty/glslang/SPIRV/doc.cpp | 10 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/doc.h | 4 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/spirv.hpp | 24 | ||||
-rw-r--r-- | thirdparty/glslang/SPIRV/spvIR.h | 1 |
10 files changed, 216 insertions, 173 deletions
diff --git a/thirdparty/glslang/SPIRV/GlslangToSpv.cpp b/thirdparty/glslang/SPIRV/GlslangToSpv.cpp index 576c680f96..ec40f663a7 100755 --- a/thirdparty/glslang/SPIRV/GlslangToSpv.cpp +++ b/thirdparty/glslang/SPIRV/GlslangToSpv.cpp @@ -43,6 +43,7 @@ #include "spirv.hpp" #include "GlslangToSpv.h" #include "SpvBuilder.h" +#include "SpvTools.h" namespace spv { #include "GLSL.std.450.h" #include "GLSL.ext.KHR.h" @@ -66,6 +67,7 @@ namespace spv { #include <iomanip> #include <list> #include <map> +#include <optional> #include <stack> #include <string> #include <vector> @@ -164,6 +166,7 @@ protected: spv::Id convertGlslangToSpvType(const glslang::TType& type, bool forwardReferenceOnly = false); spv::Id convertGlslangToSpvType(const glslang::TType& type, glslang::TLayoutPacking, const glslang::TQualifier&, bool lastBufferBlockMember, bool forwardReferenceOnly = false); + void applySpirvDecorate(const glslang::TType& type, spv::Id id, std::optional<int> member); bool filterMember(const glslang::TType& member); spv::Id convertGlslangStructToSpvType(const glslang::TType&, const glslang::TTypeList* glslangStruct, glslang::TLayoutPacking, const glslang::TQualifier&); @@ -3715,13 +3718,13 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt // Determine Cooperative Matrix Operands bits from the signedness of the types. if (isTypeSignedInt(glslangOperands[0]->getAsTyped()->getBasicType())) - matrixOperands |= spv::CooperativeMatrixOperandsMatrixASignedComponentsMask; + matrixOperands |= spv::CooperativeMatrixOperandsMatrixASignedComponentsKHRMask; if (isTypeSignedInt(glslangOperands[1]->getAsTyped()->getBasicType())) - matrixOperands |= spv::CooperativeMatrixOperandsMatrixBSignedComponentsMask; + matrixOperands |= spv::CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask; if (isTypeSignedInt(glslangOperands[2]->getAsTyped()->getBasicType())) - matrixOperands |= spv::CooperativeMatrixOperandsMatrixCSignedComponentsMask; + matrixOperands |= spv::CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask; if (isTypeSignedInt(node->getBasicType())) - matrixOperands |= spv::CooperativeMatrixOperandsMatrixResultSignedComponentsMask; + matrixOperands |= spv::CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask; std::vector<spv::IdImmediate> idImmOps; idImmOps.push_back(spv::IdImmediate(true, operands[0])); @@ -4404,7 +4407,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty if (explicitLayout != glslang::ElpNone) spvType = builder.makeUintType(32); else - spvType = builder.makeBoolType(false); + spvType = builder.makeBoolType(); break; case glslang::EbtInt: spvType = builder.makeIntType(32); @@ -4705,6 +4708,64 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty return spvType; } +// Apply SPIR-V decorations to the SPIR-V object (provided by SPIR-V ID). If member index is provided, the +// decorations are applied to this member. +void TGlslangToSpvTraverser::applySpirvDecorate(const glslang::TType& type, spv::Id id, std::optional<int> member) +{ + assert(type.getQualifier().hasSpirvDecorate()); + + const glslang::TSpirvDecorate& spirvDecorate = type.getQualifier().getSpirvDecorate(); + + // Add spirv_decorate + for (auto& decorate : spirvDecorate.decorates) { + if (!decorate.second.empty()) { + std::vector<unsigned> literals; + TranslateLiterals(decorate.second, literals); + if (member.has_value()) + builder.addMemberDecoration(id, *member, static_cast<spv::Decoration>(decorate.first), literals); + else + builder.addDecoration(id, static_cast<spv::Decoration>(decorate.first), literals); + } else { + if (member.has_value()) + builder.addMemberDecoration(id, *member, static_cast<spv::Decoration>(decorate.first)); + else + builder.addDecoration(id, static_cast<spv::Decoration>(decorate.first)); + } + } + + // Add spirv_decorate_id + if (member.has_value()) { + // spirv_decorate_id not applied to members + assert(spirvDecorate.decorateIds.empty()); + } else { + for (auto& decorateId : spirvDecorate.decorateIds) { + std::vector<spv::Id> operandIds; + assert(!decorateId.second.empty()); + for (auto extraOperand : decorateId.second) { + if (extraOperand->getQualifier().isFrontEndConstant()) + operandIds.push_back(createSpvConstant(*extraOperand)); + else + operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode())); + } + builder.addDecorationId(id, static_cast<spv::Decoration>(decorateId.first), operandIds); + } + } + + // Add spirv_decorate_string + for (auto& decorateString : spirvDecorate.decorateStrings) { + std::vector<const char*> strings; + assert(!decorateString.second.empty()); + for (auto extraOperand : decorateString.second) { + const char* string = extraOperand->getConstArray()[0].getSConst()->c_str(); + strings.push_back(string); + } + if (member.has_value()) + builder.addMemberDecoration(id, *member, static_cast<spv::Decoration>(decorateString.first), strings); + else + builder.addDecoration(id, static_cast<spv::Decoration>(decorateString.first), strings); + } +} + // TODO: this functionality should exist at a higher level, in creating the AST // // Identify interface members that don't have their required extension turned on. @@ -4943,37 +5004,9 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type, builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough); } - // - // Add SPIR-V decorations for members (GL_EXT_spirv_intrinsics) - // - if (glslangMember.getQualifier().hasSprivDecorate()) { - const glslang::TSpirvDecorate& spirvDecorate = glslangMember.getQualifier().getSpirvDecorate(); - - // Add spirv_decorate - for (auto& decorate : spirvDecorate.decorates) { - if (!decorate.second.empty()) { - std::vector<unsigned> literals; - TranslateLiterals(decorate.second, literals); - builder.addMemberDecoration(spvType, member, static_cast<spv::Decoration>(decorate.first), literals); - } - else - builder.addMemberDecoration(spvType, member, static_cast<spv::Decoration>(decorate.first)); - } - - // spirv_decorate_id not applied to members - assert(spirvDecorate.decorateIds.empty()); - - // Add spirv_decorate_string - for (auto& decorateString : spirvDecorate.decorateStrings) { - std::vector<const char*> strings; - assert(!decorateString.second.empty()); - for (auto extraOperand : decorateString.second) { - const char* string = extraOperand->getConstArray()[0].getSConst()->c_str(); - strings.push_back(string); - } - builder.addDecoration(spvType, static_cast<spv::Decoration>(decorateString.first), strings); - } - } + // Add SPIR-V decorations (GL_EXT_spirv_intrinsics) + if (glslangMember.getQualifier().hasSpirvDecorate()) + applySpirvDecorate(glslangMember, spvType, member); } // Decorate the structure @@ -5403,9 +5436,17 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF for (int f = 0; f < (int)glslFunctions.size(); ++f) { glslang::TIntermAggregate* glslFunction = glslFunctions[f]->getAsAggregate(); - if (! glslFunction || glslFunction->getOp() != glslang::EOpFunction || isShaderEntryPoint(glslFunction)) + if (! glslFunction || glslFunction->getOp() != glslang::EOpFunction) continue; - + if (isShaderEntryPoint(glslFunction)) { + if (glslangIntermediate->getSource() != glslang::EShSourceHlsl) { + builder.setupDebugFunctionEntry(shaderEntry, glslangIntermediate->getEntryPointMangledName().c_str(), + glslFunction->getLoc().line, + std::vector<spv::Id>(), // main function has no param + std::vector<char const*>()); + } + continue; + } // We're on a user function. Set up the basic interface for the function now, // so that it's available to call. Translating the body will happen later. // @@ -5454,7 +5495,9 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF spv::Function* function = builder.makeFunctionEntry( TranslatePrecisionDecoration(glslFunction->getType()), convertGlslangToSpvType(glslFunction->getType()), glslFunction->getName().c_str(), convertGlslangLinkageToSpv(glslFunction->getLinkType()), paramTypes, - paramNames, paramDecorations, &functionBlock); + paramDecorations, &functionBlock); + builder.setupDebugFunctionEntry(function, glslFunction->getName().c_str(), glslFunction->getLoc().line, + paramTypes, paramNames); if (implicitThis) function->setImplicitThis(); @@ -9588,47 +9631,9 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol spv::DecorationRestrictPointerEXT : spv::DecorationAliasedPointerEXT); } - // - // Add SPIR-V decorations for structure (GL_EXT_spirv_intrinsics) - // - if (symbol->getType().getQualifier().hasSprivDecorate()) { - const glslang::TSpirvDecorate& spirvDecorate = symbol->getType().getQualifier().getSpirvDecorate(); - - // Add spirv_decorate - for (auto& decorate : spirvDecorate.decorates) { - if (!decorate.second.empty()) { - std::vector<unsigned> literals; - TranslateLiterals(decorate.second, literals); - builder.addDecoration(id, static_cast<spv::Decoration>(decorate.first), literals); - } - else - builder.addDecoration(id, static_cast<spv::Decoration>(decorate.first)); - } - - // Add spirv_decorate_id - for (auto& decorateId : spirvDecorate.decorateIds) { - std::vector<spv::Id> operandIds; - assert(!decorateId.second.empty()); - for (auto extraOperand : decorateId.second) { - if (extraOperand->getQualifier().isFrontEndConstant()) - operandIds.push_back(createSpvConstant(*extraOperand)); - else - operandIds.push_back(getSymbolId(extraOperand->getAsSymbolNode())); - } - builder.addDecorationId(id, static_cast<spv::Decoration>(decorateId.first), operandIds); - } - - // Add spirv_decorate_string - for (auto& decorateString : spirvDecorate.decorateStrings) { - std::vector<const char*> strings; - assert(!decorateString.second.empty()); - for (auto extraOperand : decorateString.second) { - const char* string = extraOperand->getConstArray()[0].getSConst()->c_str(); - strings.push_back(string); - } - builder.addDecoration(id, static_cast<spv::Decoration>(decorateString.first), strings); - } - } + // Add SPIR-V decorations (GL_EXT_spirv_intrinsics) + if (symbol->getType().getQualifier().hasSpirvDecorate()) + applySpirvDecorate(symbol->getType(), id, {}); return id; } diff --git a/thirdparty/glslang/SPIRV/GlslangToSpv.h b/thirdparty/glslang/SPIRV/GlslangToSpv.h index b9736d7c98..1b9ef3c514 100644 --- a/thirdparty/glslang/SPIRV/GlslangToSpv.h +++ b/thirdparty/glslang/SPIRV/GlslangToSpv.h @@ -35,19 +35,25 @@ #pragma once -#if defined(_MSC_VER) && _MSC_VER >= 1900 - #pragma warning(disable : 4464) // relative include path contains '..' -#endif - -#include "SpvTools.h" -#include "glslang/Include/intermediate.h" - #include <string> #include <vector> #include "Logger.h" namespace glslang { +class TIntermediate; + +struct SpvOptions { + bool generateDebugInfo {false}; + bool stripDebugInfo {false}; + bool disableOptimizer {true}; + bool optimizeSize {false}; + bool disassemble {false}; + bool validate {false}; + bool emitNonSemanticShaderDebugInfo {false}; + bool emitNonSemanticShaderDebugSource{ false }; + bool compileOnly{false}; +}; void GetSpirvVersion(std::string&); int GetSpirvGeneratorVersion(); diff --git a/thirdparty/glslang/SPIRV/SPVRemapper.h b/thirdparty/glslang/SPIRV/SPVRemapper.h index 42b01686ee..33efe331e4 100644 --- a/thirdparty/glslang/SPIRV/SPVRemapper.h +++ b/thirdparty/glslang/SPIRV/SPVRemapper.h @@ -77,9 +77,9 @@ public: #include <cassert> #include "spirv.hpp" -#include "spvIR.h" namespace spv { +const Id NoResult = 0; // class to hold SPIR-V binary data for remapping, DCE, and debug stripping class spirvbin_t : public spirvbin_base_t diff --git a/thirdparty/glslang/SPIRV/SpvBuilder.cpp b/thirdparty/glslang/SPIRV/SpvBuilder.cpp index d42f728816..9216817a2a 100644 --- a/thirdparty/glslang/SPIRV/SpvBuilder.cpp +++ b/thirdparty/glslang/SPIRV/SpvBuilder.cpp @@ -182,7 +182,7 @@ Id Builder::makeVoidType() return type->getResultId(); } -Id Builder::makeBoolType(bool const compilerGenerated) +Id Builder::makeBoolType() { Instruction* type; if (groupedTypes[OpTypeBool].size() == 0) { @@ -190,14 +190,15 @@ Id Builder::makeBoolType(bool const compilerGenerated) groupedTypes[OpTypeBool].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type)); module.mapInstruction(type); + + if (emitNonSemanticShaderDebugInfo) { + auto const debugResultId = makeBoolDebugType(32); + debugId[type->getResultId()] = debugResultId; + } + } else type = groupedTypes[OpTypeBool].back(); - if (emitNonSemanticShaderDebugInfo && !compilerGenerated) - { - auto const debugResultId = makeBoolDebugType(32); - debugId[type->getResultId()] = debugResultId; - } return type->getResultId(); } @@ -1182,13 +1183,26 @@ Id Builder::makeDebugExpression() return debugExpression; } -Id Builder::makeDebugDeclare(Id const debugLocalVariable, Id const localVariable) +Id Builder::makeDebugDeclare(Id const debugLocalVariable, Id const pointer) { Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst); inst->addIdOperand(nonSemanticShaderDebugInfo); inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugDeclare); inst->addIdOperand(debugLocalVariable); // debug local variable id - inst->addIdOperand(localVariable); // local variable id + inst->addIdOperand(pointer); // pointer to local variable id + inst->addIdOperand(makeDebugExpression()); // expression id + buildPoint->addInstruction(std::unique_ptr<Instruction>(inst)); + + return inst->getResultId(); +} + +Id Builder::makeDebugValue(Id const debugLocalVariable, Id const value) +{ + Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), OpExtInst); + inst->addIdOperand(nonSemanticShaderDebugInfo); + inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugValue); + inst->addIdOperand(debugLocalVariable); // debug local variable id + inst->addIdOperand(value); // value of local variable id inst->addIdOperand(makeDebugExpression()); // expression id buildPoint->addInstruction(std::unique_ptr<Instruction>(inst)); @@ -2061,11 +2075,6 @@ Function* Builder::makeEntryPoint(const char* entryPoint) { assert(! entryPointFunction); - Block* entry; - std::vector<Id> paramsTypes; - std::vector<char const*> paramNames; - std::vector<std::vector<Decoration>> decorations; - auto const returnType = makeVoidType(); restoreNonSemanticShaderDebugInfo = emitNonSemanticShaderDebugInfo; @@ -2073,7 +2082,8 @@ Function* Builder::makeEntryPoint(const char* entryPoint) emitNonSemanticShaderDebugInfo = false; } - entryPointFunction = makeFunctionEntry(NoPrecision, returnType, entryPoint, LinkageTypeMax, paramsTypes, paramNames, decorations, &entry); + Block* entry = nullptr; + entryPointFunction = makeFunctionEntry(NoPrecision, returnType, entryPoint, LinkageTypeMax, {}, {}, &entry); emitNonSemanticShaderDebugInfo = restoreNonSemanticShaderDebugInfo; @@ -2082,8 +2092,8 @@ Function* Builder::makeEntryPoint(const char* entryPoint) // Comments in header Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const char* name, LinkageType linkType, - const std::vector<Id>& paramTypes, const std::vector<char const*>& paramNames, - const std::vector<std::vector<Decoration>>& decorations, Block **entry) + const std::vector<Id>& paramTypes, + const std::vector<std::vector<Decoration>>& decorations, Block** entry) { // Make the function and initial instructions in it Id typeId = makeFunctionType(returnType, paramTypes); @@ -2101,12 +2111,8 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const } } - // Make the debug function instruction + // reset last debug scope if (emitNonSemanticShaderDebugInfo) { - Id nameId = getStringId(unmangleFunctionName(name)); - Id debugFuncId = makeDebugFunction(function, nameId, typeId); - debugId[funcId] = debugFuncId; - currentDebugScopeId.push(debugFuncId); lastDebugScopeId = NoResult; } @@ -2116,41 +2122,67 @@ Function* Builder::makeFunctionEntry(Decoration precision, Id returnType, const function->addBlock(*entry); setBuildPoint(*entry); + if (name) + addName(function->getId(), name); + + functions.push_back(std::unique_ptr<Function>(function)); + + return function; +} + +void Builder::setupDebugFunctionEntry(Function* function, const char* name, int line, const std::vector<Id>& paramTypes, + const std::vector<char const*>& paramNames) +{ + + if (!emitNonSemanticShaderDebugInfo) + return; + + currentLine = line; + Id nameId = getStringId(unmangleFunctionName(name)); + Id funcTypeId = function->getFuncTypeId(); + assert(debugId[funcTypeId] != 0); + Id funcId = function->getId(); + + assert(funcId != 0); + + // Make the debug function instruction + Id debugFuncId = makeDebugFunction(function, nameId, funcTypeId); + debugId[funcId] = debugFuncId; + currentDebugScopeId.push(debugFuncId); + // DebugScope and DebugLine for parameter DebugDeclares - if (emitNonSemanticShaderDebugInfo && (int)paramTypes.size() > 0) { + assert(paramTypes.size() == paramNames.size()); + if ((int)paramTypes.size() > 0) { addDebugScopeAndLine(currentFileId, currentLine, 0); - } - if (emitNonSemanticShaderDebugInfo) { - assert(paramTypes.size() == paramNames.size()); - for(size_t p = 0; p < paramTypes.size(); ++p) - { - auto getParamTypeId = [this](Id const& typeId) { - if (isPointerType(typeId) || isArrayType(typeId)) { - return getContainedTypeId(typeId); - } - else { - return typeId; - } - }; + Id firstParamId = function->getParamId(0); + + for (size_t p = 0; p < paramTypes.size(); ++p) { + bool passByRef = false; + Id paramTypeId = paramTypes[p]; + + // For pointer-typed parameters, they are actually passed by reference and we need unwrap the pointer to get the actual parameter type. + if (isPointerType(paramTypeId) || isArrayType(paramTypeId)) { + passByRef = true; + paramTypeId = getContainedTypeId(paramTypeId); + } + auto const& paramName = paramNames[p]; - auto const debugLocalVariableId = createDebugLocalVariable(debugId[getParamTypeId(paramTypes[p])], paramName, p+1); - debugId[firstParamId + p] = debugLocalVariableId; + auto const debugLocalVariableId = createDebugLocalVariable(debugId[paramTypeId], paramName, p + 1); + auto const paramId = static_cast<Id>(firstParamId + p); + debugId[paramId] = debugLocalVariableId; - makeDebugDeclare(debugLocalVariableId, firstParamId + p); + if (passByRef) { + makeDebugDeclare(debugLocalVariableId, paramId); + } else { + makeDebugValue(debugLocalVariableId, paramId); + } } } - if (name) - addName(function->getId(), name); - - functions.push_back(std::unique_ptr<Function>(function)); - // Clear debug scope stack if (emitNonSemanticShaderDebugInfo) currentDebugScopeId.pop(); - - return function; } Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id funcTypeId) @@ -2166,13 +2198,13 @@ Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunction); type->addIdOperand(nameId); type->addIdOperand(debugId[funcTypeId]); - type->addIdOperand(makeDebugSource(currentFileId)); // Will be fixed later when true filename available - type->addIdOperand(makeUintConstant(currentLine)); // Will be fixed later when true line available + type->addIdOperand(makeDebugSource(currentFileId)); // TODO: This points to file of definition instead of declaration + type->addIdOperand(makeUintConstant(currentLine)); // TODO: This points to line of definition instead of declaration type->addIdOperand(makeUintConstant(0)); // column type->addIdOperand(makeDebugCompilationUnit()); // scope type->addIdOperand(nameId); // linkage name type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); - type->addIdOperand(makeUintConstant(currentLine)); // TODO(greg-lunarg): correct scope line + type->addIdOperand(makeUintConstant(currentLine)); constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type)); module.mapInstruction(type); return funcId; @@ -2709,6 +2741,14 @@ Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& op module.mapInstruction(op); constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(op)); + // OpSpecConstantOp's using 8 or 16 bit types require the associated capability + if (containsType(typeId, OpTypeInt, 8)) + addCapability(CapabilityInt8); + if (containsType(typeId, OpTypeInt, 16)) + addCapability(CapabilityInt16); + if (containsType(typeId, OpTypeFloat, 16)) + addCapability(CapabilityFloat16); + return op->getResultId(); } diff --git a/thirdparty/glslang/SPIRV/SpvBuilder.h b/thirdparty/glslang/SPIRV/SpvBuilder.h index 2e1c07d49d..b1ca6ce1f7 100644 --- a/thirdparty/glslang/SPIRV/SpvBuilder.h +++ b/thirdparty/glslang/SPIRV/SpvBuilder.h @@ -185,7 +185,7 @@ public: // For creating new types (will return old type if the requested one was already made). Id makeVoidType(); - Id makeBoolType(bool const compilerGenerated = true); + Id makeBoolType(); Id makePointer(StorageClass, Id pointee); Id makeForwardPointer(StorageClass); Id makePointerFromForwardPointer(StorageClass, Id forwardPointerType, Id pointee); @@ -231,12 +231,15 @@ public: Id createDebugGlobalVariable(Id const type, char const*const name, Id const variable); Id createDebugLocalVariable(Id type, char const*const name, size_t const argNumber = 0); Id makeDebugExpression(); - Id makeDebugDeclare(Id const debugLocalVariable, Id const localVariable); + Id makeDebugDeclare(Id const debugLocalVariable, Id const pointer); Id makeDebugValue(Id const debugLocalVariable, Id const value); Id makeDebugFunctionType(Id returnType, const std::vector<Id>& paramTypes); Id makeDebugFunction(Function* function, Id nameId, Id funcTypeId); Id makeDebugLexicalBlock(uint32_t line); std::string unmangleFunctionName(std::string const& name) const; + void setupDebugFunctionEntry(Function* function, const char* name, int line, + const std::vector<Id>& paramTypes, + const std::vector<char const*>& paramNames); // accelerationStructureNV type Id makeAccelerationStructureType(); @@ -417,10 +420,9 @@ public: // Make a shader-style function, and create its entry block if entry is non-zero. // Return the function, pass back the entry. // The returned pointer is only valid for the lifetime of this builder. - Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name, - LinkageType linkType, const std::vector<Id>& paramTypes, - const std::vector<char const*>& paramNames, - const std::vector<std::vector<Decoration>>& precisions, Block **entry = nullptr); + Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name, LinkageType linkType, + const std::vector<Id>& paramTypes, + const std::vector<std::vector<Decoration>>& precisions, Block** entry = nullptr); // Create a return. An 'implicit' return is one not appearing in the source // code. In the case of an implicit return, no post-return block is inserted. diff --git a/thirdparty/glslang/SPIRV/SpvTools.h b/thirdparty/glslang/SPIRV/SpvTools.h index a4ce11b887..eabde46662 100644 --- a/thirdparty/glslang/SPIRV/SpvTools.h +++ b/thirdparty/glslang/SPIRV/SpvTools.h @@ -48,22 +48,11 @@ #endif #include "glslang/MachineIndependent/localintermediate.h" +#include "GlslangToSpv.h" #include "Logger.h" namespace glslang { -struct SpvOptions { - bool generateDebugInfo {false}; - bool stripDebugInfo {false}; - bool disableOptimizer {true}; - bool optimizeSize {false}; - bool disassemble {false}; - bool validate {false}; - bool emitNonSemanticShaderDebugInfo {false}; - bool emitNonSemanticShaderDebugSource{ false }; - bool compileOnly{false}; -}; - #if ENABLE_OPT // Translate glslang's view of target versioning to what SPIRV-Tools uses. diff --git a/thirdparty/glslang/SPIRV/doc.cpp b/thirdparty/glslang/SPIRV/doc.cpp index 53ce9e152b..1a05c67360 100755 --- a/thirdparty/glslang/SPIRV/doc.cpp +++ b/thirdparty/glslang/SPIRV/doc.cpp @@ -802,11 +802,11 @@ const int CooperativeMatrixOperandsCeiling = 6; const char* CooperativeMatrixOperandsString(int op) { switch (op) { - case CooperativeMatrixOperandsMatrixASignedComponentsShift: return "ASignedComponents"; - case CooperativeMatrixOperandsMatrixBSignedComponentsShift: return "BSignedComponents"; - case CooperativeMatrixOperandsMatrixCSignedComponentsShift: return "CSignedComponents"; - case CooperativeMatrixOperandsMatrixResultSignedComponentsShift: return "ResultSignedComponents"; - case CooperativeMatrixOperandsSaturatingAccumulationShift: return "SaturatingAccumulation"; + case CooperativeMatrixOperandsMatrixASignedComponentsKHRShift: return "ASignedComponentsKHR"; + case CooperativeMatrixOperandsMatrixBSignedComponentsKHRShift: return "BSignedComponentsKHR"; + case CooperativeMatrixOperandsMatrixCSignedComponentsKHRShift: return "CSignedComponentsKHR"; + case CooperativeMatrixOperandsMatrixResultSignedComponentsKHRShift: return "ResultSignedComponentsKHR"; + case CooperativeMatrixOperandsSaturatingAccumulationKHRShift: return "SaturatingAccumulationKHR"; default: return "Bad"; } diff --git a/thirdparty/glslang/SPIRV/doc.h b/thirdparty/glslang/SPIRV/doc.h index b60ad34018..521529913f 100644 --- a/thirdparty/glslang/SPIRV/doc.h +++ b/thirdparty/glslang/SPIRV/doc.h @@ -240,8 +240,8 @@ public: OperandParameters operands; protected: - int typePresent : 1; - int resultPresent : 1; + bool typePresent : 1; + bool resultPresent : 1; }; // The set of objects that hold all the instruction/operand diff --git a/thirdparty/glslang/SPIRV/spirv.hpp b/thirdparty/glslang/SPIRV/spirv.hpp index 02c1eded73..5999aba931 100644 --- a/thirdparty/glslang/SPIRV/spirv.hpp +++ b/thirdparty/glslang/SPIRV/spirv.hpp @@ -1274,26 +1274,26 @@ enum PackedVectorFormat { }; enum CooperativeMatrixOperandsShift { - CooperativeMatrixOperandsMatrixASignedComponentsShift = 0, - CooperativeMatrixOperandsMatrixBSignedComponentsShift = 1, - CooperativeMatrixOperandsMatrixCSignedComponentsShift = 2, - CooperativeMatrixOperandsMatrixResultSignedComponentsShift = 3, - CooperativeMatrixOperandsSaturatingAccumulationShift = 4, + CooperativeMatrixOperandsMatrixASignedComponentsKHRShift = 0, + CooperativeMatrixOperandsMatrixBSignedComponentsKHRShift = 1, + CooperativeMatrixOperandsMatrixCSignedComponentsKHRShift = 2, + CooperativeMatrixOperandsMatrixResultSignedComponentsKHRShift = 3, + CooperativeMatrixOperandsSaturatingAccumulationKHRShift = 4, CooperativeMatrixOperandsMax = 0x7fffffff, }; enum CooperativeMatrixOperandsMask { CooperativeMatrixOperandsMaskNone = 0, - CooperativeMatrixOperandsMatrixASignedComponentsMask = 0x00000001, - CooperativeMatrixOperandsMatrixBSignedComponentsMask = 0x00000002, - CooperativeMatrixOperandsMatrixCSignedComponentsMask = 0x00000004, - CooperativeMatrixOperandsMatrixResultSignedComponentsMask = 0x00000008, - CooperativeMatrixOperandsSaturatingAccumulationMask = 0x00000010, + CooperativeMatrixOperandsMatrixASignedComponentsKHRMask = 0x00000001, + CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask = 0x00000002, + CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask = 0x00000004, + CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask = 0x00000008, + CooperativeMatrixOperandsSaturatingAccumulationKHRMask = 0x00000010, }; enum CooperativeMatrixLayout { - CooperativeMatrixLayoutCooperativeMatrixRowMajorKHR = 0, - CooperativeMatrixLayoutCooperativeMatrixColumnMajorKHR = 1, + CooperativeMatrixLayoutRowMajorKHR = 0, + CooperativeMatrixLayoutColumnMajorKHR = 1, CooperativeMatrixLayoutMax = 0x7fffffff, }; diff --git a/thirdparty/glslang/SPIRV/spvIR.h b/thirdparty/glslang/SPIRV/spvIR.h index 1f8e28ff46..8849f42e75 100644 --- a/thirdparty/glslang/SPIRV/spvIR.h +++ b/thirdparty/glslang/SPIRV/spvIR.h @@ -352,6 +352,7 @@ public: void addLocalVariable(std::unique_ptr<Instruction> inst); Id getReturnType() const { return functionInstruction.getTypeId(); } Id getFuncId() const { return functionInstruction.getResultId(); } + Id getFuncTypeId() const { return functionInstruction.getIdOperand(1); } void setReturnPrecision(Decoration precision) { if (precision == DecorationRelaxedPrecision) |