mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-28 01:16:31 +00:00
Give better names to anonymous/unnamed variables
* With GLSL anonymous blocks the variable doesn't get a name, but the type does get a meaningful name - use that to name the variable.
This commit is contained in:
@@ -2243,6 +2243,19 @@ void Debugger::RegisterOp(Iter it)
|
||||
|
||||
if(var.storageClass == StorageClass::Function && curFunction)
|
||||
curFunction->variables.push_back(var.result);
|
||||
|
||||
// variables are always pointers
|
||||
Id varType = dataTypes[var.resultType].InnerType();
|
||||
|
||||
// if we don't have a name for this variable but it's a pointer to a struct that is named then
|
||||
// give the variable a name based on the type. This is a common pattern in GLSL for global
|
||||
// blocks, and since the variable is how we access commonly we should give it a recognisable
|
||||
// name.
|
||||
if(strings[var.result].empty() && dataTypes[varType].type == DataType::StructType &&
|
||||
!strings[varType].empty())
|
||||
{
|
||||
strings[var.result] = strings[varType] + "_var";
|
||||
}
|
||||
}
|
||||
else if(opdata.op == Op::Label)
|
||||
{
|
||||
|
||||
@@ -355,6 +355,23 @@ void Reflector::RegisterOp(Iter it)
|
||||
|
||||
memberNames.push_back({memberName.type, memberName.member, memberName.name});
|
||||
}
|
||||
else if(opdata.op == Op::Variable)
|
||||
{
|
||||
OpVariable var(it);
|
||||
|
||||
// variables are always pointers
|
||||
Id varType = dataTypes[var.resultType].InnerType();
|
||||
|
||||
// if we don't have a name for this variable but it's a pointer to a struct that is named then
|
||||
// give the variable a name based on the type. This is a common pattern in GLSL for global
|
||||
// blocks, and since the variable is how we access commonly we should give it a recognisable
|
||||
// name.
|
||||
if(strings[var.result].empty() && dataTypes[varType].type == DataType::StructType &&
|
||||
!strings[varType].empty())
|
||||
{
|
||||
strings[var.result] = strings[varType] + "_var";
|
||||
}
|
||||
}
|
||||
else if(opdata.op == Op::ModuleProcessed)
|
||||
{
|
||||
OpModuleProcessed processed(it);
|
||||
|
||||
Reference in New Issue
Block a user