Skip to content

Commit c864e99

Browse files
Internal/2022.3/staging
Internal/2022.3/staging
2 parents 9492a62 + 1503d11 commit c864e99

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,21 @@ public static void SetRenderScale(float renderScale)
155155
#endif
156156
}
157157

158+
/// <summary>
159+
/// Used by the render pipeline to retrieve the applied renderViewportScale value from the XR display.
160+
/// One use case for retriving this value is that render pipeline can properly sync some SRP owned textures to scale accordingly
161+
/// </summary>
162+
/// <returns> Returns current appliedViewportScale value from the XRDisplaySubsystem. </returns>
163+
public static float GetRenderViewportScale()
164+
{
165+
#if ENABLE_VR && ENABLE_XR_MODULE
166+
167+
return s_Display.appliedViewportScale;
168+
#else
169+
return 1.0f;
170+
#endif
171+
}
172+
158173
/// <summary>
159174
/// Used by the render pipeline to initiate a new rendering frame through a XR layout.
160175
/// </summary>

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset)
622622

623623
m_DepthPyramidMipLevelOffsetsBuffer = new ComputeBuffer(15, sizeof(int) * 2);
624624

625-
m_CustomPassColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
626-
m_CustomPassDepthBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R32_UInt, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: DepthBits.Depth32));
625+
AllocateCustomPassBuffers();
627626

628627
// For debugging
629628
MousePositionDebug.instance.Build();
@@ -2034,6 +2033,14 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c
20342033
// 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.
20352034
RTHandles.SetHardwareDynamicResolutionState(m_Asset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.dynResType == DynamicResolutionType.Hardware);
20362035

2036+
// This is to ensure that custom pass buffers have the adequate depth/number of slices when switching from XR enabled/disabled
2037+
if (m_CustomPassColorBuffer.Value.rt.volumeDepth != TextureXR.slices)
2038+
{
2039+
RTHandles.Release(m_CustomPassColorBuffer.Value);
2040+
RTHandles.Release(m_CustomPassDepthBuffer.Value);
2041+
AllocateCustomPassBuffers();
2042+
}
2043+
20372044
// Culling loop
20382045
foreach ((Camera camera, XRPass xrPass) in xrLayout.GetActivePasses())
20392046
{
@@ -2953,5 +2960,11 @@ static void AdjustUIOverlayOwnership(int cameraCount)
29532960
SupportedRenderingFeatures.active.rendersUIOverlay = true;
29542961
}
29552962
}
2963+
2964+
void AllocateCustomPassBuffers()
2965+
{
2966+
m_CustomPassColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
2967+
m_CustomPassDepthBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R32_UInt, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: DepthBits.Depth32));
2968+
}
29562969
}
29572970
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ private void OnSelectionChanged()
440440
private void RefreshView()
441441
{
442442
PopulateData();
443-
batchListView.RefreshItems();
443+
batchListView?.RefreshItems();
444444
OnSelectionChanged();
445445

446446
ResetDirty();

0 commit comments

Comments
 (0)