[Mesa-dev] [PATCH 1/4] i965: Split out brw_<stage>_populate_key into their own functions

Ian Romanick idr at freedesktop.org
Fri Mar 20 18:02:33 PDT 2015


On 03/20/2015 05:49 PM, Carl Worth wrote:
> This commit splits portions of the existing brw_upload_vs_prog and
> brw_upload_gs_prog function into new brw_vs_populate_key and
> brw_gs_populate_key functions. This follows the same style as is
> already present for all other stages, (see brw_wm_populate_key, etc.).
> 
> This commit is intended to have no functional change. It exists in
> preparation for some upcoming code movement in preparation for the
> shader cache.
> ---
>  src/mesa/drivers/dri/i965/brw_ff_gs.c |  7 +++--
>  src/mesa/drivers/dri/i965/brw_gs.c    | 39 ++++++++++++++---------
>  src/mesa/drivers/dri/i965/brw_vs.c    | 58 +++++++++++++++++++++--------------
>  3 files changed, 64 insertions(+), 40 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_ff_gs.c b/src/mesa/drivers/dri/i965/brw_ff_gs.c
> index 828e383..1dec2ab 100644
> --- a/src/mesa/drivers/dri/i965/brw_ff_gs.c
> +++ b/src/mesa/drivers/dri/i965/brw_ff_gs.c
> @@ -147,8 +147,9 @@ static void compile_ff_gs_prog(struct brw_context *brw,
>     ralloc_free(mem_ctx);
>  }
>  
> -static void populate_key(struct brw_context *brw,
> -                         struct brw_ff_gs_prog_key *key)
> +static void
> +brw_ff_gs_populate_key(struct brw_context *brw,
> +		       struct brw_ff_gs_prog_key *key)

Tabs.

>  {
>     static const unsigned swizzle_for_offset[4] = {
>        BRW_SWIZZLE4(0, 1, 2, 3),
> @@ -235,7 +236,7 @@ brw_upload_ff_gs_prog(struct brw_context *brw)
>  
>     /* Populate the key:
>      */
> -   populate_key(brw, &key);
> +   brw_ff_gs_populate_key(brw, &key);
>  
>     if (brw->ff_gs.prog_active != key.need_gs_prog) {
>        brw->state.dirty.brw |= BRW_NEW_FF_GS_PROG_DATA;
> diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
> index 45c157a..3458df3 100644
> --- a/src/mesa/drivers/dri/i965/brw_gs.c
> +++ b/src/mesa/drivers/dri/i965/brw_gs.c
> @@ -288,6 +288,30 @@ do_gs_prog(struct brw_context *brw,
>     return true;
>  }
>  
> +static void
> +brw_gs_populate_key(struct brw_context *brw,
> +		    struct brw_gs_prog_key *key)

Tabs.  There may be some in other places too.  Thunderbird's editor
isn't "too smart" to be able to search for tabs... it matches any
whitespace.

With the tabs converted to spaces, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> +{
> +   struct gl_context *ctx = &brw->ctx;
> +   struct brw_stage_state *stage_state = &brw->gs.base;
> +   struct brw_geometry_program *gp =
> +      (struct brw_geometry_program *) brw->geometry_program;
> +   struct gl_program *prog = &gp->program.Base;
> +
> +   memset(key, 0, sizeof(*key));
> +
> +   key->base.program_string_id = gp->id;
> +   brw_setup_vue_key_clip_info(brw, &key->base,
> +                               gp->program.Base.UsesClipDistanceOut);
> +
> +   /* _NEW_TEXTURE */
> +   brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
> +                                      &key->base.tex);
> +
> +   /* BRW_NEW_VUE_MAP_VS */
> +   key->input_varyings = brw->vue_map_vs.slots_valid;
> +}
> +
>  void
>  brw_upload_gs_prog(struct brw_context *brw)
>  {
> @@ -327,20 +351,7 @@ brw_upload_gs_prog(struct brw_context *brw)
>        return;
>     }
>  
> -   struct gl_program *prog = &gp->program.Base;
> -
> -   memset(&key, 0, sizeof(key));
> -
> -   key.base.program_string_id = gp->id;
> -   brw_setup_vue_key_clip_info(brw, &key.base,
> -                               gp->program.Base.UsesClipDistanceOut);
> -
> -   /* _NEW_TEXTURE */
> -   brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
> -                                      &key.base.tex);
> -
> -   /* BRW_NEW_VUE_MAP_VS */
> -   key.input_varyings = brw->vue_map_vs.slots_valid;
> +   brw_gs_populate_key(brw, &key);
>  
>     if (!brw_search_cache(&brw->cache, BRW_CACHE_GS_PROG,
>                           &key, sizeof(key),
> diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
> index ba2c23d..b8e91c1 100644
> --- a/src/mesa/drivers/dri/i965/brw_vs.c
> +++ b/src/mesa/drivers/dri/i965/brw_vs.c
> @@ -401,64 +401,76 @@ brw_setup_vue_key_clip_info(struct brw_context *brw,
>     }
>  }
>  
> -void
> -brw_upload_vs_prog(struct brw_context *brw)
> +static void
> +brw_vs_populate_key(struct brw_context *brw,
> +                    struct brw_vs_prog_key *key)
>  {
>     struct gl_context *ctx = &brw->ctx;
> -   struct brw_vs_prog_key key;
>     /* BRW_NEW_VERTEX_PROGRAM */
>     struct brw_vertex_program *vp =
>        (struct brw_vertex_program *)brw->vertex_program;
>     struct gl_program *prog = (struct gl_program *) brw->vertex_program;
>     int i;
>  
> -   if (!brw_state_dirty(brw,
> -                        _NEW_BUFFERS |
> -                        _NEW_LIGHT |
> -                        _NEW_POINT |
> -                        _NEW_POLYGON |
> -                        _NEW_TEXTURE |
> -                        _NEW_TRANSFORM,
> -                        BRW_NEW_VERTEX_PROGRAM |
> -                        BRW_NEW_VS_ATTRIB_WORKAROUNDS))
> -      return;
> -
> -   memset(&key, 0, sizeof(key));
> +   memset(key, 0, sizeof(*key));
>  
>     /* Just upload the program verbatim for now.  Always send it all
>      * the inputs it asks for, whether they are varying or not.
>      */
> -   key.base.program_string_id = vp->id;
> -   brw_setup_vue_key_clip_info(brw, &key.base,
> +   key->base.program_string_id = vp->id;
> +   brw_setup_vue_key_clip_info(brw, &key->base,
>                                 vp->program.Base.UsesClipDistanceOut);
>  
>     /* _NEW_POLYGON */
>     if (brw->gen < 6) {
> -      key.copy_edgeflag = (ctx->Polygon.FrontMode != GL_FILL ||
> -                           ctx->Polygon.BackMode != GL_FILL);
> +      key->copy_edgeflag = (ctx->Polygon.FrontMode != GL_FILL ||
> +                            ctx->Polygon.BackMode != GL_FILL);
>     }
>  
>     if (prog->OutputsWritten & (VARYING_BIT_COL0 | VARYING_BIT_COL1 |
>                                 VARYING_BIT_BFC0 | VARYING_BIT_BFC1)) {
>        /* _NEW_LIGHT | _NEW_BUFFERS */
> -      key.clamp_vertex_color = ctx->Light._ClampVertexColor;
> +      key->clamp_vertex_color = ctx->Light._ClampVertexColor;
>     }
>  
>     /* _NEW_POINT */
>     if (brw->gen < 6 && ctx->Point.PointSprite) {
>        for (i = 0; i < 8; i++) {
>  	 if (ctx->Point.CoordReplace[i])
> -	    key.point_coord_replace |= (1 << i);
> +	    key->point_coord_replace |= (1 << i);
>        }
>     }
>  
>     /* _NEW_TEXTURE */
>     brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.base.sampler_count,
> -                                      &key.base.tex);
> +                                      &key->base.tex);
>  
>     /* BRW_NEW_VS_ATTRIB_WORKAROUNDS */
> -   memcpy(key.gl_attrib_wa_flags, brw->vb.attrib_wa_flags,
> +   memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags,
>            sizeof(brw->vb.attrib_wa_flags));
> +}
> +
> +void
> +brw_upload_vs_prog(struct brw_context *brw)
> +{
> +   struct gl_context *ctx = &brw->ctx;
> +   struct brw_vs_prog_key key;
> +   /* BRW_NEW_VERTEX_PROGRAM */
> +   struct brw_vertex_program *vp =
> +      (struct brw_vertex_program *)brw->vertex_program;
> +
> +   if (!brw_state_dirty(brw,
> +                        _NEW_BUFFERS |
> +                        _NEW_LIGHT |
> +                        _NEW_POINT |
> +                        _NEW_POLYGON |
> +                        _NEW_TEXTURE |
> +                        _NEW_TRANSFORM,
> +                        BRW_NEW_VERTEX_PROGRAM |
> +                        BRW_NEW_VS_ATTRIB_WORKAROUNDS))
> +      return;
> +
> +   brw_vs_populate_key(brw, &key);
>  
>     if (!brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
>  			 &key, sizeof(key),
> 



More information about the mesa-dev mailing list