Skip to content

Commit b5dc623

Browse files
Merge pull request #8204 from Unity-Technologies/internal/2021.3/staging
Internal/2021.3/staging
2 parents c58343d + f02f9b2 commit b5dc623

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ void DoCommonSettingsGUI(ref Rect rect)
167167
{
168168
EditorGUI.PropertyField(rect, m_TargetDepthBuffer, Styles.targetDepthBuffer);
169169
rect.y += Styles.defaultLineSpace;
170+
171+
CustomPass.TargetBuffer requestedDepth = m_TargetDepthBuffer.GetEnumValue<CustomPass.TargetBuffer>();
172+
if (m_CustomPass.getConstrainedDepthBuffer() != requestedDepth)
173+
{
174+
Rect helpBoxRect = rect;
175+
float helpBoxHeight = EditorGUIUtility.singleLineHeight * 2;
176+
helpBoxRect.height = helpBoxHeight;
177+
EditorGUI.HelpBox(helpBoxRect, "Camera depth isn't supported when dynamic scaling is on. We will automatically fall back to not doing depth-testing for this pass.", MessageType.Warning);
178+
rect.y += helpBoxHeight;
179+
}
170180
}
171181

172182
if ((commonPassUIFlags & PassUIFlag.ClearFlags) != 0)
@@ -259,6 +269,13 @@ internal float GetPropertyHeight(SerializedProperty property, GUIContent label)
259269
}
260270

261271
height += Styles.defaultLineSpace * lines;
272+
273+
// Add height for the help box if it will be shown
274+
if ((commonPassUIFlags & PassUIFlag.TargetDepthBuffer) != 0 &&
275+
m_CustomPass.getConstrainedDepthBuffer() != m_TargetDepthBuffer.GetEnumValue<CustomPass.TargetBuffer>())
276+
{
277+
height += EditorGUIUtility.singleLineHeight * 2; // Help box height
278+
}
262279
}
263280

264281
return height + GetPassHeight(property);

Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ internal ProfilingSampler profilingSampler
5252
/// </summary>
5353
public TargetBuffer targetDepthBuffer;
5454

55+
// The actual depth buffer has to follow some constraints, and thus may not be the same result as the target
56+
// depth buffer that the user has requested. Apply these constraints and return a result.
57+
internal TargetBuffer getConstrainedDepthBuffer()
58+
{
59+
TargetBuffer depth = targetDepthBuffer;
60+
if (depth == TargetBuffer.Camera &&
61+
HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.enabled &&
62+
currentHDCamera.allowDynamicResolution &&
63+
injectionPoint == CustomPassInjectionPoint.AfterPostProcess)
64+
{
65+
// This custom pass is injected after postprocessing, and Dynamic Resolution Scaling is enabled, which
66+
// means an upscaler is active. In this case, the camera color buffer is the full display resolution,
67+
// but the camera depth buffer is a lower, pre-upscale resolution. So we cannot do depth testing here.
68+
depth = TargetBuffer.None;
69+
}
70+
return depth;
71+
}
72+
5573
/// <summary>
5674
/// What clear to apply when the color and depth buffer are bound
5775
/// </summary>
@@ -270,7 +288,7 @@ internal void ExecuteInternal(RenderGraph renderGraph, HDCamera hdCamera, Cullin
270288
customPass.isExecuting = false;
271289

272290
// Set back the camera color buffer if we were using a custom buffer as target
273-
if (customPass.targetDepthBuffer != TargetBuffer.Camera)
291+
if (customPass.getConstrainedDepthBuffer() != TargetBuffer.Camera)
274292
CoreUtils.SetRenderTarget(ctx.cmd, outputColorBuffer);
275293
});
276294
}
@@ -307,16 +325,17 @@ bool IsMSAAEnabled(HDCamera hdCamera)
307325
// This function must be only called from the ExecuteInternal method (requires current render target and current RT manager)
308326
void SetCustomPassTarget(CommandBuffer cmd)
309327
{
328+
TargetBuffer depth = getConstrainedDepthBuffer();
310329
// In case all the buffer are set to none, we can't bind anything
311-
if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer == TargetBuffer.None)
330+
if (targetColorBuffer == TargetBuffer.None && depth == TargetBuffer.None)
312331
return;
313332

314333
RTHandle colorBuffer = (targetColorBuffer == TargetBuffer.Custom) ? currentRenderTarget.customColorBuffer.Value : currentRenderTarget.colorBufferRG;
315-
RTHandle depthBuffer = (targetDepthBuffer == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG;
334+
RTHandle depthBuffer = (depth == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG;
316335

317-
if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer != TargetBuffer.None)
336+
if (targetColorBuffer == TargetBuffer.None && depth != TargetBuffer.None)
318337
CoreUtils.SetRenderTarget(cmd, depthBuffer, clearFlags);
319-
else if (targetColorBuffer != TargetBuffer.None && targetDepthBuffer == TargetBuffer.None)
338+
else if (targetColorBuffer != TargetBuffer.None && depth == TargetBuffer.None)
320339
CoreUtils.SetRenderTarget(cmd, colorBuffer, clearFlags);
321340
else
322341
{

Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ internal static void Place(GameObject go, GameObject parent)
7676

7777
static Light2D CreateLight(MenuCommand menuCommand, Light2D.LightType type, Vector3[] shapePath = null)
7878
{
79-
GameObject go = ObjectFactory.CreateGameObject("Light 2D", typeof(Light2D));
79+
var lightName = type != Light2D.LightType.Point ? type.ToString() : "Spot";
80+
GameObject go = ObjectFactory.CreateGameObject(lightName + " Light 2D", typeof(Light2D));
8081
Light2D light2D = go.GetComponent<Light2D>();
8182
light2D.lightType = type;
8283

Tests/SRPTests/Projects/HDRP_RuntimeTests/Assets/Tests/TestFilters/TestCaseFilters.asset

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,23 @@ MonoBehaviour:
103103
XrSdk:
104104
StereoModes: 0
105105
Reason: 'Unstable on PS4: https://jira.unity3d.com/browse/UUM-113462 '
106+
- FilteredScene: {fileID: 0}
107+
FilteredScenes:
108+
- {fileID: 102900000, guid: 32f9dd5fabc57284bb43468761c84f36, type: 3}
109+
ColorSpace: 1
110+
BuildPlatform: 31
111+
GraphicsDevice: 4
112+
Architecture: 0
113+
XrSdk:
114+
StereoModes: 0
115+
Reason: 'Unstable on PS4: https://jira.unity3d.com/browse/UUM-113462 '
116+
- FilteredScene: {fileID: 0}
117+
FilteredScenes:
118+
- {fileID: 102900000, guid: 500813a390ad4074cba926bf26eef57a, type: 3}
119+
ColorSpace: 1
120+
BuildPlatform: 31
121+
GraphicsDevice: 4
122+
Architecture: 0
123+
XrSdk:
124+
StereoModes: 0
125+
Reason: 'Unstable on PS4: https://jira.unity3d.com/browse/UUM-113462 '

0 commit comments

Comments
 (0)