Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit DebugTypePointer when non-semantic debug info is enabled. #3433

Merged
merged 5 commits into from
Dec 28, 2023
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
33 changes: 33 additions & 0 deletions SPIRV/SpvBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ Id Builder::makePointer(StorageClass storageClass, Id pointee)
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);

if (emitNonSemanticShaderDebugInfo) {
const Id debugResultId = makePointerDebugType(storageClass, pointee);
debugId[type->getResultId()] = debugResultId;
}

return type->getResultId();
}

Expand Down Expand Up @@ -1070,6 +1075,34 @@ Id Builder::makeCompositeDebugType(std::vector<Id> const& memberTypes, char cons
return type->getResultId();
}

Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType)
{
const Id debugBaseType = debugId[baseType];
if (!debugBaseType) {
return makeDebugInfoNone();
}
const Id scID = makeUintConstant(storageClass);
for (Instruction* otherType : groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer]) {
if (otherType->getIdOperand(2) == debugBaseType &&
otherType->getIdOperand(3) == scID) {
return otherType->getResultId();
}
}

Instruction* type = new Instruction(getUniqueId(), makeVoidType(), OpExtInst);
type->addIdOperand(nonSemanticShaderDebugInfo);
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer);
type->addIdOperand(debugBaseType);
type->addIdOperand(scID);
type->addIdOperand(makeUintConstant(0));

groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypePointer].push_back(type);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);

return type->getResultId();
}

Id Builder::makeDebugSource(const Id fileName) {
if (debugSourceId.find(fileName) != debugSourceId.end())
return debugSourceId[fileName];
Expand Down
1 change: 1 addition & 0 deletions SPIRV/SpvBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class Builder {
Id makeMemberDebugType(Id const memberType, DebugTypeLoc const& debugTypeLoc);
Id makeCompositeDebugType(std::vector<Id> const& memberTypes, char const*const name,
NonSemanticShaderDebugInfo100DebugCompositeType const tag, bool const isOpaqueType = false);
Id makePointerDebugType(StorageClass storageClass, Id const baseType);
Id makeDebugSource(const Id fileName);
Id makeDebugCompilationUnit();
Id createDebugGlobalVariable(Id const type, char const*const name, Id const variable);
Expand Down
233 changes: 122 additions & 111 deletions Test/baseResults/spv.debuginfo.bufferref.glsl.frag.out

Large diffs are not rendered by default.

2,330 changes: 1,172 additions & 1,158 deletions Test/baseResults/spv.debuginfo.glsl.comp.out

Large diffs are not rendered by default.

2,108 changes: 1,062 additions & 1,046 deletions Test/baseResults/spv.debuginfo.glsl.frag.out

Large diffs are not rendered by default.

629 changes: 322 additions & 307 deletions Test/baseResults/spv.debuginfo.glsl.geom.out

Large diffs are not rendered by default.

1,335 changes: 680 additions & 655 deletions Test/baseResults/spv.debuginfo.glsl.tesc.out

Large diffs are not rendered by default.

804 changes: 412 additions & 392 deletions Test/baseResults/spv.debuginfo.glsl.tese.out

Large diffs are not rendered by default.

994 changes: 505 additions & 489 deletions Test/baseResults/spv.debuginfo.glsl.vert.out

Large diffs are not rendered by default.

2,323 changes: 1,168 additions & 1,155 deletions Test/baseResults/spv.debuginfo.hlsl.comp.out

Large diffs are not rendered by default.

2,186 changes: 1,101 additions & 1,085 deletions Test/baseResults/spv.debuginfo.hlsl.frag.out

Large diffs are not rendered by default.

853 changes: 433 additions & 420 deletions Test/baseResults/spv.debuginfo.hlsl.geom.out

Large diffs are not rendered by default.

1,729 changes: 873 additions & 856 deletions Test/baseResults/spv.debuginfo.hlsl.tesc.out

Large diffs are not rendered by default.

1,131 changes: 572 additions & 559 deletions Test/baseResults/spv.debuginfo.hlsl.tese.out

Large diffs are not rendered by default.

1,124 changes: 569 additions & 555 deletions Test/baseResults/spv.debuginfo.hlsl.vert.out

Large diffs are not rendered by default.

286 changes: 149 additions & 137 deletions Test/baseResults/spv.debuginfo.scalar_types.glsl.frag.out

Large diffs are not rendered by default.