<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Nov 9, 2017 at 2:42 PM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thursday, November 9, 2017 12:31:18 PM PST Jason Ekstrand wrote:<br>
> On Thu, Nov 9, 2017 at 12:45 AM, Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> wrote:<br>
><br>
> > This fixes the missing AutomaticSize handling in the ABO code, removes<br>
> > a bunch of duplicated code, and drops an extra layer of wrapping around<br>
> > brw_emit_buffer_surface_state(<wbr>).<br>
> > ---<br>
> >  src/mesa/drivers/dri/i965/brw_<wbr>context.h          |  10 --<br>
> >  src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c | 113<br>
> > +++++++----------------<br>
> >  src/mesa/drivers/dri/i965/<wbr>gen6_constant_state.c  |   7 +-<br>
> >  3 files changed, 36 insertions(+), 94 deletions(-)<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
> > b/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
> > index 8aa0c5ff64c..5d19a6bfc9a 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
> > @@ -1395,16 +1395,6 @@ brw_get_index_type(unsigned index_size)<br>
> >  void brw_prepare_vertices(struct brw_context *brw);<br>
> ><br>
> >  /* brw_wm_surface_state.c */<br>
> > -void brw_create_constant_surface(<wbr>struct brw_context *brw,<br>
> > -                                 struct brw_bo *bo,<br>
> > -                                 uint32_t offset,<br>
> > -                                 uint32_t size,<br>
> > -                                 uint32_t *out_offset);<br>
> > -void brw_create_buffer_surface(<wbr>struct brw_context *brw,<br>
> > -                               struct brw_bo *bo,<br>
> > -                               uint32_t offset,<br>
> > -                               uint32_t size,<br>
> > -                               uint32_t *out_offset);<br>
> >  void brw_update_buffer_texture_<wbr>surface(struct gl_context *ctx,<br>
> >                                         unsigned unit,<br>
> >                                         uint32_t *surf_offset);<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> > index 27c241a87af..a483ba34151 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> > @@ -672,44 +672,6 @@ brw_update_buffer_texture_<wbr>surface(struct gl_context<br>
> > *ctx,<br>
> >                                   0);<br>
> >  }<br>
> ><br>
> > -/**<br>
> > - * Create the constant buffer surface.  Vertex/fragment shader constants<br>
> > will be<br>
> > - * read from this buffer with Data Port Read instructions/messages.<br>
> > - */<br>
> > -void<br>
> > -brw_create_constant_surface(<wbr>struct brw_context *brw,<br>
> > -                           struct brw_bo *bo,<br>
> > -                           uint32_t offset,<br>
> > -                           uint32_t size,<br>
> > -                           uint32_t *out_offset)<br>
> > -{<br>
> > -   brw_emit_buffer_surface_state(<wbr>brw, out_offset, bo, offset,<br>
> > -                                 ISL_FORMAT_R32G32B32A32_FLOAT,<br>
> > -                                 size, 1, 0);<br>
> > -}<br>
> > -<br>
> > -/**<br>
> > - * Create the buffer surface. Shader buffer variables will be<br>
> > - * read from / write to this buffer with Data Port Read/Write<br>
> > - * instructions/messages.<br>
> > - */<br>
> > -void<br>
> > -brw_create_buffer_surface(<wbr>struct brw_context *brw,<br>
> > -                          struct brw_bo *bo,<br>
> > -                          uint32_t offset,<br>
> > -                          uint32_t size,<br>
> > -                          uint32_t *out_offset)<br>
> > -{<br>
> > -   /* Use a raw surface so we can reuse existing untyped read/write/atomic<br>
> > -    * messages. We need these specifically for the fragment shader since<br>
> > they<br>
> > -    * include a pixel mask header that we need to ensure correct behavior<br>
> > -    * with helper invocations, which cannot write to the buffer.<br>
> > -    */<br>
> > -   brw_emit_buffer_surface_state(<wbr>brw, out_offset, bo, offset,<br>
> > -                                 ISL_FORMAT_RAW,<br>
> > -                                 size, 1, RELOC_WRITE);<br>
> > -}<br>
> > -<br>
> >  /**<br>
> >   * Set up a binding table entry for use by stream output logic (transform<br>
> >   * feedback).<br>
> > @@ -1271,6 +1233,31 @@ const struct brw_tracked_state<br>
> > brw_cs_texture_surfaces = {<br>
> >     .emit = brw_update_cs_texture_<wbr>surfaces,<br>
> >  };<br>
> ><br>
> > +static void<br>
> > +upload_buffer_surface(struct brw_context *brw,<br>
> > +                      struct gl_buffer_binding *binding,<br>
> > +                      uint32_t *out_offset,<br>
> > +                      enum isl_format format,<br>
> > +                      unsigned reloc_flags)<br>
> > +{<br>
> > +   struct gl_context *ctx = &brw->ctx;<br>
> > +<br>
> > +   if (binding->BufferObject == ctx->Shared->NullBufferObj) {<br>
> > +      emit_null_surface_state(brw, NULL, out_offset);<br>
> > +   } else {<br>
> > +      ptrdiff_t size = binding->BufferObject->Size - binding->Offset;<br>
> > +      if (!binding->AutomaticSize)<br>
> > +         size = MIN2(size, binding->Size);<br>
> > +<br>
> > +      struct intel_buffer_object *iobj =<br>
> > +         intel_buffer_object(binding-><wbr>BufferObject);<br>
> > +      struct brw_bo *bo =<br>
> > +         intel_bufferobj_buffer(brw, iobj, binding->Offset, size, false);<br>
> ><br>
><br>
> You're using this for both reads and writes.  I think you need another<br>
> boolean parameter instead of simply passing false all the time.  Other than<br>
> that, looks good.<br>
<br>
</div></div>Whoops, thanks for catching that!  I've changed it from 'false' to<br>
(reloc_flags & RELOC_WRITE) != 0.<br>
<br>
With that change, should I add your R-b?<br>
</blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Yeah, that's probably ok.  I don't know how I feel about keying it off of the reloc flag as opposed to the other way around but I don't care too much.  With that, it would be</div><div class="gmail_extra"><br></div><div class="gmail_extra">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div></div>