Browse Source

Perform OnRenderImage blit using an explicit temporary RT for the upscaled output. This can be blitted directly instead of needing an awkward command buffer, and it'll be less likely to cause issues than blitting from and to the same display buffer.

stable
Nico de Poel 3 years ago
parent
commit
ea05e5da58
  1. 17
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

17
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

@ -210,11 +210,12 @@ namespace UnityEngine.Rendering.PostProcessing
CommandBuffer m_LegacyCmdBufferBeforeLighting; CommandBuffer m_LegacyCmdBufferBeforeLighting;
CommandBuffer m_LegacyCmdBufferOpaque; CommandBuffer m_LegacyCmdBufferOpaque;
CommandBuffer m_LegacyCmdBuffer; CommandBuffer m_LegacyCmdBuffer;
CommandBuffer m_BlitCmdBuffer;
Camera m_Camera; Camera m_Camera;
PostProcessRenderContext m_CurrentContext; PostProcessRenderContext m_CurrentContext;
LogHistogram m_LogHistogram; LogHistogram m_LogHistogram;
RenderTexture m_upscaledOutput;
bool m_SettingsUpdateNeeded = true; bool m_SettingsUpdateNeeded = true;
bool m_IsRenderingInSceneView = false; bool m_IsRenderingInSceneView = false;
@ -252,7 +253,6 @@ namespace UnityEngine.Rendering.PostProcessing
m_LegacyCmdBufferBeforeLighting = new CommandBuffer { name = "Deferred Ambient Occlusion" }; m_LegacyCmdBufferBeforeLighting = new CommandBuffer { name = "Deferred Ambient Occlusion" };
m_LegacyCmdBufferOpaque = new CommandBuffer { name = "Opaque Only Post-processing" }; m_LegacyCmdBufferOpaque = new CommandBuffer { name = "Opaque Only Post-processing" };
m_LegacyCmdBuffer = new CommandBuffer { name = "Post-processing" }; m_LegacyCmdBuffer = new CommandBuffer { name = "Post-processing" };
m_BlitCmdBuffer = new CommandBuffer { name = "Backbuffer blit" };
m_Camera = GetComponent<Camera>(); m_Camera = GetComponent<Camera>();
@ -286,10 +286,8 @@ namespace UnityEngine.Rendering.PostProcessing
if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive()) if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive())
{ {
// Blit the upscaled image to the backbuffer // Blit the upscaled image to the backbuffer
m_BlitCmdBuffer.Blit(m_CurrentContext.destination, dst);
Graphics.ExecuteCommandBuffer(m_BlitCmdBuffer);
RenderTexture.active = dst;
Graphics.Blit(m_upscaledOutput, dst);
m_upscaledOutput.Release();
return; return;
} }
@ -584,7 +582,6 @@ namespace UnityEngine.Rendering.PostProcessing
m_LegacyCmdBufferBeforeLighting.Clear(); m_LegacyCmdBufferBeforeLighting.Clear();
m_LegacyCmdBufferOpaque.Clear(); m_LegacyCmdBufferOpaque.Clear();
m_LegacyCmdBuffer.Clear(); m_LegacyCmdBuffer.Clear();
m_BlitCmdBuffer.Clear();
SetupContext(context); SetupContext(context);
@ -716,9 +713,9 @@ namespace UnityEngine.Rendering.PostProcessing
if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive()) if (!finalBlitToCameraTarget && m_CurrentContext.IsSuperResolutionActive())
{ {
// Use the main display buffer for temporarily storing the upscaled full-resolution image
context.flip = true;
context.destination = Display.main.colorBuffer;
var displaySize = superResolution.displaySize;
m_upscaledOutput = context.GetScreenSpaceTemporaryRT(widthOverride: displaySize.x, heightOverride: displaySize.y);
context.destination = m_upscaledOutput;
} }
#if UNITY_2019_1_OR_NEWER #if UNITY_2019_1_OR_NEWER

Loading…
Cancel
Save