From b7b6ebb6eda8a65ba90e62a78ffec96f4bb5553d Mon Sep 17 00:00:00 2001 From: Francois Coulombe Date: Wed, 27 Oct 2021 18:17:19 -0400 Subject: [PATCH] Fix flood warning when combining XR with cinemachine brain case 1074030 is having issues of flood wanrings complaining about cinemachine brain conflicting with xr camera. This is due to ShouldUseVRFieldOfView() returning true in Camera::SetVerticalFieldOfView because we have a vr device. URP 10.0.0 fixed this using https://github.com/Unity-Technologies/Graphics/pull/22 by setting disableLegacyRenderer to true to force a VRDeviceToXRDisplaySetup::TeardownShimFuncs(*this);. This is so there's no function override left in the shim table when calling UninstallVRDeviceShims from ProcessPendingTextureRequestsSynchronized which will finally call ShimTeardownIfActive(); to finally reset completely the legacy render device s_LegacyDevice = NULL;.which allows ShouldUseVRFieldOfView() to return false and therefore not throw a warning in Camera::SetVerticalFieldOfView. --- .../Runtime/UniversalRenderPipeline.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs b/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs index 09312afcd1f..2333a37a96f 100644 --- a/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs +++ b/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs @@ -152,7 +152,16 @@ internal void SetupXRStates() throw new NotImplementedException("Only 1 XR display is supported."); XRDisplaySubsystem display = xrDisplayList[0]; - if(display.GetRenderPassCount() == 0) + // case 1074030 is having issues of flood wanrings complaining about cinemachine brain conflicting with xr camera. + // This is due to ShouldUseVRFieldOfView() returning true in Camera::SetVerticalFieldOfView because we have a vr device. + // URP 10.0.0 fixed this using https://github.com/Unity-Technologies/Graphics/pull/22 by setting disableLegacyRenderer to true + // to force a VRDeviceToXRDisplaySetup::TeardownShimFuncs(*this);. This is so there's no function override left in + // the shim table when calling UninstallVRDeviceShims from ProcessPendingTextureRequestsSynchronized which will finally + // call ShimTeardownIfActive(); to finally reset completely the legacy render device s_LegacyDevice = NULL;.which allows + // ShouldUseVRFieldOfView() to return false and therefore not throw a warning in Camera::SetVerticalFieldOfView. + display.disableLegacyRenderer = true; + + if (display.GetRenderPassCount() == 0) { // Disable XR rendering if display contains 0 renderpass if(!xrSkipRender)