Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions source/slang/slang-emit-spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3468,7 +3468,8 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
spvBlock,
spvFunc,
irDebugFunc,
irFunc->getDataType());
irFunc->getDataType(),
irFunc);
}
if (funcDebugScope)
{
Expand Down Expand Up @@ -7964,7 +7965,8 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
SpvInst* firstBlock,
SpvInst* spvFunc,
IRDebugFunction* debugFunc,
IRFuncType* debugType)
IRFuncType* debugType,
IRFunc* irFunc = nullptr)
{
SpvInst* debugFuncInfo = nullptr;
if (debugFunc && m_mapIRInstToSpvInst.tryGetValue(debugFunc, debugFuncInfo))
Expand Down Expand Up @@ -8002,6 +8004,11 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
builder.getIntValue(builder.getUIntType(), 0),
debugFunc->getLine());

if (irFunc)
{
registerDebugInst(irFunc, debugFuncInfo);
}

if (firstBlock && spvFunc)
{
emitOpDebugFunctionDefinition(
Expand Down
21 changes: 21 additions & 0 deletions tests/spirv/debug-local-variable-scope.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage fragment -g2 -emit-spirv-directly

Texture2D testTex : register(t0);
SamplerState testSampler : register(s0);

struct PSIn
{
float4 pos : SV_Position;
};

float4 main(PSIn input) : SV_TARGET
{
uint4 testPos = input.pos;
float bias = -1.0;
float2 tc = testPos.xy / 32.0;
float4 colVal = testTex.SampleBias(testSampler, tc, bias);
return float4(colVal.xyz, 1.0);
}

// CHECK: %[[FUNC_ID:[0-9]+]] = OpExtInst %void {{.*}} DebugFunction %{{[0-9]+}}
// CHECK: DebugLocalVariable %{{[0-9]+}} %{{[0-9]+}} %{{[0-9]+}} %{{.*}} %{{.*}} %[[FUNC_ID]]
Loading