Bug 100063

Summary: vsync setting of OpenGL programs is ignored
Product: Mesa Reporter: thedribbleondo
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED NOTOURBUG QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: notasas
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Xorg log

Description thedribbleondo 2017-03-05 08:24:13 UTC
On both the AMDGPU driver and the RadeonSI driver, My Frame rate in Payday 2 will not go above my monitors refresh rate. the FPS counter get's stuck at 75fps (my monitors refresh rate). Lowering the resolution to a more conventional refresh rate does nothing (1080@60hz is the same as 720@75hz).

Interesting to note is that the AMDGPU-PRO driver has no such problems. I'm taking a fairly good guess that something in the Open Source MESA is causing this problem.
Comment 1 Michel Dänzer 2017-03-06 02:04:20 UTC
If sync-to-vblank can't be disabled in the game settings, you can override it with the environment variable vblank_mode=0.
Comment 2 Gregor Münch 2017-03-06 07:15:54 UTC
I experience the same problem with Dirt: Showdown. Vsync is "OFF" in game settings, but it stays stubborn at 60fps.
Comment 3 Michel Dänzer 2017-03-06 07:20:45 UTC
Please attach the Xorg log file and the ~/.drirc file corresponding to the problem.
Comment 4 thedribbleondo 2017-03-06 08:02:50 UTC
(In reply to Michel Dänzer from comment #1)
> If sync-to-vblank can't be disabled in the game settings, you can override
> it with the environment variable vblank_mode=0.

Tested this very briefly, and it worked! Adding it to the list of commands Steam itself executes on runtime fixes the issue, adding this top the Payday 2 launch options does not.
Comment 5 Grazvydas Ignotas 2017-03-06 11:44:58 UTC
Created attachment 130088 [details]
Xorg log

Actually this is quite an old problem with my setup as well - ingame vsync settings are ignored (always acts as on regardless of the setting) and I always have to resort to vblank_mode override. i965, anv or radv don't have this problem on the same setup so assigning to radeonsi.

Some maybe relevant settings:
window manager: xfwm4
compositing: off
no ~/.drirc file
TearFree: on
DRI: 3
mesa+llvm git (or older)

What's worse, this forced vsync occasionally goes out of sync with the display refresh and I get stuttering (the game is surely fast enough, 100+ fps with vblank_mode override). So if I run 60fps OpenGL game like Talos, it first runs smoothly, after a while starts stuttering (for half a minute or so), then goes back to smooth again and so on and on, while the fps counter shows "clean" 60.
Comment 6 Michel Dänzer 2017-03-07 01:58:36 UTC
Since explicitly setting vblank_mode=0 works, it sounds like either the games are not actually disabling sync-to-vblank properly (an apitrace of toggling the sync-to-vblank setting in-game might shed some light on this), or vblank_mode is set to 3 (which forces sync-to-vblank regardless of what the application requests) in ~/.drirc or /etc/drirc.

Anyway, there's no radeonsi specific code involved in this.
Comment 7 Michel Dänzer 2017-03-07 02:12:13 UTC
E.g. the VSync setting in Unigine Valley works as expected for me (note that changing the setting only takes effect after clicking the OK button as well).
Comment 8 Grazvydas Ignotas 2017-03-08 01:10:21 UTC
I wanted to do more testing today, but it doesn't seem to reproduce any more on my games, except for The Talos Principle. I can confirm vsync works correctly on Unigine Valley, Left 4 Dead 2, Black Mesa, Tomb Raider, I don't have Dirt: Showdown or Payday 2.

For Talos, I think I've found what's going on and sent a patch:
https://lists.freedesktop.org/archives/mesa-dev/2017-March/147099.html
Comment 9 Michel Dänzer 2017-03-08 06:39:45 UTC
(In reply to Grazvydas Ignotas from comment #8)
> For Talos, I think I've found what's going on and sent a patch:
> https://lists.freedesktop.org/archives/mesa-dev/2017-March/147099.html

Per Ian's followup, that's actually a Talos issue. Might be the same or similar issues in Payday 2, Dirt: Showdown and other games.

Resolving this report as not our bug, since there's no evidence of a bug in Mesa or other driver components. Please only reopen if such evidence turns up.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.