radeonsi: replace SI_PM4_MAX_DW with a max_dw field
authorMarek Olšák <marek.olsak@amd.com>
Wed, 8 Dec 2021 23:40:58 +0000 (18:40 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 5 Jan 2022 06:36:10 +0000 (01:36 -0500)
it will vary

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14122>

src/gallium/drivers/radeonsi/si_pm4.c
src/gallium/drivers/radeonsi/si_pm4.h

index 2dfdc55..de12bdf 100644 (file)
@@ -29,7 +29,9 @@
 
 static void si_pm4_cmd_begin(struct si_pm4_state *state, unsigned opcode)
 {
-   assert(state->ndw < SI_PM4_MAX_DW);
+   if (!state->max_dw)
+      state->max_dw = ARRAY_SIZE(state->pm4);
+   assert(state->ndw < state->max_dw);
    assert(opcode <= 254);
    state->last_opcode = opcode;
    state->last_pm4 = state->ndw++;
@@ -37,7 +39,9 @@ static void si_pm4_cmd_begin(struct si_pm4_state *state, unsigned opcode)
 
 void si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw)
 {
-   assert(state->ndw < SI_PM4_MAX_DW);
+   if (!state->max_dw)
+      state->max_dw = ARRAY_SIZE(state->pm4);
+   assert(state->ndw < state->max_dw);
    state->pm4[state->ndw++] = dw;
    state->last_opcode = 255; /* invalid opcode */
 }
@@ -78,7 +82,10 @@ void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val)
 
    reg >>= 2;
 
-   assert(state->ndw + 2 <= SI_PM4_MAX_DW);
+   if (!state->max_dw)
+      state->max_dw = ARRAY_SIZE(state->pm4);
+
+   assert(state->ndw + 2 <= state->max_dw);
 
    if (opcode != state->last_opcode || reg != (state->last_reg + 1)) {
       si_pm4_cmd_begin(state, opcode);
index 2545c4f..3316cf7 100644 (file)
@@ -31,9 +31,6 @@
 extern "C" {
 #endif
 
-/* TODO: This is high because of cs_preamble with ac_set_reg_cu_en. */
-#define SI_PM4_MAX_DW 480
-
 // forward defines
 struct si_context;
 
@@ -56,7 +53,8 @@ struct si_pm4_state {
    struct si_atom atom;
 
    /* commands for the DE */
-   uint32_t pm4[SI_PM4_MAX_DW];
+   uint16_t max_dw;
+   uint32_t pm4[480];
 };
 
 void si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw);