mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 13:00:32 +00:00
Split out code to populate RDTreeWidget with structured data
This commit is contained in:
@@ -33,7 +33,7 @@ APIInspector::APIInspector(ICaptureContext &ctx, QWidget *parent)
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->apiEvents->setColumns({lit("EID"), tr("Event")});
|
||||
ui->apiEvents->header()->resizeSection(0, 200);
|
||||
ui->apiEvents->header()->resizeSection(0, 150);
|
||||
|
||||
ui->splitter->setCollapsible(1, true);
|
||||
ui->splitter->setSizes({1, 0});
|
||||
@@ -146,7 +146,7 @@ void APIInspector::fillAPIView()
|
||||
|
||||
root->setText(1, chunk->name);
|
||||
|
||||
addObjects(root, chunk->data.children, false);
|
||||
addStructuredObjects(root, chunk->data.children, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,89 +166,3 @@ void APIInspector::fillAPIView()
|
||||
|
||||
ui->apiEvents->setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void APIInspector::addObjects(RDTreeWidgetItem *parent, const StructuredObjectList &objs,
|
||||
bool parentIsArray)
|
||||
{
|
||||
for(const SDObject *obj : objs)
|
||||
{
|
||||
if(obj->type.flags & SDTypeFlags::Hidden)
|
||||
continue;
|
||||
|
||||
QString param;
|
||||
|
||||
if(parentIsArray)
|
||||
param = QFormatStr("[%1]").arg(parent->childCount());
|
||||
else
|
||||
param = obj->name;
|
||||
|
||||
RDTreeWidgetItem *item = new RDTreeWidgetItem({param, QString()});
|
||||
|
||||
param = QString();
|
||||
|
||||
// we don't identify via the type name as many types could be serialised as a ResourceId -
|
||||
// e.g. ID3D11Resource* or ID3D11Buffer* which would be the actual typename. We want to preserve
|
||||
// that for the best raw structured data representation instead of flattening those out to just
|
||||
// "ResourceId", and we also don't want to store two types ('fake' and 'real'), so instead we
|
||||
// check the custom string.
|
||||
if((obj->type.flags & SDTypeFlags::HasCustomString) &&
|
||||
!strncmp(obj->data.str.c_str(), "ResourceId", 10))
|
||||
{
|
||||
ResourceId id;
|
||||
static_assert(sizeof(id) == sizeof(obj->data.basic.u), "ResourceId is no longer uint64_t!");
|
||||
memcpy(&id, &obj->data.basic.u, sizeof(id));
|
||||
// for resource IDs, try to locate the resource.
|
||||
TextureDescription *tex = m_Ctx.GetTexture(id);
|
||||
BufferDescription *buf = m_Ctx.GetBuffer(id);
|
||||
|
||||
if(tex)
|
||||
{
|
||||
param += tex->name;
|
||||
}
|
||||
else if(buf)
|
||||
{
|
||||
param += buf->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
param += lit("%1 %2").arg(obj->type.name).arg(obj->data.basic.u);
|
||||
}
|
||||
}
|
||||
else if(obj->type.flags & SDTypeFlags::NullString)
|
||||
{
|
||||
param += lit("NULL");
|
||||
}
|
||||
else if(obj->type.flags & SDTypeFlags::HasCustomString)
|
||||
{
|
||||
param += obj->data.str;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(obj->type.basetype)
|
||||
{
|
||||
case SDBasic::Chunk:
|
||||
case SDBasic::Struct:
|
||||
param += QFormatStr("%1()").arg(obj->type.name);
|
||||
addObjects(item, obj->data.children, false);
|
||||
break;
|
||||
case SDBasic::Array:
|
||||
param += QFormatStr("%1[]").arg(obj->type.name);
|
||||
addObjects(item, obj->data.children, true);
|
||||
break;
|
||||
case SDBasic::Null: param += lit("NULL"); break;
|
||||
case SDBasic::Buffer: param += lit("(%1 byte buffer)").arg(obj->type.byteSize); break;
|
||||
case SDBasic::String: param += obj->data.str; break;
|
||||
case SDBasic::Enum:
|
||||
case SDBasic::UnsignedInteger: param += Formatter::Format(obj->data.basic.u); break;
|
||||
case SDBasic::SignedInteger: param += Formatter::Format(obj->data.basic.i); break;
|
||||
case SDBasic::Float: param += Formatter::Format(obj->data.basic.d); break;
|
||||
case SDBasic::Boolean: param += (obj->data.basic.b ? tr("True") : tr("False")); break;
|
||||
case SDBasic::Character: param += QLatin1Char(obj->data.basic.c); break;
|
||||
}
|
||||
}
|
||||
|
||||
item->setText(1, param);
|
||||
|
||||
parent->addChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user