[Mesa-dev] [PATCH 09/23] i965: Make brw_upload_sampler_state_table handle Gen7+ as well.

Kenneth Graunke kenneth at whitecape.org
Wed Jul 30 11:42:36 PDT 2014


On Wednesday, July 30, 2014 10:32:12 AM Pohjolainen, Topi wrote:
> On Tue, Jul 29, 2014 at 04:29:14PM -0700, Kenneth Graunke wrote:
> > This copies a few changes from gen7_upload_sampler_state_table; the next
> > patch will delete that function.
> > 
> > Gen7+ has per-stage sampler state pointer update packets, so we emit
> > them as soon as we emit a new table for a stage.  On Gen6 and earlier,
> > we have a single packet, so we delay until we've changed everything
> > that's going to be changed.
> > 
> > Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> > ---
> >  src/mesa/drivers/dri/i965/brw_sampler_state.c  | 39 +++++++++++++++++++++++---
> >  src/mesa/drivers/dri/i965/brw_state.h          |  3 ++
> >  src/mesa/drivers/dri/i965/gen7_sampler_state.c |  2 +-
> >  3 files changed, 39 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
> > index a14b5b3..dc351bd 100644
> > --- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
> > +++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
> > @@ -39,6 +39,7 @@
> >  #include "brw_context.h"
> >  #include "brw_state.h"
> >  #include "brw_defines.h"
> > +#include "intel_batchbuffer.h"
> >  #include "intel_mipmap_tree.h"
> >  
> >  #include "main/macros.h"
> > @@ -402,9 +403,16 @@ brw_upload_sampler_state_table(struct brw_context *brw,
> >        if (SamplersUsed & (1 << s)) {
> >           const unsigned unit = prog->SamplerUnits[s];
> >           if (ctx->Texture.Unit[unit]._Current) {
> > -            brw_update_sampler_state(brw, unit,
> > -                                     (struct brw_sampler_state *) sampler_state,
> > -                                     batch_offset_for_sampler_state);
> > +            if (brw->gen >= 7) {
> > +               gen7_update_sampler_state(brw, unit,
> > +                                         (struct gen7_sampler_state *)
> > +                                         sampler_state);
> > +            } else {
> > +               brw_update_sampler_state(brw, unit,
> > +                                        (struct brw_sampler_state *)
> > +                                        sampler_state,
> > +                                        batch_offset_for_sampler_state);
> > +            }
> >           }
> >        }
> >  
> > @@ -412,7 +420,30 @@ brw_upload_sampler_state_table(struct brw_context *brw,
> >        batch_offset_for_sampler_state += size_in_bytes;
> >     }
> >  
> > -   brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
> > +   if (brw->gen >= 7) {
> > +      /* Emit a 3DSTATE_SAMPLER_STATE_POINTERS_XS packet. */
> > +      static const uint16_t packet_headers[] = {
> > +         [MESA_SHADER_VERTEX] = _3DSTATE_SAMPLER_STATE_POINTERS_VS,
> > +         [MESA_SHADER_GEOMETRY] = _3DSTATE_SAMPLER_STATE_POINTERS_GS,
> > +         [MESA_SHADER_FRAGMENT] = _3DSTATE_SAMPLER_STATE_POINTERS_PS,
> > +      };
> > +
> > +      /* Ivybridge requires a workaround flush before VS packets. */
> > +      if (brw->gen == 7 && !brw->is_haswell && !brw->is_baytrail &&
> > +          stage_state->stage == MESA_SHADER_VERTEX) {
> > +         gen7_emit_vs_workaround_flush(brw);
> > +      }
> > +
> > +      BEGIN_BATCH(2);
> > +      OUT_BATCH(packet_headers[stage_state->stage] << 16 | (2 - 2));
> > +      OUT_BATCH(stage_state->sampler_offset);
> > +      ADVANCE_BATCH();
> 
> This is purely matter of taste but to me it would have been clearer to have
> the contents of this block in a helper function, say
> gen7_emit_3d_state_sampler_state_pointers_xs().

I like that idea.  I've created a gen7_emit_sampler_state_pointers_xs() helper in v2.
-------------- 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/d8d3e6d5/attachment-0001.sig>


More information about the mesa-dev mailing list