http://bugs.winehq.org/show_bug.cgi?id=34263
Bug #: 34263 Summary: Framebuffer read-before-write causes graphical glitches Product: Wine Version: 1.7.0 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d AssignedTo: wine-bugs@winehq.org ReportedBy: achurch+wine@achurch.org Classification: Unclassified
Created attachment 45608 --> http://bugs.winehq.org/attachment.cgi?id=45608 Suboptimal but functional patch
In at least the Final Fantasy XIV: A Realm Reborn character creation benchmark (http://na.finalfantasyxiv.com/benchmark/index.html), framebuffer read-before-write results in graphical glitches such as the entire display or UI overlays flickering or incorrect textures being drawn. This program uses multithreaded rendering (though I don't know whether that's relevant), and in some cases, Direct3D calls which get translated to glBlitFramebuffer() attempt to read from a framebuffer before the GPU has finished rendering to it.
The cause was found by dumping OpenGL calls using apitrace (https://github.com/apitrace/apitrace) and observing that replaying the same frame sporadically caused the same sort of glitches as observed in Wine, but the glitches went away when a glFinish() call was inserted at each thread switch.
The attached patch fixes these glitches by inserting a glFinish() call before each glBlitFramebuffer() call. This is almost certainly suboptimal, and in my case it causes the benchmark result to drop from ~3500 to ~3000, but it fixes all graphical glitches aside from black squares seen in some cases when the HDR option is enabled in rendering settings.
http://bugs.winehq.org/show_bug.cgi?id=34263
--- Comment #1 from Andrew Church achurch+wine@achurch.org 2013-08-13 16:47:34 CDT --- I should note that the patch will probably cause crashes on the Mac because it adds new function pointers but only sets them in the X11 driver.
http://bugs.winehq.org/show_bug.cgi?id=34263
--- Comment #2 from Henri Verbeet hverbeet@gmail.com 2013-08-14 02:10:01 CDT --- Yeah, that's a known issue with multi-threaded D3D applications at the moment. In principle setting the "StrictDrawOrdering" registry key is supposed to help, although it may not be enough.
http://bugs.winehq.org/show_bug.cgi?id=34263
--- Comment #3 from Andrew Church achurch+wine@achurch.org 2013-08-14 12:31:00 CDT --- Thanks for the note. FWIW, I tried setting StrictDrawOrdering on unpatched wine-1.7.0 but it doesn't seem to help much; there are perhaps fewer cases of the wrong texture getting drawn, but the flickering is just as bad with StrictDrawOrdering as without. (And the benchmark performance dropped to ~2800, compared to ~3000 with the attached glFinish() patch, just as a point of comparison.)
In case it's worth anything, it seems like the glFinish() call added by my patch in swapchain.c affects only the flickering, and the glFinish() calls added in surface.c affect only the wrong-texture glitches.
http://bugs.winehq.org/show_bug.cgi?id=34263
Jari Vetoniemi mailRoxas@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mailRoxas@gmail.com
--- Comment #4 from Jari Vetoniemi mailRoxas@gmail.com 2013-08-28 01:00:19 CDT --- With this patch, the flickering still occurs if __GL_THREADED_OPTIMISATIONS=1 is enabled for nVidia Linux driver. (Not as severely however)
I'll check out apitrace dump when I get home.
http://bugs.winehq.org/show_bug.cgi?id=34263
rmlipman@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rmlipman@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=34263
Brian Nguyen mtxcoll@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mtxcoll@gmail.com
--- Comment #5 from Brian Nguyen mtxcoll@gmail.com --- Created attachment 47921 --> http://bugs.winehq.org/attachment.cgi?id=47921 Updated patch
http://bugs.winehq.org/show_bug.cgi?id=34263
--- Comment #6 from Brian Nguyen mtxcoll@gmail.com --- As a heads up, I found the 2013-08-13 16:30 patch no longer applies cleanly to ToT wine as of 3/29/2014 (commit f3488d0fea8d8d2d803ba89ccce2b7dd0ed4165c). I manually resolved the conflicts and found the attached 2014-03-29 16:45 patch works for me.
http://bugs.winehq.org/show_bug.cgi?id=34263
Ken Thomases ken@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #47921|0 |1 is patch| |
http://bugs.winehq.org/show_bug.cgi?id=34263
Brandon Corujo haku08879@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |haku08879@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=34263
tangx246@umn.edu changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |tangx246@umn.edu
https://bugs.winehq.org/show_bug.cgi?id=34263
Luke Bratch luke@bratch.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |luke@bratch.co.uk
https://bugs.winehq.org/show_bug.cgi?id=34263
Sergey Isakov isakov-sl@bk.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |isakov-sl@bk.ru
--- Comment #7 from Sergey Isakov isakov-sl@bk.ru --- Created attachment 55229 --> https://bugs.winehq.org/attachment.cgi?id=55229 Black image in real windows
Real Windows 7 has exactly same bug.
https://bugs.winehq.org/show_bug.cgi?id=34263
joaopa jeremielapuree@yahoo.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jeremielapuree@yahoo.fr
--- Comment #8 from joaopa jeremielapuree@yahoo.fr --- Does the bug still occur with wine-5.14?
https://bugs.winehq.org/show_bug.cgi?id=34263
--- Comment #9 from Andrew Church achurch+wine@achurch.org --- The bug does not seem to occur under Wine 5.14.
https://bugs.winehq.org/show_bug.cgi?id=34263
--- Comment #10 from joaopa jeremielapuree@yahoo.fr --- Can the reporter (or an administrator) close this bug as FIXED?
https://bugs.winehq.org/show_bug.cgi?id=34263
Andrew Church achurch+wine@achurch.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED
--- Comment #11 from Andrew Church achurch+wine@achurch.org --- Done.
https://bugs.winehq.org/show_bug.cgi?id=34263
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #12 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 5.15.