https://bugs.freedesktop.org/show_bug.cgi?id=28771
Summary: Vsync always on Product: Mesa Version: git Platform: Other OS/Version: All Status: NEW Severity: normal Priority: medium Component: Drivers/DRI/r300 AssignedTo: dri-devel@lists.freedesktop.org ReportedBy: sa@whiz.se
With kernel 2.6.35, there doesn't seem to be a way to turn off vsync/vblank.
E.g. "vblank_mode=0 glxgears" has no effect.
This seems to be the same for both r300c and r300g.
System environment: -- system architecture: 32-bit -- Linux distribution: Debian unstable -- GPU: RV570 -- Model: Asus EAX1950Pro 256MB -- Display connector: DVI
-- xf86-video-ati: 801e83227a59a29eea425ea612083bbf2b536c30 -- xserver: 1.8.1.901 -- mesa: a5c44986a3f19936df448fe4ae47ca77ece9b0ce -- drm: 6ea2bda5f5ec8f27359760ce580fdad3df0464df -- kernel: 2.6.35-rc3
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #1 from Jesse Barnes jbarnes@virtuousgeek.org 2010-06-28 09:31:56 PDT --- You need both:
commit 234286c0f8b7d30ed49223c648d4c73c1a517ab3 Author: Jesse Barnes jbarnes@virtuousgeek.org Date: Thu Apr 22 12:47:41 2010 -0700
DRI2: add config query extension
and
commit 45e2b51c853471b79004a954ce3092a253b20b77 Author: Jesse Barnes jbarnes@virtuousgeek.org Date: Thu Apr 22 12:49:03 2010 -0700
DRI2/GLX: check for vblank_mode in DRI2 GLX code
for vblank_mode to work. Does your Mesa build have those?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #2 from Sven Arvidsson sa@whiz.se 2010-06-28 13:18:51 PDT --- Yes, I'm using git master, so they're both there.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #3 from Jesse Barnes jbarnes@virtuousgeek.org 2010-06-28 15:41:03 PDT --- Oh, for the DRI2 radeon driver you'll probably need to add an explicit option somewhere; maybe the code path that used to check the vblank_mode flags is no longer called.
See intel_screen.c: ... DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC) ...
there's probably a similar section in the radeon driver somewhere. You'll also need to add support for the new DRI2 config extension to the driver, again see intel_screen.c's intelScreenExtensions array: ... &dri2ConfigQueryExtension.base, ...
Hope that helps.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #4 from Alex Deucher agd5f@yahoo.com 2010-07-15 11:55:31 PDT --- Should be fixed in: 0a7803cbaca13033d9ed31ef33f59efa913fbfce
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #5 from Sven Arvidsson sa@whiz.se 2010-07-15 12:28:10 PDT --- Created an attachment (id=37084) View: https://bugs.freedesktop.org/attachment.cgi?id=37084 Review: https://bugs.freedesktop.org/review?bug=28771&attachment=37084
dri2 vblank for gallium
(In reply to comment #4)
Should be fixed in: 0a7803cbaca13033d9ed31ef33f59efa913fbfce
Thanks, it works with the classic r300 driver now.
For the Gallium one I had to make the same change in the dri state tracker. Not sure if it's the correct fix, but it works here.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #6 from Sven Arvidsson sa@whiz.se 2010-07-15 13:18:07 PDT --- Hmm, I still can't toggle vsync on/off inside games, it has no effect, but maybe that's a separate bug?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #7 from Andy Furniss lists@andyfurniss.entadsl.com 2010-07-16 05:03:29 PDT --- (In reply to comment #4)
Should be fixed in: 0a7803cbaca13033d9ed31ef33f59efa913fbfce
For me using rv670 it doesn't work from .drirc eg.
<driconf> <device screen="0" driver="r600"> <application name="all"> <option name="force_s3tc_enable" value="false" /> <option name="disable_s3tc" value="true" /> <option name="vblank_mode" value="0"/> </application> </device> </driconf>
It does work as an env so vblank_mode=0 ./gears works - but I still get wait for vline sync which means that fullscreen games or gears maximised gets capped to refresh.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #8 from Sven Arvidsson sa@whiz.se 2010-07-16 06:30:13 PDT --- I can confirm that setting vblank_mode=0 in drirc doesn't work here either.
Can't reproduce the other problem though, window or fullscreen doesn't make a difference.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #9 from Andy Furniss lists@andyfurniss.entadsl.com 2010-07-16 06:37:58 PDT --- (In reply to comment #8)
Maybe the wait for vline type vsync I get is r600 specific.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #10 from Toni Spets toni.spets@iki.fi 2010-07-17 22:36:22 PDT --- (In reply to comment #9)
I can also confirm .drirc gets ignored but env vblank_mode works.
To disable vsync completely you currently (and before) need a DDX hack along with vblank_mode=0.
With this patch interestingly glxgears goes from ~1400 fps to ~2100 fps and Quake 2 can run uncapped.
What is the real solution and why is this patch needed in DDX?
From 311d4c299ed8de4f28d3fd637a7bde8176db245b Mon Sep 17 00:00:00 2001
From: Toni Spets toni.spets@iki.fi Date: Wed, 17 Feb 2010 17:37:49 +0200 Subject: [PATCH] Disable vsync
--- src/radeon_dri2.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index a0ed085..b74a18b 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -315,7 +315,7 @@ radeon_dri2_copy_region(DrawablePtr drawable, }
vsync = info->accel_state->vsync; - info->accel_state->vsync = TRUE; + info->accel_state->vsync = FALSE;
(*gc->ops->CopyArea)(src_drawable, dst_drawable, gc, 0, 0, drawable->width, drawable->height, 0, 0);
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #11 from Alex Deucher agd5f@yahoo.com 2010-07-18 01:10:40 PDT --- (In reply to comment #10)
What is the real solution and why is this patch needed in DDX?
The real solution to what? The various GLX vsync/vblank extensions basically just expose frame counters and vertical retrace events to applications so they can use them for synchronization. They have nothing to do with tearing prevention directly. The code in the ddx you are asking about has nothing to do with the GLX vsync/vblank extensions; it is there to prevent tearing on GL buffer swaps. The variable should probably have been called vline_wait rather than vsync. What the code does is forces the GPU to wait until the current scanline is past the area that will be updated by the swap before doing the swap blit. It's the same method used by Xv to prevent tearing when rendering to the front buffer.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #12 from Andy Furniss lists@andyfurniss.entadsl.com 2010-07-18 03:35:09 PDT --- (In reply to comment #10)
With this patch interestingly glxgears goes from ~1400 fps to ~2100 fps and Quake 2 can run uncapped.
Thanks for the patch. The gears difference is expected as the wait for vline vsync still stalls GPU for the lines that the gears window covers. Changing res would also give different fps as more/less of the screen was outside the window.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #13 from Andy Furniss lists@andyfurniss.entadsl.com 2010-07-18 03:50:27 PDT --- (In reply to comment #11)
I guess what people want is a way to turn it off without patching, games don't seem to be able to.
Personally I am not that bothered about tearing in FPS type games and my old PC is often not able to render at refresh rate anyway - which means without triple buffering vsync hurts my already low framerate.
It's the same method used by Xv to prevent tearing when rendering to the front buffer.
Can GL have a switch like XV has - or should games in theory be able to turn off, but are prevented by a bug?
Digression - I notice that XV with vsync on can't live with frame rate = refresh rate, which I sometimes use for "proper" deinterlaced TV. GL vsync is fine and GL wait vline is much better that XV. Is this a driver issue or is it just that mplayers gl driver makes mplayer behave differently to it's xv driver?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #14 from Toni Spets toni.spets@iki.fi 2010-07-18 05:09:18 PDT --- (In reply to comment #13)
Yes, this is exactly what I'm talking about.
Quake-style games have options like gl_swapinterval and gl_ext_swapinterval but they do not seem to do anything. Honestly I don't even know what they should do, but on other platforms they used to disable vsync on some cards.
And it hurts performance not being able to turn it off without a patch. I like tearing! ;-)
Btw. are we still on-topic on this bug when the actual fix for vblank_mode was already committed?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #15 from Sven Arvidsson sa@whiz.se 2010-07-18 06:14:06 PDT --- (In reply to comment #14)
Btw. are we still on-topic on this bug when the actual fix for vblank_mode was already committed?
There's still three issues here:
1, The Gallium driver, not sure if the change I did is in the correct place? 2, drirc being ignored, perhaps this isn't specific to radeon? 3, Toggling vsync on/off from an application. Again, perhaps a separate issue?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #16 from Sven Arvidsson sa@whiz.se 2010-07-18 06:22:26 PDT --- (In reply to comment #15)
There's still three issues here:
1, The Gallium driver, not sure if the change I did is in the correct place?
Nevermind about this one, I should have remembered to do a git pull before commenting here :)
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #17 from Alex Deucher agd5f@yahoo.com 2010-07-19 10:29:31 PDT --- (In reply to comment #13)
Can GL have a switch like XV has - or should games in theory be able to turn off, but are prevented by a bug?
I'm not sure how you'd expose it. You could make it a driver option, but then you'd have to restart X to change it. There's no GLX extension to cover tearing as far as I know.
Xv in general does not provide any mechanism for application synchronization. I.e., here's no vblank events provided by Xv for app synchronization. That's what the GLX vsync extensions do.
The driver uses the vline wait for avoid tearing for both Xv and GL buffer swaps, they have nothing to do with the GLX vsync extensions. Those extensions only provide events that the application can use for synchronization. If you remove the vline wait code, you can still synchronize your application to the refresh rate, but you might still get tearing depending when the GL buffer swap happens.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #18 from Robert Hooker (Sarvatt) sarvatt@gmail.com 2010-07-27 23:00:11 PDT --- (In reply to comment #7)
To use vblank_mode for dri2 in .drirc you need a seperate dri2 driver with vblank_mode specified, driconf doesn't handle it right.
Using your example it'd be:
<driconf> <device screen="0" driver="dri2"> <application name="Default"> <option name="vblank_mode" value="0" /> </application> </device> <device screen="0" driver="r600"> <application name="all"> <option name="force_s3tc_enable" value="false" /> <option name="disable_s3tc" value="true" /> </application> </device> </driconf>
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #19 from Andy Furniss lists@andyfurniss.entadsl.com 2010-07-28 04:41:00 PDT --- (In reply to comment #18)
Thank you, that does the trick.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #20 from Sven Arvidsson sa@whiz.se 2010-07-28 06:44:34 PDT --- (In reply to comment #18)
To use vblank_mode for dri2 in .drirc you need a seperate dri2 driver with vblank_mode specified, driconf doesn't handle it right.
Great! Is there a bug open for driconf so this can be configured correctly?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #21 from Hans Nieser hnsr@xs4all.nl 2010-08-15 09:12:43 PDT --- (In reply to comment #20)
I believe I've run into the same problem with my RV770 (running mesa/libdrm/xf86-video-ati, tried both classic and gallium) from git master, where initially in every OpenGL app my framerate seemed to be capped to my screen's refresh (by default - even without a .drirc).
After making this change in my .drirc, the framerate is not capped anymore but it will still be swapping buffers during a retrace, and so I still get multiples of 60Hz (my screens refresh rate). This means in glxgears I get a ridicilous framerate like 2400, but in actual games like ioquake3, I get a framerate that jumps wildly from 30 to 60 to 120Hz, which I find really awkward :/
Is there any way currently to just make it swap buffers without regard for my screens vertical retrace? I realise that means I get a lot of tearing but I'd rather have that than a frame rate jumping around like that.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #22 from Andy Furniss lists@andyfurniss.entadsl.com 2010-08-16 02:45:45 PDT --- (In reply to comment #21)
For your chip you have to patch xf86-video-ati + disable as above. I'll attach the patch which someone posted in another bug when I find it.
I think this is going to come up again and again, so I hope in the absence of any way to change it on the fly, that it does get made into an xorg.conf option as suggested in comment 17.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #23 from Andy Furniss lists@andyfurniss.entadsl.com 2010-08-16 02:50:07 PDT --- Created an attachment (id=37895) View: https://bugs.freedesktop.org/attachment.cgi?id=37895 Review: https://bugs.freedesktop.org/review?bug=28771&attachment=37895
turn off wait for vline for r600+ ddx patch
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #24 from Sven Arvidsson sa@whiz.se 2010-08-18 13:22:16 PDT --- I compared how Intel (i965) compares when it comes to DRI2 and vsync, and as far as I can tell they have the same problems (needs a special driver="dri2" stansa in drirc, toggling vsync inside a game doesn't work).
This bug can proabably be closed as resolved for radeon, and bugs for the shortcomings mentioned above filed against DRI2.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
Alex Deucher agd5f@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dawitbro@sbcglobal.net
--- Comment #25 from Alex Deucher agd5f@yahoo.com 2010-08-22 21:37:56 PDT --- *** Bug 26599 has been marked as a duplicate of this bug. ***
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #26 from Tomasz Czapiewski xeros@irc.pl 2010-09-26 14:19:53 PDT --- Does anyone work on this to make it work without patching code to disable completely vsync?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #27 from Nikolay Rysev mad.f3ka@gmail.com 2010-09-27 02:55:29 PDT --- Excuse me, it's just interesting for me.
Why vsync is enabled for all OSS drivers by default?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
Tomasz Czapiewski xeros@irc.pl changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|Vsync always on |Waiting for vline forced | |always on
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #28 from Tomasz Czapiewski xeros@irc.pl 2010-10-19 05:50:18 PDT --- I want to know if are there any developers which would consider it as a bug to get fixed. It is a real problem for games, mostly for older hardware. Just try to play any first person shooter game where the framerate jumps from 60 to 30 so quickly.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #29 from Artem S. Tashkinov t.artem@mailcity.com 2010-10-22 06:17:41 PDT --- Is there a similar bug filed for Intel driver?
At least in RedHat's bugzilla there's a relevant patch: https://bugzilla.redhat.com/show_bug.cgi?id=634200
https://bugs.freedesktop.org/show_bug.cgi?id=28771
Jerome Glisse glisse@freedesktop.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|Waiting for vline forced |[RADEON:KMS::R300C:R300G] |always on |waiting for vline forced | |always on
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #30 from Ian Romanick idr@freedesktop.org 2011-02-21 13:44:15 PST --- (In reply to comment #29)
I don't see any patches there. Is it perhaps hiding in the .srpm?
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #31 from Alex Deucher agd5f@yahoo.com 2011-02-21 13:51:51 PST --- vline waits for non-pageflipped swap buffers can be disabled in both radeon and intel with: Option "SwapbuffersWait" "False" in the device section of your xorg.conf
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #32 from Sven Arvidsson sa@whiz.se 2011-02-21 16:03:49 PST --- The need to manually configure drirc to use driver=dri2 is filed as bug 34401.
I'm still not sure if toggling vsync on/off inside an application is supposed to work (it doesn't seem to with r300g in Sauerbraten or M.A.R.S. for example). What component should a bug be filed against in this case?
At least M.A.R.S. seems to be using glXSwapIntervalSGI for vsync.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
--- Comment #33 from Sven Arvidsson sa@whiz.se 2011-02-21 16:22:38 PST --- (In reply to comment #32)
Actually, forget about this part. It works, at least in MARS. Not sure about Sauerbraten, but it could be a bug in the game.
https://bugs.freedesktop.org/show_bug.cgi?id=28771
Michal Suchanek hramrach@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Depends on| |42035
https://bugs.freedesktop.org/show_bug.cgi?id=28771
Andreas Boll andreas.boll.dev@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX
--- Comment #34 from Andreas Boll andreas.boll.dev@gmail.com --- The classic r300 driver has been abandoned long ago. It was replaced by the Gallium driver r300g.
If you have issues with r300g please file a new bug report with component Drivers/Gallium/r300
Thanks.
https://bugs.freedesktop.org/show_bug.cgi?id=28771 Bug 28771 depends on bug 42035, which changed state.
Bug 42035 Summary: no way to turn off vline wait at runtime https://bugs.freedesktop.org/show_bug.cgi?id=42035
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID
dri-devel@lists.freedesktop.org