Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
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
16 changes: 8 additions & 8 deletions tools/clang/lib/SPIRV/DebugTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,16 @@ DebugTypeVisitor::lowerToDebugType(const SpirvType *spirvType) {
auto *arrType = dyn_cast<ArrayType>(spirvType);
SpirvDebugInstruction *elemDebugType =
lowerToDebugType(arrType->getElementType());

llvm::SmallVector<uint32_t, 4> counts;
if (auto *dbgArrType = dyn_cast<SpirvDebugTypeArray>(elemDebugType)) {
auto &counts = dbgArrType->getElementCount();
// Note that this is reverse order of dimension. We must iterate the
// count array in a reverse order when we actually emit it.
counts.push_back(arrType->getElementCount());
debugType = dbgArrType;
} else {
debugType = spvContext.getDebugTypeArray(spirvType, elemDebugType,
{arrType->getElementCount()});
counts.insert(counts.end(), dbgArrType->getElementCount().begin(),
dbgArrType->getElementCount().end());
elemDebugType = dbgArrType->getElementType();
}
counts.push_back(arrType->getElementCount());

debugType = spvContext.getDebugTypeArray(spirvType, elemDebugType, counts);
break;
}
case SpirvType::TK_Vector: {
Expand Down
3 changes: 3 additions & 0 deletions tools/clang/lib/SPIRV/EmitVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1343,13 +1343,16 @@ bool EmitVisitor::visit(SpirvDebugTypeArray *inst) {
curInst.push_back(inst->getDebugOpcode());
curInst.push_back(
getOrAssignResultId<SpirvInstruction>(inst->getElementType()));

// This is a reverse order of dimensions, thereby emitting in a reverse order.
for (auto it = inst->getElementCount().rbegin();
it != inst->getElementCount().rend(); ++it) {
const auto countId = typeHandler.getOrCreateConstantInt(
llvm::APInt(32, *it), context.getUIntType(32),
/* isSpecConst */ false);
curInst.push_back(countId);
}

finalizeInstruction(&richDebugInfo);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Run: %dxc -T ps_6_0 -E main -fspv-debug=rich

struct UBO
{
float4x4 a;
float4x4 b[3];
float4 c;
};

cbuffer ubo : register(b0) { UBO ubo; }

// CHECK: [[bName:%\d+]] = OpString "b"
// CHECK: [[aName:%\d+]] = OpString "a"
// CHECK: [[fooName:%\d+]] = OpString "foo"

// CHECK: [[matf4v4_arr3:%\d+]] = OpExtInst %void [[ext:%\d+]] DebugTypeArray [[dbg_f:%\d+]] %uint_3 %uint_4 %uint_4
// CHECK: OpExtInst %void [[ext]] DebugTypeMember [[bName]] [[matf4v4_arr3]]
// CHECK: [[matf4v4:%\d+]] = OpExtInst %void [[ext]] DebugTypeArray [[dbg_f]] %uint_4 %uint_4
// CHECK: OpExtInst %void [[ext]] DebugTypeMember [[aName]] [[matf4v4]]
// CHECK: OpExtInst %void [[ext]] DebugLocalVariable [[fooName]] [[matf4v4]]

void main() {
float4x4 foo = ubo.a;
foo += ubo.b[0] * ubo.c[0];
}
2 changes: 1 addition & 1 deletion tools/clang/test/CodeGenSPIRV/rich.debug.type.array.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// CHECK: [[bool:%\d+]] = OpExtInst %void [[set]] DebugTypeBasic [[boolName]] %uint_32 Boolean
// CHECK: [[int:%\d+]] = OpExtInst %void [[set]] DebugTypeBasic [[intName]] %uint_32 Signed
// CHECK: [[uint:%\d+]] = OpExtInst %void [[set]] DebugTypeBasic [[uintName]] %uint_32 Unsigned
// CHECK: [[float:%\d+]] = OpExtInst %void [[set]] DebugTypeBasic [[floatName]] %uint_32 Float
// CHECK: {{%\d+}} = OpExtInst %void [[set]] DebugTypeArray [[S]] %uint_8
// CHECK: [[boolv4:%\d+]] = OpExtInst %void [[set]] DebugTypeVector [[bool]] 4
// CHECK: {{%\d+}} = OpExtInst %void [[set]] DebugTypeArray [[boolv4]] %uint_7
// CHECK: [[float:%\d+]] = OpExtInst %void [[set]] DebugTypeBasic [[floatName]] %uint_32 Float
// CHECK: {{%\d+}} = OpExtInst %void [[set]] DebugTypeArray [[float]] %uint_8 %uint_4
// CHECK: {{%\d+}} = OpExtInst %void [[set]] DebugTypeArray [[int]] %uint_8
// CHECK: {{%\d+}} = OpExtInst %void [[set]] DebugTypeArray [[uint]] %uint_4
Expand Down
4 changes: 4 additions & 0 deletions tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,10 @@ TEST_F(FileTest, RichDebugInfoTypeArray) {
runFileTest("rich.debug.type.array.hlsl", Expect::Success,
/*runValidation*/ runValidationForRichDebugInfo);
}
TEST_F(FileTest, RichDebugInfoTypeArrayFromSameType) {
runFileTest("rich.debug.type.array-from-same-type.hlsl", Expect::Success,
/*runValidation*/ runValidationForRichDebugInfo);
}
TEST_F(FileTest, RichDebugInfoTypeFunction) {
runFileTest("rich.debug.type.function.hlsl", Expect::Success,
/*runValidation*/ runValidationForRichDebugInfo);
Expand Down