From 73a61edda8893901acad05bb4e7d3110db5041a8 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 28 Feb 2024 22:57:07 -0800 Subject: [SPIRV] Add NonSemanticDebugInfo for step-through debugging. (#3644) * [SPIRV] Add NonSemanticDebugInfo for step-through debugging. * Fix. * Fix. --- source/slang/slang-emit-spirv-ops-debug-info-ext.h | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'source/slang/slang-emit-spirv-ops-debug-info-ext.h') diff --git a/source/slang/slang-emit-spirv-ops-debug-info-ext.h b/source/slang/slang-emit-spirv-ops-debug-info-ext.h index d1ca9665a..3d2a10aab 100644 --- a/source/slang/slang-emit-spirv-ops-debug-info-ext.h +++ b/source/slang/slang-emit-spirv-ops-debug-info-ext.h @@ -24,5 +24,104 @@ SpvInst* emitOpDebugLine(SpvInstParent* parent, IRInst* inst, const T& idResultT return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(103), source, lineStart, lineEnd, colStart, colEnd); } +// https://github.com/KhronosGroup/SPIRV-Registry/blob/main/nonsemantic/NonSemantic.Shader.DebugInfo.100.asciidoc#DebugFunction +template +SpvInst* emitOpDebugFunction(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* name, SpvInst* type, IRInst* source, IRInst* lineStart, IRInst* colStart, SpvInst* scope, IRInst* linkageName, IRInst* flag, IRInst* scopeLine) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(20), name, type, source, lineStart, colStart, scope, linkageName, flag, scopeLine); +} + +template +SpvInst* emitOpDebugFunctionDefinition(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, SpvInst* debugFunc, SpvInst* spvFunc) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(101), debugFunc, spvFunc); +} + +template +SpvInst* emitOpDebugTypeFunction(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* flags, SpvInst* returnType, const Ts& argTypes) +{ + static_assert(isSingular); + static_assert(isPlural); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(8), flags, returnType, argTypes); +} + +template +SpvInst* emitOpDebugTypeComposite(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* name, IRInst* tag, IRInst* source, IRInst* line, IRInst* col, SpvInst* scope, IRInst* linkageName, IRInst* size, IRInst* flags, const Ts& members) +{ + static_assert(isSingular); + static_assert(isPlural); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(10), name, tag, source, line, col, scope, linkageName, size, flags, members); +} + +template +SpvInst* emitOpDebugTypeMember(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* name, SpvInst* type, IRInst* source, IRInst* line, IRInst* col, IRInst* offset, IRInst* size, IRInst* flags) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(11), name, type, source, line, col, offset, size, flags); +} + +template +SpvInst* emitOpDebugTypeArray(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, SpvInst* baseType, IRInst* elementCount) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(5), baseType, elementCount); +} + +template +SpvInst* emitOpDebugTypeBasic(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* name, IRInst* size, IRInst* encoding, IRInst* flags) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(2), name, size, encoding, flags); +} + +template +SpvInst* emitOpDebugTypeVector(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, SpvInst* baseType, IRInst* elementCount) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(6), baseType, elementCount); +} + +template +SpvInst* emitOpDebugTypeMatrix(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, SpvInst* vectorType, IRInst* vectorCount, IRInst* columnMajor) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(108), vectorType, vectorCount, columnMajor); +} + +template +SpvInst* emitOpDebugScope(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, SpvInst* scope) +{ + static_assert(isSingular); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(23), scope); +} + +template +SpvInst* emitOpDebugLocalVariable(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* name, SpvInst* type, IRInst* source, IRInst* line, IRInst* col, SpvInst* scope, IRInst* flags, IRInst* argIndex) +{ + static_assert(isSingular); + if (argIndex) + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(26), name, type, source, line, col, scope, flags, argIndex); + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(26), name, type, source, line, col, scope, flags); +} + +template +SpvInst* emitOpDebugValue(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, IRInst* localVar, IRInst* value, SpvInst* expression, const Ts& indices) +{ + static_assert(isSingular); + static_assert(isPlural); + + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(29), localVar, value, expression, indices); +} + +template +SpvInst* emitOpDebugExpression(SpvInstParent* parent, IRInst* inst, const T& idResultType, SpvInst* set, const Ts& operations) +{ + static_assert(isSingular); + static_assert(isPlural); + + return emitInst(parent, inst, SpvOpExtInst, idResultType, kResultID, set, SpvWord(31), operations); +} #endif // SLANG_IN_SPIRV_EMIT_CONTEXT -- cgit v1.2.3