Mesa (main): radeonsi: pack si_pm4_state

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 5 07:07:31 UTC 2022


Module: Mesa
Branch: main
Commit: 005fc20a345ee16448c1014dcdef72d2ed9c95df
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=005fc20a345ee16448c1014dcdef72d2ed9c95df

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Wed Dec  8 18:32:33 2021 -0500

radeonsi: pack si_pm4_state

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

---

 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);



More information about the mesa-commit mailing list