[Mesa-dev] [PATCH 10/14] i965/fs: Use gl_program* rather than fp->Base

Kenneth Graunke kenneth at whitecape.org
Tue Sep 2 13:05:24 PDT 2014


On Monday, September 01, 2014 09:44:34 AM Jordan Justen wrote:
> Reduce brw_fs_precompile's dependence on gl_fragment_program.

The thing is, virtually all of the fields here are fragment program specific, and not going to be useful for compute.  So, I'm not sure whether this is really useful.  Your compute key may grow extra fields, at which point you might want a brw_cs_precompile() function.

One thing I do think would be useful...we should pull out the sampler related stuff into a brw_setup_sampler_program_key_for_precompile() function or such.  That code is already duplicated between the VS/GS and FS code.

> 
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index a6a03ea..5298059 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -3471,6 +3471,7 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
>  
>     struct gl_fragment_program *fp = (struct gl_fragment_program *)
>        prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
> +   struct gl_program *glp = &fp->Base;
>     struct brw_fragment_program *bfp = brw_fragment_program(fp);
>     bool program_uses_dfdy = fp->UsesDFdy;
>  
> @@ -3480,7 +3481,7 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
>        if (fp->UsesKill)
>           key.iz_lookup |= IZ_PS_KILL_ALPHATEST_BIT;
>  
> -      if (fp->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
> +      if (glp->OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH))
>           key.iz_lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
>  
>        /* Just assume depth testing. */
> @@ -3488,13 +3489,13 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
>        key.iz_lookup |= IZ_DEPTH_WRITE_ENABLE_BIT;
>     }
>  
> -   if (brw->gen < 6 || _mesa_bitcount_64(fp->Base.InputsRead &
> +   if (brw->gen < 6 || _mesa_bitcount_64(glp->InputsRead &
>                                           BRW_FS_VARYING_INPUT_MASK) > 16)
> -      key.input_slots_valid = fp->Base.InputsRead | VARYING_BIT_POS;
> +      key.input_slots_valid = glp->InputsRead | VARYING_BIT_POS;
>  
> -   unsigned sampler_count = _mesa_fls(fp->Base.SamplersUsed);
> +   unsigned sampler_count = _mesa_fls(glp->SamplersUsed);
>     for (unsigned i = 0; i < sampler_count; i++) {
> -      if (fp->Base.ShadowSamplers & (1 << i)) {
> +      if (glp->ShadowSamplers & (1 << i)) {
>           /* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
>           key.tex.swizzles[i] =
>              MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_ONE);
> @@ -3504,15 +3505,15 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
>        }
>     }
>  
> -   if (fp->Base.InputsRead & VARYING_BIT_POS) {
> +   if (glp->InputsRead & VARYING_BIT_POS) {
>        key.drawable_height = ctx->DrawBuffer->Height;
>     }
>  
> -   key.nr_color_regions = _mesa_bitcount_64(fp->Base.OutputsWritten &
> +   key.nr_color_regions = _mesa_bitcount_64(glp->OutputsWritten &
>           ~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) |
>           BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
>  
> -   if ((fp->Base.InputsRead & VARYING_BIT_POS) || program_uses_dfdy) {
> +   if ((glp->InputsRead & VARYING_BIT_POS) || program_uses_dfdy) {
>        key.render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer) ||
>                            key.nr_color_regions > 1;
>     }
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140902/6d54c16e/attachment-0001.sig>


More information about the mesa-dev mailing list