Skip to content

Commit 118b66d

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.5] Improve UI/UX of Renderer Features with the Tile-Only Mode and bugfixes
1 parent eef7248 commit 118b66d

14 files changed

Lines changed: 318 additions & 73 deletions

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ void PropagateTextureUVOrigin()
11301130
var firstStoreAttachmentName = graph.m_ResourcesForDebugOnly.GetRenderGraphResourceName(firstStoreNativePassAttachment.handle);
11311131
var name = graph.m_ResourcesForDebugOnly.GetRenderGraphResourceName(nativePassAttachment.handle);
11321132

1133-
throw new InvalidOperationException($"From pass '{contextData.passNames[nativePassData.firstGraphPass]}' to pass '{contextData.passNames[nativePassData.lastGraphPass]}' when trying to store resource '{name}' of type {nativePassAttachment.handle.type} at index {nativePassAttachment.handle.index} - "
1133+
throw new InvalidOperationException($"From pass '{contextData.GetPassName(nativePassData.firstGraphPass)}' to pass '{contextData.GetPassName(nativePassData.lastGraphPass)}' when trying to store resource '{name}' of type {nativePassAttachment.handle.type} at index {nativePassAttachment.handle.index} - "
11341134
+ RenderGraph.RenderGraphExceptionMessages.IncompatibleTextureUVOriginStore(firstStoreAttachmentName, storeUVOrigin, name, resData.textureUVOrigin));
11351135
}
11361136

Packages/com.unity.render-pipelines.universal/Editor/RendererFeatures/FullScreenPassRendererFeatureEditor.cs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
using UnityEditor.RenderPipelines.Core;
33
using UnityEditor.ShaderGraph;
44
using UnityEngine;
5+
using UnityEngine.Rendering;
56
using UnityEngine.Rendering.Universal;
6-
using static UnityEditor.Rendering.InspectorCurveEditor;
77

88
namespace UnityEditor.Rendering.Universal
99
{
@@ -13,7 +13,7 @@ namespace UnityEditor.Rendering.Universal
1313
/// </summary>
1414
[UnityEngine.Scripting.APIUpdating.MovedFrom("")]
1515
[CustomEditor(typeof(FullScreenPassRendererFeature))]
16-
public class FullScreenPassRendererFeatureEditor : Editor
16+
public class FullScreenPassRendererFeatureEditor : Editor, IOwningRendererDataConsumer
1717
{
1818
private SerializedProperty m_InjectionPointProperty;
1919
private SerializedProperty m_RequirementsProperty;
@@ -22,13 +22,26 @@ public class FullScreenPassRendererFeatureEditor : Editor
2222
private SerializedProperty m_PassMaterialProperty;
2323
private SerializedProperty m_PassIndexProperty;
2424
private bool m_ShowDuplicateColorCopyWarning;
25+
private bool m_ShowFetchColorBufferTileOnlyError;
26+
private bool m_ShowRequirementsColorTileOnlyError;
27+
private bool m_ShowRequirementsDepthWithoutNormalTileOnlyError;
28+
private bool m_ShowRequirementsMotionWithoutNormalTileOnlyError;
2529

2630
private static readonly GUIContent k_InjectionPointGuiContent = new GUIContent("Injection Point", "Specifies where in the frame this pass will be injected.");
2731
private static readonly GUIContent k_RequirementsGuiContent = new GUIContent("Requirements", "A mask of URP internal textures that will need to be generated and bound for sampling.\n\nNote that 'Color' here corresponds to '_CameraOpaqueTexture' so most of the time you will want to use the 'Fetch Color Buffer' option instead.");
2832
private static readonly GUIContent k_FetchColorBufferGuiContent = new GUIContent("Fetch Color Buffer", "Enable this if the assigned material will need to sample the active color target. The active color will be bound to the '_BlitTexture' shader property for sampling. Note that this will introduce an internal color copy pass.");
2933
private static readonly GUIContent k_BindDepthStencilAttachmentGuiContent = new GUIContent("Bind Depth-Stencil", "Enable this to bind the active camera's depth-stencil attachment to the framebuffer (only use this if depth-stencil ops are used by the assigned material as this could have a performance impact).");
3034
private static readonly GUIContent k_PassMaterialGuiContent = new GUIContent("Pass Material", "The material used to render the full screen pass.");
3135
private static readonly GUIContent k_PassGuiContent = new GUIContent("Pass", "The name of the shader pass to use from the assigned material.");
36+
private static readonly string k_FetchColorBufferIncompatibleWithTileOnlyMode = L10n.Tr("Fetch Color Buffer is incompatible with the enabled 'Tile-Only Mode'. Disable this setting.");
37+
private static readonly string k_RequirementsColorIncompatibleWithTileOnlyMode = L10n.Tr("Color is incompatible with the enabled 'Tile-Only Mode'. Clear Color from Requirements.");
38+
private static readonly string k_RequirementsDepthWithoutNormalIncompatibleWithTileOnlyMode = L10n.Tr("Depth without Normal is incompatible with the enabled 'Tile-Only Mode'. Add Normal to Requirements or clear Depth.");
39+
private static readonly string k_RequirementsMotionWithoutNormalIncompatibleWithTileOnlyMode = L10n.Tr("Motion without Normal is incompatible with the enabled 'Tile-Only Mode'. Add Normal to Requirements or clear Motion.");
40+
41+
/// <summary>
42+
/// The renderer data that owns the feature when the inspector is drawn.
43+
/// </summary>
44+
public ScriptableRendererData owningRendererData { get; set; }
3245

3346
static readonly GUIContent k_NewFullscreenMaterialButtonText = EditorGUIUtility.TrTextContent("New", "Creates a new Fullscreen material.");
3447
static readonly string k_NewBlitShaderText = "SRP Blit Shader";
@@ -58,19 +71,38 @@ public override void OnInspectorGUI()
5871
currentFeature.passIndex = 0;
5972

6073
EditorGUILayout.PropertyField(m_InjectionPointProperty, k_InjectionPointGuiContent);
61-
EditorGUILayout.PropertyField(m_RequirementsProperty, k_RequirementsGuiContent);
74+
EditorGUILayout.PropertyField(m_RequirementsProperty, k_RequirementsGuiContent);
75+
76+
var requirements = m_RequirementsProperty.GetEnumValue<ScriptableRenderPassInput>();
77+
var rendererData = (this as IOwningRendererDataConsumer).owningRendererData as UniversalRendererData;
78+
79+
if (Event.current.type == EventType.Layout)
80+
{
81+
bool tileOnlyMode = rendererData != null && rendererData.tileOnlyMode;
82+
m_ShowFetchColorBufferTileOnlyError = tileOnlyMode && m_FetchColorBufferProperty.boolValue;
83+
m_ShowRequirementsColorTileOnlyError = tileOnlyMode && (requirements & ScriptableRenderPassInput.Color) != ScriptableRenderPassInput.None;
84+
// Depth without Normal triggers a depth copy; with Normal, URP does a prepass instead (see comment on k_RequirementsDepthWithoutNormalIncompatibleWithTileOnlyMode).
85+
m_ShowRequirementsDepthWithoutNormalTileOnlyError = tileOnlyMode && (requirements & ScriptableRenderPassInput.Depth) != ScriptableRenderPassInput.None && (requirements & ScriptableRenderPassInput.Normal) == ScriptableRenderPassInput.None;
86+
m_ShowRequirementsMotionWithoutNormalTileOnlyError = tileOnlyMode && (requirements & ScriptableRenderPassInput.Motion) != ScriptableRenderPassInput.None && (requirements & ScriptableRenderPassInput.Normal) == ScriptableRenderPassInput.None;
87+
}
88+
if (m_ShowFetchColorBufferTileOnlyError)
89+
EditorGUILayout.HelpBox(k_FetchColorBufferIncompatibleWithTileOnlyMode, MessageType.Error, true);
90+
if (m_ShowRequirementsColorTileOnlyError)
91+
EditorGUILayout.HelpBox(k_RequirementsColorIncompatibleWithTileOnlyMode, MessageType.Error, true);
92+
if (m_ShowRequirementsDepthWithoutNormalTileOnlyError)
93+
EditorGUILayout.HelpBox(k_RequirementsDepthWithoutNormalIncompatibleWithTileOnlyMode, MessageType.Error, true);
94+
if (m_ShowRequirementsMotionWithoutNormalTileOnlyError)
95+
EditorGUILayout.HelpBox(k_RequirementsMotionWithoutNormalIncompatibleWithTileOnlyMode, MessageType.Error, true);
96+
6297
EditorGUILayout.PropertyField(m_FetchColorBufferProperty, k_FetchColorBufferGuiContent);
6398

6499
if (Event.current.type == EventType.Layout)
65100
{
66-
bool requestedColor = (m_RequirementsProperty.GetEnumValue<ScriptableRenderPassInput>() & ScriptableRenderPassInput.Color) != ScriptableRenderPassInput.None;
67-
m_ShowDuplicateColorCopyWarning = requestedColor && m_FetchColorBufferProperty.boolValue;
101+
m_ShowDuplicateColorCopyWarning = (requirements & ScriptableRenderPassInput.Color) != ScriptableRenderPassInput.None && m_FetchColorBufferProperty.boolValue;
68102
}
69103

70104
if (m_ShowDuplicateColorCopyWarning)
71-
{
72105
EditorGUILayout.HelpBox("You request two different color textures: the opaque color texture via \"Requirements: Color\", and the current camera attachment via \"Fetch Color Buffer\". While this is allowed, we recommend disabling one of these two options for optimal performance.", MessageType.Warning, true);
73-
}
74106

75107
EditorGUILayout.PropertyField(m_BindDepthStencilAttachmentProperty, k_BindDepthStencilAttachmentGuiContent);
76108

Packages/com.unity.render-pipelines.universal/Editor/RendererFeatures/OnTilePostProcessFeatureEditor.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1+
using UnityEngine.Rendering.Universal;
2+
13
namespace UnityEditor.Rendering.Universal
24
{
35
[CustomEditor(typeof(OnTilePostProcessFeature))]
4-
internal class OnTilePostProcessFeatureEditor : Editor
6+
internal class OnTilePostProcessFeatureEditor : Editor, IOwningRendererDataConsumer
57
{
68
#region Serialized Properties
79
private SerializedProperty m_UseFallbackProperty;
810
#endregion
911

1012
static class Styles
1113
{
12-
public static readonly string k_NoSettingsHelpBox = L10n.Tr("This feature performs post-processing operation in tile memory. There are currently no available settings, they might be added later.");
13-
public static readonly string k_NeedsTileOnlyMode = L10n.Tr("On Tile PostProcessing feature needs 'Tile-Only Mode' set on the Renderer. Otherwise, this render feature will fallback to texture sampling mode (slow off-tile rendering)");
14+
public static readonly string k_NoSettingsHelpBox = L10n.Tr("Only pixel local post-processing effects are supported. For example color adjustments, vignette or film grain. There are currently no available settings.");
15+
public static readonly string k_TileOnlyModeOffWarning = L10n.Tr("Tile-Only Mode is not enabled on this Renderer. This feature will fallback to texture sampling mode. This uses more GPU bandwidth and can reduce performance.");
1416
}
1517

1618
private void OnEnable()
1719
{
1820
}
1921

22+
/// <summary>
23+
/// The renderer data that owns the feature when the inspector is drawn.
24+
/// </summary>
25+
public ScriptableRendererData owningRendererData { get; set; }
26+
2027
public override void OnInspectorGUI()
2128
{
22-
EditorGUILayout.HelpBox(Styles.k_NeedsTileOnlyMode, MessageType.Info);
29+
var rendererData = (this as IOwningRendererDataConsumer).owningRendererData as UniversalRendererData;
30+
if (rendererData == null || !rendererData.tileOnlyMode)
31+
EditorGUILayout.HelpBox(Styles.k_TileOnlyModeOffWarning, MessageType.Warning);
2332
EditorGUILayout.HelpBox(Styles.k_NoSettingsHelpBox, MessageType.Info);
2433
}
2534
}

Packages/com.unity.render-pipelines.universal/Editor/RendererFeatures/ScreenSpaceAmbientOcclusionEditor.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace UnityEditor.Rendering.Universal
66
{
77
[CustomEditor(typeof(ScreenSpaceAmbientOcclusion))]
8-
internal class ScreenSpaceAmbientOcclusionEditor : Editor
8+
internal class ScreenSpaceAmbientOcclusionEditor : Editor, IOwningRendererDataConsumer
99
{
1010
#region Serialized Properties
1111
private SerializedProperty m_AOMethod;
@@ -23,6 +23,14 @@ internal class ScreenSpaceAmbientOcclusionEditor : Editor
2323

2424
private bool m_IsInitialized = false;
2525
private HeaderBool m_ShowQualitySettings;
26+
private bool m_ShowAfterOpaqueTileOnlyError;
27+
28+
private static readonly string k_AfterOpaqueIncompatibleWithTileOnlyMode = L10n.Tr("'After Opaque' is incompatible with the enabled 'Tile-Only Mode'. Disable After Opaque.");
29+
30+
/// <summary>
31+
/// The renderer data that owns the feature when the inspector is drawn.
32+
/// </summary>
33+
public ScriptableRendererData owningRendererData { get; set; }
2634

2735
class HeaderBool
2836
{
@@ -123,6 +131,17 @@ public override void OnInspectorGUI()
123131

124132
EditorGUILayout.PropertyField(m_Downsample, Styles.Downsample);
125133
EditorGUILayout.PropertyField(m_AfterOpaque, Styles.AfterOpaque);
134+
135+
if (Event.current.type == EventType.Layout)
136+
{
137+
var rendererData = (this as IOwningRendererDataConsumer).owningRendererData as UniversalRendererData;
138+
bool tileOnlyMode = rendererData != null && rendererData.tileOnlyMode;
139+
bool afterOpaque = m_AfterOpaque.boolValue;
140+
m_ShowAfterOpaqueTileOnlyError = tileOnlyMode && afterOpaque;
141+
}
142+
if (m_ShowAfterOpaqueTileOnlyError)
143+
EditorGUILayout.HelpBox(k_AfterOpaqueIncompatibleWithTileOnlyMode, MessageType.Error, true);
144+
126145
EditorGUILayout.PropertyField(m_BlurQuality, Styles.BlurQuality);
127146
EditorGUILayout.PropertyField(m_Samples, Styles.Samples);
128147

Packages/com.unity.render-pipelines.universal/Editor/ScriptableRendererDataEditor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,13 @@ private void DrawRendererFeature(int index, ref SerializedProperty renderFeature
194194
}
195195

196196
EditorGUI.BeginChangeCheck();
197+
if (rendererFeatureEditor is IOwningRendererDataConsumer consumer)
198+
{
199+
consumer.owningRendererData = target as ScriptableRendererData;
200+
}
201+
197202
rendererFeatureEditor.OnInspectorGUI();
203+
198204
hasChangedProperties |= EditorGUI.EndChangeCheck();
199205

200206
EditorGUILayout.Space(EditorGUIUtility.singleLineHeight);
@@ -361,4 +367,13 @@ private void ForceSave()
361367
EditorUtility.SetDirty(target);
362368
}
363369
}
370+
371+
/// <summary>
372+
/// Implement this interface on a custom Editor for a ScriptableRendererFeature to receive the renderer data that owns the feature when the inspector is drawn.
373+
/// </summary>
374+
internal interface IOwningRendererDataConsumer
375+
{
376+
/// <summary>The renderer data that contains this feature. Set by the drawer before OnInspectorGUI, cleared after.</summary>
377+
public ScriptableRendererData owningRendererData { get; set; }
378+
}
364379
}

Packages/com.unity.render-pipelines.universal/Runtime/Passes/ScreenSpaceAmbientOcclusionPass.cs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -127,39 +127,12 @@ internal ScreenSpaceAmbientOcclusionPass()
127127
m_CurrentSettings = new ScreenSpaceAmbientOcclusionSettings();
128128
}
129129

130-
internal bool Setup(ScreenSpaceAmbientOcclusionSettings featureSettings, ScriptableRenderer renderer, Material material, Texture2D[] blueNoiseTextures)
130+
internal bool Setup(ScreenSpaceAmbientOcclusionSettings featureSettings, ScreenSpaceAmbientOcclusionSettings.DepthSource depthSource, Material material, Texture2D[] blueNoiseTextures)
131131
{
132132
m_BlueNoiseTextures = blueNoiseTextures;
133133
m_Material = material;
134134
m_CurrentSettings = featureSettings;
135-
136-
// RenderPass Event + Source Settings (Depth / Depth&Normals
137-
if (renderer is UniversalRenderer { usesDeferredLighting: true })
138-
{
139-
renderPassEvent = m_CurrentSettings.AfterOpaque ? RenderPassEvent.AfterRenderingOpaques : RenderPassEvent.AfterRenderingPrePasses;
140-
141-
m_CurrentSettings.Source = ScreenSpaceAmbientOcclusionSettings.DepthSource.DepthNormals;
142-
}
143-
else
144-
{
145-
// Rendering after PrePasses is usually correct except when depth priming is in play:
146-
// then we rely on a depth resolve taking place after the PrePasses in order to have it ready for SSAO.
147-
// Hence we set the event to RenderPassEvent.AfterRenderingPrePasses + 1 at the earliest.
148-
renderPassEvent = m_CurrentSettings.AfterOpaque ? RenderPassEvent.BeforeRenderingTransparents : RenderPassEvent.AfterRenderingPrePasses + 1;
149-
}
150-
151-
// Ask for a Depth or Depth + Normals textures
152-
switch (m_CurrentSettings.Source)
153-
{
154-
case ScreenSpaceAmbientOcclusionSettings.DepthSource.Depth:
155-
ConfigureInput(ScriptableRenderPassInput.Depth);
156-
break;
157-
case ScreenSpaceAmbientOcclusionSettings.DepthSource.DepthNormals:
158-
ConfigureInput(ScriptableRenderPassInput.Depth | ScriptableRenderPassInput.Normal); // need depthNormal prepass for forward-only geometry
159-
break;
160-
default:
161-
throw new ArgumentOutOfRangeException();
162-
}
135+
m_CurrentSettings.Source = depthSource;
163136

164137
// Blur settings
165138
switch (m_CurrentSettings.BlurQuality)
@@ -277,7 +250,6 @@ private class SSAOPassData
277250
internal MaterialPropertyBlock materialPropertyBlock;
278251
internal Material material;
279252
internal float directLightingStrength;
280-
internal TextureHandle cameraColor;
281253
internal TextureHandle AOTexture;
282254
internal TextureHandle finalTexture;
283255
internal TextureHandle blurTexture;
@@ -399,7 +371,6 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer
399371

400372
// Fill in the Pass data...
401373
InitSSAOPassData(passData);
402-
passData.cameraColor = resourceData.cameraColor;
403374
passData.AOTexture = aoTexture;
404375
passData.finalTexture = finalTexture;
405376
passData.blurTexture = blurTexture;
@@ -409,13 +380,6 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer
409380
// Declare input textures
410381
builder.SetRenderAttachment(passData.AOTexture, 0, AccessFlags.WriteAll);
411382

412-
// TODO: Refactor to eliminate the need for 'UseTexture'.
413-
// Currently required only because 'PostProcessUtils.SetSourceSize' allocates an RTHandle,
414-
// which expects a valid graphicsResource. Without this call, 'cameraColor.graphicsResource'
415-
// may be null if it wasn't initialized in an earlier pass (e.g., DrawOpaque).
416-
if (passData.cameraColor.IsValid())
417-
builder.UseTexture(passData.cameraColor, AccessFlags.Read);
418-
419383
if (cameraDepthTexture.IsValid())
420384
builder.UseTexture(cameraDepthTexture, AccessFlags.Read);
421385

@@ -427,8 +391,8 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer
427391

428392
builder.SetRenderFunc(static (SSAOPassData data, RasterGraphContext ctx) =>
429393
{
430-
// Setup
431-
PostProcessUtils.SetGlobalShaderSourceSize(ctx.cmd, data.cameraData.cameraTargetDescriptor.width, data.cameraData.cameraTargetDescriptor.height, data.cameraColor);
394+
var desc = data.cameraData.cameraTargetDescriptor;
395+
PostProcessUtils.SetGlobalShaderSourceSize(ctx.cmd, desc.width, desc.height, desc.useDynamicScale);
432396

433397
if (data.cameraNormalsTexture.IsValid())
434398
data.materialPropertyBlock.SetTexture(s_CameraNormalsTextureID, data.cameraNormalsTexture);

0 commit comments

Comments
 (0)