diff --git a/BUILD.gn b/BUILD.gn index d760e25612..c8ed2fa48e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -130,7 +130,7 @@ template("glslang_sources_common") { "SPIRV/Logger.cpp", "SPIRV/Logger.h", "SPIRV/NonSemanticDebugPrintf.h", - "SPIRV/NonSemanticShaderDebugInfo100.h", + "SPIRV/NonSemanticShaderDebugInfo.h", "SPIRV/SpvBuilder.cpp", "SPIRV/SpvBuilder.h", "SPIRV/SpvPostProcess.cpp", diff --git a/README.md b/README.md index ef447b8e41..9cd3f060d7 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,24 @@ bison --defines=MachineIndependent/glslang_tab.cpp.h The above command is also available in the bash script in `updateGrammar`, when executed from the glslang subdirectory of the glslang repository. +### If you need to update the NonSemantic instruction headers + +`SPIRV/NonSemanticShaderDebugInfo.h` and `SPIRV/NonSemanticDebugPrintf.h` are +local copies of the canonical headers from SPIRV-Headers. They are kept here +because the SPIRV-Headers include path is not unconditionally available in all +glslang build configurations (it is only present when `ENABLE_OPT` is on). + +When SPIRV-Headers publishes a new version of either header, copy the updated +file from + +``` +External/spirv-tools/external/spirv-headers/include/spirv/unified1/ +``` + +over the corresponding file in `SPIRV/`. After copying, verify that the build +still compiles and update the golden test output if instruction names or opcode +numbers changed. + ### Building to WASM for the Web and Node ### Building a standalone JS/WASM library for the Web and Node diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt index 9bac0005aa..1c5079520e 100644 --- a/SPIRV/CMakeLists.txt +++ b/SPIRV/CMakeLists.txt @@ -63,7 +63,7 @@ set(SPIRV_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.ARM.h ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.ext.QCOM.h ${CMAKE_CURRENT_SOURCE_DIR}/NonSemanticDebugPrintf.h - ${CMAKE_CURRENT_SOURCE_DIR}/NonSemanticShaderDebugInfo100.h + ${CMAKE_CURRENT_SOURCE_DIR}/NonSemanticShaderDebugInfo.h PARENT_SCOPE) set(PUBLIC_HEADERS diff --git a/SPIRV/NonSemanticShaderDebugInfo.h b/SPIRV/NonSemanticShaderDebugInfo.h new file mode 100644 index 0000000000..7e4c618cdd --- /dev/null +++ b/SPIRV/NonSemanticShaderDebugInfo.h @@ -0,0 +1,173 @@ +// Copyright (c) 2018 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and/or associated documentation files (the "Materials"), +// to deal in the Materials without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Materials, and to permit persons to whom the +// Materials are furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Materials. +// +// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +// IN THE MATERIALS. + +#ifndef SPIRV_UNIFIED1_NonSemanticShaderDebugInfo_H_ +#define SPIRV_UNIFIED1_NonSemanticShaderDebugInfo_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + NonSemanticShaderDebugInfoVersion = 101, + NonSemanticShaderDebugInfoVersion_BitWidthPadding = 0x7fffffff +}; +enum { + NonSemanticShaderDebugInfoRevision = 6, + NonSemanticShaderDebugInfoRevision_BitWidthPadding = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoInstructions { + NonSemanticShaderDebugInfoDebugInfoNone = 0, + NonSemanticShaderDebugInfoDebugCompilationUnit = 1, + NonSemanticShaderDebugInfoDebugTypeBasic = 2, + NonSemanticShaderDebugInfoDebugTypePointer = 3, + NonSemanticShaderDebugInfoDebugTypeQualifier = 4, + NonSemanticShaderDebugInfoDebugTypeArray = 5, + NonSemanticShaderDebugInfoDebugTypeVector = 6, + NonSemanticShaderDebugInfoDebugTypedef = 7, + NonSemanticShaderDebugInfoDebugTypeFunction = 8, + NonSemanticShaderDebugInfoDebugTypeEnum = 9, + NonSemanticShaderDebugInfoDebugTypeComposite = 10, + NonSemanticShaderDebugInfoDebugTypeMember = 11, + NonSemanticShaderDebugInfoDebugTypeInheritance = 12, + NonSemanticShaderDebugInfoDebugTypePtrToMember = 13, + NonSemanticShaderDebugInfoDebugTypeTemplate = 14, + NonSemanticShaderDebugInfoDebugTypeTemplateParameter = 15, + NonSemanticShaderDebugInfoDebugTypeTemplateTemplateParameter = 16, + NonSemanticShaderDebugInfoDebugTypeTemplateParameterPack = 17, + NonSemanticShaderDebugInfoDebugGlobalVariable = 18, + NonSemanticShaderDebugInfoDebugFunctionDeclaration = 19, + NonSemanticShaderDebugInfoDebugFunction = 20, + NonSemanticShaderDebugInfoDebugLexicalBlock = 21, + NonSemanticShaderDebugInfoDebugLexicalBlockDiscriminator = 22, + NonSemanticShaderDebugInfoDebugScope = 23, + NonSemanticShaderDebugInfoDebugNoScope = 24, + NonSemanticShaderDebugInfoDebugInlinedAt = 25, + NonSemanticShaderDebugInfoDebugLocalVariable = 26, + NonSemanticShaderDebugInfoDebugInlinedVariable = 27, + NonSemanticShaderDebugInfoDebugDeclare = 28, + NonSemanticShaderDebugInfoDebugValue = 29, + NonSemanticShaderDebugInfoDebugOperation = 30, + NonSemanticShaderDebugInfoDebugExpression = 31, + NonSemanticShaderDebugInfoDebugMacroDef = 32, + NonSemanticShaderDebugInfoDebugMacroUndef = 33, + NonSemanticShaderDebugInfoDebugImportedEntity = 34, + NonSemanticShaderDebugInfoDebugSource = 35, + NonSemanticShaderDebugInfoDebugFunctionDefinition = 101, + NonSemanticShaderDebugInfoDebugSourceContinued = 102, + NonSemanticShaderDebugInfoDebugLine = 103, + NonSemanticShaderDebugInfoDebugNoLine = 104, + NonSemanticShaderDebugInfoDebugBuildIdentifier = 105, + NonSemanticShaderDebugInfoDebugStoragePath = 106, + NonSemanticShaderDebugInfoDebugEntryPoint = 107, + NonSemanticShaderDebugInfoDebugTypeMatrix = 108, + NonSemanticShaderDebugInfoDebugTypeVectorIdEXT = 109, + NonSemanticShaderDebugInfoDebugTypeCooperativeMatrixKHR = 110, + NonSemanticShaderDebugInfoInstructionsMax = 0x7fffffff +}; + + +enum NonSemanticShaderDebugInfoDebugInfoFlags { + NonSemanticShaderDebugInfoNone = 0x0000, + NonSemanticShaderDebugInfoFlagIsProtected = 0x01, + NonSemanticShaderDebugInfoFlagIsPrivate = 0x02, + NonSemanticShaderDebugInfoFlagIsPublic = 0x03, + NonSemanticShaderDebugInfoFlagIsLocal = 0x04, + NonSemanticShaderDebugInfoFlagIsDefinition = 0x08, + NonSemanticShaderDebugInfoFlagFwdDecl = 0x10, + NonSemanticShaderDebugInfoFlagArtificial = 0x20, + NonSemanticShaderDebugInfoFlagExplicit = 0x40, + NonSemanticShaderDebugInfoFlagPrototyped = 0x80, + NonSemanticShaderDebugInfoFlagObjectPointer = 0x100, + NonSemanticShaderDebugInfoFlagStaticMember = 0x200, + NonSemanticShaderDebugInfoFlagIndirectVariable = 0x400, + NonSemanticShaderDebugInfoFlagLValueReference = 0x800, + NonSemanticShaderDebugInfoFlagRValueReference = 0x1000, + NonSemanticShaderDebugInfoFlagIsOptimized = 0x2000, + NonSemanticShaderDebugInfoFlagIsEnumClass = 0x4000, + NonSemanticShaderDebugInfoFlagTypePassByValue = 0x8000, + NonSemanticShaderDebugInfoFlagTypePassByReference = 0x10000, + NonSemanticShaderDebugInfoFlagUnknownPhysicalLayout = 0x20000, + NonSemanticShaderDebugInfoDebugInfoFlagsMax = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoBuildIdentifierFlags { + NonSemanticShaderDebugInfoIdentifierPossibleDuplicates = 0x01, + NonSemanticShaderDebugInfoBuildIdentifierFlagsMax = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoDebugBaseTypeAttributeEncoding { + NonSemanticShaderDebugInfoUnspecified = 0, + NonSemanticShaderDebugInfoAddress = 1, + NonSemanticShaderDebugInfoBoolean = 2, + NonSemanticShaderDebugInfoFloat = 3, + NonSemanticShaderDebugInfoSigned = 4, + NonSemanticShaderDebugInfoSignedChar = 5, + NonSemanticShaderDebugInfoUnsigned = 6, + NonSemanticShaderDebugInfoUnsignedChar = 7, + NonSemanticShaderDebugInfoDebugBaseTypeAttributeEncodingMax = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoDebugCompositeType { + NonSemanticShaderDebugInfoClass = 0, + NonSemanticShaderDebugInfoStructure = 1, + NonSemanticShaderDebugInfoUnion = 2, + NonSemanticShaderDebugInfoDebugCompositeTypeMax = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoDebugTypeQualifier { + NonSemanticShaderDebugInfoConstType = 0, + NonSemanticShaderDebugInfoVolatileType = 1, + NonSemanticShaderDebugInfoRestrictType = 2, + NonSemanticShaderDebugInfoAtomicType = 3, + NonSemanticShaderDebugInfoDebugTypeQualifierMax = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoDebugOperation { + NonSemanticShaderDebugInfoDeref = 0, + NonSemanticShaderDebugInfoPlus = 1, + NonSemanticShaderDebugInfoMinus = 2, + NonSemanticShaderDebugInfoPlusUconst = 3, + NonSemanticShaderDebugInfoBitPiece = 4, + NonSemanticShaderDebugInfoSwap = 5, + NonSemanticShaderDebugInfoXderef = 6, + NonSemanticShaderDebugInfoStackValue = 7, + NonSemanticShaderDebugInfoConstu = 8, + NonSemanticShaderDebugInfoFragment = 9, + NonSemanticShaderDebugInfoDebugOperationMax = 0x7fffffff +}; + +enum NonSemanticShaderDebugInfoDebugImportedEntity { + NonSemanticShaderDebugInfoImportedModule = 0, + NonSemanticShaderDebugInfoImportedDeclaration = 1, + NonSemanticShaderDebugInfoDebugImportedEntityMax = 0x7fffffff +}; + + +#ifdef __cplusplus +} +#endif + +#endif // SPIRV_UNIFIED1_NonSemanticShaderDebugInfo_H_ diff --git a/SPIRV/NonSemanticShaderDebugInfo100.h b/SPIRV/NonSemanticShaderDebugInfo100.h deleted file mode 100644 index f74abcb646..0000000000 --- a/SPIRV/NonSemanticShaderDebugInfo100.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2018 The Khronos Group Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and/or associated documentation files (the "Materials"), -// to deal in the Materials without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Materials, and to permit persons to whom the -// Materials are furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Materials. -// -// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS -// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ -// -// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS -// IN THE MATERIALS. - -#ifndef SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_ -#define SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - NonSemanticShaderDebugInfo100Version = 100, - NonSemanticShaderDebugInfo100Version_BitWidthPadding = 0x7fffffff -}; -enum { - NonSemanticShaderDebugInfo100Revision = 6, - NonSemanticShaderDebugInfo100Revision_BitWidthPadding = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100Instructions { - NonSemanticShaderDebugInfo100DebugInfoNone = 0, - NonSemanticShaderDebugInfo100DebugCompilationUnit = 1, - NonSemanticShaderDebugInfo100DebugTypeBasic = 2, - NonSemanticShaderDebugInfo100DebugTypePointer = 3, - NonSemanticShaderDebugInfo100DebugTypeQualifier = 4, - NonSemanticShaderDebugInfo100DebugTypeArray = 5, - NonSemanticShaderDebugInfo100DebugTypeVector = 6, - NonSemanticShaderDebugInfo100DebugTypedef = 7, - NonSemanticShaderDebugInfo100DebugTypeFunction = 8, - NonSemanticShaderDebugInfo100DebugTypeEnum = 9, - NonSemanticShaderDebugInfo100DebugTypeComposite = 10, - NonSemanticShaderDebugInfo100DebugTypeMember = 11, - NonSemanticShaderDebugInfo100DebugTypeInheritance = 12, - NonSemanticShaderDebugInfo100DebugTypePtrToMember = 13, - NonSemanticShaderDebugInfo100DebugTypeTemplate = 14, - NonSemanticShaderDebugInfo100DebugTypeTemplateParameter = 15, - NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter = 16, - NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack = 17, - NonSemanticShaderDebugInfo100DebugGlobalVariable = 18, - NonSemanticShaderDebugInfo100DebugFunctionDeclaration = 19, - NonSemanticShaderDebugInfo100DebugFunction = 20, - NonSemanticShaderDebugInfo100DebugLexicalBlock = 21, - NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator = 22, - NonSemanticShaderDebugInfo100DebugScope = 23, - NonSemanticShaderDebugInfo100DebugNoScope = 24, - NonSemanticShaderDebugInfo100DebugInlinedAt = 25, - NonSemanticShaderDebugInfo100DebugLocalVariable = 26, - NonSemanticShaderDebugInfo100DebugInlinedVariable = 27, - NonSemanticShaderDebugInfo100DebugDeclare = 28, - NonSemanticShaderDebugInfo100DebugValue = 29, - NonSemanticShaderDebugInfo100DebugOperation = 30, - NonSemanticShaderDebugInfo100DebugExpression = 31, - NonSemanticShaderDebugInfo100DebugMacroDef = 32, - NonSemanticShaderDebugInfo100DebugMacroUndef = 33, - NonSemanticShaderDebugInfo100DebugImportedEntity = 34, - NonSemanticShaderDebugInfo100DebugSource = 35, - NonSemanticShaderDebugInfo100DebugFunctionDefinition = 101, - NonSemanticShaderDebugInfo100DebugSourceContinued = 102, - NonSemanticShaderDebugInfo100DebugLine = 103, - NonSemanticShaderDebugInfo100DebugNoLine = 104, - NonSemanticShaderDebugInfo100DebugBuildIdentifier = 105, - NonSemanticShaderDebugInfo100DebugStoragePath = 106, - NonSemanticShaderDebugInfo100DebugEntryPoint = 107, - NonSemanticShaderDebugInfo100DebugTypeMatrix = 108, - NonSemanticShaderDebugInfo100InstructionsMax = 0x7fffffff -}; - - -enum NonSemanticShaderDebugInfo100DebugInfoFlags { - NonSemanticShaderDebugInfo100None = 0x0000, - NonSemanticShaderDebugInfo100FlagIsProtected = 0x01, - NonSemanticShaderDebugInfo100FlagIsPrivate = 0x02, - NonSemanticShaderDebugInfo100FlagIsPublic = 0x03, - NonSemanticShaderDebugInfo100FlagIsLocal = 0x04, - NonSemanticShaderDebugInfo100FlagIsDefinition = 0x08, - NonSemanticShaderDebugInfo100FlagFwdDecl = 0x10, - NonSemanticShaderDebugInfo100FlagArtificial = 0x20, - NonSemanticShaderDebugInfo100FlagExplicit = 0x40, - NonSemanticShaderDebugInfo100FlagPrototyped = 0x80, - NonSemanticShaderDebugInfo100FlagObjectPointer = 0x100, - NonSemanticShaderDebugInfo100FlagStaticMember = 0x200, - NonSemanticShaderDebugInfo100FlagIndirectVariable = 0x400, - NonSemanticShaderDebugInfo100FlagLValueReference = 0x800, - NonSemanticShaderDebugInfo100FlagRValueReference = 0x1000, - NonSemanticShaderDebugInfo100FlagIsOptimized = 0x2000, - NonSemanticShaderDebugInfo100FlagIsEnumClass = 0x4000, - NonSemanticShaderDebugInfo100FlagTypePassByValue = 0x8000, - NonSemanticShaderDebugInfo100FlagTypePassByReference = 0x10000, - NonSemanticShaderDebugInfo100FlagUnknownPhysicalLayout = 0x20000, - NonSemanticShaderDebugInfo100DebugInfoFlagsMax = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100BuildIdentifierFlags { - NonSemanticShaderDebugInfo100IdentifierPossibleDuplicates = 0x01, - NonSemanticShaderDebugInfo100BuildIdentifierFlagsMax = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100DebugBaseTypeAttributeEncoding { - NonSemanticShaderDebugInfo100Unspecified = 0, - NonSemanticShaderDebugInfo100Address = 1, - NonSemanticShaderDebugInfo100Boolean = 2, - NonSemanticShaderDebugInfo100Float = 3, - NonSemanticShaderDebugInfo100Signed = 4, - NonSemanticShaderDebugInfo100SignedChar = 5, - NonSemanticShaderDebugInfo100Unsigned = 6, - NonSemanticShaderDebugInfo100UnsignedChar = 7, - NonSemanticShaderDebugInfo100DebugBaseTypeAttributeEncodingMax = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100DebugCompositeType { - NonSemanticShaderDebugInfo100Class = 0, - NonSemanticShaderDebugInfo100Structure = 1, - NonSemanticShaderDebugInfo100Union = 2, - NonSemanticShaderDebugInfo100DebugCompositeTypeMax = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100DebugTypeQualifier { - NonSemanticShaderDebugInfo100ConstType = 0, - NonSemanticShaderDebugInfo100VolatileType = 1, - NonSemanticShaderDebugInfo100RestrictType = 2, - NonSemanticShaderDebugInfo100AtomicType = 3, - NonSemanticShaderDebugInfo100DebugTypeQualifierMax = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100DebugOperation { - NonSemanticShaderDebugInfo100Deref = 0, - NonSemanticShaderDebugInfo100Plus = 1, - NonSemanticShaderDebugInfo100Minus = 2, - NonSemanticShaderDebugInfo100PlusUconst = 3, - NonSemanticShaderDebugInfo100BitPiece = 4, - NonSemanticShaderDebugInfo100Swap = 5, - NonSemanticShaderDebugInfo100Xderef = 6, - NonSemanticShaderDebugInfo100StackValue = 7, - NonSemanticShaderDebugInfo100Constu = 8, - NonSemanticShaderDebugInfo100Fragment = 9, - NonSemanticShaderDebugInfo100DebugOperationMax = 0x7fffffff -}; - -enum NonSemanticShaderDebugInfo100DebugImportedEntity { - NonSemanticShaderDebugInfo100ImportedModule = 0, - NonSemanticShaderDebugInfo100ImportedDeclaration = 1, - NonSemanticShaderDebugInfo100DebugImportedEntityMax = 0x7fffffff -}; - - -#ifdef __cplusplus -} -#endif - -#endif // SPIRV_UNIFIED1_NonSemanticShaderDebugInfo100_H_ diff --git a/SPIRV/SpvBuilder.cpp b/SPIRV/SpvBuilder.cpp index b65ec30641..8dde2790c5 100644 --- a/SPIRV/SpvBuilder.cpp +++ b/SPIRV/SpvBuilder.cpp @@ -350,14 +350,10 @@ Id Builder::makeBFloat16Type() addExtension(spv::E_SPV_KHR_bfloat16); addCapability(Capability::BFloat16TypeKHR); -#if 0 - // XXX not supported - if (emitNonSemanticShaderDebugInfo) - { - auto const debugResultId = makeFloatDebugType(width); + if (emitNonSemanticShaderDebugInfo) { + auto const debugResultId = makeFloatDebugType(16, makeUintConstant((unsigned)FPEncoding::BFloat16KHR)); debugTypeIdLookup[type->getResultId()] = debugResultId; } -#endif return type->getResultId(); } @@ -387,14 +383,10 @@ Id Builder::makeFloatE5M2Type() addExtension(spv::E_SPV_EXT_float8); addCapability(Capability::Float8EXT); -#if 0 - // XXX not supported - if (emitNonSemanticShaderDebugInfo) - { - auto const debugResultId = makeFloatDebugType(width); + if (emitNonSemanticShaderDebugInfo) { + auto const debugResultId = makeFloatDebugType(8, makeUintConstant((unsigned)FPEncoding::Float8E5M2EXT)); debugTypeIdLookup[type->getResultId()] = debugResultId; } -#endif return type->getResultId(); } @@ -424,14 +416,10 @@ Id Builder::makeFloatE4M3Type() addExtension(spv::E_SPV_EXT_float8); addCapability(Capability::Float8EXT); -#if 0 - // XXX not supported - if (emitNonSemanticShaderDebugInfo) - { - auto const debugResultId = makeFloatDebugType(width); + if (emitNonSemanticShaderDebugInfo) { + auto const debugResultId = makeFloatDebugType(8, makeUintConstant((unsigned)FPEncoding::Float8E4M3EXT)); debugTypeIdLookup[type->getResultId()] = debugResultId; } -#endif return type->getResultId(); } @@ -459,7 +447,7 @@ Id Builder::makeStructType(const std::vector& members, const std::vectorgetResultId()] = debugResultId; } @@ -578,40 +566,8 @@ Id Builder::makeCooperativeMatrixTypeKHR(Id component, Id scope, Id rows, Id col constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); - if (emitNonSemanticShaderDebugInfo) - { - // Find a name for one of the parameters. It can either come from debuginfo for another - // type, or an OpName from a constant. - auto const findName = [&](Id id) { - Id id2 = getDebugType(id); - for (auto &t : groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic]) { - if (t->getResultId() == id2) { - for (auto &s : strings) { - if (s->getResultId() == t->getIdOperand(2)) { - return s->getNameString(); - } - } - } - } - for (auto &t : names) { - if (t->getIdOperand(0) == id) { - return t->getNameString(); - } - } - return "unknown"; - }; - std::string debugName = "coopmat<"; - debugName += std::string(findName(component)) + ", "; - if (isConstantScalar(scope)) { - debugName += std::string("gl_Scope") + std::string(spv::ScopeToString((spv::Scope)getConstantScalar(scope))) + ", "; - } else { - debugName += std::string(findName(scope)) + ", "; - } - debugName += std::string(findName(rows)) + ", "; - debugName += std::string(findName(cols)) + ">"; - // There's no nonsemantic debug info instruction for cooperative matrix types, - // use opaque composite instead. - auto const debugResultId = makeOpaqueDebugType(debugName.c_str()); + if (emitNonSemanticShaderDebugInfo) { + auto const debugResultId = makeCooperativeMatrixDebugTypeKHR(component, scope, rows, cols, use); debugTypeIdLookup[type->getResultId()] = debugResultId; } @@ -673,6 +629,11 @@ Id Builder::makeCooperativeVectorTypeNV(Id componentType, Id components) constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); + if (emitNonSemanticShaderDebugInfo) { + auto const debugResultId = makeVectorIdDebugType(componentType, components); + debugTypeIdLookup[type->getResultId()] = debugResultId; + } + return type->getResultId(); } @@ -845,8 +806,8 @@ Id Builder::makeDebugFunctionType(Id returnType, const std::vector& paramTyp auto type = new Instruction(typeId, makeVoidType(), Op::OpExtInst); type->reserveOperands(paramTypes.size() + 4); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeFunction); - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeFunction); + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsPublic)); type->addIdOperand(getDebugType(returnType)); for (auto const paramType : paramTypes) { if (isPointerType(paramType) || isArrayType(paramType)) { @@ -985,7 +946,7 @@ Id Builder::makeDebugInfoNone() Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); inst->reserveOperands(2); inst->addIdOperand(nonSemanticShaderDebugInfo); - inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugInfoNone); + inst->addImmediateOperand(NonSemanticShaderDebugInfoDebugInfoNone); constantsTypesGlobals.push_back(std::unique_ptr(inst)); module.mapInstruction(inst); @@ -999,25 +960,25 @@ Id Builder::makeBoolDebugType(int const size) { // try to find it Instruction* type; - for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) { - type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t]; + for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic].size(); ++t) { + type = groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic][t]; if (type->getIdOperand(0) == getStringId("bool") && type->getIdOperand(1) == static_cast(size) && - type->getIdOperand(2) == NonSemanticShaderDebugInfo100Boolean) + type->getIdOperand(2) == NonSemanticShaderDebugInfoBoolean) return type->getResultId(); } type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(6); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeBasic); type->addIdOperand(getStringId("bool")); // name id type->addIdOperand(makeUintConstant(size)); // size id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Boolean)); // encoding id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoBoolean)); // encoding id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoNone)); // flags id - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1036,11 +997,11 @@ Id Builder::makeIntegerDebugType(int const width, bool const hasSign) auto nameId = getStringId(typeName); // try to find it Instruction* type; - for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) { - type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t]; + for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic].size(); ++t) { + type = groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic][t]; if (type->getIdOperand(0) == nameId && type->getIdOperand(1) == static_cast(width) && - type->getIdOperand(2) == (hasSign ? NonSemanticShaderDebugInfo100Signed : NonSemanticShaderDebugInfo100Unsigned)) + type->getIdOperand(2) == (hasSign ? NonSemanticShaderDebugInfoSigned : NonSemanticShaderDebugInfoUnsigned)) return type->getResultId(); } @@ -1048,63 +1009,86 @@ Id Builder::makeIntegerDebugType(int const width, bool const hasSign) type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(6); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeBasic); type->addIdOperand(nameId); // name id type->addIdOperand(makeUintConstant(width)); // size id if(hasSign == true) { - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Signed)); // encoding id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoSigned)); // encoding id } else { - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Unsigned)); // encoding id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoUnsigned)); // encoding id } - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoNone)); // flags id - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); return type->getResultId(); } -Id Builder::makeFloatDebugType(int const width) +Id Builder::makeFloatDebugType(int const width, Id const fpEncoding) { + if (fpEncoding != NoType) + requireNonSemanticShaderDebugInfoVersion(101); + // Determine the debug type name. FP-encoded variants have distinct names. const char* typeName = nullptr; - switch (width) { - case 16: typeName = "float16_t"; break; - case 64: typeName = "double"; break; - default: typeName = "float"; break; + if (fpEncoding != NoType) { + if (fpEncoding == makeUintConstant((unsigned)FPEncoding::BFloat16KHR)) + typeName = "bfloat16_t"; + else if (fpEncoding == makeUintConstant((unsigned)FPEncoding::Float8E4M3EXT)) + typeName = "floate4m3_t"; + else if (fpEncoding == makeUintConstant((unsigned)FPEncoding::Float8E5M2EXT)) + typeName = "floate5m2_t"; + else + typeName = "float"; + } else { + switch (width) { + case 16: typeName = "float16_t"; break; + case 64: typeName = "double"; break; + default: typeName = "float"; break; + } } auto nameId = getStringId(typeName); // try to find it Instruction* type; - for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].size(); ++t) { - type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic][t]; + for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic].size(); ++t) { + type = groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic][t]; if (type->getIdOperand(0) == nameId && type->getIdOperand(1) == static_cast(width) && - type->getIdOperand(2) == NonSemanticShaderDebugInfo100Float) - return type->getResultId(); + type->getIdOperand(2) == NonSemanticShaderDebugInfoFloat) { + if (fpEncoding == NoType) { + if (type->getNumOperands() == 6) + return type->getResultId(); + } else { + if (type->getNumOperands() == 7 && type->getIdOperand(6) == fpEncoding) + return type->getResultId(); + } + } } // not found, make it type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); - type->reserveOperands(6); + type->reserveOperands(fpEncoding == NoType ? 6 : 7); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeBasic); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeBasic); type->addIdOperand(nameId); // name id type->addIdOperand(makeUintConstant(width)); // size id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Float)); // encoding id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100None)); // flags id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFloat)); // encoding id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoNone)); // flags id + if (fpEncoding != NoType) + type->addIdOperand(fpEncoding); // optional FPEncoding id (NSDI.101) - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeBasic].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); return type->getResultId(); } -Id Builder::makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfo100Instructions const sequenceType) +Id Builder::makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfoInstructions const sequenceType) { - assert(sequenceType == NonSemanticShaderDebugInfo100DebugTypeArray || - sequenceType == NonSemanticShaderDebugInfo100DebugTypeVector); + assert(sequenceType == NonSemanticShaderDebugInfoDebugTypeArray || + sequenceType == NonSemanticShaderDebugInfoDebugTypeVector); // try to find it Instruction* type; @@ -1132,20 +1116,20 @@ Id Builder::makeSequentialDebugType(Id const baseType, Id const componentCount, Id Builder::makeArrayDebugType(Id const baseType, Id const componentCount) { - return makeSequentialDebugType(baseType, componentCount, NonSemanticShaderDebugInfo100DebugTypeArray); + return makeSequentialDebugType(baseType, componentCount, NonSemanticShaderDebugInfoDebugTypeArray); } Id Builder::makeVectorDebugType(Id const baseType, int const componentCount) { - return makeSequentialDebugType(baseType, makeUintConstant(componentCount), NonSemanticShaderDebugInfo100DebugTypeVector); + return makeSequentialDebugType(baseType, makeUintConstant(componentCount), NonSemanticShaderDebugInfoDebugTypeVector); } Id Builder::makeMatrixDebugType(Id const vectorType, int const vectorCount, bool columnMajor) { // try to find it Instruction* type; - for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMatrix].size(); ++t) { - type = groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMatrix][t]; + for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeMatrix].size(); ++t) { + type = groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeMatrix][t]; if (type->getIdOperand(0) == vectorType && type->getIdOperand(1) == makeUintConstant(vectorCount)) return type->getResultId(); @@ -1155,12 +1139,78 @@ Id Builder::makeMatrixDebugType(Id const vectorType, int const vectorCount, bool type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(5); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeMatrix); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeMatrix); type->addIdOperand(getDebugType(vectorType)); // vector type id type->addIdOperand(makeUintConstant(vectorCount)); // component count id type->addIdOperand(makeBoolConstant(columnMajor)); // column-major id - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMatrix].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeMatrix].push_back(type); + constantsTypesGlobals.push_back(std::unique_ptr(type)); + module.mapInstruction(type); + + return type->getResultId(); +} + +// DebugTypeVectorIdEXT (NSDI.101 opcode 109): describes OpTypeVectorIdEXT and +// OpTypeCooperativeVectorNV types whose component count is a SPIR-V Id (not a +// literal), including specialization-constant component counts. +Id Builder::makeVectorIdDebugType(Id const componentType, Id const componentCount) +{ + requireNonSemanticShaderDebugInfoVersion(101); + // try to find it + Instruction* type; + for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeVectorIdEXT].size(); ++t) { + type = groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeVectorIdEXT][t]; + if (type->getIdOperand(2) == getDebugType(componentType) && + type->getIdOperand(3) == componentCount) + return type->getResultId(); + } + + // not found, make it + type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); + type->reserveOperands(4); + type->addIdOperand(nonSemanticShaderDebugInfo); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeVectorIdEXT); + type->addIdOperand(getDebugType(componentType)); // component debug type + type->addIdOperand(componentCount); // component count (constant instruction Id) + + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeVectorIdEXT].push_back(type); + constantsTypesGlobals.push_back(std::unique_ptr(type)); + module.mapInstruction(type); + + return type->getResultId(); +} + +// DebugTypeCooperativeMatrixKHR (NSDI.101 opcode 110): describes +// OpTypeCooperativeMatrixKHR types. +Id Builder::makeCooperativeMatrixDebugTypeKHR(Id const componentType, Id const scope, + Id const rows, Id const cols, Id const use) +{ + requireNonSemanticShaderDebugInfoVersion(101); + // try to find it + Instruction* type; + for (int t = 0; t < (int)groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeCooperativeMatrixKHR].size(); ++t) { + type = groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeCooperativeMatrixKHR][t]; + if (type->getIdOperand(2) == getDebugType(componentType) && + type->getIdOperand(3) == scope && + type->getIdOperand(4) == rows && + type->getIdOperand(5) == cols && + type->getIdOperand(6) == use) + return type->getResultId(); + } + + // not found, make it + type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); + type->reserveOperands(7); + type->addIdOperand(nonSemanticShaderDebugInfo); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeCooperativeMatrixKHR); + type->addIdOperand(getDebugType(componentType)); // component debug type + type->addIdOperand(scope); // scope + type->addIdOperand(rows); // rows + type->addIdOperand(cols); // columns + type->addIdOperand(use); // use (MatrixA, MatrixB, Accumulator) + + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeCooperativeMatrixKHR].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1174,7 +1224,7 @@ Id Builder::makeMemberDebugType(Id const memberType, StructMemberDebugInfo const Instruction* type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(10); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeMember); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeMember); type->addIdOperand(getStringId(debugTypeLoc.name)); // name id type->addIdOperand(debugTypeLoc.debugTypeOverride != 0 ? debugTypeLoc.debugTypeOverride : getDebugType(memberType)); // type id @@ -1183,9 +1233,9 @@ Id Builder::makeMemberDebugType(Id const memberType, StructMemberDebugInfo const type->addIdOperand(makeUintConstant(debugTypeLoc.column)); // TODO: column id type->addIdOperand(makeUintConstant(0)); // TODO: offset id type->addIdOperand(makeUintConstant(0)); // TODO: size id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); // flags id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsPublic)); // flags id - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeMember].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeMember].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1193,7 +1243,7 @@ Id Builder::makeMemberDebugType(Id const memberType, StructMemberDebugInfo const } Id Builder::makeCompositeDebugType(std::vector const& memberTypes, std::vector const& memberDebugInfo, - char const* const name, NonSemanticShaderDebugInfo100DebugCompositeType const tag) + char const* const name, NonSemanticShaderDebugInfoDebugCompositeType const tag) { // Create the debug member types. std::vector memberDebugTypes; @@ -1208,7 +1258,7 @@ Id Builder::makeCompositeDebugType(std::vector const& memberTypes, std::vect Instruction* type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(memberDebugTypes.size() + 11); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeComposite); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeComposite); type->addIdOperand(getStringId(name)); // name id type->addIdOperand(makeUintConstant(tag)); // tag id type->addIdOperand(makeDebugSource(currentFileId)); // source id @@ -1217,12 +1267,12 @@ Id Builder::makeCompositeDebugType(std::vector const& memberTypes, std::vect type->addIdOperand(makeDebugCompilationUnit()); // scope id type->addIdOperand(getStringId(name)); // linkage name id type->addIdOperand(makeUintConstant(0)); // TODO: size id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); // flags id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsPublic)); // flags id for(auto const memberDebugType : memberDebugTypes) { type->addIdOperand(memberDebugType); } - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeComposite].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeComposite].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1238,9 +1288,9 @@ Id Builder::makeOpaqueDebugType(char const* const name) Instruction* type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(11); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypeComposite); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypeComposite); type->addIdOperand(getStringId(name)); // name id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100Structure)); // tag id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoStructure)); // tag id type->addIdOperand(makeDebugSource(currentFileId)); // source id type->addIdOperand(makeUintConstant(currentLine)); // line id TODO: currentLine always zero? type->addIdOperand(makeUintConstant(0)); // TODO: column id @@ -1248,9 +1298,9 @@ Id Builder::makeOpaqueDebugType(char const* const name) // Prepend '@' to opaque types. type->addIdOperand(getStringId('@' + std::string(name))); // linkage name id type->addIdOperand(makeDebugInfoNone()); // size id - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); // flags id + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsPublic)); // flags id - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeComposite].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypeComposite].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1264,7 +1314,7 @@ Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType) return makeDebugInfoNone(); } const Id scID = makeUintConstant(storageClass); - for (Instruction* otherType : groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer]) { + for (Instruction* otherType : groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypePointer]) { if (otherType->getIdOperand(2) == debugBaseType && otherType->getIdOperand(3) == scID) { return otherType->getResultId(); @@ -1274,12 +1324,12 @@ Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType) Instruction* type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); type->reserveOperands(5); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypePointer); type->addIdOperand(debugBaseType); type->addIdOperand(scID); type->addIdOperand(makeUintConstant(0)); - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypePointer].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1297,12 +1347,12 @@ Id Builder::makeForwardPointerDebugType(StorageClass storageClass) Instruction *type = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInstWithForwardRefsKHR); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugTypePointer); type->addIdOperand(type->getResultId()); type->addIdOperand(scID); type->addIdOperand(makeUintConstant(0)); - groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer].push_back(type); + groupedDebugTypes[NonSemanticShaderDebugInfoDebugTypePointer].push_back(type); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -1316,7 +1366,7 @@ Id Builder::makeDebugSource(const Id fileName) { Instruction* sourceInst = new Instruction(resultId, makeVoidType(), Op::OpExtInst); sourceInst->reserveOperands(3); sourceInst->addIdOperand(nonSemanticShaderDebugInfo); - sourceInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugSource); + sourceInst->addImmediateOperand(NonSemanticShaderDebugInfoDebugSource); sourceInst->addIdOperand(fileName); constantsTypesGlobals.push_back(std::unique_ptr(sourceInst)); module.mapInstruction(sourceInst); @@ -1338,7 +1388,7 @@ Id Builder::makeDebugSource(const Id fileName) { Instruction* sourceContinuedInst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); sourceContinuedInst->reserveOperands(2); sourceContinuedInst->addIdOperand(nonSemanticShaderDebugInfo); - sourceContinuedInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugSourceContinued); + sourceContinuedInst->addImmediateOperand(NonSemanticShaderDebugInfoDebugSourceContinued); sourceContinuedInst->addIdOperand(sourceId); constantsTypesGlobals.push_back(std::unique_ptr(sourceContinuedInst)); module.mapInstruction(sourceContinuedInst); @@ -1372,7 +1422,7 @@ Id Builder::makeDebugCompilationUnit() { Instruction* sourceInst = new Instruction(resultId, makeVoidType(), Op::OpExtInst); sourceInst->reserveOperands(6); sourceInst->addIdOperand(nonSemanticShaderDebugInfo); - sourceInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugCompilationUnit); + sourceInst->addImmediateOperand(NonSemanticShaderDebugInfoDebugCompilationUnit); sourceInst->addIdOperand(makeUintConstant(1)); // TODO(greg-lunarg): Get rid of magic number sourceInst->addIdOperand(makeUintConstant(4)); // TODO(greg-lunarg): Get rid of magic number sourceInst->addIdOperand(makeDebugSource(mainFileId)); @@ -1396,7 +1446,7 @@ Id Builder::createDebugGlobalVariable(Id const type, char const*const name, Id c Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); inst->reserveOperands(11); inst->addIdOperand(nonSemanticShaderDebugInfo); - inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugGlobalVariable); + inst->addImmediateOperand(NonSemanticShaderDebugInfoDebugGlobalVariable); inst->addIdOperand(getStringId(name)); // name id inst->addIdOperand(type); // type id inst->addIdOperand(makeDebugSource(currentFileId)); // source id @@ -1405,7 +1455,7 @@ Id Builder::createDebugGlobalVariable(Id const type, char const*const name, Id c inst->addIdOperand(makeDebugCompilationUnit()); // scope id inst->addIdOperand(getStringId(name)); // linkage name id inst->addIdOperand(variable); // variable id - inst->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsDefinition)); // flags id + inst->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsDefinition)); // flags id constantsTypesGlobals.push_back(std::unique_ptr(inst)); module.mapInstruction(inst); @@ -1421,14 +1471,14 @@ Id Builder::createDebugLocalVariable(Id type, char const*const name, size_t cons Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); inst->reserveOperands(9); inst->addIdOperand(nonSemanticShaderDebugInfo); - inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLocalVariable); + inst->addImmediateOperand(NonSemanticShaderDebugInfoDebugLocalVariable); inst->addIdOperand(getStringId(name)); // name id inst->addIdOperand(type); // type id inst->addIdOperand(makeDebugSource(currentFileId)); // source id inst->addIdOperand(makeUintConstant(currentLine)); // line id inst->addIdOperand(makeUintConstant(0)); // TODO: column id inst->addIdOperand(currentDebugScopeId.top()); // scope id - inst->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsLocal)); // flags id + inst->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsLocal)); // flags id if(argNumber != 0) { inst->addIdOperand(makeUintConstant(static_cast(argNumber))); } @@ -1447,7 +1497,7 @@ Id Builder::makeDebugExpression() Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); inst->reserveOperands(2); inst->addIdOperand(nonSemanticShaderDebugInfo); - inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugExpression); + inst->addImmediateOperand(NonSemanticShaderDebugInfoDebugExpression); constantsTypesGlobals.push_back(std::unique_ptr(inst)); module.mapInstruction(inst); @@ -1462,7 +1512,7 @@ Id Builder::makeDebugDeclare(Id const debugLocalVariable, Id const pointer) Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); inst->reserveOperands(5); inst->addIdOperand(nonSemanticShaderDebugInfo); - inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugDeclare); + inst->addImmediateOperand(NonSemanticShaderDebugInfoDebugDeclare); inst->addIdOperand(debugLocalVariable); // debug local variable id inst->addIdOperand(pointer); // pointer to local variable id inst->addIdOperand(makeDebugExpression()); // expression id @@ -1476,7 +1526,7 @@ Id Builder::makeDebugValue(Id const debugLocalVariable, Id const value) Instruction* inst = new Instruction(getUniqueId(), makeVoidType(), Op::OpExtInst); inst->reserveOperands(5); inst->addIdOperand(nonSemanticShaderDebugInfo); - inst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugValue); + inst->addImmediateOperand(NonSemanticShaderDebugInfoDebugValue); inst->addIdOperand(debugLocalVariable); // debug local variable id inst->addIdOperand(value); // value of local variable id inst->addIdOperand(makeDebugExpression()); // expression id @@ -2137,12 +2187,35 @@ Id Builder::importNonSemanticShaderDebugInfoInstructions() if(nonSemanticShaderDebugInfo == 0) { this->addExtension(spv::E_SPV_KHR_non_semantic_info); - nonSemanticShaderDebugInfo = this->import("NonSemantic.Shader.DebugInfo.100"); + // Create the import instruction directly so we can save a pointer for later + // patching by requireNonSemanticShaderDebugInfoVersion(). + std::string importName = "NonSemantic.Shader.DebugInfo." + std::to_string(nonSemanticShaderDebugInfoVersion); + auto* importInst = new Instruction(getUniqueId(), NoType, Op::OpExtInstImport); + importInst->addStringOperand(importName.c_str()); + module.mapInstruction(importInst); + imports.push_back(std::unique_ptr(importInst)); + nonSemanticShaderDebugInfo = importInst->getResultId(); + nonSemanticShaderDebugInfoImportInst = importInst; } return nonSemanticShaderDebugInfo; } +void Builder::requireNonSemanticShaderDebugInfoVersion(unsigned version) +{ + if (nonSemanticShaderDebugInfoVersion >= version) + return; + nonSemanticShaderDebugInfoVersion = version; + if (nonSemanticShaderDebugInfoImportInst != nullptr) { + // The import instruction was already emitted with an older version string. + // Rebuild the string operands in place so all referencing OpExtInst instructions + // automatically pick up the new name without needing new IDs. + std::string importName = "NonSemantic.Shader.DebugInfo." + std::to_string(version); + nonSemanticShaderDebugInfoImportInst->clearOperands(); + nonSemanticShaderDebugInfoImportInst->addStringOperand(importName.c_str()); + } +} + Id Builder::findCompositeConstant(Op typeClass, Op opcode, Id typeId, const std::vector& comps, size_t numMembers) { Instruction* constant = nullptr; @@ -2544,7 +2617,7 @@ void Builder::addInstruction(std::unique_ptr inst) { auto scopeInst = std::make_unique(getUniqueId(), makeVoidType(), Op::OpExtInst); scopeInst->reserveOperands(3); scopeInst->addIdOperand(nonSemanticShaderDebugInfo); - scopeInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugScope); + scopeInst->addImmediateOperand(NonSemanticShaderDebugInfoDebugScope); scopeInst->addIdOperand(currentDebugScopeId.top()); buildPoint->addInstruction(std::move(scopeInst)); } @@ -2567,7 +2640,7 @@ void Builder::addInstruction(std::unique_ptr inst) { auto lineInst = std::make_unique(getUniqueId(), makeVoidType(), Op::OpExtInst); lineInst->reserveOperands(7); lineInst->addIdOperand(nonSemanticShaderDebugInfo); - lineInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLine); + lineInst->addImmediateOperand(NonSemanticShaderDebugInfoDebugLine); lineInst->addIdOperand(makeDebugSource(currentFileId)); lineInst->addIdOperand(makeUintConstant(currentLine)); lineInst->addIdOperand(makeUintConstant(currentLine)); @@ -2709,7 +2782,7 @@ Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id auto type = new Instruction(funcId, makeVoidType(), Op::OpExtInst); type->reserveOperands(11); type->addIdOperand(nonSemanticShaderDebugInfo); - type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunction); + type->addImmediateOperand(NonSemanticShaderDebugInfoDebugFunction); type->addIdOperand(nameId); type->addIdOperand(getDebugType(funcTypeId)); type->addIdOperand(makeDebugSource(currentFileId)); // TODO: This points to file of definition instead of declaration @@ -2717,7 +2790,7 @@ Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id type->addIdOperand(makeUintConstant(0)); // column type->addIdOperand(makeDebugCompilationUnit()); // scope type->addIdOperand(nameId); // linkage name - type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfo100FlagIsPublic)); + type->addIdOperand(makeUintConstant(NonSemanticShaderDebugInfoFlagIsPublic)); type->addIdOperand(makeUintConstant(currentLine)); constantsTypesGlobals.push_back(std::unique_ptr(type)); module.mapInstruction(type); @@ -2731,7 +2804,7 @@ Id Builder::makeDebugLexicalBlock(uint32_t line, uint32_t column) { auto lex = new Instruction(lexId, makeVoidType(), Op::OpExtInst); lex->reserveOperands(6); lex->addIdOperand(nonSemanticShaderDebugInfo); - lex->addImmediateOperand(NonSemanticShaderDebugInfo100DebugLexicalBlock); + lex->addImmediateOperand(NonSemanticShaderDebugInfoDebugLexicalBlock); lex->addIdOperand(makeDebugSource(currentFileId)); lex->addIdOperand(makeUintConstant(line)); lex->addIdOperand(makeUintConstant(column)); // column @@ -2813,7 +2886,7 @@ void Builder::enterFunction(Function const* function) Instruction* defInst = new Instruction(resultId, makeVoidType(), Op::OpExtInst); defInst->reserveOperands(4); defInst->addIdOperand(nonSemanticShaderDebugInfo); - defInst->addImmediateOperand(NonSemanticShaderDebugInfo100DebugFunctionDefinition); + defInst->addImmediateOperand(NonSemanticShaderDebugInfoDebugFunctionDefinition); defInst->addIdOperand(debugFuncId); defInst->addIdOperand(funcId); addInstruction(std::unique_ptr(defInst)); diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index abfec52efc..001ed4bc7b 100644 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -56,7 +56,7 @@ namespace spv { #include "GLSL.ext.KHR.h" #include "GLSL.ext.EXT.h" - #include "NonSemanticShaderDebugInfo100.h" + #include "NonSemanticShaderDebugInfo.h" } #include @@ -260,15 +260,17 @@ class Builder { Id makeDebugInfoNone(); Id makeBoolDebugType(int const size); Id makeIntegerDebugType(int const width, bool const hasSign); - Id makeFloatDebugType(int const width); - Id makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfo100Instructions const sequenceType); + Id makeFloatDebugType(int const width, Id const fpEncoding = NoType); + Id makeSequentialDebugType(Id const baseType, Id const componentCount, NonSemanticShaderDebugInfoInstructions const sequenceType); Id makeArrayDebugType(Id const baseType, Id const componentCount); Id makeVectorDebugType(Id const baseType, int const componentCount); Id makeMatrixDebugType(Id const vectorType, int const vectorCount, bool columnMajor = true); Id makeMemberDebugType(Id const memberType, StructMemberDebugInfo const& debugTypeLoc); Id makeCompositeDebugType(std::vector const& memberTypes, std::vector const& memberDebugInfo, - char const* const name, NonSemanticShaderDebugInfo100DebugCompositeType const tag); + char const* const name, NonSemanticShaderDebugInfoDebugCompositeType const tag); Id makeOpaqueDebugType(char const* const name); + Id makeVectorIdDebugType(Id componentType, Id componentCount); + Id makeCooperativeMatrixDebugTypeKHR(Id componentType, Id scope, Id rows, Id cols, Id use); Id makePointerDebugType(StorageClass storageClass, Id const baseType); Id makeForwardPointerDebugType(StorageClass storageClass); Id makeDebugSource(const Id fileName); @@ -457,6 +459,11 @@ class Builder { Id makeFpConstant(Id type, double d, bool specConstant = false); Id importNonSemanticShaderDebugInfoInstructions(); + // Ensure the NonSemantic.Shader.DebugInfo import string names at least `version`. + // If the import instruction already exists, its name is patched in place. + // If it has not been created yet, importNonSemanticShaderDebugInfoInstructions() + // will use the updated version when it runs. + void requireNonSemanticShaderDebugInfoVersion(unsigned version); // Turn the array of constants into a proper spv constant of the requested type. Id makeCompositeConstant(Id type, const std::vector& comps, bool specConst = false); @@ -1036,6 +1043,12 @@ class Builder { int sourceVersion; spv::Id nonSemanticShaderCompilationUnitId {0}; spv::Id nonSemanticShaderDebugInfo {0}; + // Pointer to the OpExtInstImport instruction for NonSemantic.Shader.DebugInfo. + // Kept so requireNonSemanticShaderDebugInfoVersion() can patch the name in place. + Instruction* nonSemanticShaderDebugInfoImportInst {nullptr}; + // Spec version encoded in the NonSemantic.Shader.DebugInfo import name. + // Defaults to 100. Promoted to N the first time a version-N opcode is emitted. + unsigned int nonSemanticShaderDebugInfoVersion{100}; spv::Id debugInfoNone {0}; spv::Id debugExpression {0}; // Debug expression with zero operations. std::string sourceText; diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index 3889695134..821613fbf0 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -57,7 +57,7 @@ namespace spv { #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" #include "GLSL.ext.ARM.h" - #include "NonSemanticShaderDebugInfo100.h" + #include "NonSemanticShaderDebugInfo.h" #include "GLSL.ext.QCOM.h" } } @@ -67,7 +67,7 @@ namespace spv { static const char* GLSLextAMDGetDebugNames(const char*, unsigned); static const char* GLSLextNVGetDebugNames(const char*, unsigned); -static const char* NonSemanticShaderDebugInfo100GetDebugNames(unsigned); +static const char* NonSemanticShaderDebugInfoGetDebugNames(unsigned); static void Kill(std::ostream& out, const char* message) { @@ -83,7 +83,7 @@ enum ExtInstSet { OpenCLExtInst, NonSemanticDebugPrintfExtInst, NonSemanticDebugBreakExtInst, - NonSemanticShaderDebugInfo100 + NonSemanticShaderDebugInfo }; // Container class for a single instance of a SPIR-V stream, with methods for disassembly. @@ -547,8 +547,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, extInstSet = NonSemanticDebugPrintfExtInst; } else if (strcmp("NonSemantic.DebugBreak", name) == 0) { extInstSet = NonSemanticDebugBreakExtInst; - } else if (strcmp("NonSemantic.Shader.DebugInfo.100", name) == 0) { - extInstSet = NonSemanticShaderDebugInfo100; + } else if (strncmp("NonSemantic.Shader.DebugInfo.", name, 29) == 0) { + extInstSet = NonSemanticShaderDebugInfo; } else if (strcmp(spv::E_SPV_AMD_shader_ballot, name) == 0 || strcmp(spv::E_SPV_AMD_shader_trinary_minmax, name) == 0 || strcmp(spv::E_SPV_AMD_shader_explicit_vertex_parameter, name) == 0 || @@ -576,8 +576,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, out << "(DebugPrintf)"; } else if (extInstSet == NonSemanticDebugBreakExtInst) { out << "(DebugBreak)"; - } else if (extInstSet == NonSemanticShaderDebugInfo100) { - out << "(" << NonSemanticShaderDebugInfo100GetDebugNames(entrypoint) << ")"; + } else if (extInstSet == NonSemanticShaderDebugInfo) { + out << "(" << NonSemanticShaderDebugInfoGetDebugNames(entrypoint) << ")"; } } break; @@ -824,53 +824,55 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint) return "Bad"; } -static const char* NonSemanticShaderDebugInfo100GetDebugNames(unsigned entrypoint) +static const char* NonSemanticShaderDebugInfoGetDebugNames(unsigned entrypoint) { switch (entrypoint) { - case NonSemanticShaderDebugInfo100DebugInfoNone: return "DebugInfoNone"; - case NonSemanticShaderDebugInfo100DebugCompilationUnit: return "DebugCompilationUnit"; - case NonSemanticShaderDebugInfo100DebugTypeBasic: return "DebugTypeBasic"; - case NonSemanticShaderDebugInfo100DebugTypePointer: return "DebugTypePointer"; - case NonSemanticShaderDebugInfo100DebugTypeQualifier: return "DebugTypeQualifier"; - case NonSemanticShaderDebugInfo100DebugTypeArray: return "DebugTypeArray"; - case NonSemanticShaderDebugInfo100DebugTypeVector: return "DebugTypeVector"; - case NonSemanticShaderDebugInfo100DebugTypedef: return "DebugTypedef"; - case NonSemanticShaderDebugInfo100DebugTypeFunction: return "DebugTypeFunction"; - case NonSemanticShaderDebugInfo100DebugTypeEnum: return "DebugTypeEnum"; - case NonSemanticShaderDebugInfo100DebugTypeComposite: return "DebugTypeComposite"; - case NonSemanticShaderDebugInfo100DebugTypeMember: return "DebugTypeMember"; - case NonSemanticShaderDebugInfo100DebugTypeInheritance: return "DebugTypeInheritance"; - case NonSemanticShaderDebugInfo100DebugTypePtrToMember: return "DebugTypePtrToMember"; - case NonSemanticShaderDebugInfo100DebugTypeTemplate: return "DebugTypeTemplate"; - case NonSemanticShaderDebugInfo100DebugTypeTemplateParameter: return "DebugTypeTemplateParameter"; - case NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter: return "DebugTypeTemplateTemplateParameter"; - case NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack: return "DebugTypeTemplateParameterPack"; - case NonSemanticShaderDebugInfo100DebugGlobalVariable: return "DebugGlobalVariable"; - case NonSemanticShaderDebugInfo100DebugFunctionDeclaration: return "DebugFunctionDeclaration"; - case NonSemanticShaderDebugInfo100DebugFunction: return "DebugFunction"; - case NonSemanticShaderDebugInfo100DebugLexicalBlock: return "DebugLexicalBlock"; - case NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator: return "DebugLexicalBlockDiscriminator"; - case NonSemanticShaderDebugInfo100DebugScope: return "DebugScope"; - case NonSemanticShaderDebugInfo100DebugNoScope: return "DebugNoScope"; - case NonSemanticShaderDebugInfo100DebugInlinedAt: return "DebugInlinedAt"; - case NonSemanticShaderDebugInfo100DebugLocalVariable: return "DebugLocalVariable"; - case NonSemanticShaderDebugInfo100DebugInlinedVariable: return "DebugInlinedVariable"; - case NonSemanticShaderDebugInfo100DebugDeclare: return "DebugDeclare"; - case NonSemanticShaderDebugInfo100DebugValue: return "DebugValue"; - case NonSemanticShaderDebugInfo100DebugOperation: return "DebugOperation"; - case NonSemanticShaderDebugInfo100DebugExpression: return "DebugExpression"; - case NonSemanticShaderDebugInfo100DebugMacroDef: return "DebugMacroDef"; - case NonSemanticShaderDebugInfo100DebugMacroUndef: return "DebugMacroUndef"; - case NonSemanticShaderDebugInfo100DebugImportedEntity: return "DebugImportedEntity"; - case NonSemanticShaderDebugInfo100DebugSource: return "DebugSource"; - case NonSemanticShaderDebugInfo100DebugFunctionDefinition: return "DebugFunctionDefinition"; - case NonSemanticShaderDebugInfo100DebugSourceContinued: return "DebugSourceContinued"; - case NonSemanticShaderDebugInfo100DebugLine: return "DebugLine"; - case NonSemanticShaderDebugInfo100DebugNoLine: return "DebugNoLine"; - case NonSemanticShaderDebugInfo100DebugBuildIdentifier: return "DebugBuildIdentifier"; - case NonSemanticShaderDebugInfo100DebugStoragePath: return "DebugStoragePath"; - case NonSemanticShaderDebugInfo100DebugEntryPoint: return "DebugEntryPoint"; - case NonSemanticShaderDebugInfo100DebugTypeMatrix: return "DebugTypeMatrix"; + case NonSemanticShaderDebugInfoDebugInfoNone: return "DebugInfoNone"; + case NonSemanticShaderDebugInfoDebugCompilationUnit: return "DebugCompilationUnit"; + case NonSemanticShaderDebugInfoDebugTypeBasic: return "DebugTypeBasic"; + case NonSemanticShaderDebugInfoDebugTypePointer: return "DebugTypePointer"; + case NonSemanticShaderDebugInfoDebugTypeQualifier: return "DebugTypeQualifier"; + case NonSemanticShaderDebugInfoDebugTypeArray: return "DebugTypeArray"; + case NonSemanticShaderDebugInfoDebugTypeVector: return "DebugTypeVector"; + case NonSemanticShaderDebugInfoDebugTypedef: return "DebugTypedef"; + case NonSemanticShaderDebugInfoDebugTypeFunction: return "DebugTypeFunction"; + case NonSemanticShaderDebugInfoDebugTypeEnum: return "DebugTypeEnum"; + case NonSemanticShaderDebugInfoDebugTypeComposite: return "DebugTypeComposite"; + case NonSemanticShaderDebugInfoDebugTypeMember: return "DebugTypeMember"; + case NonSemanticShaderDebugInfoDebugTypeInheritance: return "DebugTypeInheritance"; + case NonSemanticShaderDebugInfoDebugTypePtrToMember: return "DebugTypePtrToMember"; + case NonSemanticShaderDebugInfoDebugTypeTemplate: return "DebugTypeTemplate"; + case NonSemanticShaderDebugInfoDebugTypeTemplateParameter: return "DebugTypeTemplateParameter"; + case NonSemanticShaderDebugInfoDebugTypeTemplateTemplateParameter: return "DebugTypeTemplateTemplateParameter"; + case NonSemanticShaderDebugInfoDebugTypeTemplateParameterPack: return "DebugTypeTemplateParameterPack"; + case NonSemanticShaderDebugInfoDebugGlobalVariable: return "DebugGlobalVariable"; + case NonSemanticShaderDebugInfoDebugFunctionDeclaration: return "DebugFunctionDeclaration"; + case NonSemanticShaderDebugInfoDebugFunction: return "DebugFunction"; + case NonSemanticShaderDebugInfoDebugLexicalBlock: return "DebugLexicalBlock"; + case NonSemanticShaderDebugInfoDebugLexicalBlockDiscriminator: return "DebugLexicalBlockDiscriminator"; + case NonSemanticShaderDebugInfoDebugScope: return "DebugScope"; + case NonSemanticShaderDebugInfoDebugNoScope: return "DebugNoScope"; + case NonSemanticShaderDebugInfoDebugInlinedAt: return "DebugInlinedAt"; + case NonSemanticShaderDebugInfoDebugLocalVariable: return "DebugLocalVariable"; + case NonSemanticShaderDebugInfoDebugInlinedVariable: return "DebugInlinedVariable"; + case NonSemanticShaderDebugInfoDebugDeclare: return "DebugDeclare"; + case NonSemanticShaderDebugInfoDebugValue: return "DebugValue"; + case NonSemanticShaderDebugInfoDebugOperation: return "DebugOperation"; + case NonSemanticShaderDebugInfoDebugExpression: return "DebugExpression"; + case NonSemanticShaderDebugInfoDebugMacroDef: return "DebugMacroDef"; + case NonSemanticShaderDebugInfoDebugMacroUndef: return "DebugMacroUndef"; + case NonSemanticShaderDebugInfoDebugImportedEntity: return "DebugImportedEntity"; + case NonSemanticShaderDebugInfoDebugSource: return "DebugSource"; + case NonSemanticShaderDebugInfoDebugFunctionDefinition: return "DebugFunctionDefinition"; + case NonSemanticShaderDebugInfoDebugSourceContinued: return "DebugSourceContinued"; + case NonSemanticShaderDebugInfoDebugLine: return "DebugLine"; + case NonSemanticShaderDebugInfoDebugNoLine: return "DebugNoLine"; + case NonSemanticShaderDebugInfoDebugBuildIdentifier: return "DebugBuildIdentifier"; + case NonSemanticShaderDebugInfoDebugStoragePath: return "DebugStoragePath"; + case NonSemanticShaderDebugInfoDebugEntryPoint: return "DebugEntryPoint"; + case NonSemanticShaderDebugInfoDebugTypeMatrix: return "DebugTypeMatrix"; + case NonSemanticShaderDebugInfoDebugTypeVectorIdEXT: return "DebugTypeVectorIdEXT"; + case NonSemanticShaderDebugInfoDebugTypeCooperativeMatrixKHR: return "DebugTypeCooperativeMatrixKHR"; default: return "Bad"; } diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h index ce7afbcce5..75de288247 100644 --- a/SPIRV/spvIR.h +++ b/SPIRV/spvIR.h @@ -189,6 +189,11 @@ class Instruction { operands[idx] = immediate; } + void clearOperands() { + operands.clear(); + idOperand.clear(); + } + void addStringOperand(const char* str) { unsigned int word = 0; diff --git a/Test/baseResults/spv.debuginfo.coopmatKHR.comp.out b/Test/baseResults/spv.debuginfo.coopmatKHR.comp.out deleted file mode 100644 index bcec069b12..0000000000 --- a/Test/baseResults/spv.debuginfo.coopmatKHR.comp.out +++ /dev/null @@ -1,649 +0,0 @@ -spv.debuginfo.coopmatKHR.comp -// Module Version 10300 -// Generated by (magic number): 8000b -// Id's are bound by 412 - - Capability Shader - Capability Float16 - Capability StorageUniformBufferBlock16 - Capability VulkanMemoryModelKHR - Capability CooperativeMatrixKHR - Extension "SPV_KHR_cooperative_matrix" - Extension "SPV_KHR_non_semantic_info" - Extension "SPV_KHR_vulkan_memory_model" - 1: ExtInstImport "NonSemantic.Shader.DebugInfo.100" - 3: ExtInstImport "GLSL.std.450" - MemoryModel Logical VulkanKHR - EntryPoint GLCompute 14 "main" - ExecutionMode 14 LocalSize 1 1 1 - 2: String "spv.debuginfo.coopmatKHR.comp" - 8: String "uint" - 16: String "main" - 19: String "/* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#version 450 core -#pragma use_vulkan_memory_model -#extension GL_EXT_scalar_block_layout : enable -#extension GL_KHR_memory_scope_semantics : enable -#extension GL_KHR_cooperative_matrix : enable -#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable -#extension GL_EXT_shader_explicit_arithmetic_types_int8 : enable -#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable -#extension GL_EXT_buffer_reference : enable -#extension GL_EXT_control_flow_attributes : enable - -layout(constant_id = 0) const uint lM = 1; -layout(constant_id = 1) const uint lN = 1; -layout(constant_id = 2) const uint lK = 1; -layout(constant_id = 3) const uint TILE_M = 1; -layout(constant_id = 4) const uint TILE_N = 1; -layout(constant_id = 5) const uint TILE_K = 1; -layout(constant_id = 6) const uint K = 1; - -#define A_BITS 16 -#define A_TYPE float16_t -#define C_BITS 16 -#define C_TYPE float16_t - -buffer Output { C_TYPE x[]; } outputO; - -shared uvec4 Ash[128]; -shared uvec4 Bsh[128]; - -const uint C_ROWS = 2; -const uint C_COLS = 2; -coopmat result[C_ROWS][C_COLS]; - -void main() -{ - [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { - [[unroll]] for (uint j = 0; j < C_COLS; ++j) { - result[i][j] = coopmat(0.0); - } - } - - for (uint chunkK = 0; chunkK < K; chunkK += TILE_K) { - [[unroll]] for (uint k = 0; k < TILE_K / lK; ++k) - { - coopmat matA[C_ROWS]; - [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { - coopMatLoad(matA[i], Ash, 0, 0, gl_CooperativeMatrixLayoutRowMajor); - } - - coopmat matB; - [[unroll]] for (uint j = 0; j < C_COLS; ++j) { - coopMatLoad(matB, Bsh, 0, 0, gl_CooperativeMatrixLayoutRowMajor); - - [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { - result[i][j] = coopMatMulAdd(matA[i], matB, result[i][j]); - } - } - } - } - - [[unroll]] for (uint i = 0; i < C_ROWS; ++i) { - [[unroll]] for (uint j = 0; j < C_COLS; ++j) { - coopMatStore(result[i][j], outputO.x, 0, 0, gl_CooperativeMatrixLayoutRowMajor); - } - } -} -" - 27: String "lM" - 32: String "lN" - 36: String "lK" - 40: String "TILE_M" - 44: String "TILE_N" - 48: String "TILE_K" - 52: String "K" - 55: String "float16_t" - 62: String "x" - 66: String "Output" - 72: String "outputO" - 82: String "Ash" - 86: String "Bsh" - 89: String "C_ROWS" - 92: String "C_COLS" - 96: String "coopmat" - 98: String "@coopmat" - 108: String "result" - 119: String "i" - 135: String "bool" - 143: String "j" - 172: String "int" - 185: String "chunkK" - 204: String "k" - 222: String "coopmat" - 224: String "@coopmat" - 231: String "matA" - 271: String "coopmat" - 273: String "@coopmat" - 278: String "matB" - SourceExtension "GL_EXT_buffer_reference" - SourceExtension "GL_EXT_control_flow_attributes" - SourceExtension "GL_EXT_scalar_block_layout" - SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16" - SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int32" - SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int8" - SourceExtension "GL_KHR_cooperative_matrix" - SourceExtension "GL_KHR_memory_scope_semantics" - Name 14 "main" - Name 25 "lM" - Name 30 "lN" - Name 34 "lK" - Name 38 "TILE_M" - Name 42 "TILE_N" - Name 46 "TILE_K" - Name 50 "K" - Name 60 "Output" - MemberName 60(Output) 0 "x" - Name 70 "outputO" - Name 80 "Ash" - Name 84 "Bsh" - Name 106 "result" - Name 117 "i" - Name 141 "j" - Name 183 "chunkK" - Name 202 "k" - Name 229 "matA" - Name 237 "i" - Name 276 "matB" - Name 284 "j" - Name 308 "i" - Name 357 "i" - Name 375 "j" - ModuleProcessed "auto-map-locations" - ModuleProcessed "auto-map-bindings" - ModuleProcessed "client vulkan100" - ModuleProcessed "target-env spirv1.3" - ModuleProcessed "target-env vulkan1.1" - ModuleProcessed "keep-uncalled" - ModuleProcessed "entry-point main" - ModuleProcessed "use-vulkan-memory-model" - ModuleProcessed "use-vulkan-memory-model" - ModuleProcessed "use-vulkan-memory-model" - ModuleProcessed "use-vulkan-memory-model" - Decorate 25(lM) SpecId 0 - Decorate 30(lN) SpecId 1 - Decorate 34(lK) SpecId 2 - Decorate 38(TILE_M) SpecId 3 - Decorate 42(TILE_N) SpecId 4 - Decorate 46(TILE_K) SpecId 5 - Decorate 50(K) SpecId 6 - Decorate 58 ArrayStride 2 - Decorate 60(Output) Block - MemberDecorate 60(Output) 0 Offset 0 - Decorate 70(outputO) Binding 0 - Decorate 70(outputO) DescriptorSet 0 - 4: TypeVoid - 5: TypeFunction 4 - 7: TypeInt 32 0 - 10: 7(int) Constant 32 - 11: 7(int) Constant 6 - 12: 7(int) Constant 0 - 9: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 8 10 11 12 - 13: 7(int) Constant 3 - 6: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 8(DebugTypeFunction) 13 4 - 18: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 35(DebugSource) 2 19 - 20: 7(int) Constant 55 - 22: 7(int) Constant 1 - 23: 7(int) Constant 4 - 24: 7(int) Constant 2 - 21: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 1(DebugCompilationUnit) 22 23 18 24 - 17: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 20(DebugFunction) 16 6 18 20 12 21 16 13 20 - 25(lM): 7(int) SpecConstant 1 - 28: 7(int) Constant 33 - 29: 7(int) Constant 8 - 26: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 27 9 18 28 12 21 27 25(lM) 29 - 30(lN): 7(int) SpecConstant 1 - 33: 7(int) Constant 34 - 31: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 32 9 18 33 12 21 32 30(lN) 29 - 34(lK): 7(int) SpecConstant 1 - 37: 7(int) Constant 35 - 35: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 36 9 18 37 12 21 36 34(lK) 29 - 38(TILE_M): 7(int) SpecConstant 1 - 41: 7(int) Constant 36 - 39: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 40 9 18 41 12 21 40 38(TILE_M) 29 - 42(TILE_N): 7(int) SpecConstant 1 - 45: 7(int) Constant 37 - 43: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 44 9 18 45 12 21 44 42(TILE_N) 29 - 46(TILE_K): 7(int) SpecConstant 1 - 49: 7(int) Constant 38 - 47: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 48 9 18 49 12 21 48 46(TILE_K) 29 - 50(K): 7(int) SpecConstant 1 - 53: 7(int) Constant 39 - 51: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 52 9 18 53 12 21 52 50(K) 29 - 54: TypeFloat 16 - 57: 7(int) Constant 16 - 56: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 55 57 13 12 - 58: TypeRuntimeArray 54(float16_t) - 59: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 56 12 - 60(Output): TypeStruct 58 - 63: 7(int) Constant 46 - 64: 7(int) Constant 24 - 61: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 11(DebugTypeMember) 62 59 18 63 64 12 12 13 - 65: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 66 22 18 63 12 21 66 12 13 61 - 67: TypePointer StorageBuffer 60(Output) - 68: 7(int) Constant 12 - 69: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 65 68 12 - 70(outputO): 67(ptr) Variable StorageBuffer - 71: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 72 65 18 63 12 21 72 70(outputO) 29 - 73: TypeVector 7(int) 4 - 74: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 6(DebugTypeVector) 9 23 - 75: 7(int) Constant 128 - 76: TypeArray 73(ivec4) 75 - 77: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 74 75 - 78: TypePointer Workgroup 76 - 79: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 77 23 12 - 80(Ash): 78(ptr) Variable Workgroup - 83: 7(int) Constant 48 - 81: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 82 77 18 83 12 21 82 80(Ash) 29 - 84(Bsh): 78(ptr) Variable Workgroup - 87: 7(int) Constant 49 - 85: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 86 77 18 87 12 21 86 84(Bsh) 29 - 90: 7(int) Constant 51 - 88: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 89 9 18 90 12 21 89 24 29 - 93: 7(int) Constant 52 - 91: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 92 9 18 93 12 21 92 24 29 - 94: TypeCooperativeMatrixKHR 54(float16_t) 13 25(lM) 30(lN) 24 - 97: 7(int) Constant 53 - 99: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 0(DebugInfoNone) - 95: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 96 22 18 97 12 21 98 99 13 - 100: TypeArray 94 24 - 101: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 95 24 - 102: TypeArray 100 24 - 103: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 101 24 - 104: TypePointer Private 102 - 105: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 103 11 12 - 106(result): 104(ptr) Variable Private - 107: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 18(DebugGlobalVariable) 108 103 18 97 12 21 108 106(result) 29 - 113: 7(int) Constant 57 - 112: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 113 57 17 - 114: TypePointer Function 7(int) - 115: 7(int) Constant 7 - 116: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 9 115 12 - 118: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 119 9 18 113 12 112 23 - 121: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 31(DebugExpression) - 134: TypeBool - 136: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 135 10 24 12 - 139: 7(int) Constant 58 - 140: 7(int) Constant 20 - 138: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 139 140 112 - 142: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 143 9 18 139 12 138 23 - 161: 7(int) Constant 59 - 163:54(float16_t) Constant 0 - 164: 94 ConstantComposite 163 - 165: TypePointer Private 94 - 166: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 95 11 12 - 171: TypeInt 32 1 - 173: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 2(DebugTypeBasic) 172 10 23 12 - 174: 171(int) Constant 1 - 181: 7(int) Constant 63 - 182: 7(int) Constant 5 - 180: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 181 182 17 - 184: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 185 9 18 181 12 180 23 - 201: 7(int) Constant 64 - 200: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 201 140 180 - 203: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 204 9 18 201 12 200 23 - 218: 7(int) SpecConstantOp 134 46(TILE_K) 34(lK) - 220: TypeCooperativeMatrixKHR 54(float16_t) 13 25(lM) 34(lK) 12 - 223: 7(int) Constant 66 - 221: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 222 22 18 223 12 21 224 99 13 - 225: TypeArray 220 24 - 226: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 5(DebugTypeArray) 221 24 - 227: TypePointer Function 225 - 228: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 226 115 12 - 230: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 231 226 18 223 12 200 23 - 236: 7(int) Constant 67 - 235: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 236 64 200 - 238: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 119 9 18 236 12 235 23 - 256: 7(int) Constant 68 - 257: TypePointer Function 220 - 258: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 221 115 12 - 260: TypePointer Workgroup 73(ivec4) - 261: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 74 23 12 - 263: 171(int) Constant 0 - 269: TypeCooperativeMatrixKHR 54(float16_t) 13 34(lK) 30(lN) 22 - 272: 7(int) Constant 71 - 270: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 10(DebugTypeComposite) 271 22 18 272 12 21 273 99 13 - 274: TypePointer Function 269 - 275: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 270 115 12 - 277: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 278 270 18 272 12 200 23 - 283: 7(int) Constant 72 - 282: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 283 64 200 - 285: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 143 9 18 283 12 282 23 - 303: 7(int) Constant 73 - 306: 7(int) Constant 75 - 307: 7(int) Constant 28 - 305: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 306 307 282 - 309: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 119 9 18 306 12 305 23 - 327: 7(int) Constant 76 - 356: 7(int) Constant 82 - 355: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 356 57 17 - 358: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 119 9 18 356 12 355 23 - 374: 7(int) Constant 83 - 373: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 21(DebugLexicalBlock) 18 374 140 355 - 376: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 26(DebugLocalVariable) 143 9 18 374 12 373 23 - 394: 7(int) Constant 84 - 398: TypePointer StorageBuffer 54(float16_t) - 399: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 3(DebugTypePointer) 56 68 12 - 411: 7(int) Constant 87 - 14(main): 4 Function None 5 - 15: Label - 117(i): 114(ptr) Variable Function - 141(j): 114(ptr) Variable Function - 183(chunkK): 114(ptr) Variable Function - 202(k): 114(ptr) Variable Function - 229(matA): 227(ptr) Variable Function - 237(i): 114(ptr) Variable Function - 276(matB): 274(ptr) Variable Function - 284(j): 114(ptr) Variable Function - 308(i): 114(ptr) Variable Function - 357(i): 114(ptr) Variable Function - 375(j): 114(ptr) Variable Function - 110: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 - 111: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 20 20 12 12 - 109: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 101(DebugFunctionDefinition) 17 14(main) - 122: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 112 - 123: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 113 113 12 12 - 120: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 118 117(i) 121 - Store 117(i) 12 - Branch 124 - 124: Label - 128: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 112 - 129: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 113 113 12 12 - LoopMerge 126 127 Unroll - Branch 130 - 130: Label - 132: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 112 - 133: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 113 113 12 12 - 131: 7(int) Load 117(i) - 137: 134(bool) ULessThan 131 24 - BranchConditional 137 125 126 - 125: Label - 145: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 138 - 146: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 139 139 12 12 - 144: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 142 141(j) 121 - Store 141(j) 12 - Branch 147 - 147: Label - 151: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 138 - 152: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 139 139 12 12 - LoopMerge 149 150 Unroll - Branch 153 - 153: Label - 155: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 138 - 156: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 139 139 12 12 - 154: 7(int) Load 141(j) - 157: 134(bool) ULessThan 154 24 - BranchConditional 157 148 149 - 148: Label - 159: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 138 - 160: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 161 161 12 12 - 158: 7(int) Load 117(i) - 162: 7(int) Load 141(j) - 167: 165(ptr) AccessChain 106(result) 158 162 - Store 167 164 - Branch 150 - 150: Label - 169: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 138 - 170: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 139 139 12 12 - 168: 7(int) Load 141(j) - 175: 7(int) IAdd 168 174 - Store 141(j) 175 - Branch 147 - 149: Label - Branch 127 - 127: Label - 177: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 112 - 178: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 113 113 12 12 - 176: 7(int) Load 117(i) - 179: 7(int) IAdd 176 174 - Store 117(i) 179 - Branch 124 - 126: Label - 187: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 180 - 188: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 181 181 12 12 - 186: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 184 183(chunkK) 121 - Store 183(chunkK) 12 - Branch 189 - 189: Label - 193: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 180 - 194: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 181 181 12 12 - LoopMerge 191 192 None - Branch 195 - 195: Label - 197: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 180 - 198: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 181 181 12 12 - 196: 7(int) Load 183(chunkK) - 199: 134(bool) ULessThan 196 50(K) - BranchConditional 199 190 191 - 190: Label - 206: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 200 - 207: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 201 201 12 12 - 205: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 203 202(k) 121 - Store 202(k) 12 - Branch 208 - 208: Label - 212: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 200 - 213: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 201 201 12 12 - LoopMerge 210 211 Unroll - Branch 214 - 214: Label - 216: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 200 - 217: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 201 201 12 12 - 215: 7(int) Load 202(k) - 219: 134(bool) ULessThan 215 218 - BranchConditional 219 209 210 - 209: Label - 233: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 200 - 234: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 223 223 12 12 - 232: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 230 229(matA) 121 - 240: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 235 - 241: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 236 236 12 12 - 239: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 238 237(i) 121 - Store 237(i) 12 - Branch 242 - 242: Label - 246: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 235 - 247: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 236 236 12 12 - LoopMerge 244 245 Unroll - Branch 248 - 248: Label - 250: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 235 - 251: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 236 236 12 12 - 249: 7(int) Load 237(i) - 252: 134(bool) ULessThan 249 24 - BranchConditional 252 243 244 - 243: Label - 254: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 235 - 255: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 256 256 12 12 - 253: 7(int) Load 237(i) - 259: 257(ptr) AccessChain 229(matA) 253 - 262: 260(ptr) AccessChain 80(Ash) 12 - 264: 220 CooperativeMatrixLoadKHR 262 263 12 MakePointerVisibleKHR NonPrivatePointerKHR 24 - Store 259 264 - Branch 245 - 245: Label - 266: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 235 - 267: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 236 236 12 12 - 265: 7(int) Load 237(i) - 268: 7(int) IAdd 265 174 - Store 237(i) 268 - Branch 242 - 244: Label - 280: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 200 - 281: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 272 272 12 12 - 279: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 277 276(matB) 121 - 287: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 282 - 288: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 283 283 12 12 - 286: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 285 284(j) 121 - Store 284(j) 12 - Branch 289 - 289: Label - 293: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 282 - 294: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 283 283 12 12 - LoopMerge 291 292 Unroll - Branch 295 - 295: Label - 297: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 282 - 298: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 283 283 12 12 - 296: 7(int) Load 284(j) - 299: 134(bool) ULessThan 296 24 - BranchConditional 299 290 291 - 290: Label - 301: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 282 - 302: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 303 303 12 12 - 300: 260(ptr) AccessChain 84(Bsh) 12 - 304: 269 CooperativeMatrixLoadKHR 300 263 12 MakePointerVisibleKHR NonPrivatePointerKHR 24 - Store 276(matB) 304 - 311: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 305 - 312: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 306 306 12 12 - 310: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 309 308(i) 121 - Store 308(i) 12 - Branch 313 - 313: Label - 317: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 305 - 318: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 306 306 12 12 - LoopMerge 315 316 Unroll - Branch 319 - 319: Label - 321: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 305 - 322: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 306 306 12 12 - 320: 7(int) Load 308(i) - 323: 134(bool) ULessThan 320 24 - BranchConditional 323 314 315 - 314: Label - 325: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 305 - 326: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 327 327 12 12 - 324: 7(int) Load 308(i) - 328: 7(int) Load 284(j) - 329: 7(int) Load 308(i) - 330: 257(ptr) AccessChain 229(matA) 329 - 331: 220 Load 330 - 332: 269 Load 276(matB) - 333: 7(int) Load 308(i) - 334: 7(int) Load 284(j) - 335: 165(ptr) AccessChain 106(result) 333 334 - 336: 94 Load 335 - 337: 94 CooperativeMatrixMulAddKHR 331 332 336 - 338: 165(ptr) AccessChain 106(result) 324 328 - Store 338 337 - Branch 316 - 316: Label - 340: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 305 - 341: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 306 306 12 12 - 339: 7(int) Load 308(i) - 342: 7(int) IAdd 339 174 - Store 308(i) 342 - Branch 313 - 315: Label - Branch 292 - 292: Label - 344: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 282 - 345: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 283 283 12 12 - 343: 7(int) Load 284(j) - 346: 7(int) IAdd 343 174 - Store 284(j) 346 - Branch 289 - 291: Label - Branch 211 - 211: Label - 348: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 200 - 349: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 201 201 12 12 - 347: 7(int) Load 202(k) - 350: 7(int) IAdd 347 174 - Store 202(k) 350 - Branch 208 - 210: Label - Branch 192 - 192: Label - 352: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 180 - 353: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 181 181 12 12 - 351: 7(int) Load 183(chunkK) - 354: 7(int) IAdd 351 46(TILE_K) - Store 183(chunkK) 354 - Branch 189 - 191: Label - 360: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 355 - 361: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 356 356 12 12 - 359: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 358 357(i) 121 - Store 357(i) 12 - Branch 362 - 362: Label - 366: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 355 - 367: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 356 356 12 12 - LoopMerge 364 365 Unroll - Branch 368 - 368: Label - 370: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 355 - 371: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 356 356 12 12 - 369: 7(int) Load 357(i) - 372: 134(bool) ULessThan 369 24 - BranchConditional 372 363 364 - 363: Label - 378: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 373 - 379: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 374 374 12 12 - 377: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 28(DebugDeclare) 376 375(j) 121 - Store 375(j) 12 - Branch 380 - 380: Label - 384: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 373 - 385: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 374 374 12 12 - LoopMerge 382 383 Unroll - Branch 386 - 386: Label - 388: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 373 - 389: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 374 374 12 12 - 387: 7(int) Load 375(j) - 390: 134(bool) ULessThan 387 24 - BranchConditional 390 381 382 - 381: Label - 392: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 373 - 393: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 394 394 12 12 - 391: 7(int) Load 357(i) - 395: 7(int) Load 375(j) - 396: 165(ptr) AccessChain 106(result) 391 395 - 397: 94 Load 396 - 400: 398(ptr) AccessChain 70(outputO) 263 12 - CooperativeMatrixStoreKHR 400 397 263 12 None - Branch 383 - 383: Label - 402: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 373 - 403: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 374 374 12 12 - 401: 7(int) Load 375(j) - 404: 7(int) IAdd 401 174 - Store 375(j) 404 - Branch 380 - 382: Label - Branch 365 - 365: Label - 406: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 355 - 407: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 356 356 12 12 - 405: 7(int) Load 357(i) - 408: 7(int) IAdd 405 174 - Store 357(i) 408 - Branch 362 - 364: Label - 409: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 23(DebugScope) 17 - 410: 4 ExtInst 1(NonSemantic.Shader.DebugInfo.100) 103(DebugLine) 18 411 411 12 12 - Return - FunctionEnd diff --git a/gtests/CMakeLists.txt b/gtests/CMakeLists.txt index 2112577549..c957058c6e 100644 --- a/gtests/CMakeLists.txt +++ b/gtests/CMakeLists.txt @@ -58,6 +58,7 @@ if(GLSLANG_TESTS) ${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/StructName.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SpvPatternTest.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/SpvDebugInfoTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/VkRelaxed.FromFile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GlslMapIO.FromFile.cpp ${CMAKE_CURRENT_SOURCE_DIR}/UboUnsizedArray.cpp) diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index e9bcc4fe69..ee1ec59a1a 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -85,7 +85,6 @@ using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam>; using GlslSpirvDebugInfoTest = GlslangTest<::testing::TestWithParam>; using GlslNonSemanticShaderDebugInfoTest = GlslangTest<::testing::TestWithParam>; -using GlslNonSemanticShaderDebugInfoSpirv13Test = GlslangTest<::testing::TestWithParam>; using GlslNonSemanticShaderDebugInfoVulkanLatestTest = GlslangTest<::testing::TestWithParam>; // Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully @@ -279,13 +278,6 @@ TEST_P(GlslNonSemanticShaderDebugInfoTest, FromFile) "/baseResults/", false, true, true); } -TEST_P(GlslNonSemanticShaderDebugInfoSpirv13Test, FromFile) -{ - loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), Source::GLSL, Semantics::Vulkan, - glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_3, Target::Spv, true, "", - "/baseResults/", false, true, true); -} - TEST_P(GlslNonSemanticShaderDebugInfoVulkanLatestTest, FromFile) { loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), Source::GLSL, Semantics::Vulkan, @@ -1157,14 +1149,6 @@ INSTANTIATE_TEST_SUITE_P( FileNameAsCustomTestSuffix ); -INSTANTIATE_TEST_SUITE_P( - Glsl, GlslNonSemanticShaderDebugInfoSpirv13Test, - ::testing::ValuesIn(std::vector({ - "spv.debuginfo.coopmatKHR.comp", - })), - FileNameAsCustomTestSuffix -); - INSTANTIATE_TEST_SUITE_P( Glsl, GlslNonSemanticShaderDebugInfoVulkanLatestTest, ::testing::ValuesIn(std::vector({ diff --git a/gtests/SpvDebugInfoTest.cpp b/gtests/SpvDebugInfoTest.cpp new file mode 100644 index 0000000000..4df374ac9b --- /dev/null +++ b/gtests/SpvDebugInfoTest.cpp @@ -0,0 +1,328 @@ +// Copyright (C) 2026 NVIDIA Corporation. +// +// 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. + +// Tests for NonSemantic.Shader.DebugInfo (NSDI) features. + +#include "TestFixture.h" +#include "glslang/Public/ResourceLimits.h" +#include +#include +#include + +namespace glslangtest { +namespace { + +class SpvDebugInfoTest : public ::testing::Test { +protected: + // Compile a GLSL compute shader with NonSemantic debug info enabled, targeting + // Vulkan 1.1 / SPIR-V 1.3, and return the disassembly. + std::string compileWithDebugInfo(const std::string& source) + { + glslang::TShader shader(EShLangCompute); + const char* str = source.c_str(); + shader.setStrings(&str, 1); + shader.setEnvInput(glslang::EShSourceGlsl, EShLangCompute, + glslang::EShClientVulkan, 110); + shader.setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_1); + shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_3); + + EShMessages messages = static_cast(EShMsgDefault | EShMsgDebugInfo); + if (!shader.parse(GetDefaultResources(), 450, false, messages)) + return "COMPILATION_FAILED: " + std::string(shader.getInfoLog()); + + glslang::TProgram program; + program.addShader(&shader); + if (!program.link(messages)) + return "LINKING_FAILED: " + std::string(program.getInfoLog()); + + glslang::SpvOptions opts; + opts.generateDebugInfo = true; + opts.emitNonSemanticShaderDebugInfo = true; + opts.disableOptimizer = true; + + std::vector spirv; + glslang::GlslangToSpv(*program.getIntermediate(EShLangCompute), spirv, &opts); + + std::ostringstream out; + spv::Disassemble(out, spirv); + return out.str(); + } +}; + +// DebugTypeVectorIdEXT (opcode 109) must be emitted for OpTypeCooperativeVectorNV +// when NonSemantic debug info is enabled. +TEST_F(SpvDebugInfoTest, CooperativeVectorNVEmitsDebugTypeVectorIdEXT) +{ + const std::string source = R"( +#version 450 core +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_NV_cooperative_vector : enable +#extension GL_EXT_shader_explicit_arithmetic_types : enable +layout(local_size_x = 64) in; +layout(set = 0, binding = 0) buffer B { float data[]; } buf; +void main() { + coopvecNV v = coopvecNV(0.0); + v = v + v; + buf.data[gl_GlobalInvocationID.x] = v[0]; +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("DebugTypeVectorIdEXT"), std::string::npos) + << "Expected DebugTypeVectorIdEXT in disassembly.\nSPIR-V:\n" << spirv; + EXPECT_NE(spirv.find("TypeCooperativeVectorNV"), std::string::npos) + << "Expected TypeCooperativeVectorNV in disassembly.\nSPIR-V:\n" << spirv; +} + +// DebugTypeVectorIdEXT must also be emitted when the component count is a +// specialization constant (OpSpecConstant), since the spec allows any constant +// instruction for the ComponentCount operand. +TEST_F(SpvDebugInfoTest, CooperativeVectorNVSpecConstCountEmitsDebugTypeVectorIdEXT) +{ + const std::string source = R"( +#version 450 core +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_NV_cooperative_vector : enable +#extension GL_EXT_shader_explicit_arithmetic_types : enable +layout(local_size_x = 64) in; +layout(constant_id = 0) const uint N = 16; +layout(set = 0, binding = 0) buffer B { float data[]; } buf; +void main() { + coopvecNV v = coopvecNV(1.0); + buf.data[gl_GlobalInvocationID.x] = v[0]; +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("DebugTypeVectorIdEXT"), std::string::npos) + << "Expected DebugTypeVectorIdEXT with spec-constant count.\nSPIR-V:\n" << spirv; +} + +// DebugTypeCooperativeMatrixKHR (opcode 110) must replace the former +// opaque-composite workaround for OpTypeCooperativeMatrixKHR. +TEST_F(SpvDebugInfoTest, CooperativeMatrixKHREmitsDebugTypeCooperativeMatrixKHR) +{ + const std::string source = R"( +#version 450 core +#pragma use_vulkan_memory_model +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable +layout(local_size_x = 32) in; +layout(set = 0, binding = 0) buffer B { float16_t data[]; } buf; +void main() { + coopmat m = + coopmat(float16_t(0.0)); + coopMatStore(m, buf.data, 0, 0, gl_CooperativeMatrixLayoutRowMajor); +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("DebugTypeCooperativeMatrixKHR"), std::string::npos) + << "Expected DebugTypeCooperativeMatrixKHR in disassembly.\nSPIR-V:\n" << spirv; + // The old opaque-composite workaround must not appear. + EXPECT_EQ(spirv.find("coopmat<"), std::string::npos) + << "Opaque-composite workaround should not appear in disassembly.\nSPIR-V:\n" << spirv; +} + +// DebugTypeCooperativeMatrixKHR must be emitted when Rows and Columns are +// specialization constants (OpSpecConstant), since the spec allows any constant +// instruction for those operands. +TEST_F(SpvDebugInfoTest, CooperativeMatrixKHRSpecConstDimsEmitsDebugType) +{ + const std::string source = R"( +#version 450 core +#pragma use_vulkan_memory_model +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable +layout(local_size_x = 32) in; +layout(constant_id = 0) const uint M = 16; +layout(constant_id = 1) const uint N = 16; +layout(set = 0, binding = 0) buffer B { float16_t data[]; } buf; +void main() { + coopmat m = + coopmat(float16_t(0.0)); + coopMatStore(m, buf.data, 0, 0, gl_CooperativeMatrixLayoutRowMajor); +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("DebugTypeCooperativeMatrixKHR"), std::string::npos) + << "Expected DebugTypeCooperativeMatrixKHR with spec-constant dims.\nSPIR-V:\n" << spirv; +} + +// DebugTypeCooperativeMatrixKHR must be emitted for each distinct (component, +// scope, rows, cols, use) tuple -- MatrixUseA, MatrixUseB, and MatrixUseAccumulator +// with different component types all produce separate debug type instructions. +TEST_F(SpvDebugInfoTest, CooperativeMatrixKHRMultipleUsesEmitDistinctDebugTypes) +{ + const std::string source = R"( +#version 450 core +#pragma use_vulkan_memory_model +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable +layout(local_size_x = 32) in; +layout(set = 0, binding = 0) buffer B { float16_t data[]; } buf; +void main() { + coopmat matA; + coopmat matB; + coopmat matC = + coopmat(0.0); + matC = coopMatMulAdd(matA, matB, matC); + coopMatStore(matC, buf.data, 0, 0, gl_CooperativeMatrixLayoutRowMajor); +} +)"; + std::string spirv = compileWithDebugInfo(source); + + // Count occurrences of DebugTypeCooperativeMatrixKHR: one for each distinct + // (component, scope, rows, cols, use) combination used above. + size_t count = 0; + size_t pos = 0; + while ((pos = spirv.find("DebugTypeCooperativeMatrixKHR", pos)) != std::string::npos) { + ++count; + pos += 1; + } + EXPECT_GE(count, 3u) + << "Expected at least 3 DebugTypeCooperativeMatrixKHR instructions.\nSPIR-V:\n" << spirv; +} + +// DebugTypeBasic for bfloat16_t must include the FPEncoding operand +// (BFloat16KHR = 0) as the fifth argument. +TEST_F(SpvDebugInfoTest, BFloat16EmitsDebugTypeBasicWithFPEncoding) +{ + const std::string source = R"( +#version 450 core +#extension GL_EXT_bfloat16 : require +#extension GL_EXT_shader_explicit_arithmetic_types : enable +layout(local_size_x = 64) in; +layout(set = 0, binding = 0) buffer B { float data[]; } buf; +void main() { + bfloat16_t bf = bfloat16_t(1.0); + buf.data[gl_GlobalInvocationID.x] = float(bf); +} +)"; + std::string spirv = compileWithDebugInfo(source); + // The DebugTypeBasic for bfloat16_t should contain the name "bfloat16_t". + EXPECT_NE(spirv.find("\"bfloat16_t\""), std::string::npos) + << "Expected \"bfloat16_t\" string in debug type.\nSPIR-V:\n" << spirv; +} + +// DebugTypeBasic for floate4m3_t must include the FPEncoding operand +// (Float8E4M3EXT = 4214). +TEST_F(SpvDebugInfoTest, Float8E4M3EmitsDebugTypeBasicWithFPEncoding) +{ + const std::string source = R"( +#version 450 core +#extension GL_EXT_bfloat16 : require +#extension GL_EXT_float_e4m3 : require +#extension GL_EXT_shader_explicit_arithmetic_types : enable +layout(local_size_x = 64) in; +layout(set = 0, binding = 0) buffer B { float data[]; } buf; +void main() { + floate4m3_t f = floate4m3_t(2.0); + buf.data[gl_GlobalInvocationID.x] = float(f); +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("\"floate4m3_t\""), std::string::npos) + << "Expected \"floate4m3_t\" string in debug type.\nSPIR-V:\n" << spirv; +} + +// DebugTypeBasic for floate5m2_t must include the FPEncoding operand +// (Float8E5M2EXT = 4215). +TEST_F(SpvDebugInfoTest, Float8E5M2EmitsDebugTypeBasicWithFPEncoding) +{ + const std::string source = R"( +#version 450 core +#extension GL_EXT_bfloat16 : require +#extension GL_EXT_float_e5m2 : require +#extension GL_EXT_shader_explicit_arithmetic_types : enable +layout(local_size_x = 64) in; +layout(set = 0, binding = 0) buffer B { float data[]; } buf; +void main() { + floate5m2_t f = floate5m2_t(3.0); + buf.data[gl_GlobalInvocationID.x] = float(f); +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("\"floate5m2_t\""), std::string::npos) + << "Expected \"floate5m2_t\" string in debug type.\nSPIR-V:\n" << spirv; +} + +// When a version-101 opcode is emitted the import string must be promoted to +// NonSemantic.Shader.DebugInfo.101. +TEST_F(SpvDebugInfoTest, Version101OpcodePromotesImportStringTo101) +{ + // DebugTypeCooperativeMatrixKHR is a version-101 opcode; using it must + // cause the import string to read ".101", not ".100". + const std::string source = R"( +#version 450 core +#pragma use_vulkan_memory_model +#extension GL_KHR_memory_scope_semantics : enable +#extension GL_KHR_cooperative_matrix : enable +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable +layout(local_size_x = 32) in; +layout(set = 0, binding = 0) buffer B { float16_t data[]; } buf; +void main() { + coopmat m = + coopmat(float16_t(0.0)); + coopMatStore(m, buf.data, 0, 0, gl_CooperativeMatrixLayoutRowMajor); +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("\"NonSemantic.Shader.DebugInfo.101\""), std::string::npos) + << "Expected import string NonSemantic.Shader.DebugInfo.101.\nSPIR-V:\n" << spirv; + EXPECT_EQ(spirv.find("\"NonSemantic.Shader.DebugInfo.100\""), std::string::npos) + << "Import string must not be .100 when version-101 opcodes are used.\nSPIR-V:\n" << spirv; +} + +// When only version-100 opcodes are emitted the import string must stay at +// NonSemantic.Shader.DebugInfo.100 and must not be promoted to .101. +TEST_F(SpvDebugInfoTest, Version100OnlyKeepsImportStringAt100) +{ + const std::string source = R"( +#version 450 core +layout(local_size_x = 64) in; +layout(set = 0, binding = 0) buffer B { float data[]; } buf; +void main() { + float x = buf.data[gl_GlobalInvocationID.x]; + buf.data[gl_GlobalInvocationID.x] = x * 2.0; +} +)"; + std::string spirv = compileWithDebugInfo(source); + EXPECT_NE(spirv.find("\"NonSemantic.Shader.DebugInfo.100\""), std::string::npos) + << "Expected import string NonSemantic.Shader.DebugInfo.100.\nSPIR-V:\n" << spirv; + EXPECT_EQ(spirv.find("\"NonSemantic.Shader.DebugInfo.101\""), std::string::npos) + << "Import string must not be .101 when only version-100 opcodes are used.\nSPIR-V:\n" << spirv; +} + +} // namespace +} // namespace glslangtest diff --git a/known_good.json b/known_good.json index 1dfa5dc702..14833d394f 100644 --- a/known_good.json +++ b/known_good.json @@ -5,14 +5,14 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit": "fbe4f3ad913c44fe8700545f8ffe35d1382b7093" + "commit": "8d245e02504488aaa51ab561cfd8725b7916c91d" }, { "name" : "spirv-tools/external/spirv-headers", "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Headers", "subdir" : "External/spirv-tools/external/spirv-headers", - "commit" : "04f10f650d514df88b76d25e83db360142c7b174" + "commit": "ad9184e76a66b1001c29db9b0a3e87f646c64de0" }, { "name": "googletest", diff --git a/license-checker.cfg b/license-checker.cfg index 305a04aa61..8298857ebe 100644 --- a/license-checker.cfg +++ b/license-checker.cfg @@ -35,7 +35,7 @@ "SPIRV/GLSL.*.h", "SPIRV/NonSemanticDebugPrintf.h", - "SPIRV/NonSemanticShaderDebugInfo100.h", + "SPIRV/NonSemanticShaderDebugInfo.h", "SPIRV/spirv.hpp11" ] }