draw: add support for passing images to vs/gs shaders.
authorDave Airlie <airlied@redhat.com>
Mon, 21 Mar 2016 21:58:39 +0000 (07:58 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 30 Mar 2016 23:14:11 +0000 (09:14 +1000)
This just adds support for passing through images to the
tgsi execution stage.

Reviewed-by: Brian Paul <brianp@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 16a261c14cf6ce3390c9bf81f2003ffc2c530fd1..2ba9b09966456991594cdaa165e4a555315dcfb7 100644 (file)
@@ -731,6 +731,24 @@ draw_texture_sampler(struct draw_context *draw,
    }
 }
 
+/**
+ * Provide TGSI image objects for vertex/geometry shaders that use
+ * texture fetches.  This state only needs to be set once per context.
+ * This might only be used by software drivers for the time being.
+ */
+void
+draw_image(struct draw_context *draw,
+           uint shader,
+           struct tgsi_image *image)
+{
+   if (shader == PIPE_SHADER_VERTEX) {
+      draw->vs.tgsi.image = image;
+   } else {
+      debug_assert(shader == PIPE_SHADER_GEOMETRY);
+      draw->gs.tgsi.image = image;
+   }
+}
+
 
 
 
index a5a6df5b72e3d2e027aa6b7c4cead51bad8466b9..5d9870b115c0c7af66bf0c3d1a195b0b0ce89075 100644 (file)
@@ -48,6 +48,7 @@ struct draw_vertex_shader;
 struct draw_geometry_shader;
 struct draw_fragment_shader;
 struct tgsi_sampler;
+struct tgsi_image;
 
 /*
  * structure to contain driver internal information 
@@ -154,6 +155,11 @@ draw_texture_sampler(struct draw_context *draw,
                      uint shader_type,
                      struct tgsi_sampler *sampler);
 
+void
+draw_image(struct draw_context *draw,
+           uint shader_type,
+           struct tgsi_image *image);
+
 void
 draw_set_sampler_views(struct draw_context *draw,
                        unsigned shader_stage,
index 2f18df8f789f909bdbe5fb1eadbb0e95d353e557..14db2d6f39d284059df37e4a9ff9efc587ed5186 100644 (file)
@@ -681,7 +681,7 @@ 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, NULL);
+                                    draw->gs.tgsi.sampler, draw->gs.tgsi.image);
    }
 }
 
index 8774bebd5f98538a11b1362503e96688637c9457..211bd6f7e704f977dc8910b360b080b97241e74b 100644 (file)
@@ -66,6 +66,7 @@ struct draw_stage;
 struct vbuf_render;
 struct tgsi_exec_machine;
 struct tgsi_sampler;
+struct tgsi_image;
 struct draw_pt_front_end;
 struct draw_assembler;
 struct draw_llvm;
@@ -267,6 +268,7 @@ struct draw_context
          struct tgsi_exec_machine *machine;
 
          struct tgsi_sampler *sampler;
+         struct tgsi_image *image;
       } tgsi;
 
       struct translate *fetch;
@@ -286,6 +288,7 @@ struct draw_context
          struct tgsi_exec_machine *machine;
 
          struct tgsi_sampler *sampler;
+         struct tgsi_image *image;
       } tgsi;
 
    } gs;
index c1266e7ffece3b197654ddbf99ee6ef46188018b..5b53cff29f012075ff804e50e82bad10124e3086 100644 (file)
@@ -70,7 +70,7 @@ 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, NULL);
+                                    draw->vs.tgsi.sampler, draw->vs.tgsi.image);
    }
 }