mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-03 05:11:06 +00:00
Cache text for GPUAddress values properly
This commit is contained in:
@@ -2064,7 +2064,7 @@ bool CaptureContext::OpenRGPProfile(const rdcstr &filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
rdcstr CaptureContext::GetResourceNameUnsuffixed(ResourceId id)
|
||||
rdcstr CaptureContext::GetResourceNameUnsuffixed(ResourceId id) const
|
||||
{
|
||||
if(id == ResourceId())
|
||||
return tr("No Resource");
|
||||
@@ -2072,7 +2072,7 @@ rdcstr CaptureContext::GetResourceNameUnsuffixed(ResourceId id)
|
||||
if(m_ReplacedToOrigResources.contains(id))
|
||||
return GetResourceName(m_ReplacedToOrigResources[id]);
|
||||
|
||||
ResourceDescription *desc = GetResource(id);
|
||||
const ResourceDescription *desc = GetResource(id);
|
||||
|
||||
if(desc)
|
||||
return GetResourceNameUnsuffixed(desc);
|
||||
@@ -2082,7 +2082,7 @@ rdcstr CaptureContext::GetResourceNameUnsuffixed(ResourceId id)
|
||||
return tr("Unknown Resource %1").arg(num);
|
||||
}
|
||||
|
||||
rdcstr CaptureContext::GetResourceNameUnsuffixed(const ResourceDescription *desc)
|
||||
rdcstr CaptureContext::GetResourceNameUnsuffixed(const ResourceDescription *desc) const
|
||||
{
|
||||
if(m_CustomNames.contains(desc->resourceId))
|
||||
return m_CustomNames[desc->resourceId];
|
||||
@@ -2090,7 +2090,7 @@ rdcstr CaptureContext::GetResourceNameUnsuffixed(const ResourceDescription *desc
|
||||
return desc->name;
|
||||
}
|
||||
|
||||
rdcstr CaptureContext::GetResourceName(ResourceId id)
|
||||
rdcstr CaptureContext::GetResourceName(ResourceId id) const
|
||||
{
|
||||
rdcstr ret = GetResourceNameUnsuffixed(id);
|
||||
|
||||
@@ -2108,7 +2108,7 @@ bool CaptureContext::IsAutogeneratedName(ResourceId id)
|
||||
if(m_CustomNames.contains(id))
|
||||
return false;
|
||||
|
||||
ResourceDescription *desc = GetResource(id);
|
||||
const ResourceDescription *desc = GetResource(id);
|
||||
|
||||
if(desc)
|
||||
return desc->autogeneratedName;
|
||||
|
||||
@@ -166,18 +166,18 @@ public:
|
||||
bool OpenRGPProfile(const rdcstr &filename) override;
|
||||
IRGPInterop *GetRGPInterop() override { return m_RGP; }
|
||||
const rdcarray<ActionDescription> &CurRootActions() override { return *m_Actions; }
|
||||
ResourceDescription *GetResource(ResourceId id) override { return m_Resources[id]; }
|
||||
const ResourceDescription *GetResource(ResourceId id) const override { return m_Resources[id]; }
|
||||
const rdcarray<ResourceDescription> &GetResources() override { return m_ResourceList; }
|
||||
rdcstr GetResourceName(ResourceId id) override;
|
||||
rdcstr GetResourceNameUnsuffixed(ResourceId id) override;
|
||||
rdcstr GetResourceName(ResourceId id) const override;
|
||||
rdcstr GetResourceNameUnsuffixed(ResourceId id) const override;
|
||||
bool IsAutogeneratedName(ResourceId id) override;
|
||||
bool HasResourceCustomName(ResourceId id) override;
|
||||
void SetResourceCustomName(ResourceId id, const rdcstr &name) override;
|
||||
int32_t ResourceNameCacheID() override { return m_CustomNameCachedID; }
|
||||
int32_t ResourceNameCacheID() const override { return m_CustomNameCachedID; }
|
||||
TextureDescription *GetTexture(ResourceId id) override { return m_Textures[id]; }
|
||||
const rdcarray<TextureDescription> &GetTextures() override { return m_TextureList; }
|
||||
BufferDescription *GetBuffer(ResourceId id) override { return m_Buffers[id]; }
|
||||
const rdcarray<BufferDescription> &GetBuffers() override { return m_BufferList; }
|
||||
const rdcarray<BufferDescription> &GetBuffers() const override { return m_BufferList; }
|
||||
const ActionDescription *GetAction(uint32_t eventId) override
|
||||
{
|
||||
return GetAction(*m_Actions, eventId);
|
||||
@@ -323,7 +323,7 @@ private:
|
||||
void LoadEdits(const QString &data);
|
||||
|
||||
void CacheResources();
|
||||
rdcstr GetResourceNameUnsuffixed(const ResourceDescription *desc);
|
||||
rdcstr GetResourceNameUnsuffixed(const ResourceDescription *desc) const;
|
||||
|
||||
float m_LoadProgress = 0.0f;
|
||||
float m_PostloadProgress = 0.0f;
|
||||
|
||||
@@ -2011,7 +2011,7 @@ more information for how this differs.
|
||||
:return: The information about a resource, or ``None`` if the ID does not correspond to a resource.
|
||||
:rtype: renderdoc.ResourceDescription
|
||||
)");
|
||||
virtual ResourceDescription *GetResource(ResourceId id) = 0;
|
||||
virtual const ResourceDescription *GetResource(ResourceId id) const = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the list of resources in the current capture.
|
||||
|
||||
@@ -2031,7 +2031,7 @@ the resource type.
|
||||
:return: The current name of the resource.
|
||||
:rtype: str
|
||||
)");
|
||||
virtual rdcstr GetResourceName(ResourceId id) = 0;
|
||||
virtual rdcstr GetResourceName(ResourceId id) const = 0;
|
||||
|
||||
DOCUMENT(R"(Returns the same name as :meth:`GetResourceName` but without any added suffix, e.g. to
|
||||
indicate the resource's status such as (Edited).
|
||||
@@ -2040,7 +2040,7 @@ indicate the resource's status such as (Edited).
|
||||
:return: The unsuffixed resource name.
|
||||
:rtype: str
|
||||
)");
|
||||
virtual rdcstr GetResourceNameUnsuffixed(ResourceId id) = 0;
|
||||
virtual rdcstr GetResourceNameUnsuffixed(ResourceId id) const = 0;
|
||||
|
||||
DOCUMENT(R"(Determines whether the name for the given resource has been customised at all, either
|
||||
during capture time or with :meth:`SetResourceCustomName`.
|
||||
@@ -2093,7 +2093,7 @@ considered out of date
|
||||
:return: An incrementing index that can be used as a quick check if any names have changed.
|
||||
:rtype: int
|
||||
)");
|
||||
virtual int32_t ResourceNameCacheID() = 0;
|
||||
virtual int32_t ResourceNameCacheID() const = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the information about a particular texture.
|
||||
|
||||
@@ -2123,7 +2123,7 @@ considered out of date
|
||||
:return: The list of buffers.
|
||||
:rtype: List[renderdoc.BufferDescription]
|
||||
)");
|
||||
virtual const rdcarray<BufferDescription> &GetBuffers() = 0;
|
||||
virtual const rdcarray<BufferDescription> &GetBuffers() const = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the information about an action at a given
|
||||
:data:`eventId <renderdoc.APIEvent.eventId>`.
|
||||
|
||||
@@ -174,7 +174,7 @@ rdcstr DoStringise(const PointerVal &el)
|
||||
}
|
||||
}
|
||||
|
||||
QString GetTruncatedResourceName(ICaptureContext &ctx, ResourceId id)
|
||||
QString GetTruncatedResourceName(const ICaptureContext &ctx, ResourceId id)
|
||||
{
|
||||
QString name = ctx.GetResourceName(id);
|
||||
if(name.length() > 64)
|
||||
@@ -222,7 +222,7 @@ struct RichResourceText
|
||||
bool forcehtml = false;
|
||||
|
||||
// cache the context once we've obtained it.
|
||||
ICaptureContext *ctxptr = NULL;
|
||||
const ICaptureContext *ctxptr = NULL;
|
||||
|
||||
void cacheText(const QWidget *widget)
|
||||
{
|
||||
@@ -232,7 +232,13 @@ struct RichResourceText
|
||||
if(!ctxptr)
|
||||
return;
|
||||
|
||||
ICaptureContext &ctx = *(ICaptureContext *)ctxptr;
|
||||
cacheText(*ctxptr);
|
||||
}
|
||||
|
||||
void cacheText(const ICaptureContext &ctx)
|
||||
{
|
||||
if(!ctxptr)
|
||||
ctxptr = &ctx;
|
||||
|
||||
int refCache = ctx.ResourceNameCacheID();
|
||||
|
||||
@@ -439,6 +445,14 @@ void GPUAddress::cacheAddress(const QWidget *widget)
|
||||
if(!ctxptr)
|
||||
return;
|
||||
|
||||
cacheAddress(*ctxptr);
|
||||
}
|
||||
|
||||
void GPUAddress::cacheAddress(const ICaptureContext &ctx)
|
||||
{
|
||||
if(!ctxptr)
|
||||
ctxptr = &ctx;
|
||||
|
||||
// bail if we're already cached
|
||||
if(base != ResourceId())
|
||||
return;
|
||||
@@ -999,7 +1013,7 @@ bool RichResourceTextMouseEvent(const QWidget *owner, const QVariant &var, QRect
|
||||
{
|
||||
ResourceId id;
|
||||
GPUAddressPtr ptr;
|
||||
ICaptureContext *ctxptr = NULL;
|
||||
const ICaptureContext *ctxptr = NULL;
|
||||
|
||||
if(var.userType() == qMetaTypeId<ResourceId>())
|
||||
{
|
||||
@@ -1199,6 +1213,17 @@ QString RichResourceTextFormat(ICaptureContext &ctx, QVariant var)
|
||||
if(var.userType() == qMetaTypeId<ResourceId>())
|
||||
return GetTruncatedResourceName(ctx, var.value<ResourceId>());
|
||||
|
||||
if(var.userType() == qMetaTypeId<GPUAddressPtr>())
|
||||
{
|
||||
var.value<GPUAddressPtr>()->cacheAddress(ctx);
|
||||
|
||||
// a bit hacky, but recurse to pick up the 'name' of the pointer base buffer
|
||||
return RichResourceTextFormat(ctx, var.toString());
|
||||
}
|
||||
|
||||
if(var.userType() == qMetaTypeId<RichResourceTextPtr>())
|
||||
var.value<RichResourceTextPtr>()->cacheText(ctx);
|
||||
|
||||
// either it's something else and wasn't rich resource, in which case just return the string
|
||||
// representation, or it's a fully formatted rich resource document, where the cached text will do
|
||||
// the trick with ResIdTextToString.
|
||||
|
||||
@@ -303,9 +303,10 @@ struct GPUAddress
|
||||
uint64_t offset = 0;
|
||||
|
||||
// cache the context once we've obtained it.
|
||||
ICaptureContext *ctxptr = NULL;
|
||||
const ICaptureContext *ctxptr = NULL;
|
||||
|
||||
void cacheAddress(const QWidget *widget);
|
||||
void cacheAddress(const ICaptureContext &ctx);
|
||||
};
|
||||
|
||||
struct EnumInterpValue
|
||||
|
||||
@@ -447,13 +447,16 @@ struct CaptureContextInvoker : ObjectForwarder<ICaptureContext>
|
||||
{
|
||||
return m_Obj.CurRootActions();
|
||||
}
|
||||
virtual ResourceDescription *GetResource(ResourceId id) override { return m_Obj.GetResource(id); }
|
||||
virtual const ResourceDescription *GetResource(ResourceId id) const override
|
||||
{
|
||||
return m_Obj.GetResource(id);
|
||||
}
|
||||
virtual const rdcarray<ResourceDescription> &GetResources() override
|
||||
{
|
||||
return m_Obj.GetResources();
|
||||
}
|
||||
virtual rdcstr GetResourceName(ResourceId id) override { return m_Obj.GetResourceName(id); }
|
||||
virtual rdcstr GetResourceNameUnsuffixed(ResourceId id) override
|
||||
virtual rdcstr GetResourceName(ResourceId id) const override { return m_Obj.GetResourceName(id); }
|
||||
virtual rdcstr GetResourceNameUnsuffixed(ResourceId id) const override
|
||||
{
|
||||
return m_Obj.GetResourceNameUnsuffixed(id);
|
||||
}
|
||||
@@ -462,11 +465,14 @@ struct CaptureContextInvoker : ObjectForwarder<ICaptureContext>
|
||||
{
|
||||
return m_Obj.HasResourceCustomName(id);
|
||||
}
|
||||
virtual int32_t ResourceNameCacheID() override { return m_Obj.ResourceNameCacheID(); }
|
||||
virtual int32_t ResourceNameCacheID() const override { return m_Obj.ResourceNameCacheID(); }
|
||||
virtual TextureDescription *GetTexture(ResourceId id) override { return m_Obj.GetTexture(id); }
|
||||
virtual const rdcarray<TextureDescription> &GetTextures() override { return m_Obj.GetTextures(); }
|
||||
virtual BufferDescription *GetBuffer(ResourceId id) override { return m_Obj.GetBuffer(id); }
|
||||
virtual const rdcarray<BufferDescription> &GetBuffers() override { return m_Obj.GetBuffers(); }
|
||||
virtual const rdcarray<BufferDescription> &GetBuffers() const override
|
||||
{
|
||||
return m_Obj.GetBuffers();
|
||||
}
|
||||
virtual const ActionDescription *GetAction(uint32_t eventId) override
|
||||
{
|
||||
return m_Obj.GetAction(eventId);
|
||||
|
||||
@@ -5614,7 +5614,7 @@ void ShaderViewer::updateVariableTooltip()
|
||||
QString tooltip;
|
||||
|
||||
if(var.type == VarType::Sampler || var.type == VarType::ReadOnlyResource ||
|
||||
var.type == VarType::ReadWriteResource)
|
||||
var.type == VarType::ReadWriteResource || var.type == VarType::GPUPointer)
|
||||
{
|
||||
tooltip = QFormatStr("%1: ").arg(var.name) + RichResourceTextFormat(m_Ctx, stringRep(var, 0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user