Added DXIL support to DXBCContainer::FillTraceLineInfo

The DXBC container adds output to the disassembly view, need to include that output when computing the per instruction lineInfo "disassemblyLine" value

Removed "void Program::ProcessFunctions(std::function<bool(const Function *)> callback) const;"
This commit is contained in:
Jake Turner committed 2024-06-03 12:32:21 +01:00
1 parent 701220cc63
commit c731589bd0
4 files changed
+33 -27

No files matched your search

@@ -638,6 +638,19 @@ const rdcstr &DXBCContainer::GetDisassembly(bool dxcStyle)
void DXBCContainer::FillTraceLineInfo(ShaderDebugTrace &trace) const
{
// we add some number of lines for the header we added with shader hash, debug name, etc on
// top of what the bytecode disassembler did
// 2 minimum for the shader hash we always print
uint32_t extraLines = 2;
if(!m_DebugFileName.empty())
extraLines++;
if(m_ShaderExt.second != ~0U)
extraLines++;
if(m_GlobalFlags != GlobalShaderFlags::None)
extraLines += (uint32_t)Bits::CountOnes((uint32_t)m_GlobalFlags) + 2;
if(m_DXBCByteCode)
{
trace.instInfo.resize(m_DXBCByteCode->GetNumInstructions());
@@ -650,19 +663,6 @@ void DXBCContainer::FillTraceLineInfo(ShaderDebugTrace &trace) const
if(m_DebugInfo)
m_DebugInfo->GetLineInfo(i, op.offset, trace.instInfo[i].lineInfo);
// we add some number of lines for the header we added with shader hash, debug name, etc on
// top of what the bytecode disassembler did
// 2 minimum for the shader hash we always print
uint32_t extraLines = 2;
if(!m_DebugFileName.empty())
extraLines++;
if(m_ShaderExt.second != ~0U)
extraLines++;
if(m_GlobalFlags != GlobalShaderFlags::None)
extraLines += (uint32_t)Bits::CountOnes((uint32_t)m_GlobalFlags) + 2;
if(op.line > 0)
trace.instInfo[i].lineInfo.disassemblyLine = extraLines + op.line;
@@ -672,7 +672,25 @@ void DXBCContainer::FillTraceLineInfo(ShaderDebugTrace &trace) const
}
else if(m_DXILByteCode)
{
RDCERR("DXIL FillTraceLineInfo not implemented");
#if ENABLED(DXC_COMPATIBLE_DISASM)
extraLines = 0;
#endif
size_t instrCount = m_DXILByteCode->GetInstructionCount();
trace.instInfo.resize(instrCount);
for(size_t i = 0; i < instrCount; i++)
{
trace.instInfo[i].instruction = (uint32_t)i;
if(m_DebugInfo)
m_DebugInfo->GetLineInfo(i, 0, trace.instInfo[i].lineInfo);
else
m_DXILByteCode->GetLineInfo(i, 0, trace.instInfo[i].lineInfo);
trace.instInfo[i].lineInfo.disassemblyLine += extraLines;
if(m_DebugInfo)
m_DebugInfo->GetLocals(this, i, 0, trace.instInfo[i].sourceVars);
}
}
}
@@ -1513,8 +1513,6 @@ public:
void FillEntryPointInterfaces();
size_t GetInstructionCount() const;
rdcstr GetResourceReferenceName(ResourceClass resClass, const BindingSlot &slot) const;
// false means stop processing
void ProcessFunctions(std::function<bool(const Function *)> callback) const;
void FillRayPayloads(
Program *executable,
rdcflatmap<ShaderEntryPoint, rdcpair<DXBC::CBufferVariableType, DXBC::CBufferVariableType>>
@@ -2644,7 +2644,7 @@ rdcstr ProcessNormCompType(ComponentType &compType)
void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection)
{
m_Disassembly.clear();
m_DisassemblyInstructionLine = 4;
m_DisassemblyInstructionLine = 1;
m_Disassembly += StringFormat::Fmt("; %s Shader, compiled under SM%u.%u",
shaderNames[int(m_Type)], m_Major, m_Minor);
@@ -1785,16 +1785,6 @@ const ResourceReference *Program::GetResourceReference(const rdcstr &handleStr)
return NULL;
}
void Program::ProcessFunctions(std::function<bool(const Function *)> callback) const
{
for(const DXIL::Function *f : m_Functions)
{
// false means stop processing
if(!callback(f))
break;
}
}
size_t Program::GetInstructionCount() const
{
size_t ret = 0;