Ground work for RenderDoc specific DXIL disassembly view

Currently not exposed to the UI and code uses the existing DXC compatibile DXIL disassembly

Add bool parameter to DXBC::GetDisassembly()
Add bool parameter to DXIL::GetDisassembly()
Add void DXIL::MakeDXCDisassemblyString()
Add void DXIL::MakeRDDisassemblyString()
This commit is contained in:
Jake Turner
2024-04-18 15:46:39 +01:00
parent 70b7b770e8
commit 62d3cd5f43
9 changed files with 42 additions and 22 deletions
+1 -1
View File
@@ -339,7 +339,7 @@ rdcstr D3D11Replay::DisassembleShader(ResourceId pipeline, const ShaderReflectio
DXBC::DXBCContainer *dxbc = it->second->GetDXBC();
if(target == DXBCDisassemblyTarget || target.empty())
return dxbc->GetDisassembly();
return dxbc->GetDisassembly(true);
return StringFormat::Fmt("; Invalid disassembly target %s", target.c_str());
}
+3 -3
View File
@@ -1466,7 +1466,7 @@ ShaderDebugTrace *D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui
if(!dxbc)
return new ShaderDebugTrace;
dxbc->GetDisassembly();
dxbc->GetDisassembly(true);
D3D11RenderState *rs = m_pImmediateContext->GetCurrentPipelineState();
@@ -1857,7 +1857,7 @@ ShaderDebugTrace *D3D11Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
if(!dxbc)
return new ShaderDebugTrace;
dxbc->GetDisassembly();
dxbc->GetDisassembly(true);
DXBC::DXBCContainer *prevdxbc = NULL;
@@ -2599,7 +2599,7 @@ ShaderDebugTrace *D3D11Replay::DebugThread(uint32_t eventId,
if(!dxbc)
return new ShaderDebugTrace;
dxbc->GetDisassembly();
dxbc->GetDisassembly(true);
D3D11RenderState *rs = m_pImmediateContext->GetCurrentPipelineState();
+1 -1
View File
@@ -972,7 +972,7 @@ void D3D12Replay::PatchQuadWritePS(D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC &pi
if(!D3D12_Debug_OverlayDumpDirPath().empty())
FileIO::WriteAll(D3D12_Debug_OverlayDumpDirPath() + "/after_quadps.dxbc", patchedPs);
DXBC::DXBCContainer(patchedPs, rdcstr(), GraphicsAPI::D3D12, ~0U, ~0U).GetDisassembly();
DXBC::DXBCContainer(patchedPs, rdcstr(), GraphicsAPI::D3D12, ~0U, ~0U).GetDisassembly(true);
pipeDesc.PS.pShaderBytecode = patchedPs.data();
pipeDesc.PS.BytecodeLength = patchedPs.size();
+2 -2
View File
@@ -524,7 +524,7 @@ rdcarray<rdcstr> D3D12Replay::GetDisassemblyTargets(bool withPipeline)
{
rdcarray<rdcstr> ret;
// DXBC is always first
// DXBC/DXIL is always first
ret.push_back(DXBCDXILDisassemblyTarget);
if(!m_ISAChecked && m_TexRender.BlendPipe)
@@ -568,7 +568,7 @@ rdcstr D3D12Replay::DisassembleShader(ResourceId pipeline, const ShaderReflectio
DXBC::DXBCContainer *dxbc = sh->GetDXBC();
if(target == DXBCDXILDisassemblyTarget || target.empty())
return dxbc->GetDisassembly();
return dxbc->GetDisassembly(true);
if(target == LiveDriverDisassemblyTarget)
{
+3 -3
View File
@@ -1519,7 +1519,7 @@ ShaderDebugTrace *D3D12Replay::DebugVertex(uint32_t eventId, uint32_t vertid, ui
return new ShaderDebugTrace;
}
dxbc->GetDisassembly();
dxbc->GetDisassembly(true);
const ActionDescription *action = m_pDevice->GetAction(eventId);
@@ -1901,7 +1901,7 @@ ShaderDebugTrace *D3D12Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
return new ShaderDebugTrace;
}
dxbc->GetDisassembly();
dxbc->GetDisassembly(true);
// Fetch the previous stage's disassembly, to match outputs to PS inputs
DXBCContainer *prevDxbc = NULL;
@@ -2725,7 +2725,7 @@ ShaderDebugTrace *D3D12Replay::DebugThread(uint32_t eventId,
return new ShaderDebugTrace;
}
dxbc->GetDisassembly();
dxbc->GetDisassembly(true);
InterpretDebugger *interpreter = new InterpretDebugger;
interpreter->eventId = eventId;
@@ -511,10 +511,11 @@ D3D_PRIMITIVE_TOPOLOGY DXBCContainer::GetOutputTopology(const void *ByteCode, si
return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
}
const rdcstr &DXBCContainer::GetDisassembly()
const rdcstr &DXBCContainer::GetDisassembly(bool dxcStyle)
{
if(m_Disassembly.empty())
if(m_Disassembly.empty() || (dxcStyle != m_DXCStyle))
{
m_DXCStyle = dxcStyle;
rdcstr globalFlagsString;
const rdcstr commentString = m_DXBCByteCode ? "//" : ";";
@@ -609,7 +610,7 @@ const rdcstr &DXBCContainer::GetDisassembly()
m_Disassembly += "\n\n";
#endif
m_Disassembly += m_DXILByteCode->GetDisassembly();
m_Disassembly += m_DXILByteCode->GetDisassembly(dxcStyle);
}
}
@@ -184,7 +184,7 @@ public:
const Reflection *GetReflection() const { return m_Reflection; }
D3D_PRIMITIVE_TOPOLOGY GetOutputTopology();
const rdcstr &GetDisassembly();
const rdcstr &GetDisassembly(bool dxcStyle);
void FillTraceLineInfo(ShaderDebugTrace &trace) const;
static void StripChunk(bytebuf &ByteCode, uint32_t fourcc);
@@ -227,6 +227,7 @@ private:
bytebuf m_ShaderBlob;
rdcstr m_Disassembly;
bool m_DXCStyle = false;
D3D_PRIMITIVE_TOPOLOGY m_OutputTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
@@ -1115,12 +1115,7 @@ public:
uint32_t GetMajorVersion() const { return m_Major; }
uint32_t GetMinorVersion() const { return m_Minor; }
D3D_PRIMITIVE_TOPOLOGY GetOutputTopology();
const rdcstr &GetDisassembly()
{
if(m_Disassembly.empty())
MakeDisassemblyString();
return m_Disassembly;
}
const rdcstr &GetDisassembly(bool dxcStyle);
// IDebugInfo interface
@@ -1138,7 +1133,8 @@ public:
const Metadata *GetMetadataByName(const rdcstr &name) const;
uint32_t GetDirectHeapAcessCount() const { return m_directHeapAccessCount; }
protected:
void MakeDisassemblyString();
void MakeDXCDisassemblyString();
void MakeRDDisassemblyString();
void ParseConstant(ValueList &values, const LLVMBC::BlockOrRecord &constant);
bool ParseDebugMetaRecord(MetadataList &metadata, const LLVMBC::BlockOrRecord &metaRecord,
@@ -1200,6 +1196,7 @@ protected:
rdcarray<DebugLocation> m_DebugLocations;
bool m_Uselists = false;
bool m_DXCStyle = false;
rdcstr m_Triple, m_Datalayout;
@@ -72,7 +72,21 @@ rdcstr escapeStringIfNeeded(const rdcstr &name)
return needsEscaping(name) ? escapeString(name) : name;
}
void Program::MakeDisassemblyString()
const rdcstr &Program::GetDisassembly(bool dxcStyle)
{
if(m_Disassembly.empty() || (dxcStyle != m_DXCStyle))
{
m_DXCStyle = dxcStyle;
if(dxcStyle)
MakeDXCDisassemblyString();
else
MakeRDDisassemblyString();
}
return m_Disassembly;
}
void Program::MakeDXCDisassemblyString()
{
const char *shaderName[] = {
"Pixel", "Vertex", "Geometry", "Hull", "Domain",
@@ -1517,6 +1531,13 @@ void Program::MakeDisassemblyString()
m_Disassembly += "\n";
}
void Program::MakeRDDisassemblyString()
{
m_Disassembly.clear();
m_Disassembly += "\n";
}
rdcstr Type::toString() const
{
if(!name.empty())