From: Nicolai Hähnle Date: Thu, 16 Nov 2017 11:16:52 +0000 (+0100) Subject: radeonsi/gfx10: add si_context::emit_cache_flush X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c6c6810bd2a1e98c0ae07d6db981b8d4f79856f;p=mesa.git radeonsi/gfx10: add si_context::emit_cache_flush The introduction of GCR_CNTL makes cache flush handling on gfx10 sufficiently different that it makes sense to just use a separate function. Since emit_cache_flush is called quite early during context init, we initialize the pointer explicitly in si_create_context. Acked-by: Bas Nieuwenhuizen --- diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 63c95ed2604..f482fed51d8 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -935,7 +935,7 @@ static void si_launch_grid( } if (sctx->flags) - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); if (!si_switch_compute_shader(sctx, program, &program->shader, code_object, info->pc)) diff --git a/src/gallium/drivers/radeonsi/si_compute_blit.c b/src/gallium/drivers/radeonsi/si_compute_blit.c index 4c5464ac118..29ead4cdfaa 100644 --- a/src/gallium/drivers/radeonsi/si_compute_blit.c +++ b/src/gallium/drivers/radeonsi/si_compute_blit.c @@ -434,7 +434,7 @@ void si_retile_dcc(struct si_context *sctx, struct si_texture *tex) SI_CONTEXT_CS_PARTIAL_FLUSH | si_get_flush_flags(sctx, SI_COHERENCY_CB_META, L2_LRU) | si_get_flush_flags(sctx, SI_COHERENCY_SHADER, L2_LRU); - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); /* Save states. */ void *saved_cs = sctx->cs_shader_state.program; diff --git a/src/gallium/drivers/radeonsi/si_cp_dma.c b/src/gallium/drivers/radeonsi/si_cp_dma.c index e83016fc531..e9ddfe6f49d 100644 --- a/src/gallium/drivers/radeonsi/si_cp_dma.c +++ b/src/gallium/drivers/radeonsi/si_cp_dma.c @@ -187,7 +187,7 @@ static void si_cp_dma_prepare(struct si_context *sctx, struct pipe_resource *dst * Also wait for the previous CP DMA operations. */ if (!(user_flags & SI_CPDMA_SKIP_GFX_SYNC) && sctx->flags) - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); if (!(user_flags & SI_CPDMA_SKIP_SYNC_BEFORE) && *is_first && !(*packet_flags & CP_DMA_CLEAR)) diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index d27cf9f2824..330943085d6 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -1904,7 +1904,7 @@ static void si_upload_bindless_descriptors(struct si_context *sctx) */ sctx->flags |= SI_CONTEXT_PS_PARTIAL_FLUSH | SI_CONTEXT_CS_PARTIAL_FLUSH; - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); util_dynarray_foreach(&sctx->resident_tex_handles, struct si_texture_handle *, tex_handle) { @@ -1930,7 +1930,7 @@ static void si_upload_bindless_descriptors(struct si_context *sctx) /* Invalidate L1 because it doesn't know that L2 changed. */ sctx->flags |= SI_CONTEXT_INV_SCACHE; - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); sctx->bindless_descriptors_dirty = false; } diff --git a/src/gallium/drivers/radeonsi/si_gfx_cs.c b/src/gallium/drivers/radeonsi/si_gfx_cs.c index 9386df3a615..fb9286d6b48 100644 --- a/src/gallium/drivers/radeonsi/si_gfx_cs.c +++ b/src/gallium/drivers/radeonsi/si_gfx_cs.c @@ -173,7 +173,7 @@ void si_flush_gfx_cs(struct si_context *ctx, unsigned flags, /* Wait for draw calls to finish if needed. */ if (wait_flags) { ctx->flags |= wait_flags; - si_emit_cache_flush(ctx); + ctx->emit_cache_flush(ctx); } ctx->gfx_last_ib_is_busy = wait_flags == 0; diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index c93f2b96471..65a027fe928 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -487,6 +487,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, goto fail; /* Initialize context functions used by graphics and compute. */ + sctx->emit_cache_flush = si_emit_cache_flush; sctx->b.emit_string_marker = si_emit_string_marker; sctx->b.set_debug_callback = si_set_debug_callback; sctx->b.set_log_context = si_set_log_context; diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 6ad62e15df1..162adf05b60 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -862,6 +862,9 @@ struct si_context { struct pipe_device_reset_callback device_reset_callback; struct u_log_context *log; void *query_result_shader; + + void (*emit_cache_flush)(struct si_context *ctx); + struct blitter_context *blitter; void *custom_dsa_flush; void *custom_blend_resolve; diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 087ddacee72..a2e7fa93659 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -981,6 +981,8 @@ void si_emit_cache_flush(struct si_context *sctx) (flags & SI_CONTEXT_CS_PARTIAL_FLUSH && sctx->compute_is_busy); + assert(sctx->chip_class <= GFX9); + if (flags & SI_CONTEXT_FLUSH_AND_INV_CB) sctx->num_cb_cache_flushes++; if (flags & SI_CONTEXT_FLUSH_AND_INV_DB) @@ -1744,7 +1746,7 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i /* Emit all states except possibly render condition. */ si_emit_all_states(sctx, info, prim, instance_count, primitive_restart, masked_atoms); - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); /* <-- CUs are idle here. */ if (si_is_atom_dirty(sctx, &sctx->atoms.s.render_cond)) @@ -1772,7 +1774,7 @@ static void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *i * states, and draw at the end. */ if (sctx->flags) - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); /* Only prefetch the API VS and VBO descriptors. */ if (sctx->chip_class >= GFX7 && sctx->prefetch_L2_mask) diff --git a/src/gallium/drivers/radeonsi/si_test_dma_perf.c b/src/gallium/drivers/radeonsi/si_test_dma_perf.c index 0a0b9c4a657..17454b88b49 100644 --- a/src/gallium/drivers/radeonsi/si_test_dma_perf.c +++ b/src/gallium/drivers/radeonsi/si_test_dma_perf.c @@ -253,7 +253,7 @@ void si_test_dma_perf(struct si_screen *sscreen) /* Flush L2, so that we don't just test L2 cache performance. */ if (!test_sdma) { sctx->flags |= SI_CONTEXT_WB_L2; - si_emit_cache_flush(sctx); + sctx->emit_cache_flush(sctx); } ctx->end_query(ctx, q[iter]);