When viewing a texture from pipeline state, default to view typecast

This commit is contained in:
baldurk committed 2020-10-30 16:28:03 +00:00
1 parent b8f647c1e6
commit 695ffaaf24
8 files changed
+57 -18

No files matched your search

+5 -1
View File
@@ -255,9 +255,13 @@ struct ITextureViewer
DOCUMENT(R"(Open a texture view, optionally raising this window to the foreground.
:param ~renderdoc.ResourceId resourceId: The ID of the texture to view.
:param CompType typeCast: If possible interpret the texture with this type instead of its normal
type. If set to :data:`CompType.Typeless` then no cast is applied, otherwise where allowed the
texture data will be reinterpreted - e.g. from unsigned integers to floats, or to unsigned
normalised values.
:param bool focus: ``True`` if the :class:`TextureViewer` should be raised.
)");
virtual void ViewTexture(ResourceId resourceId, bool focus) = 0;
virtual void ViewTexture(ResourceId resourceId, CompType typeCast, bool focus) = 0;
DOCUMENT(R"(Highlights the given pixel location in the current texture.
:param int x: The X co-ordinate.
@@ -1954,6 +1954,7 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
TextureDescription *tex = NULL;
BufferDescription *buf = NULL;
CompType typeCast = CompType::Typeless;
if(tag.canConvert<ResourceId>())
{
@@ -1966,6 +1967,7 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
D3D11ViewTag view = tag.value<D3D11ViewTag>();
tex = m_Ctx.GetTexture(view.res.resourceResourceId);
buf = m_Ctx.GetBuffer(view.res.resourceResourceId);
typeCast = view.res.viewFormat.compType;
}
if(tex)
@@ -1982,7 +1984,7 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
if(!m_Ctx.HasTextureViewer())
m_Ctx.ShowTextureViewer();
ITextureViewer *viewer = m_Ctx.GetTextureViewer();
viewer->ViewTexture(tex->resourceId, true);
viewer->ViewTexture(tex->resourceId, typeCast, true);
}
return;
@@ -1930,6 +1930,7 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
TextureDescription *tex = NULL;
BufferDescription *buf = NULL;
CompType typeCast = CompType::Typeless;
if(tag.canConvert<ResourceId>())
{
@@ -1942,6 +1943,7 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
D3D12ViewTag view = tag.value<D3D12ViewTag>();
tex = m_Ctx.GetTexture(view.res.resourceId);
buf = m_Ctx.GetBuffer(view.res.resourceId);
typeCast = view.res.viewFormat.compType;
}
if(tex)
@@ -1958,7 +1960,7 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
if(!m_Ctx.HasTextureViewer())
m_Ctx.ShowTextureViewer();
ITextureViewer *viewer = m_Ctx.GetTextureViewer();
viewer->ViewTexture(tex->resourceId, true);
viewer->ViewTexture(tex->resourceId, typeCast, true);
}
return;
@@ -2204,7 +2204,7 @@ void GLPipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, int c
if(!m_Ctx.HasTextureViewer())
m_Ctx.ShowTextureViewer();
ITextureViewer *viewer = m_Ctx.GetTextureViewer();
viewer->ViewTexture(tex->resourceId, true);
viewer->ViewTexture(tex->resourceId, CompType::Typeless, true);
}
return;
@@ -102,6 +102,20 @@ struct VulkanBufferTag
Q_DECLARE_METATYPE(VulkanBufferTag);
struct VulkanTextureTag
{
VulkanTextureTag() { compType = CompType::Typeless; }
VulkanTextureTag(ResourceId id, CompType ty)
{
ID = id;
compType = ty;
}
ResourceId ID;
CompType compType;
};
Q_DECLARE_METATYPE(VulkanTextureTag);
VulkanPipelineStateViewer::VulkanPipelineStateViewer(ICaptureContext &ctx,
PipelineStateViewer &common, QWidget *parent)
: QFrame(parent), ui(new Ui::VulkanPipelineStateViewer), m_Ctx(ctx), m_Common(common)
@@ -1176,7 +1190,8 @@ void VulkanPipelineStateViewer::addResourceRow(ShaderReflection *shaderDetails,
restype = tex->type;
samples = tex->msSamp;
tag = QVariant::fromValue(descriptorBind->resourceResourceId);
tag = QVariant::fromValue(VulkanTextureTag(descriptorBind->resourceResourceId,
descriptorBind->viewFormat.compType));
}
// if not a texture, it must be a buffer
@@ -2487,7 +2502,8 @@ void VulkanPipelineStateViewer::setState()
{slotname, p.imageResourceId, typeName, w, h, d, a, format, QString()});
if(tex)
node->setTag(QVariant::fromValue(p.imageResourceId));
node->setTag(
QVariant::fromValue(VulkanTextureTag(p.imageResourceId, p.viewFormat.compType)));
if(p.imageResourceId == ResourceId())
{
@@ -2732,9 +2748,11 @@ void VulkanPipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, i
QVariant tag = item->tag();
if(tag.canConvert<ResourceId>())
if(tag.canConvert<VulkanTextureTag>())
{
TextureDescription *tex = m_Ctx.GetTexture(tag.value<ResourceId>());
VulkanTextureTag vtex = tag.value<VulkanTextureTag>();
TextureDescription *tex = m_Ctx.GetTexture(vtex.ID);
if(tex)
{
@@ -2750,7 +2768,7 @@ void VulkanPipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, i
if(!m_Ctx.HasTextureViewer())
m_Ctx.ShowTextureViewer();
ITextureViewer *viewer = m_Ctx.GetTextureViewer();
viewer->ViewTexture(tex->resourceId, true);
viewer->ViewTexture(tex->resourceId, vtex.compType, true);
}
return;
+1 -1
View File
@@ -478,7 +478,7 @@ void ResourceInspector::on_viewContents_clicked()
if(!m_Ctx.HasTextureViewer())
m_Ctx.ShowTextureViewer();
ITextureViewer *viewer = m_Ctx.GetTextureViewer();
viewer->ViewTexture(tex->resourceId, true);
viewer->ViewTexture(tex->resourceId, CompType::Typeless, true);
}
}
else if(buf)
+20 -7
View File
@@ -1981,14 +1981,17 @@ void TextureViewer::GotoLocation(int x, int y)
UI_UpdateStatusText();
}
void TextureViewer::ViewTexture(ResourceId ID, bool focus)
void TextureViewer::ViewTexture(ResourceId ID, CompType typeCast, bool focus)
{
if(QThread::currentThread() != QCoreApplication::instance()->thread())
{
GUIInvoke::call(this, [this, ID, focus] { this->ViewTexture(ID, focus); });
GUIInvoke::call(this, [this, ID, typeCast, focus] { this->ViewTexture(ID, typeCast, focus); });
return;
}
if(typeCast != CompType::Typeless)
m_TextureSettings[ID].typeCast = typeCast;
if(m_LockedTabs.contains(ID))
{
if(focus)
@@ -2062,10 +2065,15 @@ void TextureViewer::texContextItem_triggered()
return;
}
QVariant id = act->property("id");
if(id.isValid())
QVariant idvar = act->property("id");
if(idvar.isValid())
{
ViewTexture(id.value<ResourceId>(), false);
ResourceId id = idvar.value<ResourceId>();
CompType typeCast = CompType::Typeless;
if(m_TextureSettings.contains(id))
typeCast = m_TextureSettings[id].typeCast;
ViewTexture(id, typeCast, false);
return;
}
}
@@ -2361,7 +2369,9 @@ void TextureViewer::thumb_doubleClicked(QMouseEvent *e)
ResourceId id = m_Following.GetResourceId(m_Ctx);
if(id != ResourceId())
ViewTexture(id, false);
{
ViewTexture(id, m_Following.GetTypeHint(m_Ctx), false);
}
}
}
@@ -3996,7 +4006,10 @@ void TextureViewer::texture_itemActivated(RDTreeWidgetItem *item, int column)
}
else
{
ViewTexture(tex->resourceId, true);
CompType typeCast = CompType::Typeless;
if(m_TextureSettings.contains(tex->resourceId))
typeCast = m_TextureSettings[tex->resourceId].typeCast;
ViewTexture(tex->resourceId, typeCast, true);
}
}
+1 -1
View File
@@ -144,7 +144,7 @@ public:
// ITextureViewer
QWidget *Widget() override { return this; }
void ViewTexture(ResourceId ID, bool focus) override;
void ViewTexture(ResourceId ID, CompType typeCast, bool focus) override;
void GotoLocation(int x, int y) override;
// ICaptureViewer