DXIL Disassembly and Debug sanitise global variable names

Using newly added DXIL::SanisiseName()

Current implementation converts '.' -> '_'
This commit is contained in:
Jake Turner
2024-11-12 10:11:32 +00:00
parent f896599620
commit be24fc8aaa
3 changed files with 18 additions and 1 deletions
@@ -1737,6 +1737,8 @@ bool IsLLVMDebugCall(const Instruction &inst);
bool isUndef(const Value *v);
void SanitiseName(rdcstr &name);
}; // namespace DXIL
DECLARE_REFLECTION_ENUM(DXIL::Attribute);
+3 -1
View File
@@ -5755,7 +5755,9 @@ ShaderDebugTrace *Debugger::BeginDebug(uint32_t eventId, const DXBC::DXBCContain
continue;
GlobalVariable globalVar;
globalVar.var.name = DXBC::BasicDemangle(gv->name);
rdcstr n = DXBC::BasicDemangle(gv->name);
DXIL::SanitiseName(n);
globalVar.var.name = n;
globalVar.id = gv->ssaId;
state.AllocateMemoryForType(gv->type, globalVar.id, globalVar.var);
@@ -163,6 +163,16 @@ bool DXIL::FindSigParameter(const rdcarray<SigParameter> &inputSig,
return false;
}
// Replace '.' -> '_'
void DXIL::SanitiseName(rdcstr &name)
{
for(size_t c = 0; c < name.size(); ++c)
{
if(name[c] == '.')
name[c] = '_';
}
}
static const char *shaderNames[] = {
"Pixel", "Vertex", "Geometry", "Hull", "Domain",
"Compute", "Library", "RayGeneration", "Intersection", "AnyHit",
@@ -1576,7 +1586,10 @@ rdcstr Program::DisassembleGlobalVars(int &instructionLine) const
rdcstr n = g.name;
if(!m_DXCStyle)
{
n = DXBC::BasicDemangle(g.name);
DXIL::SanitiseName(n);
}
ret += StringFormat::Fmt("@%s = ", escapeStringIfNeeded(n).c_str());
switch(g.flags & GlobalFlags::LinkageMask)
{