From 952c040665be6e6d562d62b075c42b828421483c Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Wed, 28 Apr 2021 16:38:02 +0200 Subject: [PATCH 1/2] Fix history buffer allocation for AOVs when the request does not come in first frame # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs Fix bad merge --- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index ebc5bd7818a..24f3640df7a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -684,10 +684,24 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, if (isHistoryColorPyramidRequired) // Superset of case above numColorPyramidBuffersRequired = 2; - int numVolumetricBuffersRequired = isVolumetricHistoryRequired ? 2 : 0; // History + feedback + bool forceReallocPyramid = false; + int colorBufferID = (int)HDCameraFrameHistoryType.ColorBufferMipChain; + int numColorPyramidBuffersAllocated = m_HistoryRTSystem.GetNumFramesAllocated(colorBufferID); - if ((m_NumColorPyramidBuffersAllocated != numColorPyramidBuffersRequired) || - (m_NumVolumetricBuffersAllocated != numVolumetricBuffersRequired)) + // Check if we have any AOV requests that require history buffer allocations (the actual allocation happens later in this function) + foreach (var aovRequest in aovRequests) + { + var aovHistory = GetHistoryRTHandleSystem(aovRequest); + if (aovHistory.GetNumFramesAllocated(colorBufferID) != numColorPyramidBuffersRequired) + { + forceReallocPyramid = true; + break; + } + } + + int numVolumetricBuffersRequired = isVolumetricHistoryRequired ? 2 : 0; // History + feedback + if ((numColorPyramidBuffersAllocated != numColorPyramidBuffersRequired) || + (m_NumVolumetricBuffersAllocated != numVolumetricBuffersRequired) || forceReallocPyramid) { // Reinit the system. colorPyramidHistoryIsValid = false; @@ -723,7 +737,6 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, } // Mark as init. - m_NumColorPyramidBuffersAllocated = numColorPyramidBuffersRequired; m_NumVolumetricBuffersAllocated = numVolumetricBuffersRequired; } } @@ -1136,7 +1149,6 @@ public RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSyst HDAdditionalCameraData m_AdditionalCameraData = null; // Init in Update BufferedRTHandleSystem m_HistoryRTSystem = new BufferedRTHandleSystem(); - int m_NumColorPyramidBuffersAllocated = 0; int m_NumVolumetricBuffersAllocated = 0; float m_AmbientOcclusionResolutionScale = 0.0f; // Factor used to track if history should be reallocated for Ambient Occlusion float m_ScreenSpaceAccumulationResolutionScale = 0.0f; // Use another scale if AO & SSR don't have the same resolution From 4f3e104c2aa9553b89c6fd386e409c35519a620b Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Mon, 3 May 2021 19:01:02 +0200 Subject: [PATCH 2/2] Changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1fe1bb11c7f..0fd6046a636 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -184,6 +184,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed contact shadows tile coordinates calculations. - Fixed blocky looking bloom when dynamic resolution scaling was used. - Fixed material Emission properties not begin animated when recording an animation (case 1328108). +- Fixed issue with history buffer allocation for AOVs when the request does not come in first frame. ### Changed - Removed the material pass probe volumes evaluation mode.