Skip to content

[Backport 2021.1] Fix history buffer allocation for AOVs when the request does not come in first frame #4419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -723,7 +737,6 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
}

// Mark as init.
m_NumColorPyramidBuffersAllocated = numColorPyramidBuffersRequired;
m_NumVolumetricBuffersAllocated = numVolumetricBuffersRequired;
}
}
Expand Down Expand Up @@ -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
Expand Down