[Mesa-dev] [PATCH] st/mesa: use correct pipe functions to create tess shaders

Brian Paul brianp at vmware.com
Thu Feb 11 15:55:20 UTC 2016


On 02/11/2016 08:48 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> Broken by one of my cleanups. Spotted by luck.
>
> Radeonsi doesn't care, because all shader create callbacks go to the same
> function.
> ---
>   src/mesa/state_tracker/st_atom_shader.c |  9 ++++++---
>   src/mesa/state_tracker/st_program.c     | 24 ++++++++++++++++++++----
>   src/mesa/state_tracker/st_program.h     |  1 +
>   3 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
> index 23b7abf..c8650a5 100644
> --- a/src/mesa/state_tracker/st_atom_shader.c
> +++ b/src/mesa/state_tracker/st_atom_shader.c
> @@ -172,7 +172,8 @@ update_gp( struct st_context *st )
>      stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
>      assert(stgp->Base.Base.Target == GL_GEOMETRY_PROGRAM_NV);
>
> -   st->gp_variant = st_get_basic_variant(st, &stgp->tgsi, &stgp->variants);
> +   st->gp_variant = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY,
> +                                         &stgp->tgsi, &stgp->variants);
>
>      st_reference_geomprog(st, &st->gp, stgp);
>
> @@ -204,7 +205,8 @@ update_tcp( struct st_context *st )
>      sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
>      assert(sttcp->Base.Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
>
> -   st->tcp_variant = st_get_basic_variant(st, &sttcp->tgsi, &sttcp->variants);
> +   st->tcp_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL,
> +                                          &sttcp->tgsi, &sttcp->variants);
>
>      st_reference_tesscprog(st, &st->tcp, sttcp);
>
> @@ -236,7 +238,8 @@ update_tep( struct st_context *st )
>      sttep = st_tesseval_program(st->ctx->TessEvalProgram._Current);
>      assert(sttep->Base.Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
>
> -   st->tep_variant = st_get_basic_variant(st, &sttep->tgsi, &sttep->variants);
> +   st->tep_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL,
> +                                          &sttep->tgsi, &sttep->variants);
>
>      st_reference_tesseprog(st, &st->tep, sttep);
>
> diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
> index 624586e..5bd626f 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -1271,6 +1271,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)
>   {
> @@ -1293,7 +1294,22 @@ st_get_basic_variant(struct st_context *st,
>         v = CALLOC_STRUCT(st_basic_variant);
>         if (v) {
>            /* fill in new variant */
> -         v->driver_shader = pipe->create_gs_state(pipe, tgsi);
> +         switch (pipe_shader) {
> +         case PIPE_SHADER_TESS_CTRL:
> +            v->driver_shader = pipe->create_tcs_state(pipe, tgsi);
> +            break;
> +         case PIPE_SHADER_TESS_EVAL:
> +            v->driver_shader = pipe->create_tes_state(pipe, tgsi);
> +            break;
> +         case PIPE_SHADER_GEOMETRY:
> +            v->driver_shader = pipe->create_gs_state(pipe, tgsi);
> +            break;
> +         default:
> +            assert(!"unhandled shader type");
> +            free(v);
> +            return NULL;
> +         }
> +
>            v->key = key;
>
>            /* insert into list */
> @@ -1587,19 +1603,19 @@ st_precompile_shader_variant(struct st_context *st,
>
>      case GL_TESS_CONTROL_PROGRAM_NV: {
>         struct st_tessctrl_program *p = (struct st_tessctrl_program *)prog;
> -      st_get_basic_variant(st, &p->tgsi, &p->variants);
> +      st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &p->tgsi, &p->variants);
>         break;
>      }
>
>      case GL_TESS_EVALUATION_PROGRAM_NV: {
>         struct st_tesseval_program *p = (struct st_tesseval_program *)prog;
> -      st_get_basic_variant(st, &p->tgsi, &p->variants);
> +      st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, &p->tgsi, &p->variants);
>         break;
>      }
>
>      case GL_GEOMETRY_PROGRAM_NV: {
>         struct st_geometry_program *p = (struct st_geometry_program *)prog;
> -      st_get_basic_variant(st, &p->tgsi, &p->variants);
> +      st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &p->tgsi, &p->variants);
>         break;
>      }
>
> diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
> index 7717d02..74f3def 100644
> --- a/src/mesa/state_tracker/st_program.h
> +++ b/src/mesa/state_tracker/st_program.h
> @@ -352,6 +352,7 @@ st_get_fp_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);
>
>

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list