Skip to content
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
f3b8ce6
initial commit and prototype of 1:1 RenderPass conversion
jonuuukas Jan 13, 2021
39aaaad
enabling blit as renderpass
jonuuukas Jan 14, 2021
2326e65
adding shadows and depthonly renderpass support
jonuuukas Jan 14, 2021
dfb0c68
fix load/store actions for depth
jonuuukas Jan 14, 2021
dc9c43f
added opt-out flag at the RenderPass level. The CopyColor pass now op…
manuele-bonanno Jan 15, 2021
36cd0d1
depthonly and depthcopy renderpass-ed
jonuuukas Jan 15, 2021
78aa012
disable native render pass on postprocess and colorgrading passes
jonuuukas Jan 15, 2021
ef791ee
some changes for msaa ( not working just yet)
jonuuukas Jan 18, 2021
bee37cc
adding clear for targets and reverting blit stuff
jonuuukas Jan 18, 2021
7561217
fix for intermediate RT for non-msaa
jonuuukas Jan 18, 2021
03cb8aa
fix msaa on RenderPass platforms. revert blit as well
jonuuukas Jan 19, 2021
2bf178d
fixing PP to respect the MSAA resolve target
jonuuukas Jan 19, 2021
abe0bfb
fixing depthOnly clear (temp fix, will need to rework this a bit)
jonuuukas Jan 20, 2021
7b6aaf3
blit to use RP
jonuuukas Jan 20, 2021
20915b4
making m_ActiveColorAttachmentDescriptor to an array and adding some …
jonuuukas Jan 20, 2021
6f170c0
changing rendertextureformat to graphicsformat and making it array fo…
jonuuukas Jan 20, 2021
6e53c52
moving ConfigureTarget overload call around for the format and hookin…
jonuuukas Jan 21, 2021
1ed5d03
force store single RT attachments for the time being to fix android b…
jonuuukas Jan 22, 2021
19bf12f
moving some code and camera stacking code fixes
jonuuukas Jan 22, 2021
0b24504
Added simple scene information and replaced the hard coded isBlit checks
manuele-bonanno Jan 25, 2021
78ddd02
temporary fix for CopyColor to use our ResolveTexture
manuele-bonanno Jan 25, 2021
34839dd
add renderpass width/height calc depending on cameraRect
jonuuukas Jan 25, 2021
0d628a5
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Jan 25, 2021
30a7775
respect qualitysettings msaa sample count in the last pass to BB
jonuuukas Jan 26, 2021
7cc83d7
fix isLastPassToBB to respect previous logic for setting colorattachment
jonuuukas Jan 26, 2021
8fffce0
load/store actions improvements
manuele-bonanno Jan 26, 2021
88535e5
added missing isLastPassToBB fix
manuele-bonanno Jan 26, 2021
6f90801
excluding other cameras for NativeRenderPass besides CameraType.Game
jonuuukas Jan 26, 2021
855abf4
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Jan 26, 2021
00885db
using cameraDepth target if cameraData.targetTexture is not null
jonuuukas Jan 26, 2021
be5bec4
deferred MSAA samples count 0 fix. Added finalPasstoBB logic to the M…
manuele-bonanno Jan 26, 2021
6a2f163
Merge branch 'universal/render-pass-conversion' of github.com:Unity-T…
manuele-bonanno Jan 26, 2021
ae600f7
fix graphics format that checks for hdr
jonuuukas Jan 26, 2021
2ac6795
fix finalblit to camera.targetTexture
jonuuukas Jan 26, 2021
c080511
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Jan 26, 2021
5559743
Revert "fix graphics format that checks for hdr"
jonuuukas Jan 26, 2021
4ec0446
add hdr picker for graphicsformat when creating attachment descriptor
jonuuukas Jan 26, 2021
8589a4c
some whitespace cleanup
jonuuukas Jan 26, 2021
bb9c43f
deleting accidentally created files
jonuuukas Jan 26, 2021
180a754
Revert "deleting accidentally created files"
jonuuukas Jan 26, 2021
6f857b9
Revert "Revert "deleting accidentally created files""
jonuuukas Jan 26, 2021
2726435
more cleanup
jonuuukas Jan 26, 2021
65dfc45
revert EditorUserSettings.asset
jonuuukas Jan 27, 2021
b9df3c6
fix camerastack with overlay camera clearing issues
jonuuukas Jan 27, 2021
09f10ad
adding ENABLE_RENDER_PASS_UI define to hide UI setting for enabling R…
jonuuukas Jan 27, 2021
4901d6b
revert final blit, require intermediateRT on vulkan for MSAA renderpa…
jonuuukas Jan 28, 2021
1ab69fa
disabling MSAA when using the renderpass API, until the trunk issues …
manuele-bonanno Feb 1, 2021
a436159
removing camera width calculations for last pass
jonuuukas Feb 1, 2021
67efea8
refactoring: simplified the code that figures out the scene's last pass
manuele-bonanno Feb 1, 2021
2e6c47a
Merge branch 'universal/render-pass-conversion' of github.com:Unity-T…
manuele-bonanno Feb 1, 2021
ffec644
minor code cleanup
manuele-bonanno Feb 1, 2021
3246c64
Vulkan/Dx11 fix: setting viewport explicitly to the RP attachment dim…
manuele-bonanno Feb 2, 2021
a8b9375
Merge branch 'universal/render-pass-conversion' of github.com:Unity-T…
manuele-bonanno Feb 2, 2021
dd3a81d
adding SxriptableRenderPassDescriptor class
jonuuukas Feb 2, 2021
37694bb
adding srpDescs to passes and switching the logic in ScriptableRenderer
jonuuukas Feb 2, 2021
451ae1d
removing old descriptor info and hooking up isLastPass
jonuuukas Feb 2, 2021
0654bc1
removing empty descriptor
jonuuukas Feb 2, 2021
ec17a62
renaming SrpDescriptor related methods and vars
jonuuukas Feb 3, 2021
4c2aa5f
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Feb 3, 2021
216f416
reverting test project accidental changes
jonuuukas Feb 3, 2021
ea59b26
Revert "Vulkan/Dx11 fix: setting viewport explicitly to the RP attach…
manuele-bonanno Feb 3, 2021
380c000
Merge branch 'universal/render-pass-conversion' of github.com:Unity-T…
manuele-bonanno Feb 3, 2021
aec1b59
reverting more changes
jonuuukas Feb 3, 2021
55aa16b
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Feb 3, 2021
91d69e2
Revert "Merge branch 'universal/render-pass-conversion' of ssh://gith…
jonuuukas Feb 3, 2021
4aa0bbf
cleanup whitespace and revert some unnecessary code
jonuuukas Feb 3, 2021
d0b8f7a
Merge branch 'master' into universal/render-pass-conversion
jonuuukas Feb 3, 2021
9271789
cleanup after merge
jonuuukas Feb 3, 2021
1bab4f4
Revert "Revert "Merge branch 'universal/render-pass-conversion' of ss…
jonuuukas Feb 3, 2021
f37f9ef
add intermediateRT check to match when using renderpass
jonuuukas Feb 3, 2021
2863c7e
revert GBufferlighting graphicsformat to none and use cameradescriptor
jonuuukas Feb 3, 2021
938ec32
some more cleanup of unused code/whitespace and etc.
jonuuukas Feb 3, 2021
1af4d89
reverting finalblit whitespace changes
jonuuukas Feb 3, 2021
685d55a
additional cleanup after code review
manuele-bonanno Feb 3, 2021
c70d38e
formatting test fixes
manuele-bonanno Feb 4, 2021
3611339
Merge branch 'master' into universal/render-pass-conversion
jonuuukas Feb 11, 2021
3e2f945
reverting ScriptableRenderPassDescriptor changes
jonuuukas Feb 12, 2021
9cb631e
moving RenderPass-related ConfigureTarget overloads to internal scope
jonuuukas Feb 12, 2021
7c2f4fd
simplified some unneeded checks and fixed an MSAA to backbuffer depth…
manuele-bonanno Feb 12, 2021
1ad3fb0
Merge branch 'universal/render-pass-conversion' of github.com:Unity-T…
manuele-bonanno Feb 12, 2021
ee852a5
cleaning up Clear mechanism to respect the same flags as SetRenderTar…
jonuuukas Feb 12, 2021
39be2b1
Added some extra comments regarding the isLastPassToBB flag
manuele-bonanno Feb 15, 2021
1460457
refactoring color/depthAttachmentTarget to include renderbuffers and …
jonuuukas Feb 23, 2021
b82de55
Merge branch 'master' into universal/render-pass-conversion
jonuuukas Feb 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private static class Styles
public static readonly GUIContent TransparentMask = new GUIContent("Transparent Layer Mask", "Controls which transparent layers this renderer draws.");
public static readonly GUIContent LightingLabel = new GUIContent("Lighting", "Settings related to lighting and rendering paths.");
public static readonly GUIContent RenderingModeLabel = new GUIContent("Rendering Path", "Select a rendering path.");
public static readonly GUIContent RenderPassLabel = new GUIContent("Native RenderPass", "Enables URP to use RenderPass API");
public static readonly GUIContent accurateGbufferNormalsLabel = EditorGUIUtility.TrTextContent("Accurate G-buffer normals", "Normals in G-buffer use octahedron encoding/decoding. This improves visual quality but might reduce performance.");
//public static readonly GUIContent tiledDeferredShadingLabel = EditorGUIUtility.TrTextContent("Tiled Deferred Shading (Experimental)", "Allows Tiled Deferred Shading on appropriate lights");
public static readonly GUIContent defaultStencilStateLabel = EditorGUIUtility.TrTextContent("Default Stencil State", "Configure the stencil state for the opaque and transparent render passes.");
Expand All @@ -30,6 +31,9 @@ private static class Styles
SerializedProperty m_RenderingMode;
SerializedProperty m_AccurateGbufferNormals;
//SerializedProperty m_TiledDeferredShading;
#if ENABLE_RENDER_PASS_UI
SerializedProperty m_UseNativeRenderPass;
#endif
SerializedProperty m_DefaultStencilState;
SerializedProperty m_PostProcessData;
SerializedProperty m_Shaders;
Expand All @@ -43,6 +47,9 @@ private void OnEnable()
m_AccurateGbufferNormals = serializedObject.FindProperty("m_AccurateGbufferNormals");
// Not exposed yet.
//m_TiledDeferredShading = serializedObject.FindProperty("m_TiledDeferredShading");
#if ENABLE_RENDER_PASS_UI
m_UseNativeRenderPass = serializedObject.FindProperty("m_UseNativeRenderPass");
#endif
m_DefaultStencilState = serializedObject.FindProperty("m_DefaultStencilState");
m_PostProcessData = serializedObject.FindProperty("postProcessData");
m_Shaders = serializedObject.FindProperty("shaders");
Expand Down Expand Up @@ -74,6 +81,13 @@ public override void OnInspectorGUI()
}
EditorGUI.indentLevel--;
EditorGUILayout.Space();
#if ENABLE_RENDER_PASS_UI
EditorGUILayout.LabelField("RenderPass", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_UseNativeRenderPass, Styles.RenderPassLabel);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
#endif
EditorGUILayout.LabelField("Shadows", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_ShadowTransparentReceiveProp, Styles.shadowTransparentReceiveLabel);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Unity.Collections;
using UnityEngine.Experimental.Rendering;

namespace UnityEngine.Rendering.Universal.Internal
{
Expand Down Expand Up @@ -792,7 +793,7 @@ public bool Setup(ref RenderingData renderingData)
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
m_AdditionalLightsShadowmapTexture = ShadowUtils.GetTemporaryShadowTexture(m_ShadowmapWidth, m_ShadowmapHeight, k_ShadowmapBufferBits);
ConfigureTarget(new RenderTargetIdentifier(m_AdditionalLightsShadowmapTexture));
ConfigureTarget(new RenderTargetIdentifier(m_AdditionalLightsShadowmapTexture), GraphicsFormat.ShadowAuto, m_ShadowmapWidth, m_ShadowmapHeight, 1, true);
ConfigureClear(ClearFlag.All, Color.black);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Material Load(Shader shader)
m_HdrLutFormat = GraphicsFormat.R8G8B8A8_UNorm;

m_LdrLutFormat = GraphicsFormat.R8G8B8A8_UNorm;
base.useNativeRenderPass = false;
}

public void Setup(in RenderTargetHandle internalLut)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public CopyColorPass(RenderPassEvent evt, Material samplingMaterial, Material co
m_SampleOffsetShaderHandle = Shader.PropertyToID("_SampleOffset");
renderPassEvent = evt;
m_DownsamplingMethod = Downsampling.None;
base.useNativeRenderPass = false;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine.Experimental.Rendering;

namespace UnityEngine.Rendering.Universal.Internal
{
Expand Down Expand Up @@ -47,7 +48,7 @@ public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderin
cmd.GetTemporaryRT(destination.id, descriptor, FilterMode.Point);

// On Metal iOS, prevent camera attachments to be bound and cleared during this pass.
ConfigureTarget(new RenderTargetIdentifier(destination.Identifier(), 0, CubemapFace.Unknown, -1));
ConfigureTarget(new RenderTargetIdentifier(destination.Identifier(), 0, CubemapFace.Unknown, -1), GraphicsFormat.DepthAuto, descriptor.width, descriptor.height, descriptor.msaaSamples, true);
ConfigureClear(ClearFlag.None, Color.black);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public override void Configure(CommandBuffer cmd, RenderTextureDescriptor camera
RenderTargetIdentifier lightingAttachmentId = m_DeferredLights.GbufferAttachmentIdentifiers[m_DeferredLights.GBufferLightingIndex];
RenderTargetIdentifier depthAttachmentId = m_DeferredLights.DepthAttachmentIdentifier;

// TODO: change to m_DeferredLights.GetGBufferFormat(m_DeferredLights.GBufferLightingIndex) when it's not GraphicsFormat.None
// TODO: Cannot currently bind depth texture as read-only!
ConfigureTarget(lightingAttachmentId, depthAttachmentId);
ConfigureTarget(lightingAttachmentId, depthAttachmentId, cameraTextureDescripor.graphicsFormat);
}

// ScriptableRenderPass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine.Experimental.Rendering;

namespace UnityEngine.Rendering.Universal.Internal
{
Expand Down Expand Up @@ -55,7 +56,8 @@ public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderin
{
if (this.allocateDepth)
cmd.GetTemporaryRT(depthAttachmentHandle.id, descriptor, FilterMode.Point);
ConfigureTarget(new RenderTargetIdentifier(depthAttachmentHandle.Identifier(), 0, CubemapFace.Unknown, -1));
var desc = renderingData.cameraData.cameraTargetDescriptor;
ConfigureTarget(new RenderTargetIdentifier(depthAttachmentHandle.Identifier(), 0, CubemapFace.Unknown, -1), GraphicsFormat.DepthAuto, desc.width, desc.height, 1, true);
ConfigureClear(ClearFlag.All, Color.black);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class FinalBlitPass : ScriptableRenderPass
public FinalBlitPass(RenderPassEvent evt, Material blitMaterial)
{
base.profilingSampler = new ProfilingSampler(nameof(FinalBlitPass));
base.useNativeRenderPass = false;

m_BlitMaterial = blitMaterial;
renderPassEvent = evt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ public GBufferPass(RenderPassEvent evt, RenderQueueRange renderQueueRange, Layer
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
RenderTargetHandle[] gbufferAttachments = m_DeferredLights.GbufferAttachments;
GraphicsFormat[] gbufferFormats = new GraphicsFormat[gbufferAttachments.Length];

// Create and declare the render targets used in the pass
for (int i = 0; i < gbufferAttachments.Length; ++i)
{
gbufferFormats[i] = m_DeferredLights.GetGBufferFormat(i);
// Lighting buffer has already been declared with line ConfigureCameraTarget(m_ActiveCameraColorAttachment.Identifier(), ...) in DeferredRenderer.Setup
if (i == m_DeferredLights.GBufferLightingIndex)
continue;
Expand All @@ -68,11 +70,11 @@ public override void Configure(CommandBuffer cmd, RenderTextureDescriptor camera
RenderTextureDescriptor gbufferSlice = cameraTextureDescriptor;
gbufferSlice.depthBufferBits = 0; // make sure no depth surface is actually created
gbufferSlice.stencilFormat = GraphicsFormat.None;
gbufferSlice.graphicsFormat = m_DeferredLights.GetGBufferFormat(i);
gbufferSlice.graphicsFormat = gbufferFormats[i];
cmd.GetTemporaryRT(m_DeferredLights.GbufferAttachments[i].id, gbufferSlice);
}

ConfigureTarget(m_DeferredLights.GbufferAttachmentIdentifiers, m_DeferredLights.DepthAttachmentIdentifier);
ConfigureTarget(m_DeferredLights.GbufferAttachmentIdentifiers, m_DeferredLights.DepthAttachmentIdentifier, gbufferFormats);
// We must explicitely specify we don't want any clear to avoid unwanted side-effects.
// ScriptableRenderer may still implicitely force a clear the first time the camera color/depth targets are bound.
ConfigureClear(ClearFlag.None, Color.black);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using UnityEngine.Experimental.Rendering;

namespace UnityEngine.Rendering.Universal.Internal
{
Expand Down Expand Up @@ -122,7 +123,7 @@ public override void Configure(CommandBuffer cmd, RenderTextureDescriptor camera
{
m_MainLightShadowmapTexture = ShadowUtils.GetTemporaryShadowTexture(m_ShadowmapWidth,
m_ShadowmapHeight, k_ShadowmapBufferBits);
ConfigureTarget(new RenderTargetIdentifier(m_MainLightShadowmapTexture));
ConfigureTarget(new RenderTargetIdentifier(m_MainLightShadowmapTexture), GraphicsFormat.ShadowAuto, m_ShadowmapWidth, m_ShadowmapHeight, 1, true);
ConfigureClear(ClearFlag.All, Color.black);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public PostProcessPass(RenderPassEvent evt, PostProcessData data, Material blitM

m_MRT2 = new RenderTargetIdentifier[2];
m_ResetHistory = true;
base.useNativeRenderPass = false;
}

public void Cleanup() => m_Materials.Cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine.Scripting.APIUpdating;
using UnityEngine.Experimental.Rendering;

namespace UnityEngine.Rendering.Universal
{
Expand Down Expand Up @@ -173,6 +174,18 @@ public Color clearColor
internal bool overrideCameraTarget { get; set; }
internal bool isBlitRenderPass { get; set; }

internal bool useNativeRenderPass { get; set; }

internal int renderTargetWidth { get; set; }
internal int renderTargetHeight { get; set; }
internal int renderTargetSampleCount { get; set; }

internal bool depthOnly { get; set; }
// this flag is updated each frame to keep track of which pass is the last for the current camera
internal bool isLastPass { get; set; }


internal GraphicsFormat[] renderTargetFormat { get; set; }
RenderTargetIdentifier[] m_ColorAttachments = new RenderTargetIdentifier[] {BuiltinRenderTextureType.CameraTarget};
RenderTargetIdentifier m_DepthAttachment = BuiltinRenderTextureType.CameraTarget;
ScriptableRenderPassInput m_Input = ScriptableRenderPassInput.None;
Expand All @@ -189,6 +202,16 @@ public ScriptableRenderPass()
overrideCameraTarget = false;
isBlitRenderPass = false;
profilingSampler = new ProfilingSampler(nameof(ScriptableRenderPass));
useNativeRenderPass = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

This API is internal, what does it mean for custom passes that can't change this userNativeRenderPass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: add a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the end, we expect to have a preprocessing mechanism that would determine whether pass is eligible or not to be inside a RenderPass, so this is temporary. Also, Native RenderPass has to be enabled in the renderer asset and having this value as true won't really affect anything unless it's explicitly enabled

renderTargetWidth = -1;
renderTargetHeight = -1;
renderTargetSampleCount = -1;
renderTargetFormat = new GraphicsFormat[]
{
GraphicsFormat.None, GraphicsFormat.None, GraphicsFormat.None,
GraphicsFormat.None, GraphicsFormat.None, GraphicsFormat.None, GraphicsFormat.None, GraphicsFormat.None
};
depthOnly = false;
}

/// <summary>
Expand All @@ -215,6 +238,12 @@ public void ConfigureTarget(RenderTargetIdentifier colorAttachment, RenderTarget
ConfigureTarget(colorAttachment);
}

internal void ConfigureTarget(RenderTargetIdentifier colorAttachment, RenderTargetIdentifier depthAttachment, GraphicsFormat format)
{
m_DepthAttachment = depthAttachment;
ConfigureTarget(colorAttachment, format);
}

/// <summary>
/// Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget.
/// This method should be called inside Configure.
Expand All @@ -234,6 +263,13 @@ public void ConfigureTarget(RenderTargetIdentifier[] colorAttachments, RenderTar
m_DepthAttachment = depthAttachment;
}

internal void ConfigureTarget(RenderTargetIdentifier[] colorAttachments, RenderTargetIdentifier depthAttachment, GraphicsFormat[] formats)
{
ConfigureTarget(colorAttachments, depthAttachment);
for (int i = 0; i < formats.Length; ++i)
renderTargetFormat[i] = formats[i];
}

/// <summary>
/// Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget.
/// This method should be called inside Configure.
Expand All @@ -249,6 +285,19 @@ public void ConfigureTarget(RenderTargetIdentifier colorAttachment)
m_ColorAttachments[i] = 0;
}

internal void ConfigureTarget(RenderTargetIdentifier colorAttachment, GraphicsFormat format, int width = -1, int height = -1, int sampleCount = -1, bool depth = false)
{
ConfigureTarget(colorAttachment);
for (int i = 1; i < m_ColorAttachments.Length; ++i)
renderTargetFormat[i] = GraphicsFormat.None;

renderTargetWidth = width;
renderTargetHeight = height;
renderTargetSampleCount = sampleCount;
depthOnly = depth;
renderTargetFormat[0] = format;
}

/// <summary>
/// Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget.
/// This method should be called inside Configure.
Expand Down
24 changes: 24 additions & 0 deletions com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ namespace UnityEngine.Rendering.Universal
new ShaderTagId("VertexLM"),
};

static AttachmentDescriptor s_EmptyAttachment = new AttachmentDescriptor(GraphicsFormat.None);
internal static AttachmentDescriptor emptyAttachment
{
get
{
return s_EmptyAttachment;
}
}


static Mesh s_FullscreenMesh = null;

/// <summary>
Expand Down Expand Up @@ -335,6 +345,20 @@ internal static uint GetValidColorBufferCount(RenderTargetIdentifier[] colorBuff
return nonNullColorBuffers;
}

internal static uint GetValidColorAttachmentCount(AttachmentDescriptor[] colorAttachments)
{
uint nonNullColorBuffers = 0;
if (colorAttachments != null)
{
foreach (var attachment in colorAttachments)
{
if (attachment != RenderingUtils.emptyAttachment)
++nonNullColorBuffers;
}
}
return nonNullColorBuffers;
}

/// <summary>
/// Return true if colorBuffers is an actual MRT setup
/// </summary>
Expand Down
Loading