Skip to content
Open
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
7 changes: 3 additions & 4 deletions Packages/com.unity.render-pipelines.core/Runtime/XR/XRPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ namespace UnityEngine.Experimental.Rendering
/// </summary>
public struct XRPassCreateInfo
{
public static RenderTargetIdentifier mvInvalidRT = -1;
public bool motionVectorRenderTargetValid { get => motionVectorRenderTarget != mvInvalidRT; }

internal RenderTargetIdentifier renderTarget;
internal RenderTextureDescriptor renderTargetDesc;
internal bool motionVectorRenderTargetValid;
internal RenderTargetIdentifier motionVectorRenderTarget;
internal RenderTextureDescriptor motionVectorRenderTargetDesc;
internal ScriptableCullingParameters cullingParameters;
Expand Down Expand Up @@ -126,7 +124,7 @@ public bool supportsFoveatedRendering
/// <summary>
// Check if render target is valid
/// <summary>
public bool motionVectorRenderTargetValid { get => motionVectorRenderTarget != XRPassCreateInfo.mvInvalidRT; }
public bool motionVectorRenderTargetValid { get; private set; }

/// <summary>
/// Destination render target descriptor
Expand Down Expand Up @@ -350,6 +348,7 @@ public void InitBase(XRPassCreateInfo createInfo)
multipassId = createInfo.multipassId;
AssignCullingParams(createInfo.cullingPassId, createInfo.cullingParameters);
renderTarget = new RenderTargetIdentifier(createInfo.renderTarget, 0, CubemapFace.Unknown, -1);
motionVectorRenderTargetValid = createInfo.motionVectorRenderTargetValid;
motionVectorRenderTarget = new RenderTargetIdentifier(createInfo.motionVectorRenderTarget, 0, CubemapFace.Unknown, -1);
renderTargetDesc = createInfo.renderTargetDesc;
m_OcclusionMesh.SetMaterial(createInfo.occlusionMeshMaterial);
Expand Down
55 changes: 22 additions & 33 deletions Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,46 +355,35 @@ static XRView BuildView(XRDisplaySubsystem.XRRenderPass renderPass, XRDisplaySub
return new XRView(renderParameter.projection, renderParameter.view, viewport, occlusionMesh, renderParameter.textureArraySlice, prevViewValid, prevViewMatrix);
}

static XRPassCreateInfo BuildPass(XRDisplaySubsystem.XRRenderPass xrRenderPass, ScriptableCullingParameters cullingParameters)
static RenderTextureDescriptor CopyXRRenderTextureDescriptor(in RenderTextureDescriptor xrDesc)
{
// We can't use descriptor directly because y-flip is forced
// XRTODO : fix root problem
RenderTextureDescriptor xrDesc = xrRenderPass.renderTargetDesc;
RenderTextureDescriptor rtDesc = new RenderTextureDescriptor(xrDesc.width, xrDesc.height, xrDesc.colorFormat, xrDesc.depthBufferBits, xrDesc.mipCount);
rtDesc.dimension = xrRenderPass.renderTargetDesc.dimension;
rtDesc.volumeDepth = xrRenderPass.renderTargetDesc.volumeDepth;
rtDesc.vrUsage = xrRenderPass.renderTargetDesc.vrUsage;
rtDesc.sRGB = xrRenderPass.renderTargetDesc.sRGB;
rtDesc.dimension = xrDesc.dimension;
rtDesc.volumeDepth = xrDesc.volumeDepth;
rtDesc.vrUsage = xrDesc.vrUsage;
rtDesc.sRGB = xrDesc.sRGB;
return rtDesc;
}

XRPassCreateInfo passInfo = new XRPassCreateInfo
static XRPassCreateInfo BuildPass(XRDisplaySubsystem.XRRenderPass xrRenderPass, ScriptableCullingParameters cullingParameters)
{
return new XRPassCreateInfo
{
renderTarget = xrRenderPass.renderTarget,
renderTargetDesc = rtDesc,
cullingParameters = cullingParameters,
motionVectorRenderTarget = XRPassCreateInfo.mvInvalidRT,
occlusionMeshMaterial = s_OcclusionMeshMaterial,
foveatedRenderingInfo = xrRenderPass.foveatedRenderingInfo,
multipassId = s_Layout.GetActivePasses().Count,
cullingPassId = xrRenderPass.cullingPassIndex,
copyDepth = xrRenderPass.shouldFillOutDepth,
xrSdkRenderPass = xrRenderPass
renderTarget = xrRenderPass.renderTarget,
renderTargetDesc = CopyXRRenderTextureDescriptor(xrRenderPass.renderTargetDesc),
cullingParameters = cullingParameters,
occlusionMeshMaterial = s_OcclusionMeshMaterial,
foveatedRenderingInfo = xrRenderPass.foveatedRenderingInfo,
motionVectorRenderTargetValid = xrRenderPass.hasMotionVectorPass,
motionVectorRenderTarget = xrRenderPass.motionVectorRenderTarget,
motionVectorRenderTargetDesc = CopyXRRenderTextureDescriptor(xrRenderPass.motionVectorRenderTargetDesc),
multipassId = s_Layout.GetActivePasses().Count,
cullingPassId = xrRenderPass.cullingPassIndex,
copyDepth = xrRenderPass.shouldFillOutDepth,
xrSdkRenderPass = xrRenderPass
};

if (xrRenderPass.hasMotionVectorPass)
{
passInfo.motionVectorRenderTarget = new RenderTargetIdentifier(xrRenderPass.motionVectorRenderTarget, 0, CubemapFace.Unknown, -1);

RenderTextureDescriptor rtMotionVectorDesc = new RenderTextureDescriptor(xrDesc.width, xrDesc.height, xrDesc.colorFormat, xrDesc.depthBufferBits, xrDesc.mipCount);
rtMotionVectorDesc.dimension = xrRenderPass.renderTargetDesc.dimension;
rtMotionVectorDesc.volumeDepth = xrRenderPass.renderTargetDesc.volumeDepth;
rtMotionVectorDesc.vrUsage = xrRenderPass.renderTargetDesc.vrUsage;
rtMotionVectorDesc.sRGB = xrRenderPass.renderTargetDesc.sRGB;
passInfo.motionVectorRenderTargetDesc = rtMotionVectorDesc;

Debug.Assert(passInfo.motionVectorRenderTargetValid, "Invalid motion vector render target from XRDisplaySubsystem!");
}

return passInfo;
}

#endif
Expand Down