radeonsi: fix register shadowing after the pm4 state size was decreased
authorMarek Olšák <marek.olsak@amd.com>
Sun, 27 Feb 2022 03:37:14 +0000 (22:37 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 1 Mar 2022 22:30:24 +0000 (22:30 +0000)
Fixes: 946bd90a097e8 "radeonsi: decrease the size of si_pm4_state::pm4 except for cs_preamble_state"

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

src/gallium/drivers/radeonsi/si_cp_reg_shadowing.c

index c3da8af..ca6b41d 100644 (file)
@@ -68,7 +68,14 @@ static void si_build_load_reg(struct si_screen *sscreen, struct si_pm4_state *pm
 static struct si_pm4_state *
 si_create_shadowing_ib_preamble(struct si_context *sctx)
 {
-   struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+   struct si_shadow_preamble {
+      struct si_pm4_state pm4;
+      uint32_t more_pm4[150]; /* Add more space because the command buffer is large. */
+   };
+   struct si_pm4_state *pm4 = (struct si_pm4_state *)CALLOC_STRUCT(si_shadow_preamble);
+
+   /* Add all the space that we allocated. */
+   pm4->max_dw = sizeof(struct si_shadow_preamble) - offsetof(struct si_shadow_preamble, pm4.pm4);
 
    if (sctx->screen->dpbb_allowed) {
       si_pm4_cmd_add(pm4, PKT3(PKT3_EVENT_WRITE, 0, 0));