[Mesa-dev] [PATCH] st/mesa: In update_samplers(), clear all samplers at once.

Tilman Sauerbeck tilman at code-monkey.de
Mon Mar 21 11:55:26 PDT 2011


Keith Whitwell [2011-03-21 18:43]:
> On Mon, 2011-03-21 at 19:28 +0100, Tilman Sauerbeck wrote:
> > Signed-off-by: Tilman Sauerbeck <tilman at code-monkey.de>
> > ---
> > 
> > update_samplers() showed up in a profile of Heroes of Newerth;
> > this patch pushes it down the profile by ~3%.
> > 
> > Does this seem plausible?
> > 
> >  src/mesa/state_tracker/st_atom_sampler.c |    5 +++--
> >  1 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
> > index 474cbd5..4374ac1 100644
> > --- a/src/mesa/state_tracker/st_atom_sampler.c
> > +++ b/src/mesa/state_tracker/st_atom_sampler.c
> > @@ -129,12 +129,13 @@ update_samplers(struct st_context *st)
> >  
> >     st->state.num_samplers = 0;
> >  
> > +   memset(st->state.samplers, 0, st->ctx->Const.MaxTextureImageUnits *
> > +          sizeof(struct pipe_sampler_state));
> > +
> 
> At a glance, could the memset be moved up another couple of lines and
> changed to:
> 
>  memset(st->state.samplers, 0, st->state.num_samplers * sizeof(struct pipe_sampler_state));

I wondered about this, too. Consider the case where the sampler state is
undefined when update_samplers() is called though -- then we might end
up with partially uninitialized samplers, no?

Regards,
Tilman

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110321/9e223b4e/attachment.pgp>


More information about the mesa-dev mailing list