Allow multiple depth targets to be viewable in the TextureViewer

This commit is contained in:
Leonard Tsai
2023-01-10 16:32:47 -08:00
committed by Baldur Karlsson
parent 588d205279
commit f578e62684
6 changed files with 77 additions and 2 deletions
+6 -1
View File
@@ -597,13 +597,18 @@ DOCUMENT(R"(Specifies a type of followed resource for the :class:`TextureViewer`
The index specifies a resource within the given shader's
:data:`read-only resources <~renderdoc.ShaderReflection.readOnlyResources>`. The array element
then specifies the index within that resource's array, if applicable.
.. data:: OutputDepthResolve
The resource followed is the depth/stencil resolve output target. All other parameters are ignored.
)");
enum class FollowType : int
{
OutputColor,
OutputDepth,
ReadWrite,
ReadOnly
ReadOnly,
OutputDepthResolve
};
DOCUMENT("The texture viewer window.");
@@ -185,6 +185,7 @@ ShaderMessageViewer::ShaderMessageViewer(ICaptureContext &ctx, ShaderStageMask s
m_Multisampled = false;
rdcarray<BoundResource> outs = pipe.GetOutputTargets();
outs.push_back(pipe.GetDepthTarget());
outs.push_back(pipe.GetDepthResolveTarget());
for(const BoundResource &o : outs)
{
if(o.resourceId == ResourceId())
+36 -1
View File
@@ -160,6 +160,10 @@ BoundResource Following::GetBoundResource(ICaptureContext &ctx, int arrayIdx)
{
ret = GetDepthTarget(ctx);
}
else if(Type == FollowType::OutputDepthResolve)
{
ret = GetDepthResolveTarget(ctx);
}
else if(Type == FollowType::ReadWrite)
{
const rdcarray<BoundResourceArray> &rw = tex.m_ReadWriteResources[(int)Stage];
@@ -249,6 +253,17 @@ BoundResource Following::GetDepthTarget(ICaptureContext &ctx)
return ctx.CurPipelineState().GetDepthTarget();
}
BoundResource Following::GetDepthResolveTarget(ICaptureContext &ctx)
{
bool copy = false, clear = false, compute = false;
GetActionContext(ctx, copy, clear, compute);
if(copy || clear || compute)
return BoundResource(ResourceId());
else
return ctx.CurPipelineState().GetDepthResolveTarget();
}
rdcarray<BoundResourceArray> Following::GetReadWriteResources(ICaptureContext &ctx,
ShaderStage stage, bool onlyUsed)
{
@@ -1167,6 +1182,9 @@ void TextureViewer::UI_UpdateTextureDetails()
case FollowType::ReadOnly:
title = QString(tr("Cur Input %1 - %2")).arg(m_Following.index).arg(name);
break;
case FollowType::OutputDepthResolve:
title = QString(tr("Cur Depth Resolve Output - %1")).arg(name);
break;
}
}
else
@@ -1183,6 +1201,7 @@ void TextureViewer::UI_UpdateTextureDetails()
case FollowType::ReadOnly:
title = QString(tr("Cur Input %1")).arg(m_Following.index);
break;
case FollowType::OutputDepthResolve: title = QString(tr("Cur Depth Resolve Output")); break;
}
}
@@ -2099,7 +2118,7 @@ void TextureViewer::ViewFollowedResource(FollowType followType, ShaderStage stag
f.arrayEl = 0;
}
if(f.Type == FollowType::OutputDepth)
if(f.Type == FollowType::OutputDepth || f.Type == FollowType::OutputDepthResolve)
f.index = 0;
for(ResourcePreview *p :
@@ -3154,6 +3173,7 @@ void TextureViewer::OnEventChanged(uint32_t eventId)
rdcarray<BoundResource> RTs = Following::GetOutputTargets(m_Ctx);
BoundResource Depth = Following::GetDepthTarget(m_Ctx);
BoundResource DepthResolve = Following::GetDepthResolveTarget(m_Ctx);
int outIndex = 0;
int inIndex = 0;
@@ -3196,6 +3216,21 @@ void TextureViewer::OnEventChanged(uint32_t eventId)
InitResourcePreview(prev, Depth, false, follow, QString(), tr("DS"));
}
// depth resolve
{
ResourcePreview *prev;
if(outIndex < ui->outputThumbs->thumbs().size())
prev = ui->outputThumbs->thumbs()[outIndex];
else
prev = UI_CreateThumbnail(ui->outputThumbs);
outIndex++;
Following follow(*this, FollowType::OutputDepthResolve, ShaderStage::Pixel, 0, 0);
InitResourcePreview(prev, DepthResolve, false, follow, QString(), tr("DSR"));
}
const rdcarray<ShaderResource> empty;
+1
View File
@@ -72,6 +72,7 @@ struct Following
static rdcarray<BoundResource> GetOutputTargets(ICaptureContext &ctx);
static BoundResource GetDepthTarget(ICaptureContext &ctx);
static BoundResource GetDepthResolveTarget(ICaptureContext &ctx);
static rdcarray<BoundResourceArray> GetReadWriteResources(ICaptureContext &ctx, ShaderStage stage,
bool onlyUsed);
static rdcarray<BoundResourceArray> GetReadOnlyResources(ICaptureContext &ctx, ShaderStage stage,
+7
View File
@@ -388,6 +388,13 @@ For some APIs that don't distinguish by entry point, this may be empty.
)");
BoundResource GetDepthTarget() const;
DOCUMENT(R"(Retrieves the read/write resources bound to the depth-stencil resolve output.
:return: The currently bound depth-stencil resolve resource.
:rtype: BoundResource
)");
BoundResource GetDepthResolveTarget() const;
DOCUMENT(R"(Retrieves the resources bound to the color outputs.
:return: The currently bound output targets.
+26
View File
@@ -1760,6 +1760,32 @@ BoundResource PipeState::GetDepthTarget() const
return BoundResource();
}
BoundResource PipeState::GetDepthResolveTarget() const
{
if(IsCaptureLoaded())
{
if(IsCaptureVK())
{
const VKPipe::RenderPass &rp = m_Vulkan->currentPass.renderpass;
const VKPipe::Framebuffer &fb = m_Vulkan->currentPass.framebuffer;
if(rp.depthstencilResolveAttachment >= 0 &&
rp.depthstencilResolveAttachment < fb.attachments.count())
{
BoundResource ret;
ret.resourceId = fb.attachments[rp.depthstencilResolveAttachment].imageResourceId;
ret.firstMip = (int)fb.attachments[rp.depthstencilResolveAttachment].firstMip;
ret.firstSlice = (int)fb.attachments[rp.depthstencilResolveAttachment].firstSlice;
ret.typeCast = fb.attachments[rp.depthstencilResolveAttachment].viewFormat.compType;
return ret;
}
return BoundResource();
}
}
return BoundResource();
}
rdcarray<BoundResource> PipeState::GetOutputTargets() const
{
rdcarray<BoundResource> ret;