[Mesa-dev] [PATCH 3/8] gallium: interface changes necessary to implement transform feedback (v4)

Marek Olšák maraeo at gmail.com
Sat Nov 19 12:44:25 PST 2011


Namely:
- EXT_transform_feedback
- ARB_transform_feedback2
- ARB_transform_feedback_instanced

The old interface was not useful for OpenGL and had to be reworked.

This interface was originally designed for OpenGL, but additional
changes have been made in order to make st/d3d1x support easier.

The most notable change is the stream-out info must be linked
with a vertex or geometry shader and cannot be set independently.
This is due to limitations of existing hardware (special shader
instructions must be used to write into stream-out buffers),
and it's also how OpenGL works (stream outputs must be specified
prior to linking shaders).

Other than that, each stream output buffer has a "view" into it that
internally maintains the number of bytes which have been written
into it. (one buffer can be bound in several different transform
feedback objects in OpenGL, so we must be able to have several views
around) The set_stream_output_targets function contains a parameter
saying whether new data should be appended or not.

Also, the view can optionally be used to provide the vertex
count for draw_vbo. Note that the count is supposed to be stored
in device memory and the CPU never gets to know its value.

OpenGL way | Gallium way
------------------------------------
BeginTF    = set_so_targets(append_bitmask = 0)
PauseTF    = set_so_targets(num_targets = 0)
ResumeTF   = set_so_targets(append_bitmask = ~0)
EndTF      = set_so_targets(num_targets = 0)
DrawTF     = use pipe_draw_info::count_from_stream_output

v2: * removed the reset_stream_output_targets function
    * added a parameter append_bitmask to set_stream_output_targets,
      each bit specifies whether new data should be appended to each
      buffer or not.
v3: * added PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME for ARB_tfb2,
      note that the draw-auto subset is always required (for d3d10),
      only the pause/resume functionality is limited if the CAP is not
      advertised
v4: * update gallium/docs
---
 src/gallium/auxiliary/draw/draw_context.c    |    4 +-
 src/gallium/auxiliary/draw/draw_context.h    |    2 +-
 src/gallium/auxiliary/draw/draw_private.h    |    2 +-
 src/gallium/auxiliary/draw/draw_pt_so_emit.c |    2 +-
 src/gallium/docs/source/context.rst          |   61 +++++++++++++------
 src/gallium/docs/source/screen.rst           |    3 +
 src/gallium/drivers/llvmpipe/lp_state.h      |    2 +-
 src/gallium/drivers/llvmpipe/lp_state_so.c   |    2 +-
 src/gallium/drivers/nv50/nv50_screen.c       |    2 +-
 src/gallium/drivers/nvc0/nvc0_screen.c       |    2 +-
 src/gallium/drivers/nvc0/nvc0_state.c        |    2 +-
 src/gallium/drivers/r300/r300_screen.c       |    2 +-
 src/gallium/drivers/r600/r600_pipe.c         |    2 +-
 src/gallium/drivers/softpipe/sp_screen.c     |    2 +-
 src/gallium/drivers/softpipe/sp_state.h      |    2 +-
 src/gallium/drivers/softpipe/sp_state_so.c   |    2 +-
 src/gallium/include/pipe/p_context.h         |   38 +++++++-----
 src/gallium/include/pipe/p_defines.h         |    8 ++-
 src/gallium/include/pipe/p_state.h           |   83 ++++++++++++++++++++------
 19 files changed, 151 insertions(+), 72 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index a444793..9c00687 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -722,11 +722,11 @@ draw_set_mapped_so_buffers(struct draw_context *draw,
 
 void
 draw_set_so_state(struct draw_context *draw,
-                  struct pipe_stream_output_state *state)
+                  struct pipe_stream_output_info *state)
 {
    memcpy(&draw->so.state,
           state,
-          sizeof(struct pipe_stream_output_state));
+          sizeof(struct pipe_stream_output_info));
 }
 
 void
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index 799eb94..93577d0 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -202,7 +202,7 @@ draw_set_mapped_so_buffers(struct draw_context *draw,
                            unsigned num_buffers);
 void
 draw_set_so_state(struct draw_context *draw,
-                  struct pipe_stream_output_state *state);
+                  struct pipe_stream_output_info *state);
 
 
 /***********************************************************************
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 3521a03..89653e1 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -270,7 +270,7 @@ struct draw_context
 
    /** Stream output (vertex feedback) state */
    struct {
-      struct pipe_stream_output_state state;
+      struct pipe_stream_output_info state;
       void *buffers[PIPE_MAX_SO_BUFFERS];
       uint num_buffers;
    } so;
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index c86bdd9..6465e5c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -130,7 +130,7 @@ static void so_emit_prim(struct pt_so_emit *so,
    unsigned input_vertex_stride = so->input_vertex_stride;
    struct draw_context *draw = so->draw;
    const float (*input_ptr)[4];
-   const struct pipe_stream_output_state *state =
+   const struct pipe_stream_output_info *state =
       &draw->so.state;
    float **buffer = 0;
 
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 391139f..b2872cd 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -54,8 +54,6 @@ buffers, surfaces) are bound to the driver.
 
 * ``set_index_buffer``
 
-* ``set_stream_output_buffers``
-
 
 Non-CSO State
 ^^^^^^^^^^^^^
@@ -139,6 +137,47 @@ cube, and 3d textures otherwise they are 0.
 * ``surface_destroy`` destroys a surface and releases its reference to the
   associated resource.
 
+Stream output targets
+^^^^^^^^^^^^^^^^^^^^^
+
+Stream output, also known as transform feedback, allows writing the primitives
+produced by the vertex pipeline to buffers. This is done after the geometry
+shader or vertex shader if no geometry shader is present.
+
+The stream output targets are views into buffer resources which can be bound
+as stream outputs and specify a memory range where it's valid to write
+primitives. The pipe driver must implement memory protection such that any
+primitives written outside of the specified memory range are discarded.
+
+Two stream output targets can use the same resource at the same time, but
+with a disjoint memory range.
+
+Additionally, the stream output target internally maintains the offset
+into the buffer which is incremented everytime something is written to it.
+The internal offset is equal to how much data has already been written.
+It can be stored in device memory and the CPU actually doesn't have to query
+it.
+
+The stream output target can be used in a draw command to provide
+the vertex count. The vertex count is derived from the internal offset
+discussed above.
+
+* ``create_stream_output_target`` create a new target.
+
+* ``stream_output_target_destroy`` destroys a target. Users of this should
+  use pipe_so_target_reference instead.
+
+* ``set_stream_output_targets`` binds stream output targets. The parameter
+  append_bitmask is a bitmask, where the i-th bit specifies whether new
+  primitives should be appended to the i-th buffer (writing starts at
+  the internal offset), or whether writing should start at the beginning
+  (the internal offset is effectively set to 0).
+
+NOTE: The currently-bound vertex or geometry shader must be compiled with
+the properly-filled-in structure pipe_stream_output_info describing which
+outputs should be written to buffers and how. The structure is part of
+pipe_shader_state.
+
 Clearing
 ^^^^^^^^
 
@@ -394,24 +433,6 @@ The interfaces to these calls are likely to change to make it easier
 for a driver to batch multiple blits with the same source and
 destination.
 
-
-Stream Output
-^^^^^^^^^^^^^
-
-Stream output, also known as transform feedback allows writing the results of the
-vertex pipeline (after the geometry shader or vertex shader if no geometry shader
-is present) to be written to a buffer created with a ``PIPE_BIND_STREAM_OUTPUT``
-flag.
-
-First a stream output state needs to be created with the
-``create_stream_output_state`` call. It specific the details of what's being written,
-to which buffer and with what kind of a writemask.
-
-Then target buffers needs to be set with the call to ``set_stream_output_buffers``
-which sets the buffers and the offsets from the start of those buffer to where
-the data will be written to.
-
-
 Transfers
 ^^^^^^^^^
 
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index 1272171..63ed039 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -52,6 +52,8 @@ The integer capabilities:
   from color blend equations, in :ref:`Blend` state.
 * ``PIPE_CAP_SM3``: Whether the vertex shader and fragment shader support equivalent
   opcodes to the Shader Model 3 specification. XXX oh god this is horrible
+* ``PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS``: The maximum number of stream buffers.
+* ``PIPE_CAP_PRIMITIVE_RESTART``: Whether primitive restart is supported.
 * ``PIPE_CAP_MAX_COMBINED_SAMPLERS``: The total number of samplers accessible from
   the vertex and fragment shader, inclusive.
 * ``PIPE_CAP_INDEP_BLEND_ENABLE``: Whether per-rendertarget blend enabling and channel
@@ -174,6 +176,7 @@ resources might be created and handled quite differently.
 * ``PIPE_BIND_CONSTANT_BUFFER``: A buffer of shader constants.
 * ``PIPE_BIND_TRANSFER_WRITE``: A transfer object which will be written to.
 * ``PIPE_BIND_TRANSFER_READ``: A transfer object which will be read from.
+* ``PIPE_BIND_STREAM_OUTPUT``: A stream output buffer.
 * ``PIPE_BIND_CUSTOM``:
 * ``PIPE_BIND_SCANOUT``: A front color buffer or scanout buffer.
 * ``PIPE_BIND_SHARED``: A sharable buffer that can be given to another
diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h
index 7893e9c..97ca172 100644
--- a/src/gallium/drivers/llvmpipe/lp_state.h
+++ b/src/gallium/drivers/llvmpipe/lp_state.h
@@ -86,7 +86,7 @@ struct lp_velems_state
 };
 
 struct lp_so_state {
-   struct pipe_stream_output_state base;
+   struct pipe_stream_output_info base;
 };
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_so.c b/src/gallium/drivers/llvmpipe/lp_state_so.c
index 35de52c..4874bd6 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_so.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_so.c
@@ -35,7 +35,7 @@
 
 static void *
 llvmpipe_create_stream_output_state(struct pipe_context *pipe,
-                                    const struct pipe_stream_output_state *templ)
+                                    const struct pipe_stream_output_info *templ)
 {
    struct lp_so_state *so;
    so = (struct lp_so_state *) CALLOC_STRUCT(lp_so_state);
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 1270c83..e9ae9e6 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -117,7 +117,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TIMER_QUERY:
    case PIPE_CAP_OCCLUSION_QUERY:
       return 1;
-   case PIPE_CAP_STREAM_OUTPUT:
+   case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
       return 0;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
    case PIPE_CAP_INDEP_BLEND_ENABLE:
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c
index 0da7be4..2445cd6 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -106,7 +106,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TIMER_QUERY:
    case PIPE_CAP_OCCLUSION_QUERY:
       return 1;
-   case PIPE_CAP_STREAM_OUTPUT:
+   case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
       return 0;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
    case PIPE_CAP_INDEP_BLEND_ENABLE:
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c
index 0d6952d..d15a956 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -749,7 +749,7 @@ nvc0_vertex_state_bind(struct pipe_context *pipe, void *hwcso)
 
 static void *
 nvc0_tfb_state_create(struct pipe_context *pipe,
-                      const struct pipe_stream_output_state *pso)
+                      const struct pipe_stream_output_info *pso)
 {
    struct nvc0_transform_feedback_state *so;
    int n = 0;
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index ab1cec5..926f8be 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -145,7 +145,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_SCALED_RESOLVE:
         case PIPE_CAP_MIN_TEXEL_OFFSET:
         case PIPE_CAP_MAX_TEXEL_OFFSET:
-        case PIPE_CAP_STREAM_OUTPUT:
+        case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
             return 0;
 
         /* SWTCL-only features. */
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 243de14..fe74f44 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -392,7 +392,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
 		return family >= CHIP_CEDAR ? 1 : 0;
 
 	/* Unsupported features. */
-	case PIPE_CAP_STREAM_OUTPUT:
+	case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
 	case PIPE_CAP_TGSI_INSTANCEID:
 	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
 	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 49d3de7..e29e20b 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -107,7 +107,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
    case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
       return 1;
-   case PIPE_CAP_STREAM_OUTPUT:
+   case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
       return 0;
    case PIPE_CAP_PRIMITIVE_RESTART:
       return 1;
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index ec4c8cf..bdda294 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -122,7 +122,7 @@ struct sp_velems_state {
 };
 
 struct sp_so_state {
-   struct pipe_stream_output_state base;
+   struct pipe_stream_output_info base;
 };
 
 
diff --git a/src/gallium/drivers/softpipe/sp_state_so.c b/src/gallium/drivers/softpipe/sp_state_so.c
index 40e5634..b0449cd 100644
--- a/src/gallium/drivers/softpipe/sp_state_so.c
+++ b/src/gallium/drivers/softpipe/sp_state_so.c
@@ -36,7 +36,7 @@
 
 static void *
 softpipe_create_stream_output_state(struct pipe_context *pipe,
-                                    const struct pipe_stream_output_state *templ)
+                                    const struct pipe_stream_output_info *templ)
 {
    struct sp_so_state *so;
    so = (struct sp_so_state *) CALLOC_STRUCT(sp_so_state);
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index b2d5f95..de79a9b 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -56,7 +56,7 @@ struct pipe_sampler_view;
 struct pipe_scissor_state;
 struct pipe_shader_state;
 struct pipe_stencil_ref;
-struct pipe_stream_output_state;
+struct pipe_stream_output_target;
 struct pipe_surface;
 struct pipe_vertex_buffer;
 struct pipe_vertex_element;
@@ -86,11 +86,6 @@ struct pipe_context {
    /*@{*/
    void (*draw_vbo)( struct pipe_context *pipe,
                      const struct pipe_draw_info *info );
-
-   /**
-    * Draw the stream output buffer at index 0
-    */
-   void (*draw_stream_output)( struct pipe_context *pipe, unsigned mode );
    /*@}*/
 
    /**
@@ -179,11 +174,6 @@ struct pipe_context {
    void   (*bind_vertex_elements_state)(struct pipe_context *, void *);
    void   (*delete_vertex_elements_state)(struct pipe_context *, void *);
 
-   void * (*create_stream_output_state)(struct pipe_context *,
-                                        const struct pipe_stream_output_state *);
-   void   (*bind_stream_output_state)(struct pipe_context *, void *);
-   void   (*delete_stream_output_state)(struct pipe_context*, void*);
-
    /*@}*/
 
    /**
@@ -237,12 +227,26 @@ struct pipe_context {
    void (*set_index_buffer)( struct pipe_context *pipe,
                              const struct pipe_index_buffer * );
 
-   void (*set_stream_output_buffers)(struct pipe_context *,
-                                     struct pipe_resource **buffers,
-                                     int *offsets, /*array of offsets
-                                                     from the start of each
-                                                     of the buffers */
-                                     int num_buffers);
+   /*@}*/
+
+   /**
+    * Stream output functions.
+    */
+   /*@{*/
+
+   struct pipe_stream_output_target *(*create_stream_output_target)(
+                        struct pipe_context *,
+                        struct pipe_resource *,
+                        unsigned buffer_offset,
+                        unsigned buffer_size);
+
+   void (*stream_output_target_destroy)(struct pipe_context *,
+                                        struct pipe_stream_output_target *);
+
+   void (*set_stream_output_targets)(struct pipe_context *,
+                              unsigned num_targets,
+                              struct pipe_stream_output_target **targets,
+                              unsigned append_bitmask);
 
    /*@}*/
 
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 5196591..2d89b2b 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -449,7 +449,7 @@ enum pipe_cap {
    PIPE_CAP_TEXTURE_MIRROR_CLAMP = 25,
    PIPE_CAP_BLEND_EQUATION_SEPARATE = 28,
    PIPE_CAP_SM3 = 29,  /*< Shader Model, supported */
-   PIPE_CAP_STREAM_OUTPUT = 30,
+   PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS = 30,
    PIPE_CAP_PRIMITIVE_RESTART = 31,
    /** Maximum texture image units accessible from vertex and fragment shaders
     * combined */
@@ -476,7 +476,11 @@ enum pipe_cap {
    PIPE_CAP_MIN_TEXEL_OFFSET = 50,
    PIPE_CAP_MAX_TEXEL_OFFSET = 51,
    PIPE_CAP_CONDITIONAL_RENDER = 52,
-   PIPE_CAP_TEXTURE_BARRIER = 53
+   PIPE_CAP_TEXTURE_BARRIER = 53,
+   PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_ATTRIBS = 54,
+   PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS = 55,
+   PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS = 56,
+   PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME = 57
 };
 
 /* Shader caps not specific to any single stage */
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 37e0679..116d499 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -121,6 +121,12 @@ struct pipe_rasterizer_state
     */
    unsigned gl_rasterization_rules:1;
 
+   /**
+    * When true, rasterization is disabled and no pixels are written.
+    * This only makes sense with the Stream Out functionality.
+    */
+   unsigned rasterizer_discard:1;
+
    unsigned line_stipple_factor:8;  /**< [1..256] actually */
    unsigned line_stipple_pattern:16;
 
@@ -164,9 +170,28 @@ struct pipe_clip_state
 };
 
 
+/**
+ * Stream output for vertex transform feedback.
+ */
+struct pipe_stream_output_info
+{
+   /** number of the output buffer to insert each element into */
+   unsigned output_buffer[PIPE_MAX_SHADER_OUTPUTS];
+   /** which register OUT[i] to grab each output from */
+   unsigned register_index[PIPE_MAX_SHADER_OUTPUTS];
+   /** TGSI_WRITEMASK signifying which components to output */
+   ubyte register_mask[PIPE_MAX_SHADER_OUTPUTS];
+   /** number of outputs */
+   unsigned num_outputs;
+   /** stride for an entire vertex, only used if all output_buffers are 0 */
+   unsigned stride;
+};
+
+
 struct pipe_shader_state
 {
    const struct tgsi_token *tokens;
+   struct pipe_stream_output_info stream_output;
 };
 
 
@@ -375,24 +400,6 @@ struct pipe_resource
 
 
 /**
- * Stream output for vertex transform feedback.
- */
-struct pipe_stream_output_state
-{
-   /** number of the output buffer to insert each element into */
-   int output_buffer[PIPE_MAX_SHADER_OUTPUTS];
-   /** which register to grab each output from */
-   int register_index[PIPE_MAX_SHADER_OUTPUTS];
-   /** TGSI_WRITEMASK signifying which components to output */
-   ubyte register_mask[PIPE_MAX_SHADER_OUTPUTS];
-   /** number of outputs */
-   int num_outputs;
-   /** stride for an entire vertex, only used if all output_buffers are 0 */
-   unsigned stride;
-};
-
-
-/**
  * Transfer object.  For data transfer to/from a resource.
  */
 struct pipe_transfer
@@ -422,6 +429,30 @@ struct pipe_vertex_buffer
 
 
 /**
+ * A stream output target. The structure specifies the range vertices can
+ * be written to.
+ *
+ * In addition to that, the structure should internally maintain the offset
+ * into the buffer, which should be incremented everytime something is written
+ * (appended) to it. The internal offset is buffer_offset + how many bytes
+ * have been written. The internal offset can be stored on the device
+ * and the CPU actually doesn't have to query it.
+ *
+ * Use PIPE_QUERY_SO_STATISTICS to know how many primitives have
+ * actually been written.
+ */
+struct pipe_stream_output_target
+{
+   struct pipe_reference reference;
+   struct pipe_resource *buffer; /**< buffer into which this is a target view */
+   struct pipe_context *context; /**< context this view belongs to */
+
+   unsigned buffer_offset;  /**< offset where data should be written, in bytes */
+   unsigned buffer_size;    /**< how much data is allowed to be written */
+};
+
+
+/**
  * Information to describe a vertex attribute (position, color, etc)
  */
 struct pipe_vertex_element
@@ -481,6 +512,22 @@ struct pipe_draw_info
     */
    boolean primitive_restart;
    unsigned restart_index;
+
+   /**
+    * Stream output target. If not NULL, it's used to provide the 'count'
+    * parameter based on the number vertices captured by the stream output
+    * stage. (or generally, based on the number of bytes captured)
+    *
+    * Only 'mode', 'start_instance', and 'instance_count' are taken into
+    * account, all the other variables from pipe_draw_info are ignored.
+    *
+    * 'start' is implicitly 0 and 'count' is set as discussed above.
+    * The draw command is non-indexed.
+    *
+    * Note that this only provides the count. The vertex buffers must
+    * be set via set_vertex_buffers manually.
+    */
+   struct pipe_stream_output_target *count_from_stream_output;
 };
 
 
-- 
1.7.5.4



More information about the mesa-dev mailing list