https://bugs.winehq.org/show_bug.cgi?id=52563
--- Comment #6 from Zeb Figura z.figura12@gmail.com --- I started getting this too locally all of a sudden, and combined with the advent of bug 54023, I have a theory.
I think what triggered me to start getting this locally is that Mesa's CSMT thread was turned on by default. I don't know what changed it; I can't easily see anything to that effect in Mesa, so maybe Debian did it. At any rate, forcing mesa_glthread=false seems to consistently "fix" it for me. At that point it doesn't actually matter whether Wine's CSMT thread is on or off, which makes senseāI don't think we have any synchronization errors here.
By using Present() one can see where the test fails, and it's for some reason on the first few NOOVERWRITE maps on every second row where we do a deferred discard. The draw after the discard renders correctly, but the first one or more nooverwrite doesn't. And this is IIRC true of bug 54023, which is what started to clue me in.
My guess, although it's probably impossible to confirm [if this test itself can't be said to confirm it!] is that a DISCARD on a deferred context simply doesn't have the same synchronization guarantees as a DISCARD on an immediate context. Or, at least, that's what NVidia says. By tracing the map pointer one can see that NVidia will return the same pointer after the deferred discard, but a new pointer after an immediate discard. I suspect what's happening is that internally it uploads the buffer contents to the existing buffer, and *that* draw might synchronize, but the following NOOVERWRITE maps might *not*. I don't quite know what "doesn't synchronize" means, though.
The same thing is probably happening with Mesa. We too don't actually discard the buffer on a deferred discard (we could, though...) Instead we use glBufferSubData() to upload the whole deferred discard allocation. The buffer itself is allocated with GL_MAP_UNSYNCHRONIZED_BIT since it's write-only, and while the glBufferSubData() might synchronize, the following writes to the mapped buffer might not.
So I think the right thing to do is just remove the deferred context tests.