Skip to content

Commit 19c0060

Browse files
authored
[Backport 2021.1] Fix history buffer allocation for AOVs when the request does not come in first frame (#4419)
* 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 * Changelog
1 parent 6cac97a commit 19c0060

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
185185
- Fixed contact shadows tile coordinates calculations.
186186
- Fixed blocky looking bloom when dynamic resolution scaling was used.
187187
- Fixed material Emission properties not begin animated when recording an animation (case 1328108).
188+
- Fixed issue with history buffer allocation for AOVs when the request does not come in first frame.
188189

189190
### Changed
190191
- Removed the material pass probe volumes evaluation mode.

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,24 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
684684
if (isHistoryColorPyramidRequired) // Superset of case above
685685
numColorPyramidBuffersRequired = 2;
686686

687-
int numVolumetricBuffersRequired = isVolumetricHistoryRequired ? 2 : 0; // History + feedback
687+
bool forceReallocPyramid = false;
688+
int colorBufferID = (int)HDCameraFrameHistoryType.ColorBufferMipChain;
689+
int numColorPyramidBuffersAllocated = m_HistoryRTSystem.GetNumFramesAllocated(colorBufferID);
688690

689-
if ((m_NumColorPyramidBuffersAllocated != numColorPyramidBuffersRequired) ||
690-
(m_NumVolumetricBuffersAllocated != numVolumetricBuffersRequired))
691+
// Check if we have any AOV requests that require history buffer allocations (the actual allocation happens later in this function)
692+
foreach (var aovRequest in aovRequests)
693+
{
694+
var aovHistory = GetHistoryRTHandleSystem(aovRequest);
695+
if (aovHistory.GetNumFramesAllocated(colorBufferID) != numColorPyramidBuffersRequired)
696+
{
697+
forceReallocPyramid = true;
698+
break;
699+
}
700+
}
701+
702+
int numVolumetricBuffersRequired = isVolumetricHistoryRequired ? 2 : 0; // History + feedback
703+
if ((numColorPyramidBuffersAllocated != numColorPyramidBuffersRequired) ||
704+
(m_NumVolumetricBuffersAllocated != numVolumetricBuffersRequired) || forceReallocPyramid)
691705
{
692706
// Reinit the system.
693707
colorPyramidHistoryIsValid = false;
@@ -723,7 +737,6 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
723737
}
724738

725739
// Mark as init.
726-
m_NumColorPyramidBuffersAllocated = numColorPyramidBuffersRequired;
727740
m_NumVolumetricBuffersAllocated = numVolumetricBuffersRequired;
728741
}
729742
}
@@ -1136,7 +1149,6 @@ public RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSyst
11361149

11371150
HDAdditionalCameraData m_AdditionalCameraData = null; // Init in Update
11381151
BufferedRTHandleSystem m_HistoryRTSystem = new BufferedRTHandleSystem();
1139-
int m_NumColorPyramidBuffersAllocated = 0;
11401152
int m_NumVolumetricBuffersAllocated = 0;
11411153
float m_AmbientOcclusionResolutionScale = 0.0f; // Factor used to track if history should be reallocated for Ambient Occlusion
11421154
float m_ScreenSpaceAccumulationResolutionScale = 0.0f; // Use another scale if AO & SSR don't have the same resolution

0 commit comments

Comments
 (0)