From f7a8b6fff5ae23546ed92aad4ad67470355ed919 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 28 Jan 2016 01:29:25 +0100 Subject: [PATCH] radeonsi: split out code for deleting si_shader MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- .../drivers/radeonsi/si_state_shaders.c | 65 ++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index f48d7ca360f..27a981ee0dc 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -1053,6 +1053,41 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state) si_mark_atom_dirty(sctx, &sctx->cb_render_state); } +static void si_delete_shader(struct si_context *sctx, struct si_shader *shader) +{ + if (shader->pm4) { + switch (shader->selector->type) { + case PIPE_SHADER_VERTEX: + if (shader->key.vs.as_ls) + si_pm4_delete_state(sctx, ls, shader->pm4); + else if (shader->key.vs.as_es) + si_pm4_delete_state(sctx, es, shader->pm4); + else + si_pm4_delete_state(sctx, vs, shader->pm4); + break; + case PIPE_SHADER_TESS_CTRL: + si_pm4_delete_state(sctx, hs, shader->pm4); + break; + case PIPE_SHADER_TESS_EVAL: + if (shader->key.tes.as_es) + si_pm4_delete_state(sctx, es, shader->pm4); + else + si_pm4_delete_state(sctx, vs, shader->pm4); + break; + case PIPE_SHADER_GEOMETRY: + si_pm4_delete_state(sctx, gs, shader->pm4); + si_pm4_delete_state(sctx, vs, shader->gs_copy_shader->pm4); + break; + case PIPE_SHADER_FRAGMENT: + si_pm4_delete_state(sctx, ps, shader->pm4); + break; + } + } + + si_shader_destroy(shader); + free(shader); +} + static void si_delete_shader_selector(struct pipe_context *ctx, void *state) { struct si_context *sctx = (struct si_context *)ctx; @@ -1073,35 +1108,7 @@ static void si_delete_shader_selector(struct pipe_context *ctx, void *state) while (p) { c = p->next_variant; - switch (sel->type) { - case PIPE_SHADER_VERTEX: - if (p->key.vs.as_ls) - si_pm4_delete_state(sctx, ls, p->pm4); - else if (p->key.vs.as_es) - si_pm4_delete_state(sctx, es, p->pm4); - else - si_pm4_delete_state(sctx, vs, p->pm4); - break; - case PIPE_SHADER_TESS_CTRL: - si_pm4_delete_state(sctx, hs, p->pm4); - break; - case PIPE_SHADER_TESS_EVAL: - if (p->key.tes.as_es) - si_pm4_delete_state(sctx, es, p->pm4); - else - si_pm4_delete_state(sctx, vs, p->pm4); - break; - case PIPE_SHADER_GEOMETRY: - si_pm4_delete_state(sctx, gs, p->pm4); - si_pm4_delete_state(sctx, vs, p->gs_copy_shader->pm4); - break; - case PIPE_SHADER_FRAGMENT: - si_pm4_delete_state(sctx, ps, p->pm4); - break; - } - - si_shader_destroy(p); - free(p); + si_delete_shader(sctx, p); p = c; } -- 2.30.2