st/program: rework basic variant interface
authorDave Airlie <airlied@redhat.com>
Mon, 23 Oct 2017 05:18:37 +0000 (06:18 +0100)
committerDave Airlie <airlied@redhat.com>
Wed, 25 Oct 2017 23:55:52 +0000 (00:55 +0100)
This just passes st_common_program and uses it.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h

index b5ba33a48845d8ade1d3851c886efc8b552aa7e1..c6faa3f07ffa205513bbfb01b1a1fae64b63dfbe 100644 (file)
@@ -215,8 +215,7 @@ st_update_common_program(struct st_context *st, struct gl_program *prog,
    if (st->shader_has_one_variant[prog->info.stage] && stp->variants)
       return stp->variants->driver_shader;
 
-   return st_get_basic_variant(st, pipe_shader, &stp->tgsi,
-                               &stp->variants)->driver_shader;
+   return st_get_basic_variant(st, pipe_shader, stp)->driver_shader;
 }
 
 
index 41ebfa9003f829a62636e36a5689001afff58641..1695f4835dbc3ac723dcfcc12e231e6f88bdbd65 100644 (file)
@@ -1604,8 +1604,7 @@ st_translate_geometry_program(struct st_context *st,
 struct st_basic_variant *
 st_get_basic_variant(struct st_context *st,
                      unsigned pipe_shader,
-                     struct pipe_shader_state *tgsi,
-                     struct st_basic_variant **variants)
+                     struct st_common_program *prog)
 {
    struct pipe_context *pipe = st->pipe;
    struct st_basic_variant *v;
@@ -1615,7 +1614,7 @@ st_get_basic_variant(struct st_context *st,
    key.st = st->has_shareable_shaders ? NULL : st;
 
    /* Search for existing variant */
-   for (v = *variants; v; v = v->next) {
+   for (v = prog->variants; v; v = v->next) {
       if (memcmp(&v->key, &key, sizeof(key)) == 0) {
          break;
       }
@@ -1628,13 +1627,13 @@ st_get_basic_variant(struct st_context *st,
          /* fill in new variant */
          switch (pipe_shader) {
          case PIPE_SHADER_TESS_CTRL:
-            v->driver_shader = pipe->create_tcs_state(pipe, tgsi);
+            v->driver_shader = pipe->create_tcs_state(pipe, &prog->tgsi);
             break;
          case PIPE_SHADER_TESS_EVAL:
-            v->driver_shader = pipe->create_tes_state(pipe, tgsi);
+            v->driver_shader = pipe->create_tes_state(pipe, &prog->tgsi);
             break;
          case PIPE_SHADER_GEOMETRY:
-            v->driver_shader = pipe->create_gs_state(pipe, tgsi);
+            v->driver_shader = pipe->create_gs_state(pipe, &prog->tgsi);
             break;
          default:
             assert(!"unhandled shader type");
@@ -1645,8 +1644,8 @@ st_get_basic_variant(struct st_context *st,
          v->key = key;
 
          /* insert into list */
-         v->next = *variants;
-         *variants = v;
+         v->next = prog->variants;
+         prog->variants = v;
       }
    }
 
@@ -2004,19 +2003,19 @@ st_precompile_shader_variant(struct st_context *st,
 
    case GL_TESS_CONTROL_PROGRAM_NV: {
       struct st_common_program *p = st_common_program(prog);
-      st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &p->tgsi, &p->variants);
+      st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, p);
       break;
    }
 
    case GL_TESS_EVALUATION_PROGRAM_NV: {
       struct st_common_program *p = st_common_program(prog);
-      st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, &p->tgsi, &p->variants);
+      st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, p);
       break;
    }
 
    case GL_GEOMETRY_PROGRAM_NV: {
       struct st_common_program *p = st_common_program(prog);
-      st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &p->tgsi, &p->variants);
+      st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, p);
       break;
    }
 
index 8e9f4c5e826c33cf35cb49107d50c81e9996d138..27cc9b6e92f6d2e2d54c9a44f0f4a88798007036 100644 (file)
@@ -384,8 +384,7 @@ st_get_cp_variant(struct st_context *st,
 extern struct st_basic_variant *
 st_get_basic_variant(struct st_context *st,
                      unsigned pipe_shader,
-                     struct pipe_shader_state *tgsi,
-                     struct st_basic_variant **variants);
+                     struct st_common_program *p);
 
 extern void
 st_release_vp_variants( struct st_context *st,