From a031cd3c2f4f5369d2c3a86df90fa1fa8862824a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 8 Dec 2021 18:40:58 -0500 Subject: [PATCH] radeonsi: replace SI_PM4_MAX_DW with a max_dw field it will vary Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_pm4.c | 13 ++++++++++--- src/gallium/drivers/radeonsi/si_pm4.h | 6 ++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pm4.c b/src/gallium/drivers/radeonsi/si_pm4.c index 2dfdc55..de12bdf 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.c +++ b/src/gallium/drivers/radeonsi/si_pm4.c @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_pm4.h b/src/gallium/drivers/radeonsi/si_pm4.h index 2545c4f..3316cf7 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.h +++ b/src/gallium/drivers/radeonsi/si_pm4.h @@ -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); -- 2.7.4