mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-24 23:46:41 +00:00
Allow matching debug variables directly before processing path
* Debug info could theoretically contain names which include path like characters including '.' or '[]' even though these wouldn't be valid identifier names. We assume this will not happen with names that are part of structures/arrays themselves but instead only happen if there's a single matching path.
This commit is contained in:
@@ -3244,6 +3244,10 @@ QString ShaderViewer::getRegNames(const RDTreeWidgetItem *item, uint32_t swizzle
|
||||
|
||||
const ShaderVariable *reg = GetDebugVariable(debugVar);
|
||||
|
||||
// expect to find the variable
|
||||
if(!reg)
|
||||
return QString();
|
||||
|
||||
return reg->name;
|
||||
}
|
||||
|
||||
@@ -3289,6 +3293,10 @@ QString ShaderViewer::getRegNames(const RDTreeWidgetItem *item, uint32_t swizzle
|
||||
|
||||
const ShaderVariable *reg = GetDebugVariable(mapping.variables[0]);
|
||||
|
||||
// expect to find the variable
|
||||
if(!reg)
|
||||
return lit("-");
|
||||
|
||||
// return the base name with the suffix/tail that we have
|
||||
ret = reg->name + itemTag.absoluteRefPath.substr(tag.absoluteRefPath.size());
|
||||
|
||||
@@ -3303,6 +3311,10 @@ QString ShaderViewer::getRegNames(const RDTreeWidgetItem *item, uint32_t swizzle
|
||||
{
|
||||
const ShaderVariable *reg = GetDebugVariable(mapping.variables[0]);
|
||||
|
||||
// expect to find the variable
|
||||
if(!reg)
|
||||
return lit("-");
|
||||
|
||||
ret = reg->name;
|
||||
|
||||
if(mapping.type == VarType::Sampler)
|
||||
@@ -5387,24 +5399,25 @@ uint32_t ShaderViewer::CalcUpdateID(uint32_t prevID, rdcstr debugVarName) const
|
||||
// this function is a bit messy, we want a base recursion container of either QList or rdcarray
|
||||
// but further recursion is always rdcarray because of ShaderVariable::members
|
||||
template <typename Container>
|
||||
const ShaderVariable *GetShaderDebugVariable(rdcstr path, const Container &vars)
|
||||
const ShaderVariable *GetShaderDebugVariable(const rdcstr &path, const Container &vars)
|
||||
{
|
||||
rdcstr base = path;
|
||||
rdcstr elem;
|
||||
|
||||
// pick out the next element in the path
|
||||
// if this is an array index, grab that
|
||||
if(path[0] == '[')
|
||||
if(base[0] == '[')
|
||||
{
|
||||
int idx = path.indexOf(']');
|
||||
if(idx < 0)
|
||||
return NULL;
|
||||
elem = path.substr(0, idx + 1);
|
||||
base = path.substr(0, idx + 1);
|
||||
|
||||
// skip past any .s
|
||||
if(path[idx + 1] == '.')
|
||||
idx++;
|
||||
|
||||
path = path.substr(idx + 1);
|
||||
elem = path.substr(idx + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5412,32 +5425,34 @@ const ShaderVariable *GetShaderDebugVariable(rdcstr path, const Container &vars)
|
||||
int idx = path.find_first_of("[.");
|
||||
if(idx < 0)
|
||||
{
|
||||
// no results means that all that's left of the path is an identifier
|
||||
elem.swap(path);
|
||||
// no results means we want an exact match
|
||||
}
|
||||
else
|
||||
{
|
||||
elem = path.substr(0, idx);
|
||||
base = path.substr(0, idx);
|
||||
|
||||
// skip past any .s
|
||||
if(path[idx] == '.')
|
||||
idx++;
|
||||
|
||||
path = path.substr(idx);
|
||||
elem = path.substr(idx);
|
||||
}
|
||||
}
|
||||
|
||||
// look in our current set of vars for a matching variable
|
||||
for(int i = 0; i < vars.count(); i++)
|
||||
{
|
||||
if(vars[i].name == elem)
|
||||
if(vars[i].name == path)
|
||||
return &vars[i];
|
||||
|
||||
if(vars[i].name == base)
|
||||
{
|
||||
// If there's no more path, we've found the exact match, otherwise continue
|
||||
if(path.empty())
|
||||
// If there's no more, we've found the exact match, otherwise continue
|
||||
if(elem.empty())
|
||||
return &vars[i];
|
||||
|
||||
// otherwise recurse
|
||||
return GetShaderDebugVariable(path, vars[i].members);
|
||||
return GetShaderDebugVariable(elem, vars[i].members);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user