From 4ef11b883512f68d00be6ca378d714934d02ed57 Mon Sep 17 00:00:00 2001 From: Robin De Moor Date: Mon, 8 Nov 2021 10:19:48 +0100 Subject: [PATCH 1/3] fix finishPostProcessOnScreen check 2D renderer --- .../Runtime/Passes/PostProcessPass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs b/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs index b18dcb6429a..9da4509e57d 100644 --- a/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs +++ b/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs @@ -552,7 +552,7 @@ void Swap(ref ScriptableRenderer r) } // With camera stacking we not always resolve post to final screen as we might run post-processing in the middle of the stack. - bool finishPostProcessOnScreen = m_ResolveToScreen; + bool finishPostProcessOnScreen = m_UseSwapBuffer ? m_ResolveToScreen : cameraData.resolveFinalTarget || (m_Destination == cameraTargetHandle || m_HasFinalPass == true); #if ENABLE_VR && ENABLE_XR_MODULE if (cameraData.xr.enabled) From ae6b69ab6d53762674f9b4370c1acfe587b47b40 Mon Sep 17 00:00:00 2001 From: Robin De Moor Date: Mon, 8 Nov 2021 10:26:47 +0100 Subject: [PATCH 2/3] add changelog --- com.unity.render-pipelines.universal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index a626525faeb..b15f6790856 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for rendering thumbnails. [case 1348209](https://issuetracker.unity3d.com/issues/preview-of-assets-do-not-show-in-the-project-window) - Fixed a regression bug where XR camera postion can not be modified in beginCameraRendering [case 1365000] - Fixed an issue in where installing the Adaptive Performance package caused errors to the inspector UI [1368161](https://issuetracker.unity3d.com/issues/urp-package-throws-compilation-error-cs1525-when-imported-together-with-adaptive-performance-package) +- Fixed a performance regression in the 2D renderer regarding the PostProcessPass [case 1347893] ## [13.1.0] - 2021-09-24 ### Added From 9e74a6b0550417894204ea3c18e667e948e19475 Mon Sep 17 00:00:00 2001 From: Robin De Moor Date: Mon, 29 Nov 2021 09:33:11 +0100 Subject: [PATCH 3/3] Remove redundant bool --- .../Runtime/Passes/PostProcessPass.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs b/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs index 097f8a41b38..63dfa75c85b 100644 --- a/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs +++ b/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs @@ -527,6 +527,7 @@ void Swap(ref ScriptableRenderer r) #endif RenderTargetIdentifier cameraTarget = (cameraData.targetTexture != null && !cameraData.xr.enabled) ? new RenderTargetIdentifier(cameraData.targetTexture) : cameraTargetID; + // With camera stacking we not always resolve post to final screen as we might run post-processing in the middle of the stack. if (m_UseSwapBuffer) { cameraTarget = (m_ResolveToScreen) ? cameraTarget : targetDestination; @@ -537,9 +538,6 @@ void Swap(ref ScriptableRenderer r) m_ResolveToScreen = cameraData.resolveFinalTarget || (m_Destination.nameID == cameraTargetID || m_HasFinalPass == true); } - // With camera stacking we not always resolve post to final screen as we might run post-processing in the middle of the stack. - bool finishPostProcessOnScreen = m_UseSwapBuffer ? m_ResolveToScreen : cameraData.resolveFinalTarget || (m_Destination == cameraTargetHandle || m_HasFinalPass == true); - #if ENABLE_VR && ENABLE_XR_MODULE if (cameraData.xr.enabled) { @@ -561,7 +559,7 @@ void Swap(ref ScriptableRenderer r) // For now, when render post - processing in the middle of the camera stack(not resolving to screen) // we do an extra blit to ping pong results back to color texture. In future we should allow a Swap of the current active color texture // in the pipeline to avoid this extra blit. - if (!finishPostProcessOnScreen && !m_UseSwapBuffer) + if (!m_ResolveToScreen && !m_UseSwapBuffer) { cmd.SetGlobalTexture(ShaderPropertyId.sourceTex, cameraTarget); cmd.SetRenderTarget(new RenderTargetIdentifier(m_Source, 0, CubemapFace.Unknown, -1), @@ -590,7 +588,7 @@ void Swap(ref ScriptableRenderer r) // For now, when render post-processing in the middle of the camera stack (not resolving to screen) // we do an extra blit to ping pong results back to color texture. In future we should allow a Swap of the current active color texture // in the pipeline to avoid this extra blit. - if (!finishPostProcessOnScreen && !m_UseSwapBuffer) + if (!m_ResolveToScreen && !m_UseSwapBuffer) { cmd.SetGlobalTexture(ShaderPropertyId.sourceTex, cameraTarget); cmd.SetRenderTarget(m_Source, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare);