From 4c8810f335d6e8490922f11b33c231af207a36dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= Date: Wed, 22 Feb 2017 19:59:06 +0100 Subject: [PATCH] st/mesa: inform the driver of framebuffer changes before compute dispatches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even though compute shaders cannot access the framebuffer, there is a synchronization issue when a compute dispatch accesses a texture that was previously bound and drawn to as a framebuffer. Section 9.3 (Feedback Loops Between Textures and the Framebuffer) of the OpenGL 4.5 spec rather implicitly clarifies that undefined behavior results if the texture is still attached to the currently bound framebuffer. However, the feedback loop is broken when the application changes the framebuffer binding before a compute dispatch, and the state tracker needs to let the driver known about this. Fixes GL45-CTS.compute_shader.pipeline-post-fs on SI family Radeons. Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Marek Olšák (cherry picked from commit 40c77bbf83a369f21c5a95f14417348aae2dbe42) --- src/mesa/state_tracker/st_atom.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 94e012a97c7..fbc54f64823 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -188,7 +188,15 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline ) } st->compute_shader_may_be_dirty = false; - pipeline_mask = ST_PIPELINE_COMPUTE_STATE_MASK; + + /* + * We add the ST_NEW_FB_STATE bit here as well, because glBindFramebuffer + * acts as a barrier that breaks feedback loops between the framebuffer + * and textures bound to the framebuffer, even when those textures are + * accessed by compute shaders; so we must inform the driver of new + * framebuffer state. + */ + pipeline_mask = ST_PIPELINE_COMPUTE_STATE_MASK | ST_NEW_FB_STATE; break; }