radeonsi: add helpers to create and clone a sized pm4 state
to simplify si_init_cs_preamble_state and it will be used in the following commits Reviewed-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22833>
This commit is contained in:
@@ -153,3 +153,23 @@ void si_pm4_reset_emitted(struct si_context *sctx)
|
||||
sctx->dirty_states |= BITFIELD_BIT(i);
|
||||
}
|
||||
}
|
||||
|
||||
struct si_pm4_state *si_pm4_create_sized(unsigned max_dw)
|
||||
{
|
||||
struct si_pm4_state *pm4;
|
||||
unsigned size = sizeof(*pm4) + 4 * (max_dw - ARRAY_SIZE(pm4->pm4));
|
||||
|
||||
pm4 = (struct si_pm4_state *)calloc(1, size);
|
||||
if (pm4)
|
||||
pm4->max_dw = max_dw;
|
||||
return pm4;
|
||||
}
|
||||
|
||||
struct si_pm4_state *si_pm4_clone(struct si_pm4_state *orig)
|
||||
{
|
||||
struct si_pm4_state *pm4 = si_pm4_create_sized(orig->max_dw);
|
||||
|
||||
if (pm4)
|
||||
memcpy(pm4, orig, sizeof(*pm4) + 4 * (pm4->max_dw - ARRAY_SIZE(pm4->pm4)));
|
||||
return pm4;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ void si_pm4_free_state(struct si_context *sctx, struct si_pm4_state *state, unsi
|
||||
|
||||
void si_pm4_emit(struct si_context *sctx, struct si_pm4_state *state);
|
||||
void si_pm4_reset_emitted(struct si_context *sctx);
|
||||
struct si_pm4_state *si_pm4_create_sized(unsigned max_dw);
|
||||
struct si_pm4_state *si_pm4_clone(struct si_pm4_state *orig);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -5547,18 +5547,11 @@ void si_init_cs_preamble_state(struct si_context *sctx, bool uses_reg_shadowing)
|
||||
S_00B858_SH1_CU_EN(sscreen->info.spi_cu_en);
|
||||
bool has_clear_state = sscreen->info.has_clear_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);
|
||||
|
||||
/* We need more space because the preamble is large. */
|
||||
struct si_pm4_state *pm4 = si_pm4_create_sized(214);
|
||||
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)) / 4;
|
||||
|
||||
if (sctx->has_graphics && !uses_reg_shadowing) {
|
||||
si_pm4_cmd_add(pm4, PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
|
||||
si_pm4_cmd_add(pm4, CC0_UPDATE_LOAD_ENABLES(1));
|
||||
@@ -6032,8 +6025,5 @@ void si_init_cs_preamble_state(struct si_context *sctx, bool uses_reg_shadowing)
|
||||
|
||||
done:
|
||||
sctx->cs_preamble_state = pm4;
|
||||
|
||||
/* Make a copy of the preamble for TMZ. */
|
||||
sctx->cs_preamble_state_tmz = (struct si_pm4_state *)CALLOC_STRUCT(si_cs_preamble);
|
||||
memcpy(sctx->cs_preamble_state_tmz, sctx->cs_preamble_state, sizeof(struct si_cs_preamble));
|
||||
sctx->cs_preamble_state_tmz = si_pm4_clone(pm4); /* Make a copy of the preamble for TMZ. */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user