Skip to content
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

Variable Refresh Rate / Adaptive Sync support #199

Closed
ppascher opened this issue May 20, 2021 · 20 comments
Closed

Variable Refresh Rate / Adaptive Sync support #199

ppascher opened this issue May 20, 2021 · 20 comments
Labels
enhancement New feature or request

Comments

@ppascher
Copy link

Variable Refresh Rate / Adaptive Sync / Freesync is currently not supported in gamescope. It is supported in wlroots though (1).
As most modern GPUs and Monitors support VRR it would be nice to eventually have VRR support in gamescope as well.

2021-05-19 | 10:28:53  emersion: ppascher: yeah, gamescope uses a fixed refresh rate, always. see the -r flag
2021-05-19 | 10:34:00  ppascher: emersion: Thank you. I was using the -r flag to limit my refresh rate a little below the max of 160hz for my monitor so it does not jump in and out of vrr range. Would VRR be something that could be implemented for gamescope since it uses wlroots? Or was this discussed before and dismissed?
2021-05-19 | 10:35:45  emersion: ppascher: i think it could be implemented, but would need a pretty major refactoring in vblankmanager.cpp

(1) swaywm/wlroots#1987

@Plagman
Copy link
Member

Plagman commented May 29, 2021

Yeah. I have some code in progress that helps on that front. Need to figure out how to detect we're VRR-capable in both nested and embedded to enable the logic where 'vblanks' would be driven by the need to repaint.

@aqxa1
Copy link

aqxa1 commented Jun 1, 2021

Looking forward to this. For the record (until this is fixed), if you have a game that is internally capped below the monitor's refresh rate, you'll also need to cap with gamescope, as the monitor will still try and run the max refresh rate when run with gamescope.

@emersion emersion changed the title [Feature Request] Variable Refresh Rate / Adaptive Sync support Variable Refresh Rate / Adaptive Sync support Jul 25, 2021
@emersion emersion added embedded Embedded mode via DRM/KMS enhancement New feature or request and removed embedded Embedded mode via DRM/KMS labels Jul 25, 2021
@nfp0
Copy link

nfp0 commented Mar 8, 2022

Also looking forward for this feature.

@jarrard
Copy link

jarrard commented Mar 13, 2022

Yeah this is basically the last major feature I need in GS before I start using it. Hope it can happen soon!
Not sure if the steam deck can take advantage of VRR or not, but it helps smooth framerates out in many games. It's also not ALWAYS beneficial to have enabled but normally helps.

@jluthi
Copy link

jluthi commented Mar 20, 2022

Let's get this working!

@jarrard
Copy link

jarrard commented Mar 20, 2022

I don't really know whats required to make it so at this point. I thought gamescope already runs in true fullscreen mode with the -F flag but maybe its fake, or the game inside is being forced into borderless within gs....

@ppascher
Copy link
Author

ppascher commented Apr 7, 2022

I just noticed while checking for status on #163 that VRR appears to be working through gamescope playing Cyberpunk 2077. Can someone confirm? This was using sway/wlroots with enabled VRR on amdgpu.

@Plagman
Copy link
Member

Plagman commented Apr 9, 2022

VRR will 'work', but we won't present at the right time for it to have the desired effect, at the moment. It should be really easy to plumb an unconditional VRR option with how the current thing is laid out, and we can plumb it to dynamically detecting if VRR is currently on for our window or not later.

@jarrard
Copy link

jarrard commented Apr 9, 2022

It be nice if it worked for xorg since I'm holding off using wayland until it has display gamma controls and maybe HDR happening.

@TheEvilSkeleton
Copy link

TheEvilSkeleton commented May 2, 2022

Theoretical question, if Gamescope supported VRR and if a Wayland compositor like Mutter doesn't support VRR, could we use Gamescope to have VRR support in the micro-compositor (not the UI, but for anything that is running inside Gamescope)?

@Scrumplex
Copy link

Scrumplex commented May 2, 2022

Theoretical question, if Gamescope supported VRR and if a Wayland compositor like Mutter doesn't support VRR, could we use Gamescope to have the VRR support?

VRR would probably won't work in nested mode (running Gamescope nested inside another compositor or X11)

You could maybe replace mutter with Gamescope, but that sounds very impractical.

Edit: Looks like wlroots only contains code for the DRM backend and for some reason also for the X11 backend

@jarrard
Copy link

jarrard commented May 2, 2022

Doesn't Mutter do fullscreen unredirect anyway which should allow VRR to work?

@misyltoad
Copy link
Collaborator

misyltoad commented May 2, 2022

We want to do DRM leasing for stuff like this when nested

@misyltoad
Copy link
Collaborator

Doesn't Mutter do fullscreen unredirect anyway which should allow VRR to work?

Don't think itd play nicely, but we can always find out...

@wsippel
Copy link

wsippel commented May 5, 2022

Mutter supports neither VRR nor DRM leasing. Don't think anybody's working on DRM lease support, either: https://gitlab.gnome.org/GNOME/mutter/-/issues/1743

@CorvetteCole
Copy link

mutter supports VRR in https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154 which should hopefully be merged soon

@orowith2os
Copy link

I think the best option for adding VRR support to gamescope would be enabling it as a launch option, same with most (all?) other features it has. If someone launches it with the option when their desktop doesn't support it and it breaks something, there's not much that could be done if implemented that way.
I'm not very knowledgeable on how stuff would be implemented, and these are just my thoughts, so take em with an abnormally large grain of salt lol

@TheEvilSkeleton
Copy link

Related: ec6bd30

@chaitan3
Copy link

chaitan3 commented Oct 29, 2022

VRR seems to be finally working in embedded (drm) mode.

Verified by running gamescope in VT after applying the following hacky patch on latest master (could not find a way to enable it via an environment variable or flag). Monitor OSD now displays game FPS.

diff --git a/src/drm.cpp b/src/drm.cpp
index 1e9b96a..8ceb950 100644
--- a/src/drm.cpp
+++ b/src/drm.cpp
@@ -2002,7 +2002,7 @@ bool drm_set_color_mtx(struct drm_t *drm, float *mtx, enum drm_screen_type scree

 void drm_set_vrr_enabled(struct drm_t *drm, bool enabled)
 {
-       drm->wants_vrr_enabled = enabled;
+       drm->wants_vrr_enabled = true;
 }

 bool drm_get_vrr_in_use(struct drm_t *drm)

@misyltoad
Copy link
Collaborator

I'll add a startup flag for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests