radeonsi: convert si_gfx_resources_add_all_to_bo_list to a state atom
authorMarek Olšák <marek.olsak@amd.com>
Sun, 16 Jul 2023 18:23:29 +0000 (14:23 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 17 Aug 2023 15:34:06 +0000 (15:34 +0000)
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 <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24732>

src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.h
src/gallium/drivers/radeonsi/si_state_draw.cpp

index 171fd12..d05746a 100644 (file)
@@ -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;
 }
 
index 7dd0309..656972d 100644 (file)
@@ -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 */
index 3e2d207..0f9d684 100644 (file)
@@ -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);
index 623e381..fab81d5 100644 (file)
@@ -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.