From e660fc85dd9142c370135090367b0eac40fe32ea Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 25 Mar 2022 11:12:28 +0000 Subject: [PATCH] Ensure custom shader output is updated before fetching histogram * The custom shader output is updated when displaying, but this can lag by a call or two (a 'frame' if you like) when the display is only triggered by a window repaint and the histogram can be fetched first. Since the custom shader apply is only expensive when we need to recreate the output texture, we can do it on-demand similar to what we do with the overlay texture. --- renderdoc/replay/replay_controller.h | 1 + renderdoc/replay/replay_output.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/renderdoc/replay/replay_controller.h b/renderdoc/replay/replay_controller.h index f7540e9ab..3bf3a75d9 100644 --- a/renderdoc/replay/replay_controller.h +++ b/renderdoc/replay/replay_controller.h @@ -79,6 +79,7 @@ private: ReplayController *m_pController; + bool m_CustomDirty; bool m_OverlayDirty; bool m_ForceOverlayRefresh; diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index a2fd6a2e6..cd003338b 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -92,6 +92,7 @@ ReplayOutput::ReplayOutput(ReplayController *parent, WindowingData window, Repla m_MainOutput.dirty = true; + m_CustomDirty = false; m_OverlayDirty = false; m_ForceOverlayRefresh = false; @@ -196,6 +197,7 @@ void ReplayOutput::SetTextureDisplay(const TextureDisplay &o) } if(wasClearBeforeDraw && o.backgroundColor != m_RenderData.texDisplay.backgroundColor) m_OverlayDirty = true; + m_CustomDirty = true; m_RenderData.texDisplay = o; m_MainOutput.dirty = true; } @@ -217,6 +219,7 @@ void ReplayOutput::SetFrameEvent(int eventId) m_EventID = eventId; m_OverlayDirty = (m_RenderData.texDisplay.overlay != DebugOverlay::NoOverlay); + m_CustomDirty = true; m_MainOutput.dirty = true; for(size_t i = 0; i < m_Thumbnails.size(); i++) @@ -298,6 +301,18 @@ ResourceId ReplayOutput::GetCustomShaderTexID() { CHECK_REPLAY_THREAD(); + if(m_CustomDirty) + { + TextureDisplay texDisplay = m_RenderData.texDisplay; + texDisplay.rawOutput = false; + texDisplay.resourceId = m_pDevice->GetLiveID(texDisplay.resourceId); + + m_CustomShaderResourceId = m_pDevice->ApplyCustomShader(texDisplay); + m_pController->FatalErrorCheck(); + + m_CustomDirty = false; + } + return m_CustomShaderResourceId; } @@ -768,6 +783,8 @@ void ReplayOutput::DisplayTex() texDisplay.typeCast = CompType::Typeless; texDisplay.customShaderId = ResourceId(); texDisplay.subresource.slice = 0; + + m_CustomDirty = false; } FloatVector color;