Signed-off-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
---
 src/gallium/drivers/radeonsi/si_pipe.h       |  2 ++
 src/gallium/drivers/radeonsi/si_state_draw.c | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 743c782..d9dfb59 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -192,6 +192,8 @@ struct si_context {
        void                            *pstipple_sampler_state;
        struct si_screen                *screen;
        struct radeon_winsys_cs         *ce_ib;
+       bool                            ce_need_synchronization;
+
 
        struct pipe_fence_handle        *last_gfx_fence;
        struct si_shader_ctx_state      fixed_func_tcs_shader;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index 40cad50..dd13d51 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -753,6 +753,25 @@ static void si_get_draw_start_count(struct si_context 
*sctx,
        }
 }
 
+static void si_ce_pre_draw_synchronization(struct si_context *sctx) {
+       if (sctx->ce_need_synchronization) {
+               radeon_emit(sctx->ce_ib, PKT3(PKT3_INCREMENT_CE_COUNTER, 0, 0));
+               radeon_emit(sctx->ce_ib, 1);
+
+               radeon_emit(sctx->b.gfx.cs, PKT3(PKT3_WAIT_ON_CE_COUNTER, 0, 
0));
+               radeon_emit(sctx->b.gfx.cs, 1);
+       }
+}
+
+static void si_ce_post_draw_synchronization(struct si_context *sctx) {
+       if (sctx->ce_need_synchronization) {
+               radeon_emit(sctx->b.gfx.cs, PKT3(PKT3_INCREMENT_DE_COUNTER, 0, 
0));
+               radeon_emit(sctx->b.gfx.cs, 0);
+
+               sctx->ce_need_synchronization = false;
+       }
+}
+
 void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 {
        struct si_context *sctx = (struct si_context *)ctx;
@@ -882,8 +901,13 @@ void si_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *info)
        si_emit_scratch_reloc(sctx);
        si_emit_rasterizer_prim_state(sctx);
        si_emit_draw_registers(sctx, info);
+
+       si_ce_pre_draw_synchronization(sctx);
+
        si_emit_draw_packets(sctx, info, &ib);
 
+       si_ce_post_draw_synchronization(sctx);
+
        if (sctx->trace_buf)
                si_trace_emit(sctx);
 
-- 
2.8.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to