<div dir="ltr"><div><div><div>Hi,<br>Sounds great but, do you think a separate buffer pipe is required for this? Changing Constant buffer to a generic buffer (with alu+load+store) can help.<br></div><br></div>What about for R600? Do we have to add<br><br><span class="">r600_init_atom</span>(rctx, &rctx->shaderbuf_state[PIPE_SHADER_VERTEX].<span class="">atom</span>, id++, r600_emit_vs_shader_buffers, <span class="">0</span>); <br><br></div><div>to backend? Will this be specific to Atomics?<br><br></div><div>Thank you!!<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 7, 2015 at 4:56 AM, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
set_shader_resources is unused.<br>
<br>
set_shader_buffers should support shader atomic counter buffers and shader<br>
storage buffers from OpenGL.<br>
<br>
The plan is to use slots 0..15 for atomic counters and slots 16..31<br>
for storage buffers. Atomic counters are planned to be supported first.<br>
<br>
This doesn't add any interface for images. The documentation is added<br>
for future reference.<br>
---<br>
<br>
This is the interface only. I don't plan to do anything else for now.<br>
Comments welcome.<br>
<br>
 src/gallium/docs/source/context.rst             | 16 ++++++++--------<br>
 src/gallium/docs/source/screen.rst              |  4 ++--<br>
 src/gallium/drivers/galahad/glhd_context.c      |  2 +-<br>
 src/gallium/drivers/ilo/ilo_state.c             |  2 +-<br>
 src/gallium/drivers/nouveau/nouveau_buffer.c    |  2 +-<br>
 src/gallium/drivers/nouveau/nouveau_screen.c    |  2 +-<br>
 src/gallium/drivers/nouveau/nv50/nv50_formats.c |  2 +-<br>
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c   |  2 +-<br>
 src/gallium/include/pipe/p_context.h            | 20 +++++++++++---------<br>
 src/gallium/include/pipe/p_defines.h            |  2 +-<br>
 src/gallium/include/pipe/p_state.h              | 10 ++++++++++<br>
 11 files changed, 38 insertions(+), 26 deletions(-)<br>
<br>
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst<br>
index 5861f46..73fd35f 100644<br>
--- a/src/gallium/docs/source/context.rst<br>
+++ b/src/gallium/docs/source/context.rst<br>
@@ -126,14 +126,14 @@ from a shader without an associated sampler.  This means that they<br>
 have no support for floating point coordinates, address wrap modes or<br>
 filtering.<br>
<br>
-Shader resources are specified for all the shader stages at once using<br>
-the ``set_shader_resources`` method.  When binding texture resources,<br>
-the ``level``, ``first_layer`` and ``last_layer`` pipe_surface fields<br>
-specify the mipmap level and the range of layers the texture will be<br>
-constrained to.  In the case of buffers, ``first_element`` and<br>
-``last_element`` specify the range within the buffer that will be used<br>
-by the shader resource.  Writes to a shader resource are only allowed<br>
-when the ``writable`` flag is set.<br>
+There are 2 types of shader resources: buffers and images.<br>
+<br>
+Buffers are specified using the ``set_shader_buffers`` method.<br>
+<br>
+Images are specified using the ``set_shader_images`` method. When binding<br>
+images, the ``level``, ``first_layer`` and ``last_layer`` pipe_image_view<br>
+fields specify the mipmap level and the range of layers the image will be<br>
+constrained to.<br>
<br>
 Surfaces<br>
 ^^^^^^^^<br>
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst<br>
index 55d114c..c81ad66 100644<br>
--- a/src/gallium/docs/source/screen.rst<br>
+++ b/src/gallium/docs/source/screen.rst<br>
@@ -403,8 +403,8 @@ resources might be created and handled quite differently.<br>
   process.<br>
 * ``PIPE_BIND_GLOBAL``: A buffer that can be mapped into the global<br>
   address space of a compute program.<br>
-* ``PIPE_BIND_SHADER_RESOURCE``: A buffer or texture that can be<br>
-  bound to the graphics pipeline as a shader resource.<br>
+* ``PIPE_BIND_SHADER_BUFFER``: A buffer that can be bound to a shader where<br>
+  it should support reads, writes, and atomics.<br>
 * ``PIPE_BIND_COMPUTE_RESOURCE``: A buffer or texture that can be<br>
   bound to the compute program as a shader resource.<br>
 * ``PIPE_BIND_COMMAND_ARGS_BUFFER``: A buffer that may be sourced by the<br>
diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c<br>
index 37ea170..383d76c 100644<br>
--- a/src/gallium/drivers/galahad/glhd_context.c<br>
+++ b/src/gallium/drivers/galahad/glhd_context.c<br>
@@ -1017,7 +1017,7 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)<br>
    GLHD_PIPE_INIT(set_scissor_states);<br>
    GLHD_PIPE_INIT(set_viewport_states);<br>
    GLHD_PIPE_INIT(set_sampler_views);<br>
-   //GLHD_PIPE_INIT(set_shader_resources);<br>
+   //GLHD_PIPE_INIT(set_shader_buffers);<br>
    GLHD_PIPE_INIT(set_vertex_buffers);<br>
    GLHD_PIPE_INIT(set_index_buffer);<br>
    GLHD_PIPE_INIT(create_stream_output_target);<br>
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c<br>
index b852f9f..09209ec 100644<br>
--- a/src/gallium/drivers/ilo/ilo_state.c<br>
+++ b/src/gallium/drivers/ilo/ilo_state.c<br>
@@ -1267,7 +1267,7 @@ ilo_init_state_functions(struct ilo_context *ilo)<br>
    ilo->base.set_scissor_states = ilo_set_scissor_states;<br>
    ilo->base.set_viewport_states = ilo_set_viewport_states;<br>
    ilo->base.set_sampler_views = ilo_set_sampler_views;<br>
-   ilo->base.set_shader_resources = ilo_set_shader_resources;<br>
+   //ilo->base.set_shader_resources = ilo_set_shader_resources;<br>
    ilo->base.set_vertex_buffers = ilo_set_vertex_buffers;<br>
    ilo->base.set_index_buffer = ilo_set_index_buffer;<br>
<br>
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c<br>
index 49ff100..722c516 100644<br>
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c<br>
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c<br>
@@ -44,7 +44,7 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,<br>
<br>
    if (buf->base.bind & (PIPE_BIND_CONSTANT_BUFFER |<br>
                          PIPE_BIND_COMPUTE_RESOURCE |<br>
-                         PIPE_BIND_SHADER_RESOURCE))<br>
+                         PIPE_BIND_SHADER_BUFFER))<br>
       size = align(size, 0x100);<br>
<br>
    if (domain == NOUVEAU_BO_VRAM) {<br>
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c<br>
index 517978d..68ab672 100644<br>
--- a/src/gallium/drivers/nouveau/nouveau_screen.c<br>
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c<br>
@@ -197,7 +197,7 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)<br>
                PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT |<br>
                PIPE_BIND_CURSOR |<br>
                PIPE_BIND_SAMPLER_VIEW |<br>
-               PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE |<br>
+               PIPE_BIND_SHADER_BUFFER | PIPE_BIND_COMPUTE_RESOURCE |<br>
                PIPE_BIND_GLOBAL;<br>
        screen->sysmem_bindings =<br>
                PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT |<br>
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_formats.c b/src/gallium/drivers/nouveau/nv50/nv50_formats.c<br>
index d394015..4fc8380 100644<br>
--- a/src/gallium/drivers/nouveau/nv50/nv50_formats.c<br>
+++ b/src/gallium/drivers/nouveau/nv50/nv50_formats.c<br>
@@ -44,7 +44,7 @@<br>
  */<br>
 #define U_V   PIPE_BIND_VERTEX_BUFFER<br>
 #define U_T   PIPE_BIND_SAMPLER_VIEW<br>
-#define U_I   PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE<br>
+#define U_I   PIPE_BIND_SHADER_BUFFER | PIPE_BIND_COMPUTE_RESOURCE<br>
 #define U_TR  PIPE_BIND_RENDER_TARGET | U_T<br>
 #define U_IR  U_TR | U_I<br>
 #define U_TB  PIPE_BIND_BLENDABLE | U_TR<br>
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c<br>
index 728618f..f8fb955 100644<br>
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c<br>
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c<br>
@@ -1269,7 +1269,7 @@ nvc0_init_state_functions(struct nvc0_context *nvc0)<br>
<br>
    pipe->set_global_binding = nvc0_set_global_bindings;<br>
    pipe->set_compute_resources = nvc0_set_compute_resources;<br>
-   pipe->set_shader_resources = nvc0_set_shader_resources;<br>
+   //pipe->set_shader_resources = nvc0_set_shader_resources;<br>
<br>
    nvc0->sample_mask = ~0;<br>
    nvc0->min_samples = 1;<br>
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h<br>
index af5674f..641b93a 100644<br>
--- a/src/gallium/include/pipe/p_context.h<br>
+++ b/src/gallium/include/pipe/p_context.h<br>
@@ -57,6 +57,7 @@ struct pipe_resource;<br>
 struct pipe_sampler_state;<br>
 struct pipe_sampler_view;<br>
 struct pipe_scissor_state;<br>
+struct pipe_shader_buffer;<br>
 struct pipe_shader_state;<br>
 struct pipe_stencil_ref;<br>
 struct pipe_stream_output_target;<br>
@@ -222,20 +223,21 @@ struct pipe_context {<br>
                              struct pipe_sampler_view **);<br>
<br>
    /**<br>
-    * Bind an array of shader resources that will be used by the<br>
-    * graphics pipeline.  Any resources that were previously bound to<br>
-    * the specified range will be unbound after this call.<br>
+    * Bind an array of shader buffers that will be used by a shader.<br>
+    * Any resources that were previously bound to the specified range<br>
+    * will be unbound.<br>
     *<br>
-    * \param start      first resource to bind.<br>
-    * \param count      number of consecutive resources to bind.<br>
-    * \param resources  array of pointers to the resources to bind, it<br>
+    * \param shader     shader stage where the buffers will be bound.<br>
+    * \param start_slot first buffer slot to bind.<br>
+    * \param count      number of consecutive buffers to bind.<br>
+    * \param buffers    array of pointers to the buffers to bind, it<br>
     *                   should contain at least \a count elements<br>
     *                   unless it's NULL, in which case no new<br>
     *                   resources will be bound.<br>
     */<br>
-   void (*set_shader_resources)(struct pipe_context *,<br>
-                                unsigned start, unsigned count,<br>
-                                struct pipe_surface **resources);<br>
+   void (*set_shader_buffers)(struct pipe_context *, unsigned shader,<br>
+                              unsigned start_slot, unsigned count,<br>
+                              struct pipe_shader_buffer *buffers);<br>
<br>
    void (*set_vertex_buffers)( struct pipe_context *,<br>
                                unsigned start_slot,<br>
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index 6c5703a..b964fd6 100644<br>
--- a/src/gallium/include/pipe/p_defines.h<br>
+++ b/src/gallium/include/pipe/p_defines.h<br>
@@ -348,7 +348,7 @@ enum pipe_flush_flags {<br>
 #define PIPE_BIND_CURSOR               (1 << 16) /* mouse cursor */<br>
 #define PIPE_BIND_CUSTOM               (1 << 17) /* state-tracker/winsys usages */<br>
 #define PIPE_BIND_GLOBAL               (1 << 18) /* set_global_binding */<br>
-#define PIPE_BIND_SHADER_RESOURCE      (1 << 19) /* set_shader_resources */<br>
+#define PIPE_BIND_SHADER_BUFFER        (1 << 19) /* set_shader_buffers */<br>
 #define PIPE_BIND_COMPUTE_RESOURCE     (1 << 20) /* set_compute_resources */<br>
 #define PIPE_BIND_COMMAND_ARGS_BUFFER  (1 << 21) /* pipe_draw_info.indirect */<br>
<br>
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h<br>
index 43bc48b..450a270 100644<br>
--- a/src/gallium/include/pipe/p_state.h<br>
+++ b/src/gallium/include/pipe/p_state.h<br>
@@ -464,6 +464,16 @@ struct pipe_constant_buffer {<br>
<br>
<br>
 /**<br>
+ * An untyped shader buffer supporting loads, stores, and atomics.<br>
+ */<br>
+struct pipe_shader_buffer {<br>
+   struct pipe_resource *buffer; /**< the actual buffer */<br>
+   unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */<br>
+   unsigned buffer_size;   /**< how much data can be read in shader */<br>
+};<br>
+<br>
+<br>
+/**<br>
  * A stream output target. The structure specifies the range vertices can<br>
  * be written to.<br>
  *<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.0<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>
</font></span></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>