ppy / osu-framework

A game framework written with osu! in mind.
MIT License
1.66k stars 419 forks source link

SDL forces monitor to optimal refresh rate in fullscreen mode #4081

Open Joppe27 opened 3 years ago

Joppe27 commented 3 years ago

When switching to fullscreen using SDL, no matter which frame limiter is used, osu! forces the display's (not the game's) refresh rate back down to optimal. This is a problem for players using overclocked monitors, which I imagine there to be quite a few (myself included).

I'm not entirely sure about the optimal refresh rate part, the only info I have is that I have tested this on multiple monitors rated at 60hz, running at 75hz and they all got forced back down to 60hz using SDL. However, a 144hz monitor runs just fine at it's rated refresh rate which means SDL is not hard capping to 60hz and makes me think it's forcing down to the optimal refresh rate reported by the display instead.

This issue is does not occur using osuTK.

Example of a 60hz rated display running at 75hz: https://streamable.com/07mfqb (the display goes black for a second or two when switching between borderless and fullscreen since it needs to readjust because of the new refresh rate, this is not visible here)

osu!lazer version: 2020.1204.0

Specs: GTX 1060, Windows 10

peppy commented 3 years ago

I've moved this to framework as this is most definitely a framework-side issue. Currently the method we are using to choose the display resolution is very naive. Will probably need further testing and prefer higher refresh rates when available (rather than the "default" we're currently using).

Eventually we may also want to expose refresh rates to the user, rather than just base resolutions.

@Joppe27 do you happen to have a development environment setup?

Joppe27 commented 3 years ago

@Joppe27 do you happen to have a development environment setup?

No sorry, I'm just a regular user. Feel free to make me test stuff that doesn't require coding knowledge though! Maybe InfinityGhost from discord can help you out instead? They seem to have a similar setup.

peppy commented 3 years ago

Can you show some screenshots of what your display options look like in windows?

The dropdowns shown at the end of this sequence:

2020-12-10 13 56 40

Need to discern if the "overclocked" display modes are shown there, and/or if the order is different to what is expected. Then we can investigate what SDL2 is seeing at its end (which may again be different).

Currently we are just telling SDL2 to use the best available mode.

Joppe27 commented 3 years ago

afbeelding afbeelding Note that the 75hz option gets hidden when the 'Hide modes that this monitor cannot display' box is checked (this is to be expected when overclocking, the monitor displays 75Hz just fine). The 75Hz option will only show up in these menus if it is added through the Nvidia control panel first. It is not a standard option in the Windows display settings since the monitor does not officially support running at this refresh rate, but it will get added to the menu when set up via Nvidia control panel as I said earlier.

bdach commented 3 years ago

Looking at SDL source they seem to be using one of the EnumDisplaySettings family WinAPI calls.

Not sure how that plays together with what the control panel, and not sure I have the hardware to test anyway (I only have HDMI displays on hand which can't physically transfer more than 60Hz from what I know). It might be that adding the display modes via Nvidia control panel might be required for the overclocking to work (because we won't get the display mode from WinAPI otherwise).

ghost commented 3 years ago

Can confirm this is still an issue.

After osuTK got removed SDL forced me to use the optimal resolution/refresh rate, though this wasn't an issue for me since I was able to workaround this by changing the screen mode to borderless and disabling Desktop Composition on System Properties. However, since the last osu!lazer release, lazer no longer runs on Windows 7 (and accordingly to the thread, support for Windows 7 might get dropped unless they figure something out) so I was forced to update.

I'm curious about the current state of this issue, as disabling DWM is no longer possible and can produce lagspikes on modern versions of Windows.

peppy commented 3 years ago

I'm curious about the current state of this issue, as disabling DWM is no longer possible and can produce lagspikes on modern versions of Windows.

Your issue is quite specific as most people aren't "overclocking" their monitors. I'd recommend just not doing this for the time being. Or if you are, find a way to override the game's setting via drivers or more hacks.

ghost commented 3 years ago

Or if you are, find a way to override the game's setting via drivers or more hacks.

Some people apparently got luck by dumping, modifying and flashing a custom EDID for their monitors, however I don't have a way of doing so for my monitor, at least not for this one. Another option would be getting a Quadro GPU, where you can apparently load/unload custom EDIDs without having to read/write them from/to the monitor.

Looks like one of my options is going to be dual-booting a Linux install if I want to continue using my overclocked monitor.

EDIT: After tinkering around for a while I found out about CRU, it allows you to override any resolution setting directly in the registry. After adding a custom resolution with CRU, Windows and games are forced to use the custom one, as the "optimal" 60Hz no longer shows up or is available to be used, apparently.

The monitor no longer turns off and on to switch to the "optimal" resolution when opening or alt-tabbing the game. This can also be seen in-game, setting the frame limit to (e.g) 8x refresh rate shows 608Hz in the draw thread, instead of what was showed previously (480Hz).

@Joppe27 You might want to check this out if you haven't already.

Joppe27 commented 3 years ago

Your issue is quite specific as most people aren't "overclocking" their monitors.

Just want to quickly say that the amount of people with overclocked monitors shouldn't be underestimated, especially in a game like osu! where competitive players seem to have agreed that every extra frame matters. There are loads of monitors that advertise 60Hz but are perfectly capable at running 75Hz, which is a pretty stark difference even to non-competitive players.

@Joppe27 You might want to check this out if you haven't already.

Thanks for your suggestion, but I'm hesitant to use this as I switch monitors very regularly which would be a bit of a hassle using this workaround. I'm also not super comfortable with a program changing registry values because I am not a developer.

I will probably just wait for the several window-related fixes that are hopefully coming relatively soon, since I have not been able to play osu!lazer in fullscreen mode since the switch to SDL, nor have I been able to run borderless properly (that issue was also present in osuTK). Thanks for your work!

peppy commented 3 years ago

Please avoid replying to this issue unless you are working on a solution. There is already enough context explaining the issue.

DantesFromWISH commented 3 months ago

Hey, I found a solution for that issue (works for me). Everytime I turned my PC on with my monitor turned off it would force osu 60hz, but if I turned on my monitor first, then my PC the issue is gone. i noticed that if I turn PC on with monitor turned off, the VGA LED glows red, as if my GPU won't recognize my monitor, issue is gone if my monitor is turned on first.