From 005fc20a345ee16448c1014dcdef72d2ed9c95df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 8 Dec 2021 18:32:33 -0500 Subject: [PATCH] radeonsi: pack si_pm4_state Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_pm4.c | 4 +++- src/gallium/drivers/radeonsi/si_pm4.h | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pm4.c b/src/gallium/drivers/radeonsi/si_pm4.c index 556bb5f2896..2dfdc557d89 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.c +++ b/src/gallium/drivers/radeonsi/si_pm4.c @@ -30,6 +30,7 @@ static void si_pm4_cmd_begin(struct si_pm4_state *state, unsigned opcode) { assert(state->ndw < SI_PM4_MAX_DW); + assert(opcode <= 254); state->last_opcode = opcode; state->last_pm4 = state->ndw++; } @@ -38,7 +39,7 @@ void si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw) { assert(state->ndw < SI_PM4_MAX_DW); state->pm4[state->ndw++] = dw; - state->last_opcode = -1; + state->last_opcode = 255; /* invalid opcode */ } static void si_pm4_cmd_end(struct si_pm4_state *state, bool predicate) @@ -84,6 +85,7 @@ void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val) state->pm4[state->ndw++] = reg; } + assert(reg <= UINT16_MAX); state->last_reg = reg; state->pm4[state->ndw++] = val; si_pm4_cmd_end(state, false); diff --git a/src/gallium/drivers/radeonsi/si_pm4.h b/src/gallium/drivers/radeonsi/si_pm4.h index 8946018829d..2545c4f43a7 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.h +++ b/src/gallium/drivers/radeonsi/si_pm4.h @@ -46,17 +46,17 @@ struct si_atom { struct si_pm4_state { /* PKT3_SET_*_REG handling */ - unsigned last_opcode; - unsigned last_reg; - unsigned last_pm4; - - /* commands for the DE */ - unsigned ndw; - uint32_t pm4[SI_PM4_MAX_DW]; + uint16_t last_reg; /* register offset in dwords */ + uint16_t last_pm4; + uint16_t ndw; /* number of dwords in pm4 */ + uint8_t last_opcode; /* For shader states only */ bool is_shader; struct si_atom atom; + + /* commands for the DE */ + uint32_t pm4[SI_PM4_MAX_DW]; }; void si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw);