Bug 97957 - Awful screen tearing in a separate X server with DRI3
Summary: Awful screen tearing in a separate X server with DRI3
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Thomas Hellström
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
: 97173 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-09-28 09:04 UTC by Marcin Mielniczuk
Modified: 2017-09-14 03:06 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Xorg.log (5.62 KB, application/gzip)
2016-09-28 18:24 UTC, Marcin Mielniczuk
Details
Patch to grab a new backbuffer if we're presenting a buffer that's already in the swap chain (579 bytes, patch)
2017-06-27 08:52 UTC, Thomas Hellström
Details | Splinter Review
Patch to grab a new backbuffer if we're presenting a buffer that's already in the swap chain (600 bytes, patch)
2017-07-04 07:44 UTC, Michel Dänzer
Details | Splinter Review
attachment-12843-0.html (928 bytes, text/html)
2017-07-04 07:58 UTC, Thomas Hellström
Details

Description Marcin Mielniczuk 2016-09-28 09:04:44 UTC
I'm using Arch Linux as my distribution, xf86-video-intel version 1:2.99.917+708+g8f33f80-1

I ran Hedgewars in a separate X server:
[code]xinit hedgewars -- :1 vt$XDG_VTNR[/code]
I start a quick battle with an AI. When the battle view is reached I experience awful screen tearing. When I ran the game through the DE, (Cinnamon) everything is ok.

If the rendering method is switched back to DRI2 from the default DRI3, the problem disappears.

This didn't happen with xf86-video-intel-1_2.99.917+604+gff0ab2c, which probably still used DRI2.
Comment 1 Chris Wilson 2016-09-28 09:17:30 UTC
Please attach your Xorg.log from the DRI3 hedgewars session.
Comment 2 Chris Wilson 2016-09-28 12:59:43 UTC
Hmm, has a definite feel to it that mesa/dri3 is rendering into the current scanout buffer.
Comment 3 Marcin Mielniczuk 2016-09-28 18:24:05 UTC
Created attachment 126833 [details]
Xorg.log

The problem happens only if fullscreen is turned on in the game.
Comment 4 Chris Wilson 2016-09-29 07:32:12 UTC
So what happens is we get a back-to-back glXSwapBuffers(); glXSwapBuffers(); and mesa submits the same pixmap for swapping twice and then loses track of when it is idle.
Comment 6 Chris Wilson 2016-09-29 08:03:34 UTC
*** Bug 97173 has been marked as a duplicate of this bug. ***
Comment 7 Dieter Nützel 2016-09-29 16:15:13 UTC
Hello Chris,

did you send this
https://cgit.freedesktop.org/~ickle/mesa/commit/?h=brw-batch&id=8ffee986f537888921716ab632236ea4c55fb0f1
in for review?

E.g. to Michel?
Maybe it solve this
https://bugs.freedesktop.org/show_bug.cgi?id=97260#c56
one , too?
Comment 8 Michel Dänzer 2016-09-30 03:00:37 UTC
(In reply to Dieter Nützel from comment #7)
> E.g. to Michel?
> Maybe it solve this
> https://bugs.freedesktop.org/show_bug.cgi?id=97260#c56
> one , too?

I'll take a look at Chris' patch once it's submitted for review with a proper rationale for all the changes. Meanwhile, for bug 97260 it would be more useful if somebody tested the patch I attached there.

Removing myself from Cc because I get notified of updates to this report via the mesa-dev mailing list.
Comment 9 Marcin Mielniczuk 2017-03-25 10:57:42 UTC
Hi,

Has the patch stuck in review? 

The same problem appears with the modesetting driver. Besides, right now with mesa 17.0.1 when using DRI3 every movement on the screen seems blurred, both on windowed mode and fullscreen. This doesn't happen with DRI2, both with xf86-video-intel and modesetting.
Comment 10 Michel Dänzer 2017-03-31 06:14:07 UTC
Chris, are you planning to submit the fix for review?
Comment 11 Michel Dänzer 2017-06-27 08:15:22 UTC
Thomas, since you've been fixing DRI3 related issues, maybe you can take a look?
Comment 12 Thomas Hellström 2017-06-27 08:52:00 UTC
Created attachment 132276 [details] [review]
Patch to grab a new backbuffer if we're presenting a buffer that's already in the swap chain
Comment 13 Thomas Hellström 2017-06-27 08:56:08 UTC
It sounds to me like a back- to back SwapBuffers() is an application bug. The back buffer content is undefined after a SwapBuffers().

But we shouldn't present a back buffer that's already in the swap chain. Hence the attached patch.

Also, we should perhaps considering implementing and advertizing GLX_SWAP_COPY_OML and GLX_SWAP_EXCHANGE_OML on dri3. There seems to be apps relying on the GLX_SWAP_COPY_OML behavior. Among others glretrace playing back traces captured on WGL.
Comment 14 Thomas Hellström 2017-06-27 10:12:20 UTC
Actually, it seems that at least Gallium advertises GLX_SWAP_COPY_OML. But dri3 doesn't implemented it.
Comment 15 Fredrik Höglund 2017-06-28 11:21:20 UTC
(In reply to Thomas Hellström from comment #13)
> It sounds to me like a back- to back SwapBuffers() is an application bug.
> The back buffer content is undefined after a SwapBuffers().

It is not undefined when the implementation supports EXT_buffer_age.
Comment 16 Thomas Hellström 2017-06-28 15:19:51 UTC
(In reply to Fredrik Höglund from comment #15)
> (In reply to Thomas Hellström from comment #13)
> > It sounds to me like a back- to back SwapBuffers() is an application bug.
> > The back buffer content is undefined after a SwapBuffers().
> 
> It is not undefined when the implementation supports EXT_buffer_age.

Well it may be for some buffers. Whether or not the app uses EXT_buffer_age correctly in this case doesn't really matter as there are apps out there that most certainly don't. Perhaps we can use a driconf option for such apps to restrict available swap methods.

But most importantly there is a mesa dri3 bug here. And looking closer at the code the glx/dri implementation of GLX_OML_swap_method appears utterly broken, so it will take some time to fix.
Comment 17 Thomas Hellström 2017-06-28 15:27:08 UTC
I'm working on a solution to the dri3 bug as well as a dri3 client side implementation of GLX_OML_swap_method.
Comment 18 Michel Dänzer 2017-07-04 07:44:00 UTC
Created attachment 132422 [details] [review]
Patch to grab a new backbuffer if we're presenting a buffer that's already in the swap chain

Here's a fixed version of Thomas' patch which fixes this problem for me.
Comment 19 Thomas Hellström 2017-07-04 07:58:37 UTC
Created attachment 132424 [details]
attachment-12843-0.html

Hi!

I'm on vacation and will be back on Monday July 31st. For vmware linux graphics driver issues, please contact
<linux-graphics-maintainer@vmware.com>

Thanks,
Thomas Hellström
Comment 20 Michel Dänzer 2017-07-13 08:21:28 UTC
Thanks for the report, fixed in Git master:

Module: Mesa
Branch: master
Commit: 81fb1547772d42c527318837d4207ecdb6899e5d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=81fb1547772d42c527318837d4207ecdb6899e5d

Author: Thomas Hellstrom <thellstrom@vmware.com>
Date:   Tue Jul  4 12:55:15 2017 +0900

loader/dri3: Use dri3_find_back in loader_dri3_swap_buffers_msc
Comment 21 Marcin Mielniczuk 2017-07-23 09:04:52 UTC
Thanks for fixing! I had a similar problems when using the modesetting driver, I'll check if it's gone when this gets into a release. 

For completeness, I describe how the modesetting driver behaves with mesa : whenever running Hedgewars with DRI3 enabled, I has a little screen tearing and the display is blurry when moving around the cursor (moving around the battlefield in the game). Disabling DRI3 (falling back to DRI2) fixed all problems and the display was smooth again.
This happens even when running the game within a DE.
Comment 22 Michel Dänzer 2017-09-13 07:31:43 UTC
Please don't reopen a bug report without justification.
Comment 23 赵九胤 2017-09-13 12:58:34 UTC
I ran the S3(the computer suspends into memory) test 500 times and my Linux system crashed,an abnormal image appears on the monitor,But it happened by accident
In the five test, the system died 3 times and passed 2 times
Error: [780]: segfault at a0 IP 00007fdd98671e sp 00007ffea5328810 error 4 in radeonsi_dri. So [7fdd9f287000+93c000]

Has the problem been solved
Thank you...!
Comment 24 赵九胤 2017-09-13 12:59:24 UTC
I ran the S3(the computer suspends into memory) test 500 times and my Linux system crashed,an abnormal image appears on the monitor,But it happened by accident
In the five test, the system died 3 times and passed 2 times
Error: [780]: segfault at a0 IP 00007fdd98671e sp 00007ffea5328810 error 4 in radeonsi_dri. So [7fdd9f287000+93c000]

Has the problem been solved
Thank you...!
Comment 25 Michel Dänzer 2017-09-14 03:06:23 UTC
(In reply to 赵九胤 from comment #24)
> I ran the S3(the computer suspends into memory) test 500 times and my Linux
> system crashed, [...]

That doesn't sound related to this bug report at all. Please file your own report.


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.