diff options
author | Marek Olšák <[email protected]> | 2019-10-11 20:32:02 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-10-16 20:10:47 -0400 |
commit | 8dfcec405ad44d43a35643b9da2157ff063622cc (patch) | |
tree | 8f240c0f5cb15feed614f9e07c9e70c1d34f6924 /src/mesa | |
parent | 196fc59c40e77248e843252908de6ad128dbb6aa (diff) |
st/mesa: clean up more after the removal of st_compute_program
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_atom_shader.c | 30 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 118 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.h | 7 |
3 files changed, 31 insertions, 124 deletions
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 52294f6da6e..5004eefc083 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -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); } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index b49c09a991f..b0605cf28ba 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -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); @@ -1726,59 +1738,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; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 343963794a2..b8ad86a4738 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -398,14 +398,7 @@ st_get_fp_variant(struct st_context *st, 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); |