From bf579559ed8e9bcb1271149f0952bd084027d0c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 16 Jul 2023 14:23:29 -0400 Subject: [PATCH] radeonsi: convert si_gfx_resources_add_all_to_bo_list to a state atom We can do this as part of the state emit loop instead of having a separate call in si_draw. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_descriptors.c | 11 +++++------ src/gallium/drivers/radeonsi/si_pipe.h | 1 - src/gallium/drivers/radeonsi/si_state.h | 2 +- src/gallium/drivers/radeonsi/si_state_draw.cpp | 9 --------- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 171fd12..d05746a 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -2778,6 +2778,8 @@ static void si_resident_buffers_add_all_to_bo_list(struct si_context *sctx) sctx->bo_list_add_all_resident_resources = false; } +static void si_emit_gfx_resources_add_all_to_bo_list(struct si_context *sctx, unsigned index); + /* INIT/DEINIT/UPLOAD */ void si_init_all_descriptors(struct si_context *sctx) @@ -2881,7 +2883,7 @@ void si_init_all_descriptors(struct si_context *sctx) sctx->b.set_polygon_stipple = si_set_polygon_stipple; - /* Shader user data. */ + sctx->atoms.s.gfx_add_all_to_bo_list.emit = si_emit_gfx_resources_add_all_to_bo_list; sctx->atoms.s.gfx_shader_pointers.emit = si_emit_graphics_shader_pointers; /* Set default and immutable mappings. */ @@ -2986,7 +2988,7 @@ bool si_gfx_resources_check_encrypted(struct si_context *sctx) return use_encrypted_bo; } -void si_gfx_resources_add_all_to_bo_list(struct si_context *sctx) +static void si_emit_gfx_resources_add_all_to_bo_list(struct si_context *sctx, unsigned index) { for (unsigned i = 0; i < SI_NUM_GRAPHICS_SHADERS; i++) { si_buffer_resources_begin_new_cs(sctx, &sctx->const_and_shader_buffers[i]); @@ -3005,9 +3007,6 @@ void si_gfx_resources_add_all_to_bo_list(struct si_context *sctx) if (sctx->bo_list_add_all_resident_resources) si_resident_buffers_add_all_to_bo_list(sctx); - - assert(sctx->bo_list_add_all_gfx_resources); - sctx->bo_list_add_all_gfx_resources = false; } bool si_compute_resources_check_encrypted(struct si_context *sctx) @@ -3048,7 +3047,7 @@ void si_add_all_descriptors_to_bo_list(struct si_context *sctx) si_add_descriptors_to_bo_list(sctx, &sctx->bindless_descriptors); sctx->bo_list_add_all_resident_resources = true; - sctx->bo_list_add_all_gfx_resources = true; + si_mark_atom_dirty(sctx, &sctx->atoms.s.gfx_add_all_to_bo_list); sctx->bo_list_add_all_compute_resources = true; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 7dd0309..656972d 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1117,7 +1117,6 @@ struct si_context { struct si_samplers samplers[SI_NUM_SHADERS]; struct si_images images[SI_NUM_SHADERS]; bool bo_list_add_all_resident_resources; - bool bo_list_add_all_gfx_resources; bool bo_list_add_all_compute_resources; /* other shader resources */ diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 3e2d207..0f9d684 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -183,6 +183,7 @@ union si_state_atoms { struct si_atoms_s { /* This must be first. */ struct si_atom pm4_states[SI_NUM_STATES]; + struct si_atom gfx_add_all_to_bo_list; struct si_atom streamout_begin; struct si_atom streamout_enable; /* must be after streamout_begin */ struct si_atom framebuffer; @@ -543,7 +544,6 @@ void si_set_ring_buffer(struct si_context *sctx, uint slot, struct pipe_resource unsigned element_size, unsigned index_stride, uint64_t offset); void si_init_all_descriptors(struct si_context *sctx); void si_release_all_descriptors(struct si_context *sctx); -void si_gfx_resources_add_all_to_bo_list(struct si_context *sctx); void si_compute_resources_add_all_to_bo_list(struct si_context *sctx); bool si_gfx_resources_check_encrypted(struct si_context *sctx); bool si_compute_resources_check_encrypted(struct si_context *sctx); diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp index 623e381..fab81d5 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.cpp +++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp @@ -2217,15 +2217,6 @@ static void si_draw(struct pipe_context *ctx, } } - /* This must be called after si_need_cs_space, because we must let - * need_cs_space flush before we add buffers to the buffer list. - * - * This must be done after si_update_shaders because si_update_shaders can - * flush the CS when enabling tess and GS rings. - */ - if (sctx->bo_list_add_all_gfx_resources) - si_gfx_resources_add_all_to_bo_list(sctx); - /* This is the optimal packet order: * Set all states first, so that all SET packets are processed in parallel with previous * draw calls. Then flush caches and wait if needed. Then draw and prefetch at the end. -- 2.7.4