diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index 444ce5905a1..f9d09e03cbc 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -844,6 +844,7 @@ static void compute_emit_cs(struct r600_context *rctx, */ radeon_emit(cs, PKT3C(PKT3_DEALLOC_STATE, 0, 0)); radeon_emit(cs, 0); + rctx->cayman_dealloc_state = true; } if (rctx->cs_shader_state.shader->ir_type == PIPE_SHADER_IR_TGSI || rctx->cs_shader_state.shader->ir_type == PIPE_SHADER_IR_NIR) diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index 57021b69f57..9b3e997fb76 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -222,6 +222,16 @@ void r600_flush_emit(struct r600_context *rctx) radeon_emit(cs, 0xffffffff); /* CP_COHER_SIZE */ radeon_emit(cs, 0); /* CP_COHER_BASE */ radeon_emit(cs, 0x0000000A); /* POLL_INTERVAL */ + + /* PKT3_CLEAR_STATE below is required on cayman to set the gpu + * in a deterministic state after a compute shader. Otherwise, + * the graphic pipeline could fail in a non-deterministic way. + * See https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33973 */ + if (unlikely(rctx->cayman_dealloc_state)) { + radeon_emit(cs, PKT3C(PKT3_CLEAR_STATE, 0, 0)); + radeon_emit(cs, 0); + rctx->cayman_dealloc_state = false; + } } if (rctx->b.flags & R600_CONTEXT_START_PIPELINE_STATS) { diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 67716ede6af..8c0315a8dbe 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -609,6 +609,7 @@ struct r600_context { bool cmd_buf_is_compute; struct pipe_resource *append_fence; uint32_t append_fence_id; + bool cayman_dealloc_state; }; static inline void r600_emit_command_buffer(struct radeon_cmdbuf *cs, diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h index 9265e957a70..1eb0a7422c5 100644 --- a/src/gallium/drivers/r600/r600d.h +++ b/src/gallium/drivers/r600/r600d.h @@ -36,6 +36,7 @@ #define PKT3_NOP 0x10 #define EG_PKT3_SET_BASE 0x11 /* >= evergreen */ #define EG_DRAW_INDEX_INDIRECT_PATCH_TABLE_BASE 1 /* DX11 Draw_Index_Indirect Patch Table Base */ +#define PKT3_CLEAR_STATE 0x12 #define EG_PKT3_INDEX_BUFFER_SIZE 0x13 #define PKT3_INDIRECT_BUFFER_END 0x17 #define PKT3_SET_PREDICATION 0x20