[Mesa-dev] [PATCH] i965: make more effective use of SamplersUsed

Pohjolainen, Topi topi.pohjolainen at intel.com
Tue Jul 5 13:33:47 UTC 2016


On Tue, Jul 05, 2016 at 04:03:54PM +0300, Pohjolainen, Topi wrote:
> On Tue, Jul 05, 2016 at 05:10:53PM +1000, Timothy Arceri wrote:
> > ---
> >  src/mesa/drivers/dri/i965/brw_cs.c      |  3 +--
> >  src/mesa/drivers/dri/i965/brw_gs.c      |  4 +---
> >  src/mesa/drivers/dri/i965/brw_program.h |  1 -
> >  src/mesa/drivers/dri/i965/brw_tcs.c     |  5 +----
> >  src/mesa/drivers/dri/i965/brw_tes.c     |  5 +----
> >  src/mesa/drivers/dri/i965/brw_vs.c      |  3 +--
> >  src/mesa/drivers/dri/i965/brw_wm.c      | 12 +++++-------
> >  7 files changed, 10 insertions(+), 23 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c
> > index d33b260..32c56c2 100644
> > --- a/src/mesa/drivers/dri/i965/brw_cs.c
> > +++ b/src/mesa/drivers/dri/i965/brw_cs.c
> > @@ -198,8 +198,7 @@ brw_cs_populate_key(struct brw_context *brw, struct brw_cs_prog_key *key)
> >     memset(key, 0, sizeof(*key));
> >  
> >     /* _NEW_TEXTURE */
> > -   brw_populate_sampler_prog_key_data(ctx, prog, brw->cs.base.sampler_count,
> > -                                      &key->tex);
> > +   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
> >  
> >     /* The unique compute program ID */
> >     key->program_string_id = cp->id;
> > diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
> > index cea9dda..df0b972 100644
> > --- a/src/mesa/drivers/dri/i965/brw_gs.c
> > +++ b/src/mesa/drivers/dri/i965/brw_gs.c
> > @@ -209,7 +209,6 @@ brw_gs_populate_key(struct brw_context *brw,
> >                      struct brw_gs_prog_key *key)
> >  {
> >     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;
> > @@ -219,8 +218,7 @@ brw_gs_populate_key(struct brw_context *brw,
> >     key->program_string_id = gp->id;
> >  
> >     /* _NEW_TEXTURE */
> > -   brw_populate_sampler_prog_key_data(ctx, prog, stage_state->sampler_count,
> > -                                      &key->tex);
> > +   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
> >  }
> >  
> >  void
> > diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
> > index 620ac3e..eed07a2 100644
> > --- a/src/mesa/drivers/dri/i965/brw_program.h
> > +++ b/src/mesa/drivers/dri/i965/brw_program.h
> > @@ -44,7 +44,6 @@ void brw_setup_tex_for_precompile(struct brw_context *brw,
> >  
> >  void brw_populate_sampler_prog_key_data(struct gl_context *ctx,
> >  				        const struct gl_program *prog,
> > -                                        unsigned sampler_count,
> >  				        struct brw_sampler_prog_key_data *key);
> >  bool brw_debug_recompile_sampler_key(struct brw_context *brw,
> >                                       const struct brw_sampler_prog_key_data *old_key,
> > diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
> > index 15265c0..19b36e5 100644
> > --- a/src/mesa/drivers/dri/i965/brw_tcs.c
> > +++ b/src/mesa/drivers/dri/i965/brw_tcs.c
> > @@ -324,7 +324,6 @@ brw_tcs_populate_key(struct brw_context *brw,
> >     struct brw_tess_eval_program *tep =
> >        (struct brw_tess_eval_program *) brw->tess_eval_program;
> >     struct gl_program *prog = &tcp->program.Base;
> > -   struct brw_stage_state *stage_state = &brw->tcs.base;
> >  
> >     memset(key, 0, sizeof(*key));
> >  
> > @@ -347,9 +346,7 @@ brw_tcs_populate_key(struct brw_context *brw,
> >        key->program_string_id = tcp->id;
> >  
> >        /* _NEW_TEXTURE */
> > -      brw_populate_sampler_prog_key_data(&brw->ctx, prog,
> > -                                         stage_state->sampler_count,
> > -                                         &key->tex);
> > +      brw_populate_sampler_prog_key_data(&brw->ctx, prog, &key->tex);
> >     } else {
> >        key->outputs_written = tep->program.Base.InputsRead;
> >     }
> > diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
> > index 1abc7cb..8105d31 100644
> > --- a/src/mesa/drivers/dri/i965/brw_tes.c
> > +++ b/src/mesa/drivers/dri/i965/brw_tes.c
> > @@ -242,7 +242,6 @@ brw_tes_populate_key(struct brw_context *brw,
> >     struct brw_tess_eval_program *tep =
> >        (struct brw_tess_eval_program *) brw->tess_eval_program;
> >     struct gl_program *prog = &tep->program.Base;
> > -   struct brw_stage_state *stage_state = &brw->tes.base;
> >  
> >     memset(key, 0, sizeof(*key));
> >  
> > @@ -266,9 +265,7 @@ brw_tes_populate_key(struct brw_context *brw,
> >     key->patch_inputs_read = per_patch_slots;
> >  
> >     /* _NEW_TEXTURE */
> > -   brw_populate_sampler_prog_key_data(&brw->ctx, prog,
> > -                                      stage_state->sampler_count,
> > -                                      &key->tex);
> > +   brw_populate_sampler_prog_key_data(&brw->ctx, prog, &key->tex);
> >  }
> >  
> >  void
> > diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
> > index 273fe3c..280e625 100644
> > --- a/src/mesa/drivers/dri/i965/brw_vs.c
> > +++ b/src/mesa/drivers/dri/i965/brw_vs.c
> > @@ -347,8 +347,7 @@ brw_vs_populate_key(struct brw_context *brw,
> >     }
> >  
> >     /* _NEW_TEXTURE */
> > -   brw_populate_sampler_prog_key_data(ctx, prog, brw->vs.base.sampler_count,
> > -                                      &key->tex);
> > +   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
> >  
> >     /* BRW_NEW_VS_ATTRIB_WORKAROUNDS */
> >     memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags,
> > diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
> > index 03335f0..29b027d 100644
> > --- a/src/mesa/drivers/dri/i965/brw_wm.c
> > +++ b/src/mesa/drivers/dri/i965/brw_wm.c
> > @@ -308,16 +308,15 @@ gen6_gather_workaround(GLenum internalformat)
> >  void
> >  brw_populate_sampler_prog_key_data(struct gl_context *ctx,
> >  				   const struct gl_program *prog,
> > -                                   unsigned sampler_count,
> >  				   struct brw_sampler_prog_key_data *key)
> >  {
> >     struct brw_context *brw = brw_context(ctx);
> > +   GLbitfield mask = prog->SamplersUsed;
> >  
> > -   for (int s = 0; s < sampler_count; s++) {
> > -      key->swizzles[s] = SWIZZLE_NOOP;
> > +   while (mask) {
> 
> Aren't you looping here infinitely - I can't see mask being updated?
> 
> > +      const int s = u_bit_scan(&mask);

Ah, right, scan clears what it reads. Sorry for the noise.

> >  
> > -      if (!(prog->SamplersUsed & (1 << s)))
> > -	 continue;
> > +      key->swizzles[s] = SWIZZLE_NOOP;
> >  
> >        int unit_id = prog->SamplerUnits[s];
> >        const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
> > @@ -508,8 +507,7 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
> >     key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
> >  
> >     /* _NEW_TEXTURE */
> > -   brw_populate_sampler_prog_key_data(ctx, prog, brw->wm.base.sampler_count,
> > -                                      &key->tex);
> > +   brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
> >  
> >     /* _NEW_BUFFERS */
> >     key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list