Unity-Technologies / DynamicResolutionSample

A drop-in dynamic resolution script
Other
137 stars 21 forks source link

Debug view of current scale and resolution always shows display resolution #1

Closed wilg closed 2 years ago

wilg commented 2 years ago

Even when dynamic resolution is clearly working. Scale always shows 1 and the resolution is always the screen resolution.

MattSutherlin commented 2 years ago

I definitely know what's wrong with the indicated resolution, should have a fix for that shortly.

The scaling always showing 1 is interesting. Can you tell me which version of Unity, which render pipeline, and if it's an SRP which version?

wilg commented 2 years ago

Unity 2021.3.9f1 with HDRP 12.1.7. I am on macOS but I think I saw it on Windows too.

wilg commented 2 years ago

I definitely think something is wrong in general – it bounces around at the very bottom of the range and never uses really much of the resolution. It also does not seem to respect my target frame rate setting and always seems to optimize for the display refresh rate.

Maybe it is a misconfiguration? Or that issue where macOS/Metal reports weird timings?

Screen Shot 2022-09-09 at 5 32 21 PM
MattSutherlin commented 2 years ago

I believe the core issues are resolved in fceaae5836dce2b32730c24f5bfe6cce59ab4c03. Resolution should be correct in fullscreen and windowed, current scale should be the actual scaling value. Tested on your version of Unity and HDRP on Windows. I assume it's also fixed on Mac, but I'll be checking that shortly as part of validating your PR.

RE: the additional issues mentioned in your last comment. I think I understand what's going on, but let me know if I've missed the mark and we need to investigate this further.

For scaling behavior, I think it can be attributed to timing data being spikier on Mac/Win than other platforms, leading to two core problems. First is that it can be more common to get a long frame and trigger a scale down, which would require some rewriting to address. The second is that it takes too long to scale up when the timings are more volatile, and for this the script was written to have some tunable params to change the aggressiveness of scaling up. So I'd suggest trying to tune those values to get better behavior; the ReadMe is hopefully a suitable guide if there are any questions. It won't fix the entire problem as you'll still be at the mercy of long frames triggering scale downs, but it should be possible to be scaling up more and faster to improve the overall average resolution you're seeing.

For framerate, have you either modified the script to utilize a different target framerate or called SetTargetFramerate at runtime? The script starts up by default targeting 60fps so out of the box it would not be expected to see any other behavior.

wilg commented 2 years ago

Thanks! I'll check that out. Yes, I was calling SetTargetFramerate with various settings.

MattSutherlin commented 2 years ago

If you want to open a separate ticket and include as much relevant info as you can about the target framerate issue, I'll try to look into it when I get some time.