[Mesa-dev] [PATCH 3/3] st/mesa: create shaders which have only one variant immediatelly

Ilia Mirkin imirkin at alum.mit.edu
Mon Oct 19 11:31:08 PDT 2015


This series is Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
provided that you run a couple of piglit tests through valgrind and
get no additional memory leaks.

  -ilia

On Sat, Oct 10, 2015 at 9:09 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/mesa/state_tracker/st_cb_program.c |  5 +++--
>  src/mesa/state_tracker/st_context.c    | 14 ++++++++++++++
>  src/mesa/state_tracker/st_context.h    |  7 +++++++
>  3 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
> index 40f2af0..611aea7 100644
> --- a/src/mesa/state_tracker/st_cb_program.c
> +++ b/src/mesa/state_tracker/st_cb_program.c
> @@ -222,6 +222,7 @@ st_program_string_notify( struct gl_context *ctx,
>                                             struct gl_program *prog )
>  {
>     struct st_context *st = st_context(ctx);
> +   gl_shader_stage stage = _mesa_program_enum_to_shader_stage(target);
>
>     if (target == GL_FRAGMENT_PROGRAM_ARB) {
>        struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
> @@ -276,10 +277,10 @@ st_program_string_notify( struct gl_context *ctx,
>           st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
>     }
>
> -   if (ST_DEBUG & DEBUG_PRECOMPILE)
> +   if (ST_DEBUG & DEBUG_PRECOMPILE ||
> +       st->shader_has_one_variant[stage])
>        st_precompile_shader_variant(st, prog);
>
> -   /* XXX check if program is legal, within limits */
>     return GL_TRUE;
>  }
>
> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
> index 6256c0b..4f3f525 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -293,6 +293,20 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
>           ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectSampler = true;
>     }
>
> +   /* Set which shader types can be compiled at link time. */
> +   st->shader_has_one_variant[MESA_SHADER_VERTEX] =
> +         st->has_shareable_shaders &&
> +         !st->clamp_vert_color_in_shader;
> +
> +   st->shader_has_one_variant[MESA_SHADER_FRAGMENT] =
> +         st->has_shareable_shaders &&
> +         !st->clamp_frag_color_in_shader &&
> +         st->can_force_persample_interp;
> +
> +   st->shader_has_one_variant[MESA_SHADER_TESS_CTRL] = st->has_shareable_shaders;
> +   st->shader_has_one_variant[MESA_SHADER_TESS_EVAL] = st->has_shareable_shaders;
> +   st->shader_has_one_variant[MESA_SHADER_GEOMETRY] = st->has_shareable_shaders;
> +
>     _mesa_compute_version(ctx);
>
>     if (ctx->Version == 0) {
> diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
> index 446fe5d..d0aed7e 100644
> --- a/src/mesa/state_tracker/st_context.h
> +++ b/src/mesa/state_tracker/st_context.h
> @@ -101,6 +101,13 @@ struct st_context
>     boolean can_force_persample_interp;
>     boolean has_shareable_shaders;
>
> +   /**
> +    * If a shader can be created when we get its source.
> +    * This means it has only 1 variant, not counting glBitmap and
> +    * glDrawPixels.
> +    */
> +   boolean shader_has_one_variant[MESA_SHADER_STAGES];
> +
>     boolean needs_texcoord_semantic;
>     boolean apply_texture_swizzle_to_border_color;
>
> --
> 2.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list