Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ public static void SetRenderScale(float renderScale)
#endif
}

/// <summary>
/// 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
/// </summary>
/// <returns> Returns current appliedViewportScale value from the XRDisplaySubsystem. </returns>
public static float GetRenderViewportScale()
{
#if ENABLE_VR && ENABLE_XR_MODULE

return s_Display.appliedViewportScale;
#else
return 1.0f;
#endif
}

/// <summary>
/// Used by the render pipeline to initiate a new rendering frame through a XR layout.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset)

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

m_CustomPassColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
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));
AllocateCustomPassBuffers();

// For debugging
MousePositionDebug.instance.Build();
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -2953,5 +2960,11 @@ static void AdjustUIOverlayOwnership(int cameraCount)
SupportedRenderingFeatures.active.rendersUIOverlay = true;
}
}

void AllocateCustomPassBuffers()
{
m_CustomPassColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ private void OnSelectionChanged()
private void RefreshView()
{
PopulateData();
batchListView.RefreshItems();
batchListView?.RefreshItems();
OnSelectionChanged();

ResetDirty();
Expand Down