gallium: add BIND flags for R/W buffers and images
authorMarek Olšák <marek.olsak@amd.com>
Sun, 5 Jul 2015 11:51:16 +0000 (13:51 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 16 Jul 2015 14:52:02 +0000 (16:52 +0200)
PIPE_CAPs and TGSI support will be added later. The TGSI support should be
straightforward. We only need to split TGSI_FILE_RESOURCE into TGSI_FILE_IMAGE
and TGSI_FILE_BUFFER, though duplicating all opcodes shouldn't be necessary.

The idea is:
* ARB_shader_image_load_store should use set_shader_images.
* ARB_shader_storage_buffer_object should use set_shader_buffers(slots 0..M-1)
  if M shader storage buffers are supported.
* ARB_shader_atomic_counters should use set_shader_buffers(slots M..N)
  if N-M+1 atomic counter buffers are supported.

PIPE_CAPs can describe various constraints for early DX11 hardware.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/auxiliary/util/u_debug.c
src/gallium/docs/source/screen.rst
src/gallium/drivers/ilo/ilo_resource.c
src/gallium/drivers/nouveau/nouveau_buffer.c
src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/nouveau/nv50/nv50_formats.c
src/gallium/include/pipe/p_defines.h

index 2d2d049b205d2c3243b07a753bf77878e652596e..cf6eca77a39f28d6b358305b42f65289f3a40def 100644 (file)
@@ -758,7 +758,8 @@ debug_print_bind_flags(const char *msg, unsigned usage)
       DEBUG_NAMED_VALUE(PIPE_BIND_CURSOR),
       DEBUG_NAMED_VALUE(PIPE_BIND_CUSTOM),
       DEBUG_NAMED_VALUE(PIPE_BIND_GLOBAL),
-      DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_RESOURCE),
+      DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_BUFFER),
+      DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_IMAGE),
       DEBUG_NAMED_VALUE(PIPE_BIND_COMPUTE_RESOURCE),
       DEBUG_NAMED_VALUE(PIPE_BIND_COMMAND_ARGS_BUFFER),
       DEBUG_NAMED_VALUE(PIPE_BIND_SCANOUT),
index 246428deb87e824ba14deeda978573392be5be40..dbdccc7fcef21b51a1e74578c26e7827032d56a7 100644 (file)
@@ -430,8 +430,10 @@ resources might be created and handled quite differently.
   process.
 * ``PIPE_BIND_GLOBAL``: A buffer that can be mapped into the global
   address space of a compute program.
-* ``PIPE_BIND_SHADER_RESOURCE``: A buffer or texture that can be
-  bound to the graphics pipeline as a shader resource.
+* ``PIPE_BIND_SHADER_BUFFER``: A buffer without a format that can be bound
+  to a shader and can be used with load, store, and atomic instructions.
+* ``PIPE_BIND_SHADER_IMAGE``: A buffer or texture with a format that can be
+  bound to a shader and can be used with load, store, and atomic instructions.
 * ``PIPE_BIND_COMPUTE_RESOURCE``: A buffer or texture that can be
   bound to the compute program as a shader resource.
 * ``PIPE_BIND_COMMAND_ARGS_BUFFER``: A buffer that may be sourced by the
index 3797c8ec24f8f630f480556392c31badba8366d1..9026ba9a9838a1e16d752a002647e36e7d48db83 100644 (file)
@@ -210,7 +210,7 @@ resource_get_image_info(const struct pipe_resource *templ,
    info->bind_surface_sampler = (templ->bind & PIPE_BIND_SAMPLER_VIEW);
    info->bind_surface_dp_render = (templ->bind & PIPE_BIND_RENDER_TARGET);
    info->bind_surface_dp_typed = (templ->bind &
-         (PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE));
+         (PIPE_BIND_SHADER_IMAGE | PIPE_BIND_COMPUTE_RESOURCE));
    info->bind_zs = (templ->bind & PIPE_BIND_DEPTH_STENCIL);
    info->bind_scanout = (templ->bind & PIPE_BIND_SCANOUT);
    info->bind_cursor = (templ->bind & PIPE_BIND_CURSOR);
index 09cdbb53ecb7cea4ac16da65c1e69807d45ec3a1..23619467231cfc739177fea34d804a018a7f3d96 100644 (file)
@@ -44,7 +44,8 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,
 
    if (buf->base.bind & (PIPE_BIND_CONSTANT_BUFFER |
                          PIPE_BIND_COMPUTE_RESOURCE |
-                         PIPE_BIND_SHADER_RESOURCE))
+                         PIPE_BIND_SHADER_BUFFER |
+                         PIPE_BIND_SHADER_IMAGE))
       size = align(size, 0x100);
 
    if (domain == NOUVEAU_BO_VRAM) {
index e5b3c159c84215b50dac9c94f1f1b981e6d77f8c..0f6313c768c1d2894fbf942527af29ac10837057 100644 (file)
@@ -209,7 +209,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
                PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT |
                PIPE_BIND_CURSOR |
                PIPE_BIND_SAMPLER_VIEW |
-               PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE |
+               PIPE_BIND_SHADER_BUFFER | PIPE_BIND_SHADER_IMAGE |
+                PIPE_BIND_COMPUTE_RESOURCE |
                PIPE_BIND_GLOBAL;
        screen->sysmem_bindings =
                PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT |
index 0f86ba1de0d0a532b0b33cfe5da2e353f89b53da..49a93bf1d91951c57ce35c3aa8a6bc115ca4e87b 100644 (file)
@@ -44,7 +44,7 @@
  */
 #define U_V   PIPE_BIND_VERTEX_BUFFER
 #define U_T   PIPE_BIND_SAMPLER_VIEW
-#define U_I   PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE
+#define U_I   PIPE_BIND_SHADER_BUFFER | PIPE_BIND_SHADER_IMAGE | PIPE_BIND_COMPUTE_RESOURCE
 #define U_TR  PIPE_BIND_RENDER_TARGET | U_T
 #define U_IR  U_TR | U_I
 #define U_TB  PIPE_BIND_BLENDABLE | U_TR
index 2dc8798f3c71ed05dd9de81675fe711e1695632a..68c536f11012e2147c00128366d689a37b9cf937 100644 (file)
@@ -351,9 +351,10 @@ enum pipe_flush_flags
 #define PIPE_BIND_CURSOR               (1 << 11) /* mouse cursor */
 #define PIPE_BIND_CUSTOM               (1 << 12) /* state-tracker/winsys usages */
 #define PIPE_BIND_GLOBAL               (1 << 13) /* set_global_binding */
-#define PIPE_BIND_SHADER_RESOURCE      (1 << 14) /* set_shader_resources */
-#define PIPE_BIND_COMPUTE_RESOURCE     (1 << 15) /* set_compute_resources */
-#define PIPE_BIND_COMMAND_ARGS_BUFFER  (1 << 16) /* pipe_draw_info.indirect */
+#define PIPE_BIND_SHADER_BUFFER        (1 << 14) /* set_shader_buffers */
+#define PIPE_BIND_SHADER_IMAGE         (1 << 15) /* set_shader_images */
+#define PIPE_BIND_COMPUTE_RESOURCE     (1 << 16) /* set_compute_resources */
+#define PIPE_BIND_COMMAND_ARGS_BUFFER  (1 << 17) /* pipe_draw_info.indirect */
 
 /**
  * The first two flags above were previously part of the amorphous
@@ -374,9 +375,9 @@ enum pipe_flush_flags
  * The third flag has been added to be able to force textures to be created
  * in linear mode (no tiling).
  */
-#define PIPE_BIND_SCANOUT     (1 << 17) /*  */
-#define PIPE_BIND_SHARED      (1 << 18) /* get_texture_handle ??? */
-#define PIPE_BIND_LINEAR      (1 << 19)
+#define PIPE_BIND_SCANOUT     (1 << 18) /*  */
+#define PIPE_BIND_SHARED      (1 << 19) /* get_texture_handle ??? */
+#define PIPE_BIND_LINEAR      (1 << 20)
 
 
 /**