st/mesa: clean up more after the removal of st_compute_program
authorMarek Olšák <marek.olsak@amd.com>
Sat, 12 Oct 2019 00:32:02 +0000 (20:32 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 17 Oct 2019 00:10:47 +0000 (20:10 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_program.h

index 52294f6da6e2c62fe4381f18aa36aa1f225538ab..5004eefc083ac472700f0a8f461b6712fda6454e 100644 (file)
@@ -264,7 +264,7 @@ st_update_common_program(struct st_context *st, struct gl_program *prog,
 
    }
 
-   return st_get_basic_variant(st, pipe_shader, stp, &key)->driver_shader;
+   return st_get_basic_variant(st, stp, &key)->driver_shader;
 }
 
 
@@ -299,30 +299,10 @@ st_update_tep(struct st_context *st)
 
 
 void
-st_update_cp( struct st_context *st )
+st_update_cp(struct st_context *st)
 {
-   struct st_common_program *stcp;
-
-   if (!st->ctx->ComputeProgram._Current) {
-      cso_set_compute_shader_handle(st->cso_context, NULL);
-      st_reference_compprog(st, &st->cp, NULL);
-      return;
-   }
-
-   stcp = st_common_program(st->ctx->ComputeProgram._Current);
-   assert(stcp->Base.Target == GL_COMPUTE_PROGRAM_NV);
-
-   void *shader;
-
-   if (st->shader_has_one_variant[MESA_SHADER_COMPUTE] && stcp->variants) {
-      shader = stcp->variants->driver_shader;
-   } else {
-      shader = st_get_cp_variant(st, &stcp->tgsi,
-                                 stcp->Base.info.cs.shared_size,
-                                 &stcp->variants)->driver_shader;
-   }
-
-   st_reference_compprog(st, &st->cp, stcp);
-
+   void *shader = st_update_common_program(st,
+                                           st->ctx->ComputeProgram._Current,
+                                           PIPE_SHADER_COMPUTE, &st->cp);
    cso_set_compute_shader_handle(st->cso_context, shader);
 }
index b49c09a991f68eadfaedd86314c5d2dc119a762f..b0605cf28babb8a47b214cb935ee2977bba82e7b 100644 (file)
@@ -1647,7 +1647,6 @@ st_translate_common_program(struct st_context *st,
  */
 struct st_basic_variant *
 st_get_basic_variant(struct st_context *st,
-                     unsigned pipe_shader,
                      struct st_common_program *prog,
                      const struct st_basic_variant_key *key)
 {
@@ -1697,16 +1696,29 @@ st_get_basic_variant(struct st_context *st,
            tgsi = prog->tgsi;
          }
          /* fill in new variant */
-         switch (pipe_shader) {
-         case PIPE_SHADER_TESS_CTRL:
+         switch (prog->Base.info.stage) {
+         case MESA_SHADER_TESS_CTRL:
             v->driver_shader = pipe->create_tcs_state(pipe, &tgsi);
             break;
-         case PIPE_SHADER_TESS_EVAL:
+         case MESA_SHADER_TESS_EVAL:
             v->driver_shader = pipe->create_tes_state(pipe, &tgsi);
             break;
-         case PIPE_SHADER_GEOMETRY:
+         case MESA_SHADER_GEOMETRY:
             v->driver_shader = pipe->create_gs_state(pipe, &tgsi);
             break;
+         case MESA_SHADER_COMPUTE: {
+            struct pipe_compute_state cs = {0};
+            cs.ir_type = tgsi.type;
+            cs.req_local_mem = prog->Base.info.cs.shared_size;
+
+            if (tgsi.type == PIPE_SHADER_IR_NIR)
+               cs.prog = tgsi.ir.nir;
+            else
+               cs.prog = tgsi.tokens;
+
+            v->driver_shader = pipe->create_compute_state(pipe, &cs);
+            break;
+         }
          default:
             assert(!"unhandled shader type");
             free(v);
@@ -1725,59 +1737,6 @@ st_get_basic_variant(struct st_context *st,
 }
 
 
-/**
- * Get/create compute program variant.
- */
-struct st_basic_variant *
-st_get_cp_variant(struct st_context *st,
-                  struct pipe_shader_state *tgsi,
-                  unsigned shared_size,
-                  struct st_basic_variant **variants)
-{
-   struct pipe_context *pipe = st->pipe;
-   struct st_basic_variant *v;
-   struct st_basic_variant_key key;
-
-   /* use memset, not an initializer to be sure all memory is zeroed */
-   memset(&key, 0, sizeof(key));
-
-   key.st = st->has_shareable_shaders ? NULL : st;
-
-   /* Search for existing variant */
-   for (v = *variants; v; v = v->next) {
-      if (memcmp(&v->key, &key, sizeof(key)) == 0) {
-         break;
-      }
-   }
-
-   if (!v) {
-      /* create new */
-      v = CALLOC_STRUCT(st_basic_variant);
-      if (v) {
-         /* fill in new variant */
-         struct pipe_compute_state cs = {0};
-
-         cs.ir_type = tgsi->type;
-         cs.req_local_mem = shared_size;
-
-         if (tgsi->type == PIPE_SHADER_IR_NIR)
-            cs.prog = nir_shader_clone(NULL, tgsi->ir.nir);
-         else
-            cs.prog = tgsi->tokens;
-
-         v->driver_shader = pipe->create_compute_state(pipe, &cs);
-         v->key = key;
-
-         /* insert into list */
-         v->next = *variants;
-         *variants = v;
-      }
-   }
-
-   return v;
-}
-
-
 /**
  * Vert/Geom/Frag programs have per-context variants.  Free all the
  * variants attached to the given program which match the given context.
@@ -1974,53 +1933,28 @@ st_precompile_shader_variant(struct st_context *st,
       break;
    }
 
-   case GL_TESS_CONTROL_PROGRAM_NV: {
-      struct st_common_program *p = st_common_program(prog);
-      struct st_basic_variant_key key;
-
-      memset(&key, 0, sizeof(key));
-
-      key.st = st->has_shareable_shaders ? NULL : st;
-      st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, p, &key);
-      break;
-   }
-
-   case GL_TESS_EVALUATION_PROGRAM_NV: {
-      struct st_common_program *p = st_common_program(prog);
-      struct st_basic_variant_key key;
+   case GL_FRAGMENT_PROGRAM_ARB: {
+      struct st_fragment_program *p = (struct st_fragment_program *)prog;
+      struct st_fp_variant_key key;
 
       memset(&key, 0, sizeof(key));
 
       key.st = st->has_shareable_shaders ? NULL : st;
-      st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, p, &key);
+      st_get_fp_variant(st, p, &key);
       break;
    }
 
-   case GL_GEOMETRY_PROGRAM_NV: {
+   case GL_TESS_CONTROL_PROGRAM_NV:
+   case GL_TESS_EVALUATION_PROGRAM_NV:
+   case GL_GEOMETRY_PROGRAM_NV:
+   case GL_COMPUTE_PROGRAM_NV: {
       struct st_common_program *p = st_common_program(prog);
       struct st_basic_variant_key key;
 
       memset(&key, 0, sizeof(key));
 
       key.st = st->has_shareable_shaders ? NULL : st;
-      st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, p, &key);
-      break;
-   }
-
-   case GL_FRAGMENT_PROGRAM_ARB: {
-      struct st_fragment_program *p = (struct st_fragment_program *)prog;
-      struct st_fp_variant_key key;
-
-      memset(&key, 0, sizeof(key));
-
-      key.st = st->has_shareable_shaders ? NULL : st;
-      st_get_fp_variant(st, p, &key);
-      break;
-   }
-
-   case GL_COMPUTE_PROGRAM_NV: {
-      struct st_common_program *p = (struct st_common_program *)prog;
-      st_get_cp_variant(st, &p->tgsi, prog->info.cs.shared_size, &p->variants);
+      st_get_basic_variant(st, p, &key);
       break;
    }
 
index 343963794a296af24eae3872b62469abacfd43d1..b8ad86a4738c27182c9b07ee4ef6b4e3e9d2143d 100644 (file)
@@ -397,15 +397,8 @@ st_get_fp_variant(struct st_context *st,
                   struct st_fragment_program *stfp,
                   const struct st_fp_variant_key *key);
 
-extern struct st_basic_variant *
-st_get_cp_variant(struct st_context *st,
-                  struct pipe_shader_state *tgsi,
-                  unsigned shared_size,
-                  struct st_basic_variant **variants);
-
 extern struct st_basic_variant *
 st_get_basic_variant(struct st_context *st,
-                     unsigned pipe_shader,
                      struct st_common_program *p,
                      const struct st_basic_variant_key *key);