radeonsi: add a simple version of si_pm4_emit_state for non-shader states
authorMarek Olšák <marek.olsak@amd.com>
Sun, 16 Jul 2023 13:46:15 +0000 (09:46 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 17 Aug 2023 15:34:06 +0000 (15:34 +0000)
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_pm4.c
src/gallium/drivers/radeonsi/si_pm4.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state_shaders.cpp

index 9263f35..58badc4 100644 (file)
@@ -340,19 +340,23 @@ void si_pm4_emit_state(struct si_context *sctx, unsigned index)
    /* All places should unset dirty_states if this doesn't pass. */
    assert(state && state != sctx->emitted.array[index]);
 
-   if (state->is_shader) {
-      radeon_add_to_buffer_list(sctx, cs, ((struct si_shader*)state)->bo,
-                                RADEON_USAGE_READ | RADEON_PRIO_SHADER_BINARY);
-   }
-
    radeon_begin(cs);
    radeon_emit_array(state->pm4, state->ndw);
    radeon_end();
 
+   sctx->emitted.array[index] = state;
+}
+
+void si_pm4_emit_shader(struct si_context *sctx, unsigned index)
+{
+   struct si_pm4_state *state = sctx->queued.array[index];
+
+   si_pm4_emit_state(sctx, index);
+
+   radeon_add_to_buffer_list(sctx, &sctx->gfx_cs, ((struct si_shader*)state)->bo,
+                             RADEON_USAGE_READ | RADEON_PRIO_SHADER_BINARY);
    if (state->atom.emit)
       state->atom.emit(sctx, -1);
-
-   sctx->emitted.array[index] = state;
 }
 
 void si_pm4_reset_emitted(struct si_context *sctx)
index 922314e..39f72ed 100644 (file)
@@ -39,7 +39,6 @@ struct si_pm4_state {
    bool packed_is_padded; /* whether SET_*_REG_PAIRS_PACKED is padded to an even number of regs */
 
    /* For shader states only */
-   bool is_shader;
    struct si_atom atom;
 
    /* commands for the DE */
@@ -63,6 +62,7 @@ void si_pm4_free_state(struct si_context *sctx, struct si_pm4_state *state, unsi
 
 void si_pm4_emit_commands(struct si_context *sctx, struct si_pm4_state *state);
 void si_pm4_emit_state(struct si_context *sctx, unsigned index);
+void si_pm4_emit_shader(struct si_context *sctx, unsigned index);
 void si_pm4_reset_emitted(struct si_context *sctx);
 struct si_pm4_state *si_pm4_create_sized(struct si_screen *sscreen, unsigned max_dw,
                                          bool is_compute_queue);
index 2b7e6d9..83bbf09 100644 (file)
@@ -5413,8 +5413,16 @@ void si_init_state_compute_functions(struct si_context *sctx)
 
 void si_init_state_functions(struct si_context *sctx)
 {
-   for (unsigned i = 0; i < ARRAY_SIZE(sctx->atoms.s.pm4_states); i++)
-      sctx->atoms.s.pm4_states[i].emit = si_pm4_emit_state;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(blend)].emit = si_pm4_emit_state;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(rasterizer)].emit = si_pm4_emit_state;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(dsa)].emit = si_pm4_emit_state;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(poly_offset)].emit = si_pm4_emit_state;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(ls)].emit = si_pm4_emit_shader;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(hs)].emit = si_pm4_emit_shader;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(es)].emit = si_pm4_emit_shader;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(gs)].emit = si_pm4_emit_shader;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(vs)].emit = si_pm4_emit_shader;
+   sctx->atoms.s.pm4_states[SI_STATE_IDX(ps)].emit = si_pm4_emit_shader;
 
    sctx->atoms.s.framebuffer.emit = si_emit_framebuffer_state;
    sctx->atoms.s.db_render_state.emit = si_emit_db_render_state;
index d8cfc8e..4c6d6b0 100644 (file)
@@ -612,7 +612,6 @@ si_get_shader_pm4_state(struct si_shader *shader,
                         void (*emit_func)(struct si_context *ctx, unsigned index))
 {
    si_pm4_clear_state(&shader->pm4, shader->selector->screen, false);
-   shader->pm4.is_shader = true;
    shader->pm4.atom.emit = emit_func;
    return &shader->pm4;
 }