Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b4b6edf
initial store and load action SRP support
manuele-bonanno Apr 7, 2021
5c53798
removed depth prepass related temporary changes
manuele-bonanno Apr 8, 2021
6233c18
removing commented out code
manuele-bonanno Apr 8, 2021
1a77378
removing unused variables
manuele-bonanno Apr 8, 2021
03504e3
Added Store Actions settings
manuele-bonanno Apr 12, 2021
a6f59ed
moved the code that checks for injected passes
manuele-bonanno Apr 13, 2021
af2ecba
cleanup and addressing reviewer's feedback
manuele-bonanno Apr 13, 2021
1a9ce7f
Merge branch 'master' into urp/msaa_store_actions_optimization
manuele-bonanno Apr 13, 2021
1ee51a6
moved the "Store Actions" setting in the Advanced options section
manuele-bonanno Apr 13, 2021
8e95a89
further depth store action optimization for when MSAA is disabled
manuele-bonanno Apr 13, 2021
f2e7ec3
Added changelog entry
manuele-bonanno Apr 13, 2021
cc6422b
Added documentation
manuele-bonanno Apr 13, 2021
0b2d3a1
handling the opaque pass depth store actions separately for a more op…
manuele-bonanno Apr 14, 2021
701f703
Merge branch 'master' into urp/msaa_store_actions_optimization
manuele-bonanno Apr 15, 2021
f07f748
if "Store Actions"=Store, make sure to preserve and StoreAndResolve a…
manuele-bonanno Apr 15, 2021
de91e70
addressed reviewers feedback
manuele-bonanno Apr 16, 2021
060261b
added new API docs as requested by reviewers
manuele-bonanno Apr 16, 2021
cd25137
Added storeActionsOptimization property setter after reviewer's feedback
manuele-bonanno Apr 16, 2021
1bd8a24
the opaqueColorStoreAction should be StoreAndResolve only if copy col…
manuele-bonanno Apr 16, 2021
4e300f6
renamed parameter of CoreUtils.SetRenderTarget after reviewer's feedback
manuele-bonanno Apr 19, 2021
9761545
updated the tooltip after reviewer's feedback
manuele-bonanno Apr 19, 2021
887eb25
Merge branch 'master' into urp/msaa_store_actions_optimization
manuele-bonanno Apr 20, 2021
6b1315f
removed using System.ComponentModel.Design.Serialization; line added …
manuele-bonanno Apr 21, 2021
facbf42
removing files accidentally added by a previous merge
manuele-bonanno Apr 21, 2021
507291d
Edited the __Store Actions__ description.
oleks-k Apr 26, 2021
71e9011
Edited the StoreActionsOptimization API descriptions.
oleks-k Apr 26, 2021
b46f66a
Merge branch 'master' into urp/msaa_store_actions_optimization
manuele-bonanno Apr 26, 2021
23694e6
Merge branch 'master' into urp/msaa_store_actions_optimization
manuele-bonanno Apr 27, 2021
39b1394
editor test fix
manuele-bonanno Apr 27, 2021
497777f
Merge branch 'master' into urp/msaa_store_actions_optimization
phi-lira Apr 28, 2021
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
18 changes: 18 additions & 0 deletions com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,24 @@ public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier col
ClearRenderTarget(cmd, clearFlag, clearColor);
}

/// <summary>
/// Set the current render texture.
/// </summary>
/// <param name="cmd">CommandBuffer used for rendering commands.</param>
/// <param name="colorBuffer">Color buffer RenderTargetIdentifier.</param>
/// <param name="colorLoadAction">Color buffer load action.</param>
/// <param name="colorStoreAction">Color buffer store action.</param>
/// <param name="depthLoadAction">Depth buffer load action.</param>
/// <param name="depthStoreAction">Depth buffer store action.</param>
/// <param name="clearFlag">If not set to ClearFlag.None, specifies how to clear the render target after setup.</param>
/// <param name="clearColor">If applicable, color with which to clear the render texture after setup.</param>
public static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorBuffer, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction,
RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction, ClearFlag clearFlag, Color clearColor)
{
cmd.SetRenderTarget(colorBuffer, colorLoadAction, colorStoreAction, depthLoadAction, depthStoreAction);
ClearRenderTarget(cmd, clearFlag, clearColor);
}

/// <summary>
/// Set the current render texture.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal class Styles
public static GUIContent requireOpaqueTextureText = EditorGUIUtility.TrTextContent("Opaque Texture", "If enabled the pipeline will copy the screen to texture after opaque objects are drawn. For transparent objects this can be bound in shaders as _CameraOpaqueTexture.");
public static GUIContent opaqueDownsamplingText = EditorGUIUtility.TrTextContent("Opaque Downsampling", "The downsampling method that is used for the opaque texture");
public static GUIContent supportsTerrainHolesText = EditorGUIUtility.TrTextContent("Terrain Holes", "When disabled, Universal Rendering Pipeline removes all Terrain hole Shader variants when you build for the Unity Player. This decreases build time.");
public static GUIContent StoreActionsOptimizationText = EditorGUIUtility.TrTextContent("Store Actions", "Sets the store actions policy on mobile GPUs. 'Discard': discard as much as possible, 'Store': always store, 'Auto': Discard if no custom passes are injected, otherwise Store.");

// Quality
public static GUIContent hdrText = EditorGUIUtility.TrTextContent("HDR", "Controls the global HDR settings.");
Expand Down Expand Up @@ -113,6 +114,7 @@ internal class Styles
SerializedProperty m_RequireOpaqueTextureProp;
SerializedProperty m_OpaqueDownsamplingProp;
SerializedProperty m_SupportsTerrainHolesProp;
SerializedProperty m_StoreActionsOptimizationProperty;

SerializedProperty m_HDR;
SerializedProperty m_MSAA;
Expand Down Expand Up @@ -193,6 +195,7 @@ void OnEnable()
m_RequireOpaqueTextureProp = serializedObject.FindProperty("m_RequireOpaqueTexture");
m_OpaqueDownsamplingProp = serializedObject.FindProperty("m_OpaqueDownsampling");
m_SupportsTerrainHolesProp = serializedObject.FindProperty("m_SupportsTerrainHoles");
m_StoreActionsOptimizationProperty = serializedObject.FindProperty("m_StoreActionsOptimization");

m_HDR = serializedObject.FindProperty("m_SupportsHDR");
m_MSAA = serializedObject.FindProperty("m_MSAA");
Expand Down Expand Up @@ -270,6 +273,7 @@ void DrawGeneralSettings()
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel--;
EditorGUILayout.PropertyField(m_SupportsTerrainHolesProp, Styles.supportsTerrainHolesText);
EditorGUILayout.PropertyField(m_StoreActionsOptimizationProperty, Styles.StoreActionsOptimizationText);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.Space();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using UnityEditorInternal;
#endif
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Linq;

namespace UnityEngine.Rendering.LWRP
Expand Down Expand Up @@ -97,6 +98,13 @@ public enum ColorGradingMode
HighDynamicRange
}

public enum StoreActionsOptimization
{
Auto,
Discard,
Store
}

[ExcludeFromPreset]
public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerializationCallbackReceiver
{
Expand All @@ -121,6 +129,7 @@ public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerial
[SerializeField] bool m_RequireOpaqueTexture = false;
[SerializeField] Downsampling m_OpaqueDownsampling = Downsampling._2xBilinear;
[SerializeField] bool m_SupportsTerrainHoles = true;
[SerializeField] StoreActionsOptimization m_StoreActionsOptimization = StoreActionsOptimization.Auto;

// Quality settings
[SerializeField] bool m_SupportsHDR = true;
Expand Down Expand Up @@ -519,6 +528,11 @@ public bool supportsTerrainHoles
get { return m_SupportsTerrainHoles; }
}

public StoreActionsOptimization storeActionsOptimization
{
get { return m_StoreActionsOptimization; }
}

public bool supportsHDR
{
get { return m_SupportsHDR; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ public RenderTargetIdentifier depthAttachment
get => m_DepthAttachment;
}

public RenderBufferStoreAction colorStoreAction
{
get => m_ColorStoreActions[0];
}

public RenderBufferStoreAction depthStoreAction
{
get => m_DepthStoreAction;
}

/// <summary>
/// The input requirements for the <c>ScriptableRenderPass</c>, which has been set using <c>ConfigureInput</c>
/// </summary>
Expand All @@ -169,6 +179,9 @@ public Color clearColor
get => m_ClearColor;
}

RenderBufferStoreAction[] m_ColorStoreActions = new RenderBufferStoreAction[] { RenderBufferStoreAction.Store };
RenderBufferStoreAction m_DepthStoreAction = RenderBufferStoreAction.Store;
Comment on lines +183 to +184
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why not backing the entire attachemnt setup with something like https://docs.unity3d.com/ScriptReference/Rendering.RenderTargetBinding.html

I also find it weird that we provide StoreActions but don't expose LoadAction. If we don't think in terms of API completeness I feel like very soon someone might ask for Load actions as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in engine load actions are inferred based on the store actions setup, and this change or every API implementation. The only proper way right now to set load/store actions without having to fight built-in logic is to use the RenderPass API.

So while exposing the load actions here is easy, I am not sure they will have much effect in terms of determining the final store action used by the device. So there would be a lot of work needed to allow that. If it is important can be done as a future task, but from my experience the engine does a good job in figuring out the load actions and the main problems were introduced by wrong stores, so not sure the effort to have an explicit Load action API is worth it (also considering RenderPasses will do that)

I agree having only stores exposed in the API makes it feel limited, but if we want load actions too then it might involve lot of extra work. Future PRs could address it if really needed. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. sounds good to me and fair justification.


/// <summary>
/// A ProfilingSampler for the entire render pass. Used as a profiling name by <c>ScriptableRenderer</c> when executing the pass.
/// Default is <c>Unnamed_ScriptableRenderPass</c>.
Expand Down Expand Up @@ -201,6 +214,8 @@ public ScriptableRenderPass()
renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
m_ColorAttachments = new RenderTargetIdentifier[] {BuiltinRenderTextureType.CameraTarget, 0, 0, 0, 0, 0, 0, 0};
m_DepthAttachment = BuiltinRenderTextureType.CameraTarget;
m_ColorStoreActions = new RenderBufferStoreAction[] { RenderBufferStoreAction.Store, 0, 0, 0, 0, 0, 0, 0 };
m_DepthStoreAction = RenderBufferStoreAction.Store;
m_ClearFlag = ClearFlag.None;
m_ClearColor = Color.black;
overrideCameraTarget = false;
Expand Down Expand Up @@ -229,6 +244,24 @@ public void ConfigureInput(ScriptableRenderPassInput passInput)
m_Input = passInput;
}

public void ConfigureColorStoreAction(uint attachmentIndex, RenderBufferStoreAction storeAction)
{
m_ColorStoreActions[attachmentIndex] = storeAction;
}

public void ConfigureColorStoreActions(RenderBufferStoreAction[] storeActions, uint attachmentsCount)
{
for (uint i = 0; i < attachmentsCount; ++i)
{
m_ColorStoreActions[i] = storeActions[i];
}
}

public void ConfigureDepthStoreAction(RenderBufferStoreAction storeAction)
{
m_DepthStoreAction = storeAction;
}

/// <summary>
/// Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget.
/// This method should be called inside Configure.
Expand Down
56 changes: 53 additions & 3 deletions com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ static class RenderPassBlock
public static readonly int AfterRendering = 3;
}

private StoreActionsOptimization m_StoreActionsOptimizationSetting = StoreActionsOptimization.Auto;
private static bool m_UseOptimizedStoreActions = false;

const int k_RenderPassBlockCount = 4;

List<ScriptableRenderPass> m_ActiveRenderPassQueue = new List<ScriptableRenderPass>(32);
Expand All @@ -422,6 +425,14 @@ static class RenderPassBlock
static RenderTargetIdentifier[] m_ActiveColorAttachments = new RenderTargetIdentifier[] {0, 0, 0, 0, 0, 0, 0, 0 };
static RenderTargetIdentifier m_ActiveDepthAttachment;

private static RenderBufferStoreAction[] m_ActiveColorStoreActions = new RenderBufferStoreAction[]
{
RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, RenderBufferStoreAction.Store,
RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, RenderBufferStoreAction.Store
};

private static RenderBufferStoreAction m_ActiveDepthStoreAction = RenderBufferStoreAction.Store;

static AttachmentDescriptor[] m_ActiveColorAttachmentDescriptors = new AttachmentDescriptor[]
{
RenderingUtils.emptyAttachment, RenderingUtils.emptyAttachment, RenderingUtils.emptyAttachment,
Expand Down Expand Up @@ -476,6 +487,9 @@ public ScriptableRenderer(ScriptableRendererData data)
useRenderPassEnabled = data.useNativeRenderPass;
Clear(CameraRenderType.Base);
m_ActiveRenderPassQueue.Clear();

m_StoreActionsOptimizationSetting = UniversalRenderPipeline.asset.storeActionsOptimization;
m_UseOptimizedStoreActions = m_StoreActionsOptimizationSetting != StoreActionsOptimization.Store;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StoreActionsOptimization.Store should also remove store optimization from other passes like post-processing imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand what you mean?
Currently StoreActionsOptimization.Store will remove optimization from all the passes going through the new SetRenderTarget API that explicitely sets the store actions. So any passes using that new interface will be affected. Right now that is only the DrawOpaque and DrawTransparent passes, but it is extensible to other passes in the future including post processing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostProcessingPass.cs has some optimizations to load and store with SetRenderTarget. F.ex, I think we never store depth after post but some users asked for it. I was asking if these settings should affect those optimizations we already have there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that sounds like a good idea. This PR is focusing on the opaque/transparent passes on top of introducing the new API. But extending the optimization options to other passes in future PRs sounds trivial (should be a matter of making sure that the new explicit actions API is called by the postproc pass)

}

public void Dispose()
Expand Down Expand Up @@ -796,6 +810,10 @@ protected void AddRenderPasses(ref RenderingData renderingData)
if (activeRenderPassQueue[i] == null)
activeRenderPassQueue.RemoveAt(i);
}

// if any pass was injected, the "automatic" store optimization policy will disable the optimized load actions
if (count > 0 && m_StoreActionsOptimizationSetting == StoreActionsOptimization.Auto)
m_UseOptimizedStoreActions = false;
}

void ClearRenderingState(CommandBuffer cmd)
Expand Down Expand Up @@ -1179,9 +1197,10 @@ void SetRenderPassAttachments(CommandBuffer cmd, ScriptableRenderPass renderPass
else
{
// Only setup render target if current render pass attachments are different from the active ones
if (passColorAttachment != m_ActiveColorAttachments[0] || passDepthAttachment != m_ActiveDepthAttachment || finalClearFlag != ClearFlag.None)
if (passColorAttachment != m_ActiveColorAttachments[0] || passDepthAttachment != m_ActiveDepthAttachment || finalClearFlag != ClearFlag.None ||
renderPass.colorStoreAction != m_ActiveColorStoreActions[0] || renderPass.depthStoreAction != m_ActiveDepthStoreAction)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but maybe for the future we could store the current attachment setup with something like https://docs.unity3d.com/ScriptReference/Rendering.RenderTargetBinding.html then it would make code more readable to compare pass binding with active binding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May this check introduce redundant render target switches? For example if the active store action is Store and the new action is DontCare then we still have one store in total + a render target switch that implies loads for other attachments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the only place where m_ActiveColorStoreActions is read, but we only read m_ActiveColorStoreActions[0]. Is that on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the non MRT path so there should be only one color attachment (the first check that was already there only checks for color[0]: passColorAttachment != m_ActiveColorAttachments[0])

In general this optimization PR is only for the forward renderer at the moment, so I didn't do anything in MRT/deferred branches

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding redundant render target switches: I suppose that could happen potentially. It doesn't happen with the current optimizations I did, but if users want to customize further their store actions in some cases it could lead to unoptimal switches I guess. But not sure there is much we can do about it. If we expose more low level customization options this is one of the risks. more power->more responsibility?

Copy link
Contributor Author

@manuele-bonanno manuele-bonanno Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that in some cases the engine would still do extra target switches compared to URP SetRenderTarget calls. i.e. is opaque would Store depth, and transparent would discard.
Without the store actions comparison check:

  • Opaque SetRenderTarget is called: Opaque will store all the results
  • Transparent SetRenderTarget is NOT called (because of no actions check): engine will still load from Opaque, will store the all results (waste of bandwidth)

With this new check introduced the behaviour will be the same in terms of loads but now the transparent pass will discard/resolve everything, no stores. Thanks to the second URP SetRenderTarget call with optimized actions, now happening

{
SetRenderTarget(cmd, passColorAttachment, passDepthAttachment, finalClearFlag, finalClearColor);
SetRenderTarget(cmd, passColorAttachment, passDepthAttachment, finalClearFlag, finalClearColor, renderPass.colorStoreAction, renderPass.depthStoreAction);

#if ENABLE_VR && ENABLE_XR_MODULE
if (cameraData.xr.enabled)
Expand Down Expand Up @@ -1229,6 +1248,11 @@ internal static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier c
for (int i = 1; i < m_ActiveColorAttachments.Length; ++i)
m_ActiveColorAttachments[i] = 0;

m_ActiveColorStoreActions[0] = RenderBufferStoreAction.Store;
m_ActiveDepthStoreAction = RenderBufferStoreAction.Store;
for (int i = 1; i < m_ActiveColorStoreActions.Length; ++i)
m_ActiveColorStoreActions[i] = RenderBufferStoreAction.Store;

m_ActiveDepthAttachment = depthAttachment;

RenderBufferLoadAction colorLoadAction = ((uint)clearFlag & (uint)ClearFlag.Color) != 0 ?
Expand All @@ -1241,6 +1265,32 @@ internal static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier c
depthAttachment, depthLoadAction, RenderBufferStoreAction.Store, clearFlag, clearColor);
}

internal static void SetRenderTarget(CommandBuffer cmd, RenderTargetIdentifier colorAttachment, RenderTargetIdentifier depthAttachment, ClearFlag clearFlag, Color clearColor, RenderBufferStoreAction colorStoreAction, RenderBufferStoreAction depthStoreAction)
{
m_ActiveColorAttachments[0] = colorAttachment;
for (int i = 1; i < m_ActiveColorAttachments.Length; ++i)
m_ActiveColorAttachments[i] = 0;

m_ActiveColorStoreActions[0] = colorStoreAction;
m_ActiveDepthStoreAction = depthStoreAction;
for (int i = 1; i < m_ActiveColorStoreActions.Length; ++i)
m_ActiveColorStoreActions[i] = RenderBufferStoreAction.Store;
Comment on lines +1317 to +1324
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooking up on the previous idea, if we used RenderTargetBinding we could configure it here once.


m_ActiveDepthAttachment = depthAttachment;

RenderBufferLoadAction colorLoadAction = ((uint)clearFlag & (uint)ClearFlag.Color) != 0 ?
RenderBufferLoadAction.DontCare : RenderBufferLoadAction.Load;

RenderBufferLoadAction depthLoadAction = ((uint)clearFlag & (uint)ClearFlag.Depth) != 0 ?
RenderBufferLoadAction.DontCare : RenderBufferLoadAction.Load;

colorStoreAction = m_UseOptimizedStoreActions ? colorStoreAction : RenderBufferStoreAction.Store;
depthStoreAction = m_UseOptimizedStoreActions ? depthStoreAction : RenderBufferStoreAction.Store;

SetRenderTarget(cmd, colorAttachment, colorLoadAction, colorStoreAction,
depthAttachment, depthLoadAction, depthStoreAction, clearFlag, clearColor);
}

static void SetRenderTarget(
CommandBuffer cmd,
RenderTargetIdentifier colorAttachment,
Expand All @@ -1266,7 +1316,7 @@ static void SetRenderTarget(
// XRTODO: Revisit the logic. Why treat CameraTarget depth specially?
if (depthAttachment == BuiltinRenderTextureType.CameraTarget)
{
SetRenderTarget(cmd, colorAttachment, colorLoadAction, colorStoreAction, clearFlags, clearColor);
CoreUtils.SetRenderTarget(cmd, colorAttachment, colorLoadAction, colorStoreAction, depthLoadAction, depthStoreAction, clearFlags, clearColor);
}
else
{
Expand Down
33 changes: 28 additions & 5 deletions com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,21 +475,40 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re
EnqueuePass(m_XROcclusionMeshPass);
#endif

bool requiresCopyColorPass = renderingData.cameraData.requiresOpaqueTexture || renderPassInputs.requiresColorTexture;
// If a depth texture was created we necessarily need to copy it, otherwise we could have render it to a renderbuffer.
bool requiresDepthCopyPass = !requiresDepthPrepass
&& renderingData.cameraData.requiresDepthTexture
&& createDepthTexture;

if (this.actualRenderingMode == RenderingMode.Deferred)
EnqueueDeferred(ref renderingData, requiresDepthPrepass, renderPassInputs.requiresNormalsTexture, mainLightShadows, additionalLightShadows);
else
{
RenderBufferStoreAction opaquePassColorStoreAction = RenderBufferStoreAction.Store;
RenderBufferStoreAction opaquePassDepthStoreAction = RenderBufferStoreAction.Store;
if (requiresCopyColorPass || requiresDepthCopyPass)
{
opaquePassColorStoreAction = cameraTargetDescriptor.msaaSamples > 1 ? RenderBufferStoreAction.StoreAndResolve : RenderBufferStoreAction.Store;
opaquePassDepthStoreAction = cameraTargetDescriptor.msaaSamples > 1 ? RenderBufferStoreAction.StoreAndResolve : RenderBufferStoreAction.Store;
}
else
{
opaquePassColorStoreAction = cameraTargetDescriptor.msaaSamples > 1 ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.Store;
opaquePassDepthStoreAction = cameraTargetDescriptor.msaaSamples > 1 ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.Store;
}
m_RenderOpaqueForwardPass.ConfigureColorStoreAction(0, opaquePassColorStoreAction);
m_RenderOpaqueForwardPass.ConfigureDepthStoreAction(opaquePassDepthStoreAction);

EnqueuePass(m_RenderOpaqueForwardPass);
}

Skybox cameraSkybox;
cameraData.camera.TryGetComponent<Skybox>(out cameraSkybox);
bool isOverlayCamera = cameraData.renderType == CameraRenderType.Overlay;
if (camera.clearFlags == CameraClearFlags.Skybox && (RenderSettings.skybox != null || cameraSkybox?.material != null) && !isOverlayCamera)
EnqueuePass(m_DrawSkyboxPass);

// If a depth texture was created we necessarily need to copy it, otherwise we could have render it to a renderbuffer.
bool requiresDepthCopyPass = !requiresDepthPrepass
&& renderingData.cameraData.requiresDepthTexture
&& createDepthTexture;
if (requiresDepthCopyPass)
{
m_CopyDepthPass.Setup(m_ActiveCameraDepthAttachment, m_DepthTexture);
Expand All @@ -506,7 +525,7 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re
Shader.SetGlobalTexture(m_DepthTexture.id, SystemInfo.usesReversedZBuffer ? Texture2D.blackTexture : Texture2D.whiteTexture);
}

if (renderingData.cameraData.requiresOpaqueTexture || renderPassInputs.requiresColorTexture)
if (requiresCopyColorPass)
{
// TODO: Downsampling method should be store in the renderer instead of in the asset.
// We need to migrate this data to renderer. For now, we query the method in the active asset.
Expand All @@ -523,6 +542,10 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re
EnqueuePass(m_TransparentSettingsPass);
}

RenderBufferStoreAction transparentPassColorStoreAction = cameraTargetDescriptor.msaaSamples > 1 ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.Store;
RenderBufferStoreAction transparentPassDepthStoreAction = RenderBufferStoreAction.DontCare;
m_RenderTransparentForwardPass.ConfigureColorStoreAction(0, transparentPassColorStoreAction);
m_RenderTransparentForwardPass.ConfigureDepthStoreAction(transparentPassDepthStoreAction);
EnqueuePass(m_RenderTransparentForwardPass);
}
EnqueuePass(m_OnRenderObjectCallbackPass);
Expand Down