Skip to content
Open
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
9 changes: 7 additions & 2 deletions tools/clang/lib/SPIRV/DeclResultIdMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var) {

SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var,
QualType type) {
const auto name = var->getName();
const bool isGroupShared = var->hasAttr<HLSLGroupSharedAttr>();
const bool hasInlineSpirvSC = var->hasAttr<VKStorageClassExtAttr>();
const bool isACSBuffer =
Expand Down Expand Up @@ -1217,7 +1218,12 @@ SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var,
createGlobalsCBuffer(var);

auto *varInstr = astDecls[var].instr;
return varInstr ? cast<SpirvVariable>(varInstr) : nullptr;
if (varInstr) {
createDebugGlobalVariable(cast<SpirvVariable>(varInstr), type, loc, name);
return cast<SpirvVariable>(varInstr);
}

return nullptr;
}

if (isResourceOnlyStructure(type)) {
Expand Down Expand Up @@ -1245,7 +1251,6 @@ SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var,
needsFlatteningCompositeResources = true;
}

const auto name = var->getName();
SpirvVariable *varInstr = spvBuilder.addModuleVar(
type, storageClass, var->hasAttr<HLSLPreciseAttr>(),
var->hasAttr<HLSLNoInterpolationAttr>(), name, llvm::None, loc);
Expand Down
22 changes: 13 additions & 9 deletions tools/clang/test/CodeGenSPIRV/shader.debug.debuglexicalblock.hlsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// RUN: %dxc -T ps_6_0 -E main -fspv-debug=vulkan -fcgl %s -spirv | FileCheck %s

// CHECK: [[debugSet:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
// CHECK: [[debugSource:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugSource
// CHECK: [[main:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugFunction
// CHECK: [[mainFnLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_13 %uint_1 [[main]]
// CHECK: [[whileLoopLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_21 %uint_3 [[mainFnLexBlock]]
// CHECK: [[ifStmtLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_26 %uint_20 [[whileLoopLexBlock]]
// CHECK: [[tempLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_28 %uint_7 [[ifStmtLexBlock]]
// CHECK: [[forLoopLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_15 %uint_12 [[mainFnLexBlock]]
// CHECK: [[debugSet:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
// CHECK: [[foo:%[0-9]+]] = OpString "foo"
// CHECK: [[debugSource:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugSource
// CHECK: [[main:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugFunction
// CHECK: [[mainFnLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_17 %uint_1 [[main]]
// CHECK: [[whileLoopLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_25 %uint_3 [[mainFnLexBlock]]
// CHECK: [[ifStmtLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_30 %uint_20 [[whileLoopLexBlock]]
// CHECK: [[tempLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_32 %uint_7 [[ifStmtLexBlock]]
// CHECK: [[forLoopLexBlock:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugLexicalBlock [[debugSource]] %uint_19 %uint_12 [[mainFnLexBlock]]
// CHECK: [[globalVar:%[0-9]+]] = OpExtInst %void [[debugSet]] DebugGlobalVariable [[foo]] %25 [[debugSource]] %uint_14 %uint_15

uniform float foo;

float4 main(float4 color : COLOR) : SV_TARGET
{
Expand All @@ -31,6 +35,6 @@ float4 main(float4 color : COLOR) : SV_TARGET
}
}

return color + c;
return color + c * foo;
}