[Mesa-dev] [PATCH 06/17] st/mesa: unify TCS, TES, GS st_*_program structures
Brian Paul
brianp at vmware.com
Mon May 1 16:40:35 UTC 2017
On 05/01/2017 06:52 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/mesa/state_tracker/st_atom.c | 12 ++---
> src/mesa/state_tracker/st_atom_constbuf.c | 6 +--
> src/mesa/state_tracker/st_atom_shader.c | 24 ++++-----
> src/mesa/state_tracker/st_cb_program.c | 34 ++++++------
> src/mesa/state_tracker/st_context.c | 18 +++----
> src/mesa/state_tracker/st_context.h | 6 +--
> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 12 ++---
> src/mesa/state_tracker/st_program.c | 24 ++++-----
> src/mesa/state_tracker/st_program.h | 86 ++++--------------------------
> src/mesa/state_tracker/st_shader_cache.c | 30 +++++------
> 10 files changed, 93 insertions(+), 159 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
> index b40ce1e..cbac762 100644
> --- a/src/mesa/state_tracker/st_atom.c
> +++ b/src/mesa/state_tracker/st_atom.c
> @@ -58,23 +58,23 @@ void st_destroy_atoms( struct st_context *st )
> /* no-op */
> }
>
>
> /* Too complex to figure out, just check every time:
> */
> static void check_program_state( struct st_context *st )
> {
> struct gl_context *ctx = st->ctx;
> struct st_vertex_program *old_vp = st->vp;
> - struct st_tessctrl_program *old_tcp = st->tcp;
> - struct st_tesseval_program *old_tep = st->tep;
> - struct st_geometry_program *old_gp = st->gp;
> + struct st_common_program *old_tcp = st->tcp;
> + struct st_common_program *old_tep = st->tep;
> + struct st_common_program *old_gp = st->gp;
> struct st_fragment_program *old_fp = st->fp;
>
> struct gl_program *new_vp = ctx->VertexProgram._Current;
> struct gl_program *new_tcp = ctx->TessCtrlProgram._Current;
> struct gl_program *new_tep = ctx->TessEvalProgram._Current;
> struct gl_program *new_gp = ctx->GeometryProgram._Current;
> struct gl_program *new_fp = ctx->FragmentProgram._Current;
> uint64_t dirty = 0;
>
> /* Flag states used by both new and old shaders to unbind shader resources
> @@ -84,35 +84,35 @@ static void check_program_state( struct st_context *st )
> if (old_vp)
> dirty |= old_vp->affected_states;
> if (new_vp)
> dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(new_vp));
> }
>
> if (unlikely(new_tcp != &old_tcp->Base)) {
> if (old_tcp)
> dirty |= old_tcp->affected_states;
> if (new_tcp)
> - dirty |= st_tessctrl_program(new_tcp)->affected_states;
> + dirty |= st_common_program(new_tcp)->affected_states;
> }
>
> if (unlikely(new_tep != &old_tep->Base)) {
> if (old_tep)
> dirty |= old_tep->affected_states;
> if (new_tep)
> - dirty |= st_tesseval_program(new_tep)->affected_states;
> + dirty |= st_common_program(new_tep)->affected_states;
> }
>
> if (unlikely(new_gp != &old_gp->Base)) {
> if (old_gp)
> dirty |= old_gp->affected_states;
> if (new_gp)
> - dirty |= st_geometry_program(new_gp)->affected_states;
> + dirty |= st_common_program(new_gp)->affected_states;
> }
>
> if (unlikely(new_fp != &old_fp->Base)) {
> if (old_fp)
> dirty |= old_fp->affected_states;
> if (new_fp)
> dirty |= st_fragment_program(new_fp)->affected_states;
> }
>
> st->dirty |= dirty;
> diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
> index 9c04580..6cbfba7 100644
> --- a/src/mesa/state_tracker/st_atom_constbuf.c
> +++ b/src/mesa/state_tracker/st_atom_constbuf.c
> @@ -156,47 +156,47 @@ void st_update_fs_constants(struct st_context *st )
> struct gl_program_parameter_list *params = fp->Base.Parameters;
>
> st_upload_constants( st, params, MESA_SHADER_FRAGMENT );
> }
>
>
> /* Geometry shader:
> */
> void st_update_gs_constants(struct st_context *st )
> {
> - struct st_geometry_program *gp = st->gp;
> + struct st_common_program *gp = st->gp;
> struct gl_program_parameter_list *params;
>
> if (gp) {
> params = gp->Base.Parameters;
> st_upload_constants( st, params, MESA_SHADER_GEOMETRY );
> }
> }
>
> /* Tessellation control shader:
> */
> void st_update_tcs_constants(struct st_context *st )
> {
> - struct st_tessctrl_program *tcp = st->tcp;
> + struct st_common_program *tcp = st->tcp;
> struct gl_program_parameter_list *params;
>
> if (tcp) {
> params = tcp->Base.Parameters;
> st_upload_constants( st, params, MESA_SHADER_TESS_CTRL );
> }
> }
>
> /* Tessellation evaluation shader:
> */
> void st_update_tes_constants(struct st_context *st )
> {
> - struct st_tesseval_program *tep = st->tep;
> + struct st_common_program *tep = st->tep;
> struct gl_program_parameter_list *params;
>
> if (tep) {
> params = tep->Base.Parameters;
> st_upload_constants( st, params, MESA_SHADER_TESS_EVAL );
> }
> }
>
> /* Compute shader:
> */
> diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
> index 091cbe0..875279d 100644
> --- a/src/mesa/state_tracker/st_atom_shader.c
> +++ b/src/mesa/state_tracker/st_atom_shader.c
> @@ -178,83 +178,83 @@ st_update_vp( struct st_context *st )
> st_reference_vertprog(st, &st->vp, stvp);
>
> cso_set_vertex_shader_handle(st->cso_context,
> st->vp_variant->driver_shader);
> }
>
>
> void
> st_update_gp( struct st_context *st )
> {
> - struct st_geometry_program *stgp;
> + struct st_common_program *stgp;
>
> if (!st->ctx->GeometryProgram._Current) {
> cso_set_geometry_shader_handle(st->cso_context, NULL);
> - st_reference_geomprog(st, &st->gp, NULL);
> + st_reference_prog(st, &st->gp, NULL);
> return;
> }
>
> - stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
> + stgp = st_common_program(st->ctx->GeometryProgram._Current);
> assert(stgp->Base.Target == GL_GEOMETRY_PROGRAM_NV);
>
> st->gp_variant = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY,
> &stgp->tgsi, &stgp->variants);
>
> - st_reference_geomprog(st, &st->gp, stgp);
> + st_reference_prog(st, &st->gp, stgp);
>
> cso_set_geometry_shader_handle(st->cso_context,
> st->gp_variant->driver_shader);
> }
>
>
> void
> st_update_tcp( struct st_context *st )
> {
> - struct st_tessctrl_program *sttcp;
> + struct st_common_program *sttcp;
>
> if (!st->ctx->TessCtrlProgram._Current) {
> cso_set_tessctrl_shader_handle(st->cso_context, NULL);
> - st_reference_tesscprog(st, &st->tcp, NULL);
> + st_reference_prog(st, &st->tcp, NULL);
> return;
> }
>
> - sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
> + sttcp = st_common_program(st->ctx->TessCtrlProgram._Current);
> assert(sttcp->Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
>
> st->tcp_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL,
> &sttcp->tgsi, &sttcp->variants);
>
> - st_reference_tesscprog(st, &st->tcp, sttcp);
> + st_reference_prog(st, &st->tcp, sttcp);
>
> cso_set_tessctrl_shader_handle(st->cso_context,
> st->tcp_variant->driver_shader);
> }
>
>
> void
> st_update_tep( struct st_context *st )
> {
> - struct st_tesseval_program *sttep;
> + struct st_common_program *sttep;
>
> if (!st->ctx->TessEvalProgram._Current) {
> cso_set_tesseval_shader_handle(st->cso_context, NULL);
> - st_reference_tesseprog(st, &st->tep, NULL);
> + st_reference_prog(st, &st->tep, NULL);
> return;
> }
>
> - sttep = st_tesseval_program(st->ctx->TessEvalProgram._Current);
> + sttep = st_common_program(st->ctx->TessEvalProgram._Current);
> assert(sttep->Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
>
> st->tep_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL,
> &sttep->tgsi, &sttep->variants);
>
> - st_reference_tesseprog(st, &st->tep, sttep);
> + st_reference_prog(st, &st->tep, sttep);
>
> cso_set_tesseval_shader_handle(st->cso_context,
> st->tep_variant->driver_shader);
> }
>
>
> void
> st_update_cp( struct st_context *st )
> {
> struct st_compute_program *stcp;
> diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
> index b104649..531d20d 100644
> --- a/src/mesa/state_tracker/st_cb_program.c
> +++ b/src/mesa/state_tracker/st_cb_program.c
> @@ -62,32 +62,32 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
> struct st_vertex_program *prog = rzalloc(NULL,
> struct st_vertex_program);
> return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
> }
> case GL_FRAGMENT_PROGRAM_ARB: {
> struct st_fragment_program *prog = rzalloc(NULL,
> struct st_fragment_program);
> return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
> }
> case GL_GEOMETRY_PROGRAM_NV: {
> - struct st_geometry_program *prog = rzalloc(NULL,
> - struct st_geometry_program);
> + struct st_common_program *prog = rzalloc(NULL,
> + struct st_common_program);
> return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
> }
> case GL_TESS_CONTROL_PROGRAM_NV: {
> - struct st_tessctrl_program *prog = rzalloc(NULL,
> - struct st_tessctrl_program);
> + struct st_common_program *prog = rzalloc(NULL,
> + struct st_common_program);
> return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
> }
> case GL_TESS_EVALUATION_PROGRAM_NV: {
> - struct st_tesseval_program *prog = rzalloc(NULL,
> - struct st_tesseval_program);
> + struct st_common_program *prog = rzalloc(NULL,
> + struct st_common_program);
> return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
> }
> case GL_COMPUTE_PROGRAM_NV: {
> struct st_compute_program *prog = rzalloc(NULL,
> struct st_compute_program);
> return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
> }
> default:
> assert(0);
> return NULL;
> @@ -108,22 +108,22 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
> {
> struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
> st_release_vp_variants( st, stvp );
>
> if (stvp->glsl_to_tgsi)
> free_glsl_to_tgsi_visitor(stvp->glsl_to_tgsi);
> }
> break;
> case GL_GEOMETRY_PROGRAM_NV:
> {
> - struct st_geometry_program *stgp =
> - (struct st_geometry_program *) prog;
> + struct st_common_program *stgp =
> + (struct st_common_program *) prog;
Here, and a bunch of places below, I think we should be using the
st_common_program() cast wrapper. Though, that could probably be done
in a follow-on change.
-Brian
More information about the mesa-dev
mailing list