diff --git a/Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs b/Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs
index 917d489810a..a82bb7e2056 100644
--- a/Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs
+++ b/Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs
@@ -155,6 +155,21 @@ public static void SetRenderScale(float renderScale)
#endif
}
+ ///
+ /// Used by the render pipeline to retrieve the applied renderViewportScale value from the XR display.
+ /// One use case for retriving this value is that render pipeline can properly sync some SRP owned textures to scale accordingly
+ ///
+ /// Returns current appliedViewportScale value from the XRDisplaySubsystem.
+ public static float GetRenderViewportScale()
+ {
+#if ENABLE_VR && ENABLE_XR_MODULE
+
+ return s_Display.appliedViewportScale;
+#else
+ return 1.0f;
+#endif
+ }
+
///
/// Used by the render pipeline to initiate a new rendering frame through a XR layout.
///
diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index eb9b24f555c..e9c2b97ca58 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -622,8 +622,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset)
m_DepthPyramidMipLevelOffsetsBuffer = new ComputeBuffer(15, sizeof(int) * 2);
- m_CustomPassColorBuffer = new Lazy(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
- m_CustomPassDepthBuffer = new Lazy(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R32_UInt, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: DepthBits.Depth32));
+ AllocateCustomPassBuffers();
// For debugging
MousePositionDebug.instance.Build();
@@ -2034,6 +2033,14 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c
// so will present rendering at native resolution. This will only pay a small cost of memory on the texture aliasing that the runtime has to keep track of.
RTHandles.SetHardwareDynamicResolutionState(m_Asset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.dynResType == DynamicResolutionType.Hardware);
+ // This is to ensure that custom pass buffers have the adequate depth/number of slices when switching from XR enabled/disabled
+ if (m_CustomPassColorBuffer.Value.rt.volumeDepth != TextureXR.slices)
+ {
+ RTHandles.Release(m_CustomPassColorBuffer.Value);
+ RTHandles.Release(m_CustomPassDepthBuffer.Value);
+ AllocateCustomPassBuffers();
+ }
+
// Culling loop
foreach ((Camera camera, XRPass xrPass) in xrLayout.GetActivePasses())
{
@@ -2953,5 +2960,11 @@ static void AdjustUIOverlayOwnership(int cameraCount)
SupportedRenderingFeatures.active.rendersUIOverlay = true;
}
}
+
+ void AllocateCustomPassBuffers()
+ {
+ m_CustomPassColorBuffer = new Lazy(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
+ m_CustomPassDepthBuffer = new Lazy(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R32_UInt, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: DepthBits.Depth32));
+ }
}
}
diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs
index 660a9f08a15..781b51c001f 100644
--- a/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs
+++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs
@@ -440,7 +440,7 @@ private void OnSelectionChanged()
private void RefreshView()
{
PopulateData();
- batchListView.RefreshItems();
+ batchListView?.RefreshItems();
OnSelectionChanged();
ResetDirty();