draw: add support for passing buffers to vs/gs shaders.
authorDave Airlie <airlied@redhat.com>
Mon, 11 Apr 2016 02:59:25 +0000 (12:59 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 12 Apr 2016 04:15:36 +0000 (14:15 +1000)
Like the image code, but for shader buffers this time.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_vs_exec.c

index 2ba9b09966456991594cdaa165e4a555315dcfb7..75551fbe2dd6fb3acf487b7a31e69df3d498587d 100644 (file)
@@ -749,7 +749,23 @@ draw_image(struct draw_context *draw,
    }
 }
 
-
+/**
+ * Provide TGSI buffer objects for vertex/geometry shaders that use
+ * load/store/atomic ops.  This state only needs to be set once per context.
+ * This might only be used by software drivers for the time being.
+ */
+void
+draw_buffer(struct draw_context *draw,
+            uint shader,
+            struct tgsi_buffer *buffer)
+{
+   if (shader == PIPE_SHADER_VERTEX) {
+      draw->vs.tgsi.buffer = buffer;
+   } else {
+      debug_assert(shader == PIPE_SHADER_GEOMETRY);
+      draw->gs.tgsi.buffer = buffer;
+   }
+}
 
 
 void draw_set_render( struct draw_context *draw, 
index 5d9870b115c0c7af66bf0c3d1a195b0b0ce89075..3e6722fcb7e1713af0e1210c7f33ccebe3d87070 100644 (file)
@@ -49,6 +49,7 @@ struct draw_geometry_shader;
 struct draw_fragment_shader;
 struct tgsi_sampler;
 struct tgsi_image;
+struct tgsi_buffer;
 
 /*
  * structure to contain driver internal information 
@@ -160,6 +161,11 @@ draw_image(struct draw_context *draw,
            uint shader_type,
            struct tgsi_image *image);
 
+void
+draw_buffer(struct draw_context *draw,
+           uint shader_type,
+           struct tgsi_buffer *buffer);
+
 void
 draw_set_sampler_views(struct draw_context *draw,
                        unsigned shader_stage,
index a555b26c345013b21b6f339c16748bc986883ae6..ef217fa5ceba1db1499cdcc4c7fb2d2b5078811b 100644 (file)
@@ -681,7 +681,9 @@ void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
    if (!use_llvm && shader && shader->machine->Tokens != shader->state.tokens) {
       tgsi_exec_machine_bind_shader(shader->machine,
                                     shader->state.tokens,
-                                    draw->gs.tgsi.sampler, draw->gs.tgsi.image, NULL);
+                                    draw->gs.tgsi.sampler,
+                                    draw->gs.tgsi.image,
+                                    draw->gs.tgsi.buffer);
    }
 }
 
index 211bd6f7e704f977dc8910b360b080b97241e74b..a18f6632124cbae9822fe6c4c5cea6d1e5949ee4 100644 (file)
@@ -67,6 +67,7 @@ struct vbuf_render;
 struct tgsi_exec_machine;
 struct tgsi_sampler;
 struct tgsi_image;
+struct tgsi_buffer;
 struct draw_pt_front_end;
 struct draw_assembler;
 struct draw_llvm;
@@ -269,6 +270,7 @@ struct draw_context
 
          struct tgsi_sampler *sampler;
          struct tgsi_image *image;
+         struct tgsi_buffer *buffer;
       } tgsi;
 
       struct translate *fetch;
@@ -289,6 +291,7 @@ struct draw_context
 
          struct tgsi_sampler *sampler;
          struct tgsi_image *image;
+         struct tgsi_buffer *buffer;
       } tgsi;
 
    } gs;
index feb222b8fa5093fc06990c6c30e2cf4ae6f3ee90..da0d1a7f9a8f8d79cb6aadfbfd242238312bb744 100644 (file)
@@ -70,7 +70,9 @@ vs_exec_prepare( struct draw_vertex_shader *shader,
    if (evs->machine->Tokens != shader->state.tokens) {
       tgsi_exec_machine_bind_shader(evs->machine,
                                     shader->state.tokens,
-                                    draw->vs.tgsi.sampler, draw->vs.tgsi.image, NULL);
+                                    draw->vs.tgsi.sampler,
+                                    draw->vs.tgsi.image,
+                                    draw->vs.tgsi.buffer);
    }
 }