Win32 - Support rendering at max refresh rate of current displays - #21643
Conversation
|
|
||
| var maxDisplayFrequency = Instance.Screen?.AllScreens?.Max(s => (s as WinScreen)?.Frequency); | ||
|
|
||
| if (maxDisplayFrequency != null && | ||
| maxDisplayFrequency != 0 && | ||
| renderTimer is SleepLoopRenderTimer sleepLoopRenderTimer) | ||
| { | ||
| sleepLoopRenderTimer.DesiredFps = (int)maxDisplayFrequency; | ||
| } | ||
|
|
There was a problem hiding this comment.
Please extract this logic and reuse it here and in WindowImpl.
| AvaloniaLocator.CurrentMutable.Bind<IPlatformDragSource>().ToSingleton<DragSource>(); | ||
|
|
||
|
|
||
| var maxDisplayFrequency = Instance.Screen?.AllScreens?.Max(s => (s as WinScreen)?.Frequency); |
There was a problem hiding this comment.
In #18558 for X11, we take the larger of 60 and the maximum refresh rate. Even though sub-60Hz monitors are pretty rare, please do the same here so we're consistent and always ensure at least 60 FPS.
Note: we can tweak this behavior later or expose a configuration knob to the users if needed.
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
What does the pull request do?
Updates
SleepRenderTimerwith the max refresh rate reported for the displays available on Windows. This allows Vulkan and WGL to render at the highest refresh rate available, though there are some inconsistencies due to the lack of hardware timing.This doesn't affect AngleGL because that backend uses the DWM Composition as timer.
WGL and Vulkan behave differently based on display and driver settings.
WGL: On a Nvidia GPU
Fast, render rate will be locked to the refresh rate of the last display the window was resized on. 2 monitors with 60hz and 120hz will result in Avalonia rendering at 120fps if initially moved from the second monitor to the first, and 60fps if initially moved from the first monitor to the second. Resizing will reset the frame rate to the current monitor.Vulkan:
Fastor equivalent, it will adapt to the current display's refresh rate, dynamically switching with no need to resize. This would have been the more favored present mode, if it didn't rely on the driver settings.What is the current behavior?
Rendering is locked to 60fps, regardless of the display's refresh rate.
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues