[Mesa-dev] [PATCH 18/23] i965: Delete redundant sampler state dumping code.

Kenneth Graunke kenneth at whitecape.org
Wed Jul 30 12:05:19 PDT 2014


On Wednesday, July 30, 2014 11:24:24 AM Pohjolainen, Topi wrote:
> On Tue, Jul 29, 2014 at 04:29:23PM -0700, Kenneth Graunke wrote:
> > Although the Gen4-6 and Gen7+ variants used different structure types,
> > they didn't use any of the fields - only the size, which is identical.
> > So both decoders did exactly the same thing.
> > 
> > Someday we should implement useful decoders for SAMPLER_STATE.
> > 
> > Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> > ---
> >  src/mesa/drivers/dri/i965/brw_state_dump.c | 39 ++++--------------------------
> >  1 file changed, 5 insertions(+), 34 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
> > index 9d83859..611998f 100644
> > --- a/src/mesa/drivers/dri/i965/brw_state_dump.c
> > +++ b/src/mesa/drivers/dri/i965/brw_state_dump.c
> > @@ -255,33 +255,9 @@ static void dump_sampler_state(struct brw_context *brw,
> >  			       uint32_t offset, uint32_t size)
> >  {
> >     int i;
> > -   struct brw_sampler_state *samp = brw->batch.bo->virtual + offset;
> > +   uint32_t *samp = brw->batch.bo->virtual + offset;
> >  
> > -   assert(brw->gen < 7);
> > -
> > -   for (i = 0; i < size / sizeof(*samp); i++) {
> > -      char name[20];
> > -
> > -      sprintf(name, "WM SAMP%d", i);
> > -      batch_out(brw, name, offset, 0, "filtering\n");
> > -      batch_out(brw, name, offset, 1, "wrapping, lod\n");
> > -      batch_out(brw, name, offset, 2, "default color pointer\n");
> > -      batch_out(brw, name, offset, 3, "chroma key, aniso\n");
> > -
> > -      samp++;
> > -      offset += sizeof(*samp);
> > -   }
> > -}
> > -
> > -static void dump_gen7_sampler_state(struct brw_context *brw,
> > -				    uint32_t offset, uint32_t size)
> > -{
> > -   struct gen7_sampler_state *samp = brw->batch.bo->virtual + offset;
> > -   int i;
> > -
> > -   assert(brw->gen >= 7);
> > -
> > -   for (i = 0; i < size / sizeof(*samp); i++) {
> > +   for (i = 0; i < size / 16; i++) {
> 
> Here you use 16, but for augmenting the offset "4 * sizeof(uint32_t)".
> How about using a helper:
> 
>          const int sampler_size = 4 * sizeof(uint32_t);

I like that a lot better.  I ended up doing:

   const int sampler_state_size = 16; /* 16 bytes */

since the comment right above it explains that SAMPLER_STATE is 16 bytes.

I'd originally used 4 * sizeof(uint32_t) to try and distinguish the 16 byte
size from the groups of 16 samplers.  But, the local variable works even better.
-------------- 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/20140730/fe6980e8/attachment.sig>


More information about the mesa-dev mailing list