From f578e626841b25fa3cf5e7f99fa49113c2fca4f6 Mon Sep 17 00:00:00 2001 From: Leonard Tsai Date: Tue, 10 Jan 2023 16:32:47 -0800 Subject: [PATCH] Allow multiple depth targets to be viewable in the TextureViewer --- qrenderdoc/Code/Interface/QRDInterface.h | 7 +++- qrenderdoc/Windows/ShaderMessageViewer.cpp | 1 + qrenderdoc/Windows/TextureViewer.cpp | 37 +++++++++++++++++++++- qrenderdoc/Windows/TextureViewer.h | 1 + renderdoc/api/replay/pipestate.h | 7 ++++ renderdoc/api/replay/pipestate.inl | 26 +++++++++++++++ 6 files changed, 77 insertions(+), 2 deletions(-) diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index 60ad8b199..68ab66550 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -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."); diff --git a/qrenderdoc/Windows/ShaderMessageViewer.cpp b/qrenderdoc/Windows/ShaderMessageViewer.cpp index 137641a7b..70ae869db 100644 --- a/qrenderdoc/Windows/ShaderMessageViewer.cpp +++ b/qrenderdoc/Windows/ShaderMessageViewer.cpp @@ -185,6 +185,7 @@ ShaderMessageViewer::ShaderMessageViewer(ICaptureContext &ctx, ShaderStageMask s m_Multisampled = false; rdcarray outs = pipe.GetOutputTargets(); outs.push_back(pipe.GetDepthTarget()); + outs.push_back(pipe.GetDepthResolveTarget()); for(const BoundResource &o : outs) { if(o.resourceId == ResourceId()) diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index ab5450731..bb2574d3a 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -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 &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 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 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 empty; diff --git a/qrenderdoc/Windows/TextureViewer.h b/qrenderdoc/Windows/TextureViewer.h index c40eed19b..2486e0ba3 100644 --- a/qrenderdoc/Windows/TextureViewer.h +++ b/qrenderdoc/Windows/TextureViewer.h @@ -72,6 +72,7 @@ struct Following static rdcarray GetOutputTargets(ICaptureContext &ctx); static BoundResource GetDepthTarget(ICaptureContext &ctx); + static BoundResource GetDepthResolveTarget(ICaptureContext &ctx); static rdcarray GetReadWriteResources(ICaptureContext &ctx, ShaderStage stage, bool onlyUsed); static rdcarray GetReadOnlyResources(ICaptureContext &ctx, ShaderStage stage, diff --git a/renderdoc/api/replay/pipestate.h b/renderdoc/api/replay/pipestate.h index a0560e7ab..8f5e92193 100644 --- a/renderdoc/api/replay/pipestate.h +++ b/renderdoc/api/replay/pipestate.h @@ -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. diff --git a/renderdoc/api/replay/pipestate.inl b/renderdoc/api/replay/pipestate.inl index d55f53785..baa2dd823 100644 --- a/renderdoc/api/replay/pipestate.inl +++ b/renderdoc/api/replay/pipestate.inl @@ -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 PipeState::GetOutputTargets() const { rdcarray ret;