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.