[Mesa-dev] [PATCH 10/10] mesa: Use a new, more specific hook for shader uniform changes.

Paul Berry stereotype441 at gmail.com
Fri Aug 24 12:27:55 PDT 2012


On 24 August 2012 03:06, Kenneth Graunke <kenneth at whitecape.org> wrote:

> Gallium drivers and i965 don't require special notification when
> sampler uniforms change.  They simply see the _NEW_TEXTURE and adjust
> their indirection tables.  These drivers don't want ProgramStringNotify:
> it simply causes pointless recompiles.
>
> Unfortunately, i915 still requires shader recompiles and needs
> ProgramStringNotify.  Rather than trying to fix that, simply change the
> hook to a new, more specific one: ShaderUniformChange.  On i915, this
> translates to ProgramStringNotify; others simply ignore it.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>

I don't feel qualified to review this one.  I've already commented on 1, 3,
5, 7, 8, and 9.  The others (2, 4, and 6) are:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>


> ---
>  src/mesa/drivers/dri/i915/i915_fragprog.c | 8 ++++++++
>  src/mesa/main/dd.h                        | 7 +++++++
>  src/mesa/main/ff_fragment_shader.cpp      | 3 ++-
>  src/mesa/main/uniform_query.cpp           | 3 ++-
>  4 files changed, 19 insertions(+), 2 deletions(-)
>
> Killing the ProgramStringNotify calls is what fixes Cogs.
> This also should help Gallium: st/mesa doesn't need nor want this.
>
> diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c
> b/src/mesa/drivers/dri/i915/i915_fragprog.c
> index 5b7e93e..7a6e067 100644
> --- a/src/mesa/drivers/dri/i915/i915_fragprog.c
> +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c
> @@ -1303,6 +1303,13 @@ i915ProgramStringNotify(struct gl_context * ctx,
>     return true;
>  }
>
> +static void
> +i915SamplerUniformChange(struct gl_context *ctx,
> +                         GLenum target, struct gl_program *prog)
> +{
> +   i915ProgramStringNotify(ctx, target, prog);
> +}
> +
>  void
>  i915_update_program(struct gl_context *ctx)
>  {
> @@ -1456,4 +1463,5 @@ i915InitFragProgFuncs(struct dd_function_table
> *functions)
>     functions->DeleteProgram = i915DeleteProgram;
>     functions->IsProgramNative = i915IsProgramNative;
>     functions->ProgramStringNotify = i915ProgramStringNotify;
> +   functions->SamplerUniformChange = i915SamplerUniformChange;
>  }
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index 226897b..153e819 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -396,6 +396,13 @@ struct dd_function_table {
>     GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target,
>                                      struct gl_program *prog);
>
> +   /**
> +    * Notify driver that the sampler uniforms for the current program have
> +    * changed.  On some drivers, this may require shader recompiles.
> +    */
> +   void (*SamplerUniformChange)(struct gl_context *ctx, GLenum target,
> +                                struct gl_program *prog);
> +
>     /** Query if program can be loaded onto hardware */
>     GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target,
>                                 struct gl_program *prog);
> diff --git a/src/mesa/main/ff_fragment_shader.cpp
> b/src/mesa/main/ff_fragment_shader.cpp
> index f743ce1..e850d47 100644
> --- a/src/mesa/main/ff_fragment_shader.cpp
> +++ b/src/mesa/main/ff_fragment_shader.cpp
> @@ -1363,7 +1363,8 @@ create_new_program(struct gl_context *ctx, struct
> state_key *key)
>     _mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters);
>
>     _mesa_update_shader_textures_used(p.shader_program, fp);
> -   (void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp);
> +   if (ctx->Driver.SamplerUniformChange)
> +      ctx->Driver.SamplerUniformChange(ctx, fp->Target, fp);
>
>     if (!p.shader_program->LinkStatus)
>        _mesa_problem(ctx, "Failed to link fixed function fragment shader:
> %s\n",
> diff --git a/src/mesa/main/uniform_query.cpp
> b/src/mesa/main/uniform_query.cpp
> index 816c277..bddb8f9 100644
> --- a/src/mesa/main/uniform_query.cpp
> +++ b/src/mesa/main/uniform_query.cpp
> @@ -809,7 +809,8 @@ _mesa_uniform(struct gl_context *ctx, struct
> gl_shader_program *shProg,
>                    sizeof(shProg->SamplerUnits));
>
>             _mesa_update_shader_textures_used(shProg, prog);
> -           (void) ctx->Driver.ProgramStringNotify(ctx, prog->Target,
> prog);
> +            if (ctx->Driver.SamplerUniformChange)
> +              ctx->Driver.SamplerUniformChange(ctx, prog->Target, prog);
>          }
>        }
>     }
> --
> 1.7.11.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120824/f9aea16e/attachment.html>


More information about the mesa-dev mailing list