Emit debug info for buffer references
Using OpExtInstWithForwardRefs, the debug type information for buffer reference types can be emitted alongside the OpFowardPointer opcode.
This commit is contained in:
parent
996c5d3123
commit
81f7045aa0
3 changed files with 188 additions and 146 deletions
|
|
@ -182,6 +182,10 @@ Id Builder::makeForwardPointer(StorageClass storageClass)
|
|||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
const Id debugResultId = makeForwardPointerDebugType(storageClass);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
|
|
@ -204,6 +208,15 @@ Id Builder::makePointerFromForwardPointer(StorageClass storageClass, Id forwardP
|
|||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
// If we are emitting nonsemantic debuginfo, we need to patch the debug pointer type
|
||||
// that was emitted alongside the forward pointer, now that we have a pointee debug
|
||||
// type for it to point to.
|
||||
if (emitNonSemanticShaderDebugInfo) {
|
||||
Instruction *debugForwardPointer = module.getInstruction(debugId[forwardPointerType]);
|
||||
assert(debugId[pointee]);
|
||||
debugForwardPointer->setIdOperand(2, debugId[pointee]);
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
|
|
@ -1045,6 +1058,29 @@ Id Builder::makePointerDebugType(StorageClass storageClass, Id const baseType)
|
|||
return type->getResultId();
|
||||
}
|
||||
|
||||
// Emit a OpExtInstWithForwardRefs nonsemantic instruction for a pointer debug type
|
||||
// where we don't have the pointee yet. Since we don't have the pointee yet, it just
|
||||
// points to itself and we rely on patching it later.
|
||||
Id Builder::makeForwardPointerDebugType(StorageClass storageClass)
|
||||
{
|
||||
const Id scID = makeUintConstant(storageClass);
|
||||
|
||||
this->addExtension(spv::E_SPV_KHR_relaxed_extended_instruction);
|
||||
|
||||
Instruction *type = new Instruction(getUniqueId(), makeVoidType(), OpExtInstWithForwardRefs);
|
||||
type->addIdOperand(nonSemanticShaderDebugInfo);
|
||||
type->addImmediateOperand(NonSemanticShaderDebugInfo100DebugTypePointer);
|
||||
type->addIdOperand(type->getResultId());
|
||||
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];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue