radeonsi: split out code for deleting si_shader
authorMarek Olšák <marek.olsak@amd.com>
Thu, 28 Jan 2016 00:29:25 +0000 (01:29 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 9 Feb 2016 20:19:51 +0000 (21:19 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_state_shaders.c

index f48d7ca360fd493eb794b59f574ee971b2481b90..27a981ee0dc648de4312e06df07f4d3a1c704ba2 100644 (file)
@@ -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;
        }