From 3324b7f86c690a3c71a09e8544a2dffe018561dc Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 18 Oct 2021 17:53:08 +0100 Subject: [PATCH] Hide hidden/internal parameters in resource inspector --- qrenderdoc/Code/QRDUtils.cpp | 57 ++++++++++++++++++++++-- renderdoc/api/replay/structured_data.h | 6 +++ renderdoc/serialise/codecs/xml_codec.cpp | 18 ++++++++ renderdoc/serialise/serialiser.h | 2 + 4 files changed, 80 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index f4fc6c0d9..ac420fa6e 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -3311,6 +3311,24 @@ QModelIndex StructuredDataItemModel::index(int row, int column, const QModelInde } else { + if(par->type.flags & SDTypeFlags::HiddenChildren) + { + // if this node has hidden children, get the index relative to only visible children + int idx = 0; + for(size_t i = 0; i < par->NumChildren(); i++) + { + SDObject *ch = par->GetChild(i); + + if(ch->type.flags & SDTypeFlags::Hidden) + continue; + + if(idx == row) + return createIndex(row, column, encodeIndex({Direct, ch, 0})); + + idx++; + } + } + return createIndex(row, column, encodeIndex({Direct, par->GetChild(row), 0})); } } @@ -3379,9 +3397,21 @@ QModelIndex StructuredDataItemModel::parent(const QModelIndex &index) const } // search our parent to find out our child index + int idx = 0; + bool largeArray = isLargeArray(parent); for(size_t i = 0; i < parent->NumChildren(); i++) - if(parent->GetChild(i) == obj) - return createIndex((int)i, 0, obj); + { + const SDObject *ch = parent->GetChild(i); + if(ch == obj) + return createIndex(idx, 0, obj); + + // for non-large arrays, we account for hidden children. Large arrays should not have any + // hidden children anyway + if(!largeArray && (ch->type.flags & SDTypeFlags::Hidden)) + continue; + + idx++; + } return QModelIndex(); } @@ -3418,9 +3448,30 @@ int StructuredDataItemModel::rowCount(const QModelIndex &parent) const if(obj) { if(isLargeArray(obj)) + { return (int(obj->NumChildren()) + ArrayPageSize - 1) / ArrayPageSize; + } else - return (int)obj->NumChildren(); + { + if(obj->type.flags & SDTypeFlags::HiddenChildren) + { + // if this node has hidden children, count the *actual* number of children + int numChildren = 0; + for(size_t i = 0; i < obj->NumChildren(); i++) + { + if(obj->GetChild(i)->type.flags & SDTypeFlags::Hidden) + continue; + + numChildren++; + } + + return numChildren; + } + else + { + return (int)obj->NumChildren(); + } + } } return 0; diff --git a/renderdoc/api/replay/structured_data.h b/renderdoc/api/replay/structured_data.h index f921e5df2..1232a9bad 100644 --- a/renderdoc/api/replay/structured_data.h +++ b/renderdoc/api/replay/structured_data.h @@ -159,6 +159,11 @@ DOCUMENT(R"(Bitfield flags that could be applied to a type. Indicates that only important children should be processed, as noted in :data:`Important`. This may appear on an object which has no important children - which indicates explicitly that there are no important children so when summarising no parameters should be shown. + +.. data:: HiddenChildren + + Indicates that some children are marked as hidden. This can be important for cases where the + number of children is important. )"); enum class SDTypeFlags : uint32_t { @@ -171,6 +176,7 @@ enum class SDTypeFlags : uint32_t Union = 0x20, Important = 0x40, ImportantChildren = 0x80, + HiddenChildren = 0x100, }; BITMASK_OPERATORS(SDTypeFlags); diff --git a/renderdoc/serialise/codecs/xml_codec.cpp b/renderdoc/serialise/codecs/xml_codec.cpp index 9775f516b..97d0418b0 100644 --- a/renderdoc/serialise/codecs/xml_codec.cpp +++ b/renderdoc/serialise/codecs/xml_codec.cpp @@ -221,6 +221,15 @@ static void Obj2XML(pugi::xml_node &parent, SDObject &child) if(child.type.flags & SDTypeFlags::Union) obj.append_attribute("union") = true; + if(child.type.flags & SDTypeFlags::Important) + obj.append_attribute("important") = true; + + if(child.type.flags & SDTypeFlags::ImportantChildren) + obj.append_attribute("importantchildren") = true; + + if(child.type.flags & SDTypeFlags::HiddenChildren) + obj.append_attribute("hiddenchildren") = true; + if(child.type.basetype == SDBasic::Chunk) { RDCFATAL("Nested chunks!"); @@ -500,6 +509,15 @@ static SDObject *XML2Obj(pugi::xml_node &obj) if(obj.attribute("union")) ret->type.flags |= SDTypeFlags::Union; + if(obj.attribute("important")) + ret->type.flags |= SDTypeFlags::Important; + + if(obj.attribute("importantchildren")) + ret->type.flags |= SDTypeFlags::ImportantChildren; + + if(obj.attribute("hiddenchildren")) + ret->type.flags |= SDTypeFlags::HiddenChildren; + if(obj.attribute("typename")) ret->type.name = obj.attribute("typename").as_string(); diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index a66bb19e2..2e7657676 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -1142,6 +1142,8 @@ public: { SDObject ¤t = *m_StructureStack.back(); + current.type.flags |= SDTypeFlags::HiddenChildren; + if(current.NumChildren() > 0) current.GetChild(current.NumChildren() - 1)->type.flags |= SDTypeFlags::Hidden; }