mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 22:25:55 +00:00
Add source variables for named IDs where possible
This commit is contained in:
@@ -149,8 +149,9 @@ void ThreadState::EnterFunction(ShaderDebugState *state, const rdcarray<Id> &arg
|
||||
|
||||
rdcstr sourceName = debugger.GetHumanName(decl.result);
|
||||
|
||||
debugger.AllocateVariable(decl.result, decl.resultType, DebugVariableType::Variable, sourceName,
|
||||
stackvar);
|
||||
// don't add source vars - SetDst below will do that
|
||||
debugger.AllocateVariable(decl.result, decl.resultType, DebugVariableType::Undefined,
|
||||
sourceName, stackvar);
|
||||
|
||||
if(decl.HasInitializer())
|
||||
AssignValue(stackvar, ids[decl.initializer]);
|
||||
@@ -187,6 +188,8 @@ void ThreadState::SetDst(ShaderDebugState *state, Id id, const ShaderVariable &v
|
||||
ids[id] = val;
|
||||
ids[id].name = debugger.GetRawName(id);
|
||||
live.push_back(id);
|
||||
|
||||
debugger.AddSourceVars(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -267,6 +270,8 @@ void ThreadState::SetDst(ShaderDebugState *state, Id id, const ShaderVariable &v
|
||||
ShaderVariableChange change;
|
||||
change.after = debugger.EvaluatePointerVariable(ids[id]);
|
||||
state->changes.push_back(change);
|
||||
|
||||
debugger.AddSourceVars(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ public:
|
||||
const DataType &GetType(Id typeId);
|
||||
rdcstr GetRawName(Id id) const;
|
||||
rdcstr GetHumanName(Id id);
|
||||
void AddSourceVars(Id id);
|
||||
void AllocateVariable(Id id, Id typeId, DebugVariableType sourceVarType, const rdcstr &sourceName,
|
||||
ShaderVariable &outVar);
|
||||
|
||||
@@ -154,6 +155,8 @@ private:
|
||||
void AllocateVariable(const Decorations &varDecorations, const Decorations &curDecorations,
|
||||
DebugVariableType sourceVarType, const rdcstr &sourceName, uint32_t offset,
|
||||
const DataType &inType, ShaderVariable &outVar);
|
||||
void AddSourceVars(const DataType &inType, const rdcstr &sourceName, const rdcstr &varName,
|
||||
uint32_t &offset);
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// debug data
|
||||
|
||||
@@ -552,6 +552,102 @@ rdcstr Debugger::GetHumanName(Id id)
|
||||
return name;
|
||||
}
|
||||
|
||||
void Debugger::AddSourceVars(Id id)
|
||||
{
|
||||
rdcstr name;
|
||||
|
||||
auto it = dynamicNames.find(id);
|
||||
if(it != dynamicNames.end())
|
||||
name = it->second;
|
||||
else
|
||||
name = strings[id];
|
||||
|
||||
if(!name.empty())
|
||||
{
|
||||
Id type = idTypes[id];
|
||||
|
||||
uint32_t offset = 0;
|
||||
AddSourceVars(dataTypes[type], name, GetRawName(id), offset);
|
||||
}
|
||||
}
|
||||
|
||||
void Debugger::AddSourceVars(const DataType &inType, const rdcstr &sourceName,
|
||||
const rdcstr &varName, uint32_t &offset)
|
||||
{
|
||||
SourceVariableMapping sourceVar;
|
||||
|
||||
switch(inType.type)
|
||||
{
|
||||
case DataType::UnknownType:
|
||||
case DataType::ImageType:
|
||||
case DataType::SamplerType:
|
||||
case DataType::SampledImageType: return;
|
||||
case DataType::PointerType:
|
||||
{
|
||||
// step silently into pointers
|
||||
AddSourceVars(dataTypes[inType.InnerType()], sourceName, varName, offset);
|
||||
return;
|
||||
}
|
||||
case DataType::ScalarType:
|
||||
{
|
||||
sourceVar.type = inType.scalar().Type();
|
||||
sourceVar.rows = 1;
|
||||
sourceVar.columns = 1;
|
||||
break;
|
||||
}
|
||||
case DataType::VectorType:
|
||||
{
|
||||
sourceVar.type = inType.scalar().Type();
|
||||
sourceVar.rows = 1;
|
||||
sourceVar.columns = RDCMAX(1U, inType.vector().count);
|
||||
break;
|
||||
}
|
||||
case DataType::MatrixType:
|
||||
{
|
||||
sourceVar.type = inType.scalar().Type();
|
||||
sourceVar.columns = RDCMAX(1U, inType.matrix().count);
|
||||
sourceVar.rows = RDCMAX(1U, inType.vector().count);
|
||||
break;
|
||||
}
|
||||
case DataType::StructType:
|
||||
{
|
||||
for(int32_t i = 0; i < inType.children.count(); i++)
|
||||
{
|
||||
rdcstr childVarName = StringFormat::Fmt("%s._child%d", varName.c_str(), i);
|
||||
|
||||
rdcstr childSourceName;
|
||||
if(inType.children[i].name.empty())
|
||||
childSourceName = StringFormat::Fmt("%s._child%d", sourceName.c_str(), i);
|
||||
else
|
||||
childSourceName = sourceName + "." + inType.children[i].name;
|
||||
|
||||
AddSourceVars(dataTypes[inType.children[i].type], childSourceName, childVarName, offset);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case DataType::ArrayType:
|
||||
{
|
||||
ShaderVariable len = GetActiveLane().ids[inType.length];
|
||||
for(uint32_t i = 0; i < len.value.u.x; i++)
|
||||
{
|
||||
rdcstr idx = StringFormat::Fmt("[%u]", i);
|
||||
|
||||
AddSourceVars(dataTypes[inType.InnerType()], sourceName + idx, varName + idx, offset);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sourceVar.name = sourceName;
|
||||
sourceVar.offset = offset;
|
||||
for(uint32_t x = 0; x < sourceVar.rows * sourceVar.columns; x++)
|
||||
sourceVar.variables.push_back(DebugVariableReference(DebugVariableType::Variable, varName, x));
|
||||
|
||||
sourceVars.push_back(sourceVar);
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
||||
void Debugger::CalcActiveMask(rdcarray<bool> &activeMask)
|
||||
{
|
||||
// one bool per workgroup thread
|
||||
@@ -672,6 +768,9 @@ void Debugger::AllocateVariable(const Decorations &varDecorations, const Decorat
|
||||
}
|
||||
}
|
||||
|
||||
if(sourceVarType == DebugVariableType::Undefined)
|
||||
return;
|
||||
|
||||
SourceVariableMapping sourceVar;
|
||||
sourceVar.name = sourceName;
|
||||
sourceVar.offset = offset;
|
||||
|
||||
Reference in New Issue
Block a user