Skip to content

Reset RT Handle size every now and then in editor if set to a big resolution and then reverted back #2322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 5 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
20 changes: 20 additions & 0 deletions com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

/// <summary>
/// RTHandleSystem constructor.
Expand Down Expand Up @@ -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 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++;
}
#endif

bool sizeChanged = width > GetMaxWidth() || height > GetMaxHeight() || reset;
bool msaaSamplesChanged = (msaaSamples != m_ScaledRTCurrentMSAASamples);

Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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).
- 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.
Expand Down