diff options
author | Marek Olšák <[email protected]> | 2016-06-11 21:07:14 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-10-04 16:12:05 +0200 |
commit | 53d2c8f00f5422a872cedbea4674c004378d9999 (patch) | |
tree | 74761bdcf8917f2baaada2e58be567c7f64fe734 | |
parent | 6c0168439348e6ea801258e373693d4aaa4ee44e (diff) |
radeonsi: don't re-create shader PM4 states after scratch buffer update
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Edward O'Callaghan <[email protected]>
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pm4.c | 9 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pm4.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 30 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pm4.c b/src/gallium/drivers/radeonsi/si_pm4.c index c3032fc45b5..386d0935e83 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.c +++ b/src/gallium/drivers/radeonsi/si_pm4.c @@ -103,11 +103,18 @@ void si_pm4_add_bo(struct si_pm4_state *state, 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); } diff --git a/src/gallium/drivers/radeonsi/si_pm4.h b/src/gallium/drivers/radeonsi/si_pm4.h index 35fa6c3a16f..9b02a8025a6 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.h +++ b/src/gallium/drivers/radeonsi/si_pm4.h @@ -71,6 +71,7 @@ void si_pm4_add_bo(struct si_pm4_state *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, diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 816aadcc4ff..acbcebaecd9 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -329,13 +329,23 @@ static void si_set_tesseval_regs(struct si_screen *sscreen, 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; @@ -363,7 +373,7 @@ static void si_shader_hs(struct si_shader *shader) 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; @@ -391,8 +401,7 @@ static void si_shader_es(struct si_screen *sscreen, struct si_shader *shader) 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; @@ -467,8 +476,7 @@ static void si_shader_gs(struct si_shader *shader) /* 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; @@ -525,8 +533,7 @@ static void si_shader_vs(struct si_screen *sscreen, struct si_shader *shader, 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; @@ -689,8 +696,7 @@ static void si_shader_ps(struct si_shader *shader) 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; @@ -791,10 +797,6 @@ static void si_shader_ps(struct si_shader *shader) 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) |