[Mesa-dev] [PATCH 05/24] st/mesa: unify update_gp/tcp/tep code
Gert Wollny
gw.fossdev at gmail.com
Sat Jul 1 10:32:03 UTC 2017
Hello Marek,
this patch makes most of the tesselation shaders in piglit crash
because now you are passing MESA_SHADER_TESS_* to st_get_basic_variant,
but this function tests for PIPE_SHADER_TESS_* when allocating new
variants. Hence, the function doesn't fulfill the assert in debug
mode, or it returns a null pointer in release.
Replacing MESA_SHADER_TESS_* with PIPE_SHADER_TESS_* fixes the problem
for me.
Best,
Gert
Am Montag, den 12.06.2017, 20:18 +0200 schrieb Marek Olšák:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/mesa/state_tracker/st_atom_shader.c | 91 ++++++++++-------------
> ----------
> 1 file changed, 28 insertions(+), 63 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_shader.c
> b/src/mesa/state_tracker/st_atom_shader.c
> index b6b3222..c1869d3 100644
> --- a/src/mesa/state_tracker/st_atom_shader.c
> +++ b/src/mesa/state_tracker/st_atom_shader.c
> @@ -189,103 +189,68 @@ st_update_vp( struct st_context *st )
> st->vp_variant = st_get_vp_variant(st, stvp, &key);
> }
>
> 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 )
> +static void *
> +st_update_common_program(struct st_context *st, struct gl_program
> *prog,
> + unsigned pipe_shader, struct
> st_common_program **dst)
> {
> - struct st_common_program *stgp;
> + struct st_common_program *stp;
>
> - if (!st->ctx->GeometryProgram._Current) {
> - cso_set_geometry_shader_handle(st->cso_context, NULL);
> - st_reference_prog(st, &st->gp, NULL);
> - return;
> + if (!prog) {
> + st_reference_prog(st, dst, NULL);
> + return NULL;
> }
>
> - stgp = st_common_program(st->ctx->GeometryProgram._Current);
> - assert(stgp->Base.Target == GL_GEOMETRY_PROGRAM_NV);
> + stp = st_common_program(prog);
> + st_reference_prog(st, dst, stp);
>
> - void *shader;
> + if (st-
> >shader_has_one_variant[prog->info.stage] && stp->variants)
> + return stp->variants->driver_shader;
>
> - if (st->shader_has_one_variant[MESA_SHADER_GEOMETRY] && stgp-
> >variants) {
> - shader = stgp->variants->driver_shader;
> - } else {
> - shader = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &stgp-
> >tgsi,
> - &stgp->variants)->driver_shader;
> - }
> + return st_get_basic_variant(st, pipe_shader, &stp->tgsi,
> + &stp->variants)->driver_shader;
> +}
>
> - st_reference_prog(st, &st->gp, stgp);
>
> +void
> +st_update_gp(struct st_context *st)
> +{
> + void *shader = st_update_common_program(st,
> + st->ctx-
> >GeometryProgram._Current,
> + PIPE_SHADER_GEOMETRY,
> &st->gp);
> cso_set_geometry_shader_handle(st->cso_context, shader);
> }
>
>
> void
> -st_update_tcp( struct st_context *st )
> +st_update_tcp(struct st_context *st)
> {
> - struct st_common_program *sttcp;
> -
> - if (!st->ctx->TessCtrlProgram._Current) {
> - cso_set_tessctrl_shader_handle(st->cso_context, NULL);
> - st_reference_prog(st, &st->tcp, NULL);
> - return;
> - }
> -
> - sttcp = st_common_program(st->ctx->TessCtrlProgram._Current);
> - assert(sttcp->Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
> -
> - void *shader;
> -
> - if (st->shader_has_one_variant[MESA_SHADER_TESS_CTRL] && sttcp-
> >variants) {
> - shader = sttcp->variants->driver_shader;
> - } else {
> - shader = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL,
> &sttcp->tgsi,
> - &sttcp->variants)-
> >driver_shader;
> - }
> -
> - st_reference_prog(st, &st->tcp, sttcp);
> -
> + void *shader = st_update_common_program(st,
> + st->ctx-
> >TessCtrlProgram._Current,
> + MESA_SHADER_TESS_CTRL,
> &st->tcp);
> cso_set_tessctrl_shader_handle(st->cso_context, shader);
> }
>
>
> void
> -st_update_tep( struct st_context *st )
> +st_update_tep(struct st_context *st)
> {
> - struct st_common_program *sttep;
> -
> - if (!st->ctx->TessEvalProgram._Current) {
> - cso_set_tesseval_shader_handle(st->cso_context, NULL);
> - st_reference_prog(st, &st->tep, NULL);
> - return;
> - }
> -
> - sttep = st_common_program(st->ctx->TessEvalProgram._Current);
> - assert(sttep->Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
> -
> - void *shader;
> -
> - if (st->shader_has_one_variant[MESA_SHADER_TESS_EVAL] && sttep-
> >variants) {
> - shader = sttep->variants->driver_shader;
> - } else {
> - shader = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL,
> &sttep->tgsi,
> - &sttep->variants)-
> >driver_shader;
> - }
> -
> - st_reference_prog(st, &st->tep, sttep);
> -
> + void *shader = st_update_common_program(st,
> + st->ctx-
> >TessEvalProgram._Current,
> + MESA_SHADER_TESS_EVAL,
> &st->tep);
> cso_set_tesseval_shader_handle(st->cso_context, shader);
> }
>
>
> void
> st_update_cp( struct st_context *st )
> {
> struct st_compute_program *stcp;
>
> if (!st->ctx->ComputeProgram._Current) {
More information about the mesa-dev
mailing list