<div dir="ltr"><div><div><div>Hi,<br></div>I agree with the solution. Considering "images" as "buffers" or "buffers" as "images" (as they are operated inside shaders but not texture units) makes sense. I think we can make atomic buffers as a part of ARB_shader_image_load_store. Because, images are 2D array of buffers with atomic operations run on them.<br><br></div>You have mentioned in our previous conversation about the un-necessity of store. The spec for ARB_shader_image_load_store says imageStore(). If we are implementing the same for atomics, then we have to use store for it too.<br><br></div>Thank you!!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 17, 2014 at 11:28 AM, Ilia Mirkin <span dir="ltr"><<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Because shader resources were already specified as pipe_surfaces (in<br>
the existing, albeit presently unused API). A pipe_surface is a<br>
wrapper around a resource that specifies what "view" of the resource<br>
should be writable, and attaches an optional format to that resource.<br>
Normally pipe_surfaces are used for render targets, but it applies<br>
just as well here. It applies especially well with a view towards<br>
ARB_shader_image_load_store.<br>
<br>
It's conceivable to make a totally separate thing for atomic buffers,<br>
but there's no good reason to -- they will have to be handled in<br>
essentially the same way as regular "image" surfaces will for<br>
ARB_shader_image_load_store.<br>
<br>
Cheers,<br>
<br>
  -ilia<br>
<br>
On Mon, Nov 17, 2014 at 11:19 AM, Aditya Avinash<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:adityaavinash1@gmail.com">adityaavinash1@gmail.com</a>> wrote:<br>
> Hi,<br>
> I am having difficulty in understanding why you implemented pipe_surface in<br>
> st_atom_atomicbuf.c.<br>
><br>
> On Mon, Nov 17, 2014 at 2:24 AM, Aditya Avinash <<a href="mailto:adityaavinash1@gmail.com">adityaavinash1@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> On Sunday, November 16, 2014, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br>
>>><br>
>>> The direction I went in was by adapting the shader resources interface<br>
>>> for this. I believe it will be possible to use for<br>
>>> shader_image_load_store as well.<br>
>><br>
>><br>
>> I asked some questions on mailing list about the implementation. I took<br>
>> the same path as uniform buffers. But, I realized that it's not efficient to<br>
>> do that.<br>
>><br>
>>><br>
>>> See <a href="https://github.com/imirkin/mesa/commits/atomic" target="_blank">https://github.com/imirkin/mesa/commits/atomic</a><br>
>>><br>
>><br>
>> The commits are similar to my previous patch. I was doing atomics similar<br>
>> to uniform buffers, Now I was changing cso_context.<br>
>><br>
>>><br>
>>> I believe that makes a lot more sense than creating a special counter<br>
>>> buffer type only to be used for this. pipe_surface has the requisite<br>
>>> offset/etc options.<br>
>><br>
>><br>
>> I thought of using uniform buffer data structure with certain flags which<br>
>> differentiate between atomics, uniforms, index. Like a generic buffer.<br>
>><br>
>>><br>
>>> I feel like I've mentioned this before when you asked questions, but<br>
>>> I'd highly recommend taking my work and improving on it (or at least<br>
>>> understanding it). It's at the point where a driver can implement the<br>
>>> backend logic, although some of the mesa/st bits are going to be<br>
>>> subject to discussion (and need fixing, it messes up the DCE tgsi<br>
>>> pass, so I just disabled it).<br>
>>><br>
>>> On Thu, Nov 13, 2014 at 12:18 AM, adityaatluri <<a href="mailto:adityaavinash1@gmail.com">adityaavinash1@gmail.com</a>><br>
>>> wrote:<br>
>>> > ---<br>
>>> >  src/gallium/include/pipe/p_context.h |  5 +++++<br>
>>> >  src/gallium/include/pipe/p_defines.h |  7 ++++++-<br>
>>> >  src/gallium/include/pipe/p_state.h   | 10 ++++++++++<br>
>>> >  3 files changed, 21 insertions(+), 1 deletion(-)<br>
>>> ><br>
>>> > diff --git a/src/gallium/include/pipe/p_context.h<br>
>>> > b/src/gallium/include/pipe/p_context.h<br>
>>> > index af5674f..bf3be31 100644<br>
>>> > --- a/src/gallium/include/pipe/p_context.h<br>
>>> > +++ b/src/gallium/include/pipe/p_context.h<br>
>>> > @@ -44,6 +44,7 @@ struct pipe_blit_info;<br>
>>> >  struct pipe_box;<br>
>>> >  struct pipe_clip_state;<br>
>>> >  struct pipe_constant_buffer;<br>
>>> > +struct pipe_counter_buffer;<br>
>>> >  struct pipe_depth_stencil_alpha_state;<br>
>>> >  struct pipe_draw_info;<br>
>>> >  struct pipe_fence_handle;<br>
>>> > @@ -201,6 +202,10 @@ struct pipe_context {<br>
>>> >                                  uint shader, uint index,<br>
>>> >                                  struct pipe_constant_buffer *buf );<br>
>>> ><br>
>>> > +   void (*set_counter_buffer)( struct pipe_context *,<br>
>>> > +                               uint shader, uint index,<br>
>>> > +                               struct pipe_counter_buffer *buf );<br>
>>> > +<br>
>>> >     void (*set_framebuffer_state)( struct pipe_context *,<br>
>>> >                                    const struct pipe_framebuffer_state<br>
>>> > * );<br>
>>> ><br>
>>> > diff --git a/src/gallium/include/pipe/p_defines.h<br>
>>> > b/src/gallium/include/pipe/p_defines.h<br>
>>> > index 8c4e415..717ab6a 100644<br>
>>> > --- a/src/gallium/include/pipe/p_defines.h<br>
>>> > +++ b/src/gallium/include/pipe/p_defines.h<br>
>>> > @@ -341,6 +341,7 @@ enum pipe_flush_flags {<br>
>>> >  #define PIPE_BIND_VERTEX_BUFFER        (1 << 4) /* set_vertex_buffers<br>
>>> > */<br>
>>> >  #define PIPE_BIND_INDEX_BUFFER         (1 << 5) /* draw_elements */<br>
>>> >  #define PIPE_BIND_CONSTANT_BUFFER      (1 << 6) /* set_constant_buffer<br>
>>> > */<br>
>>> > +#define PIPE_BIND_COUNTER_BUFFER       (1 << 7) /* set_counter_buffer<br>
>>> > */<br>
>>> >  #define PIPE_BIND_DISPLAY_TARGET       (1 << 8) /* flush_front_buffer<br>
>>> > */<br>
>>> >  #define PIPE_BIND_TRANSFER_WRITE       (1 << 9) /* transfer_map */<br>
>>> >  #define PIPE_BIND_TRANSFER_READ        (1 << 10) /* transfer_map */<br>
>>> > @@ -572,6 +573,8 @@ enum pipe_cap {<br>
>>> >     PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE = 109,<br>
>>> >     PIPE_CAP_SAMPLER_VIEW_TARGET = 110,<br>
>>> >     PIPE_CAP_CLIP_HALFZ = 111,<br>
>>> > +   PIPE_CAP_USER_COUNTER_BUFFERS = 112,<br>
>>> > +   PIPE_CAP_COUNTER_BUFFER_OFFSET_ALIGNMENT = 113,<br>
>>> >  };<br>
>>> ><br>
>>> >  #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)<br>
>>> > @@ -631,7 +634,9 @@ enum pipe_shader_cap<br>
>>> >     PIPE_SHADER_CAP_PREFERRED_IR,<br>
>>> >     PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED,<br>
>>> >     PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS,<br>
>>> > -   PIPE_SHADER_CAP_DOUBLES<br>
>>> > +   PIPE_SHADER_CAP_DOUBLES,<br>
>>> > +   PIPE_SHADER_CAP_MAX_COUNTER_BUFFER_SIZE,<br>
>>> > +   PIPE_SHADER_CAP_MAX_COUNTER_BUFFERS<br>
>>> >  };<br>
>>> ><br>
>>> >  /**<br>
>>> > diff --git a/src/gallium/include/pipe/p_state.h<br>
>>> > b/src/gallium/include/pipe/p_state.h<br>
>>> > index 43bc48b..49fae5d 100644<br>
>>> > --- a/src/gallium/include/pipe/p_state.h<br>
>>> > +++ b/src/gallium/include/pipe/p_state.h<br>
>>> > @@ -57,6 +57,7 @@ extern "C" {<br>
>>> >  #define PIPE_MAX_CLIP_PLANES       8<br>
>>> >  #define PIPE_MAX_COLOR_BUFS        8<br>
>>> >  #define PIPE_MAX_CONSTANT_BUFFERS 32<br>
>>> > +#define PIPE_MAX_COUNTER_BUFFERS  32<br>
>>> >  #define PIPE_MAX_SAMPLERS         16<br>
>>> >  #define PIPE_MAX_SHADER_INPUTS    32<br>
>>> >  #define PIPE_MAX_SHADER_OUTPUTS   48 /* 32 GENERICs + POS, PSIZE, FOG,<br>
>>> > etc. */<br>
>>> > @@ -462,6 +463,15 @@ struct pipe_constant_buffer {<br>
>>> >     const void *user_buffer;  /**< pointer to a user buffer if buffer<br>
>>> > == NULL */<br>
>>> >  };<br>
>>> ><br>
>>> > +/**<br>
>>> > + * A Counter buffer. A new buffer is set everytime a variable with<br>
>>> > + * atomic_uint is defined.<br>
>>> > + */<br>
>>> > +struct pipe_counter_buffer{<br>
>>> > +   struct pipe_resource *buffer; /**< The actual buffer */<br>
>>> > +   unsigned buffer_offset; /**< The offset to start of data in buffer<br>
>>> > in bytes */<br>
>>> > +   const void *user_buffer; /**< The buffer which is created by the<br>
>>> > compiler */<br>
>>> > +};<br>
>>> ><br>
>>> >  /**<br>
>>> >   * A stream output target. The structure specifies the range vertices<br>
>>> > can<br>
>>> > --<br>
>>> > 1.9.1<br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > mesa-dev mailing list<br>
>>> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
>>> > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
>><br>
>><br>
>><br>
>> --<br>
>> Regards,<br>
>> Aditya Atluri,<br>
>> USA.<br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Regards,<br>
> Aditya Atluri,<br>
> USA.<br>
><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div><font style="font-family:trebuchet ms,sans-serif">Regards,<br></font></div><font style="font-family:trebuchet ms,sans-serif"><b style="background-color:rgb(255,255,255);color:rgb(0,0,153)">Aditya Atluri,<br></b></font></div><div><font style="font-family:trebuchet ms,sans-serif"><b style="background-color:rgb(255,255,255);color:rgb(0,0,153)">USA.<br></b></font></div><font style="font-family:trebuchet ms,sans-serif"><b style="background-color:rgb(255,255,255);color:rgb(0,0,153)"></b><span style="background-color:rgb(255,255,255);color:rgb(0,0,153)"></span></font><br></div></div>
</div>