mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-22 22:46:41 +00:00
Sorting array members in the Watch and High Level Variables window
This sets the offset of the VariableTag for array members in the watch window. This ensures they are sorted correctly when displayed. This also adds sorting by sourceVarIdx if the memebers are globalSourceVars which fixes the sorting in the High Level Variables window for built-in Variables
This commit is contained in:
@@ -155,6 +155,22 @@ static bool ResourceReferencesMatch(const ShaderVariable &a, const ShaderVariabl
|
||||
return false;
|
||||
}
|
||||
|
||||
void SortRDWidgetItems(QVector<RDTreeWidgetItem *> &members)
|
||||
{
|
||||
// Sort the children by offset, then global source var index, then by text.
|
||||
// Using the global source var index allows resource arrays to be presented in index order
|
||||
// rather than by name, so for example arr[2] comes before arr[10]
|
||||
std::sort(members.begin(), members.end(), [](const RDTreeWidgetItem *a, const RDTreeWidgetItem *b) {
|
||||
VariableTag at = a->tag().value<VariableTag>();
|
||||
VariableTag bt = b->tag().value<VariableTag>();
|
||||
if(at.offset != bt.offset)
|
||||
return at.offset < bt.offset;
|
||||
if(at.globalSourceVar && bt.globalSourceVar)
|
||||
return at.sourceVarIdx < bt.sourceVarIdx;
|
||||
return a->text(0) < b->text(0);
|
||||
});
|
||||
}
|
||||
|
||||
struct AccessedResourceTag
|
||||
{
|
||||
AccessedResourceTag() : type(VarType::Unknown), step(0)
|
||||
@@ -3130,17 +3146,7 @@ void ShaderViewer::combineStructures(RDTreeWidgetItem *root, int skipPrefixLengt
|
||||
c--;
|
||||
}
|
||||
|
||||
// Sort the children by offset, then global source var index, then by text.
|
||||
// Using the global source var index allows resource arrays to be presented in index order
|
||||
// rather than by name, so for example arr[2] comes before arr[10]
|
||||
std::sort(matches.begin(), matches.end(),
|
||||
[](const RDTreeWidgetItem *a, const RDTreeWidgetItem *b) {
|
||||
VariableTag at = a->tag().value<VariableTag>();
|
||||
VariableTag bt = b->tag().value<VariableTag>();
|
||||
if(at.offset != bt.offset)
|
||||
return at.offset < bt.offset;
|
||||
return a->text(0) < b->text(0);
|
||||
});
|
||||
SortRDWidgetItems(matches);
|
||||
|
||||
// create a new parent with just the prefix
|
||||
prefix.chop(1);
|
||||
@@ -4560,6 +4566,7 @@ bool ShaderViewer::updateWatchVariable(RDTreeWidgetItem *watchItem, const RDTree
|
||||
});
|
||||
VariableTag tag = VariableTag(DebugVariableType::Variable, path);
|
||||
tag.state = WatchVarState::Valid;
|
||||
tag.offset = i;
|
||||
item->setTag(QVariant::fromValue(tag));
|
||||
watchItem->addChild(item);
|
||||
valid.push_back(false);
|
||||
@@ -4586,14 +4593,7 @@ bool ShaderViewer::updateWatchVariable(RDTreeWidgetItem *watchItem, const RDTree
|
||||
while(watchItem->childCount())
|
||||
members.push_back(watchItem->takeChild(0));
|
||||
|
||||
std::sort(members.begin(), members.end(),
|
||||
[](const RDTreeWidgetItem *a, const RDTreeWidgetItem *b) {
|
||||
VariableTag at = a->tag().value<VariableTag>();
|
||||
VariableTag bt = b->tag().value<VariableTag>();
|
||||
if(at.offset != bt.offset)
|
||||
return at.offset < bt.offset;
|
||||
return a->text(0) < b->text(0);
|
||||
});
|
||||
SortRDWidgetItems(members);
|
||||
|
||||
for(int i = 0; i < members.count(); i++)
|
||||
watchItem->addChild(members[i]);
|
||||
@@ -4604,6 +4604,7 @@ bool ShaderViewer::updateWatchVariable(RDTreeWidgetItem *watchItem, const RDTree
|
||||
|
||||
VariableTag tag = VariableTag(DebugVariableType::Variable, path);
|
||||
tag.state = WatchVarState::Valid;
|
||||
tag.offset = watchItem->tag().value<VariableTag>().offset;
|
||||
watchItem->setTag(QVariant::fromValue(tag));
|
||||
|
||||
return true;
|
||||
@@ -4803,6 +4804,9 @@ bool ShaderViewer::updateWatchVariable(RDTreeWidgetItem *watchItem, const RDTree
|
||||
|
||||
VariableTag tag = VariableTag(DebugVariableType::Variable, path);
|
||||
tag.state = WatchVarState::Valid;
|
||||
// Grab the offset that is already set
|
||||
uint32_t offset = watchItem->tag().value<VariableTag>().offset;
|
||||
tag.offset = offset;
|
||||
watchItem->setTag(QVariant::fromValue(tag));
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user