From 55c9cf8ff2c6bfa22b6a38e6600014ad56c6053e Mon Sep 17 00:00:00 2001 From: Johann Muszynski Date: Wed, 3 Jul 2024 20:23:36 +0300 Subject: [PATCH] Invalidate temporal accumulation on frame resize --- src/pt/deferred_renderer.cpp | 9 +++++++++ src/pt/deferred_renderer.hpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/pt/deferred_renderer.cpp b/src/pt/deferred_renderer.cpp index 1f94670..07df8a7 100644 --- a/src/pt/deferred_renderer.cpp +++ b/src/pt/deferred_renderer.cpp @@ -555,6 +555,8 @@ void DeferredRenderer::resize(const GpuContext& gpuContext, const Extent2u& newS mDebugPass.resize(gpuContext, mAlbedoTextureView, mNormalTextureView, mDepthTextureView); mLightingPass.resize(gpuContext, mAlbedoTextureView, mNormalTextureView, mDepthTextureView); + + invalidateTemporalAccumulation(); } DeferredRenderer::GbufferPass::GbufferPass( @@ -2041,4 +2043,11 @@ DeferredRenderer::PerfStats DeferredRenderer::getPerfStats() const mResolvePassDurationsNs.begin(), mResolvePassDurationsNs.end(), 0ll)) / mResolvePassDurationsNs.size()}; } + +void DeferredRenderer::invalidateTemporalAccumulation() +{ + // In the first frame of the accumulation sequence, we are forced to write the lighting pass + // sample straight to the accumulation buffer. This effectively resets the accumulation. + mFrameCount = 0; +} } // namespace nlrs diff --git a/src/pt/deferred_renderer.hpp b/src/pt/deferred_renderer.hpp index b656605..8221b56 100644 --- a/src/pt/deferred_renderer.hpp +++ b/src/pt/deferred_renderer.hpp @@ -274,6 +274,8 @@ class DeferredRenderer Gui& gui); }; + void invalidateTemporalAccumulation(); + WGPUTexture mDepthTexture; WGPUTextureView mDepthTextureView; WGPUTexture mAlbedoTexture;