From 27e1be6f790847a47aa203bf798b2ee624c8fbef Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Thu, 22 Oct 2020 15:28:58 +0200 Subject: [PATCH 1/5] Reset every now and then --- .../Runtime/Textures/RTHandleSystem.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs index 91b0c5a02bc..9cfefad9c15 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs @@ -67,6 +67,10 @@ internal enum ResizeMode int m_MaxWidths = 0; int m_MaxHeights = 0; +#if UNITY_EDITOR + // In editor every now and then we must reset the size of the rthandle system if it was set very high and then switched back to a much smaller scale. + int m_FramesSinceLastReset = 0; +#endif /// /// RTHandleSystem constructor. @@ -172,6 +176,22 @@ public void SetReferenceSize(int width, int height, MSAASamples msaaSamples, boo width = Mathf.Max(width, 1); height = Mathf.Max(height, 1); +#if UNITY_EDITOR + // If the reference size is significantly higher than the current actualWidth/Height and it is larger than 1080p dimensions, we reset the reference size every several frames + // in editor to avoid issues if a large resolution was temporarily set. + const int resetInterval = 100; + if (((m_MaxWidths / (float)width) > 2.0f && m_MaxWidths > 1920) || + ((m_MaxHeights / (float)height) > 2.0f && m_MaxHeights > 1080)) + { + if (m_FramesSinceLastReset > resetInterval) + { + m_FramesSinceLastReset = 0; + ResetReferenceSize(width, height); + } + m_FramesSinceLastReset++; + } +#endif + bool sizeChanged = width > GetMaxWidth() || height > GetMaxHeight() || reset; bool msaaSamplesChanged = (msaaSamples != m_ScaledRTCurrentMSAASamples); From 6e14e687164dceb6affea30c6d8affcaa8b035bd Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Thu, 22 Oct 2020 15:33:14 +0200 Subject: [PATCH 2/5] Changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index ef0c8b4be0d..8b9afd1c9ce 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -24,6 +24,7 @@ The version number for this package has increased due to a version update of a r - Fixed upside down XR occlusion mesh. - Fixed precision issue with the atmospheric fog. - Claryfied doc for the LayeredLit material. +- Fix an issue that caused issues of usability of editor if a very high resolution is set by mistake and then reverted back to a smaller resolution. ### Changed - Combined occlusion meshes into one to reduce draw calls and state changes with XR single-pass. From 6e38bb40f249510154960632d802083af53dbbbb Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Fri, 23 Oct 2020 11:25:38 +0200 Subject: [PATCH 3/5] Bump min to 1440 --- .../Runtime/Textures/RTHandleSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs index 9cfefad9c15..996752e3007 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs @@ -177,11 +177,11 @@ public void SetReferenceSize(int width, int height, MSAASamples msaaSamples, boo height = Mathf.Max(height, 1); #if UNITY_EDITOR - // If the reference size is significantly higher than the current actualWidth/Height and it is larger than 1080p dimensions, we reset the reference size every several frames + // If the reference size is significantly higher than the current actualWidth/Height and it is larger than 1440p dimensions, we reset the reference size every several frames // in editor to avoid issues if a large resolution was temporarily set. const int resetInterval = 100; - if (((m_MaxWidths / (float)width) > 2.0f && m_MaxWidths > 1920) || - ((m_MaxHeights / (float)height) > 2.0f && m_MaxHeights > 1080)) + if (((m_MaxWidths / (float)width) > 2.0f && m_MaxWidths > 2560) || + ((m_MaxHeights / (float)height) > 2.0f && m_MaxHeights > 1440)) { if (m_FramesSinceLastReset > resetInterval) { From ffe04405b42076ba6dd840106269b86b335c4e18 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Fri, 23 Oct 2020 11:57:42 +0200 Subject: [PATCH 4/5] Update CHANGELOG.md Fixed changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index b948e66e640..5a6ee325903 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -26,7 +26,6 @@ The version number for this package has increased due to a version update of a r - Fixed precision issue with the atmospheric fog. - Fixed issue with TAA and no motion vectors. - Fixed the stripping not working the terrain alphatest feature required for terrain holes (case 1205902). -- Claryfied doc for the LayeredLit material. - Fix an issue that caused issues of usability of editor if a very high resolution is set by mistake and then reverted back to a smaller resolution. ### Changed From 19cb87d07ba6ead3a05c357b542b41fa7f4287d0 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Fri, 23 Oct 2020 13:03:13 +0200 Subject: [PATCH 5/5] Avoid reset if we still need the high res --- .../Runtime/Textures/RTHandleSystem.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs index 996752e3007..e99623c511d 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs @@ -190,6 +190,10 @@ public void SetReferenceSize(int width, int height, MSAASamples msaaSamples, boo } m_FramesSinceLastReset++; } + + // If some cameras is requesting the same res as the max res, we don't want to reset + if (m_MaxWidths == width && m_MaxHeights == height) + m_FramesSinceLastReset = 0; #endif bool sizeChanged = width > GetMaxWidth() || height > GetMaxHeight() || reset;