Fixes Bug 43406
Unbinding the FBO before executing the compute shader makes sure that it doesn't read garbage from it. This only an issue on open source drivers, since the proprietary drivers play safe and synchronize. But since this is undefined behavior, wine should avoid relying on that.
Many thanks to Matias N. Goldberg and Philip Rebohle for investigating and solving the bug!
Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/wined3d/drawprim.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 404623c9ac..f39c9961e9 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -858,6 +858,10 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state return; }
+ /* Unbind the FBOs to avoid have undefined behavior when reading data from it */ + GL_EXTCALL(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0)); + GL_EXTCALL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)); + if (parameters->indirect) { const struct wined3d_indirect_dispatch_parameters *indirect = ¶meters->u.indirect; @@ -875,6 +879,10 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state } checkGLcall("dispatch compute");
+ /* Now rebind the FBOs to restore the original state */ + GL_EXTCALL(glBindFramebuffer(GL_READ_FRAMEBUFFER, context->fbo_read_binding)); + GL_EXTCALL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->fbo_draw_binding)); + GL_EXTCALL(glMemoryBarrier(GL_ALL_BARRIER_BITS)); checkGLcall("glMemoryBarrier");