[HDRP][Fix] Case 1158661: Hardware mode for dynamic resolution breaks editor and game views #1652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist for PR maker
need-backport-*
label. After you backport the PR, the label changes tobackported-*
.CHANGELOG.md
file.Purpose of this PR
Fixes the visual artifacts and issues with hardware dynamic resolution, and re-enables it for Metal.
Specifically, this PR adds an overload of RTHandleSystem::SetReferenceSize that takes in the size of the final full resolution (without dyn-res applied) so that when hardware dynamic resolution is enabled, rtHandleScale stores the final resolution / maxSize. This is necessary to upscale to the final resolution correctly during the final pass, instead of upscaling to the maxSize of the render texture which causes the scaling artifacts that were previously seen when resizing the game view.
This PR also prevents the Lanczos upsampling shader function from dividing by 0, which previously caused numerous black line artifacts, especially noticeable when resizing.

Finally, this also ensures that the RTHandleSystem always populates the m_AutoSizedRTsArray when setting a new hardware dynamic resolution state so that render textures are always recreated with the correct dynamic resolution state (this fixes case 1158661: https://fogbugz.unity3d.com/f/cases/1158661/ where the Scene View wasn't turning dynamic resolution off).
Testing status
NOTE: There was an existing issue with DX12 that causes the editor to crash when hardware dynamic resolution is enabled. That's fixed in this trunk PR: https://ono.unity3d.com/unity/unity/pull-request/111190/_/graphics/dynamic-resolution/case-1158661 and tests should be run against the custom revision: adc71429b87e
Manual Tests: What did you do?
Yamato: (Select your branch):
https://yamato.prd.cds.internal.unity3d.com/jobs/902-Graphics/tree/HDRP%252Fhardware-dynamic-resolution