diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs index 91b0c5a02bc..e99623c511d 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,26 @@ 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 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 > 2560) || + ((m_MaxHeights / (float)height) > 2.0f && m_MaxHeights > 1440)) + { + if (m_FramesSinceLastReset > resetInterval) + { + m_FramesSinceLastReset = 0; + ResetReferenceSize(width, height); + } + 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; bool msaaSamplesChanged = (msaaSamples != m_ScaledRTCurrentMSAASamples); diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index ab419bdbb78..2624db78174 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -41,6 +41,7 @@ The version number for this package has increased due to a version update of a r - Fixed NullRef Exception when decals are in the scene, no asset is set and HDRP wizard is run. - Fixed nan when a decal affects normals. - Fixed issue with TAA causing bleeding of a view into another when multiple views are visible. +- 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.