From 946bd90a097e8bf4f060f7a18d04f1df1c23275f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 8 Dec 2021 19:00:08 -0500 Subject: [PATCH] radeonsi: decrease the size of si_pm4_state::pm4 except for cs_preamble_state Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_pm4.h | 4 +++- src/gallium/drivers/radeonsi/si_state.c | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pm4.h b/src/gallium/drivers/radeonsi/si_pm4.h index 3316cf77840..4ebc97cc260 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.h +++ b/src/gallium/drivers/radeonsi/si_pm4.h @@ -54,7 +54,9 @@ struct si_pm4_state { /* commands for the DE */ uint16_t max_dw; - uint32_t pm4[480]; + + /* This must be the last field because the array can continue after the structure. */ + uint32_t pm4[64]; }; void si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw); diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 8d242b85c40..293b9b81f8e 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -5383,11 +5383,19 @@ void si_init_cs_preamble_state(struct si_context *sctx, bool uses_reg_shadowing) struct si_screen *sscreen = sctx->screen; uint64_t border_color_va = sctx->border_color_buffer->gpu_address; bool has_clear_state = sscreen->info.has_clear_state; - struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); + + struct si_cs_preamble { + struct si_pm4_state pm4; + uint32_t more_pm4[150]; /* Add more space because the preamble is large. */ + }; + struct si_pm4_state *pm4 = (struct si_pm4_state *)CALLOC_STRUCT(si_cs_preamble); if (!pm4) return; + /* Add all the space that we allocated. */ + pm4->max_dw = sizeof(struct si_cs_preamble) - offsetof(struct si_cs_preamble, pm4.pm4); + if (!uses_reg_shadowing) { si_pm4_cmd_add(pm4, PKT3(PKT3_CONTEXT_CONTROL, 1, 0)); si_pm4_cmd_add(pm4, CC0_UPDATE_LOAD_ENABLES(1));