radeonsi: pack si_pm4_state
authorMarek Olšák <marek.olsak@amd.com>
Wed, 8 Dec 2021 23:32:33 +0000 (18:32 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 5 Jan 2022 06:36:10 +0000 (01:36 -0500)
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 556bb5f..2dfdc55 100644 (file)
@@ -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);
index 8946018..2545c4f 100644 (file)
@@ -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);