Bug 72889

Summary: wayland/weston EGL/GLESv2 client corruption/flicker on r600 mesa-10.x
Product: Mesa Reporter: emiettin
Component: EGL/WaylandAssignee: Wayland bug list <wayland-bugs>
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: major    
Priority: medium    
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: patch

Description emiettin 2013-12-19 21:00:01 UTC
On my Radeon HD 5770, upgrading from mesa-9.2.5 to either mesa-10.0.1 or mesa-git master introduces (in both versions) a corruption/flickering bug concerning wayland/weston EGL/GLESv2 clients. See http://www.youtube.com/watch?v=RQXE4h-E8PI for a relevant screen capture. 

It looks to me as if the glClear(GL_COLOR_BUFFER_BIT) call wasn't actually coming into effect; instead, previous (or random) color data lingers in the part of the frame buffer that isn't updated during rendering. The bug doesn't really manifest itself in a weston client that updates each and every pixel within each frame during rendering.

setup: Arch Linux x86_64 (Linux 3.12.5),
       mesa-git (+ ati-dri-git & mesa-libgl-git). Bug also in 10.0.1 stable.
       wayland/weston 1.3.0/1.3.1 as well as git
Comment 1 Alex Deucher 2013-12-19 21:08:45 UTC
Can you bisect?
Comment 2 Alex Deucher 2013-12-19 21:09:39 UTC
*** Bug 72890 has been marked as a duplicate of this bug. ***
Comment 3 Alex Deucher 2013-12-19 21:10:29 UTC
Possibly related to Bug 72863 and/or Bug 72854?
Comment 4 Martin Andersson 2013-12-23 11:59:25 UTC
I had the the same issue and I bisected it to this commit

http://cgit.freedesktop.org/mesa/mesa/commit/?h=10.0&id=e64633e8c3a5498998a45ab721bf80edca101cf5 (r600g,radeonsi: share r600_texture.c)

As far as I can tell that commit changed the default tiling mode from LINEAR_ALIGNED to 2D. That change seems to cause this issue, because when I change the last return in r600_choose_tiling from:

return RADEON_SURF_MODE_2D;
to
return RADEON_SURF_MODE_LINEAR_ALIGNED;

It works correctly.
Comment 5 Michel Dänzer 2013-12-25 02:56:14 UTC
I suspect the problem is that fast colour clears are not resolved during buffer swaps on Wayland (linear buffers cannot use fast clears, which is why your r600_choose_tiling change works around the problem) and that something like commit 6349b3235cc07d396325863ece9ca6261daf8e77 ('st/egl: flush resources before presentation') needs to be done in src/gallium/state_trackers/egl/wayland/ as well.
Comment 6 Martin Andersson 2013-12-25 13:51:56 UTC
Created attachment 91188 [details] [review]
patch

Yep, that seems to be the issue. The attached patch fixes the issue for me, but I'm not familiar with that code so I have no idea if this is the proper fix.
Comment 7 Michel Dänzer 2013-12-26 01:09:40 UTC
Looks like a good start at least. Please submit it to the mesa-dev / wayland-devel mailing list(s) for review.
Comment 8 Michel Dänzer 2014-04-28 09:02:35 UTC
commit c156d245258842c41d1ffac06a08ee7eeb45b33f
Author: Martin Andersson <g02maran@gmail.com>
Date:   Thu Dec 26 10:33:28 2013 +0100

    st/egl: Flush resources before presentation

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.