state->bo_priority[idx] = priority;
}
-void si_pm4_free_state_simple(struct si_pm4_state *state)
+void si_pm4_clear_state(struct si_pm4_state *state)
{
for (int i = 0; i < state->nbo; ++i)
r600_resource_reference(&state->bo[i], NULL);
r600_resource_reference(&state->indirect_buffer, NULL);
+ state->nbo = 0;
+ state->ndw = 0;
+}
+
+void si_pm4_free_state_simple(struct si_pm4_state *state)
+{
+ si_pm4_clear_state(state);
FREE(state);
}
void si_pm4_upload_indirect_buffer(struct si_context *sctx,
struct si_pm4_state *state);
+void si_pm4_clear_state(struct si_pm4_state *state);
void si_pm4_free_state_simple(struct si_pm4_state *state);
void si_pm4_free_state(struct si_context *sctx,
struct si_pm4_state *state,
S_028B6C_DISTRIBUTION_MODE(distribution_mode));
}
+static struct si_pm4_state *si_get_shader_pm4_state(struct si_shader *shader)
+{
+ if (shader->pm4)
+ si_pm4_clear_state(shader->pm4);
+ else
+ shader->pm4 = CALLOC_STRUCT(si_pm4_state);
+
+ return shader->pm4;
+}
+
static void si_shader_ls(struct si_shader *shader)
{
struct si_pm4_state *pm4;
unsigned vgpr_comp_cnt;
uint64_t va;
- pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
+ pm4 = si_get_shader_pm4_state(shader);
if (!pm4)
return;
struct si_pm4_state *pm4;
uint64_t va;
- pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
+ pm4 = si_get_shader_pm4_state(shader);
if (!pm4)
return;
uint64_t va;
unsigned oc_lds_en;
- pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
-
+ pm4 = si_get_shader_pm4_state(shader);
if (!pm4)
return;
/* The GSVS_RING_ITEMSIZE register takes 15 bits */
assert(gsvs_itemsize < (1 << 15));
- pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
-
+ pm4 = si_get_shader_pm4_state(shader);
if (!pm4)
return;
shader->selector->info.properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION];
bool enable_prim_id = si_vs_exports_prim_id(shader);
- pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
-
+ pm4 = si_get_shader_pm4_state(shader);
if (!pm4)
return;
G_0286CC_LINEAR_CENTROID_ENA(input_ena) ||
G_0286CC_LINE_STIPPLE_TEX_ENA(input_ena));
- pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state);
-
+ pm4 = si_get_shader_pm4_state(shader);
if (!pm4)
return;
static void si_shader_init_pm4_state(struct si_screen *sscreen,
struct si_shader *shader)
{
-
- if (shader->pm4)
- si_pm4_free_state_simple(shader->pm4);
-
switch (shader->selector->type) {
case PIPE_SHADER_VERTEX:
if (shader->key.vs.as_ls)