radeonsi: make si_pm4_cmd_begin/end static and simplify all usages
authorMarek Olšák <marek.olsak@amd.com>
Tue, 16 Jun 2020 02:39:00 +0000 (22:39 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 26 Jun 2020 07:02:57 +0000 (07:02 +0000)
There is no longer the confusing trailing si_pm4_cmd_end call.

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

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

index a5d93071eccadb5747f39a9dbcfa5e3ff524dd5a..a7d57258591f1cf2f75ff0564804200ff8542224 100644 (file)
 #include "sid.h"
 #include "util/u_memory.h"
 
-void si_pm4_cmd_begin(struct si_pm4_state *state, unsigned opcode)
+static void si_pm4_cmd_begin(struct si_pm4_state *state, unsigned opcode)
 {
+   assert(state->ndw < SI_PM4_MAX_DW);
    state->last_opcode = opcode;
    state->last_pm4 = state->ndw++;
 }
 
 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;
 }
 
-void si_pm4_cmd_end(struct si_pm4_state *state, bool predicate)
+static void si_pm4_cmd_end(struct si_pm4_state *state, bool predicate)
 {
    unsigned count;
    count = state->ndw - state->last_pm4 - 2;
    state->pm4[state->last_pm4] = PKT3(state->last_opcode, count, predicate);
-
-   assert(state->ndw <= SI_PM4_MAX_DW);
 }
 
 void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val)
index 37ade60b25ae7c036fd1bce90a17dca4e26b05a1..772512596f1dc92d842998482595bfd26992e03e 100644 (file)
@@ -54,10 +54,7 @@ struct si_pm4_state {
    struct si_atom atom;
 };
 
-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);
-void si_pm4_cmd_end(struct si_pm4_state *state, bool predicate);
-
 void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val);
 
 void si_pm4_clear_state(struct si_pm4_state *state);
index 2a0aa64056acbbce29d860273f345317c0f890de..1531ee5cf5e88ef772f79f36d01ee422c6dbce7d 100644 (file)
@@ -5118,15 +5118,13 @@ void si_init_cs_preamble_state(struct si_context *sctx)
    if (!pm4)
       return;
 
-   si_pm4_cmd_begin(pm4, PKT3_CONTEXT_CONTROL);
+   si_pm4_cmd_add(pm4, PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
    si_pm4_cmd_add(pm4, CC0_UPDATE_LOAD_ENABLES(1));
    si_pm4_cmd_add(pm4, CC1_UPDATE_SHADOW_ENABLES(1));
-   si_pm4_cmd_end(pm4, false);
 
    if (has_clear_state) {
-      si_pm4_cmd_begin(pm4, PKT3_CLEAR_STATE);
+      si_pm4_cmd_add(pm4, PKT3(PKT3_CLEAR_STATE, 0, 0));
       si_pm4_cmd_add(pm4, 0);
-      si_pm4_cmd_end(pm4, false);
    }
 
    if (sctx->chip_class <= GFX8)
index 61af8ce2893b494397946499d539d86a5505bd18..cd14fdc741edc3f65a4ff65d239efe96ad23e7dc 100644 (file)
@@ -3293,14 +3293,12 @@ static void si_cs_preamble_add_vgt_flush(struct si_context *sctx)
       return;
 
    /* Done by Vulkan before VGT_FLUSH. */
-   si_pm4_cmd_begin(sctx->cs_preamble_state, PKT3_EVENT_WRITE);
+   si_pm4_cmd_add(sctx->cs_preamble_state, PKT3(PKT3_EVENT_WRITE, 0, 0));
    si_pm4_cmd_add(sctx->cs_preamble_state, EVENT_TYPE(V_028A90_VS_PARTIAL_FLUSH) | EVENT_INDEX(4));
-   si_pm4_cmd_end(sctx->cs_preamble_state, false);
 
    /* VGT_FLUSH is required even if VGT is idle. It resets VGT pointers. */
-   si_pm4_cmd_begin(sctx->cs_preamble_state, PKT3_EVENT_WRITE);
+   si_pm4_cmd_add(sctx->cs_preamble_state, PKT3(PKT3_EVENT_WRITE, 0, 0));
    si_pm4_cmd_add(sctx->cs_preamble_state, EVENT_TYPE(V_028A90_VGT_FLUSH) | EVENT_INDEX(0));
-   si_pm4_cmd_end(sctx->cs_preamble_state, false);
    sctx->cs_preamble_has_vgt_flush = true;
 }