Initial work for post-transformed vertex feedback buffers.
authorBrian <brian.paul@tungstengraphics.com>
Thu, 6 Sep 2007 23:07:09 +0000 (17:07 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 6 Sep 2007 23:07:09 +0000 (17:07 -0600)
This will be used for:
   GL_NV_transform_feedback, or similar GL3 functionality
   glRasterPos
   GL selection/feedback modes

src/mesa/pipe/draw/draw_context.c
src/mesa/pipe/draw/draw_context.h
src/mesa/pipe/draw/draw_prim.c
src/mesa/pipe/draw/draw_private.h
src/mesa/pipe/p_context.h
src/mesa/pipe/p_state.h
src/mesa/sources

index 2936a14d65a9e508f94bd56cc43d7faaf3dd9b86..3c095810e55510a9453901100c5e4236c78c7bf5 100644 (file)
@@ -137,7 +137,12 @@ static void validate_pipeline( struct draw_context *draw )
       draw->pipeline.flatshade->next = next;
       next = draw->pipeline.flatshade;
    }
-   
+
+   if (draw->feedback.enabled || draw->feedback.discard) {
+      draw->pipeline.feedback->next = next;
+      next = draw->pipeline.feedback;
+   }
+
    draw->pipeline.first = next;
 }
 
@@ -189,6 +194,14 @@ void draw_set_viewport_state( struct draw_context *draw,
 }
 
 
+void
+draw_set_vertex_shader(struct draw_context *draw,
+                       const struct pipe_shader_state *shader)
+{
+   draw->vertex_shader = *shader;
+}
+
+
 void
 draw_set_vertex_buffer(struct draw_context *draw,
                        unsigned attr,
@@ -209,9 +222,30 @@ draw_set_vertex_element(struct draw_context *draw,
 }
 
 
+/**
+ * Tell drawing context where to find mapped vertex buffers.
+ */
 void
-draw_set_vertex_shader(struct draw_context *draw,
-                       const struct pipe_shader_state *shader)
+draw_set_mapped_vertex_buffer(struct draw_context *draw,
+                              unsigned attr, const void *buffer)
 {
-   draw->vertex_shader = *shader;
+   draw->mapped_vbuffer[attr] = buffer;
+}
+
+
+void
+draw_set_mapped_constant_buffer(struct draw_context *draw,
+                                const void *buffer)
+{
+   draw->mapped_constants = buffer;
 }
+
+
+void
+draw_set_mapped_feedback_buffer(struct draw_context *draw, uint index,
+                                void *buffer, uint size)
+{
+   draw->mapped_feedback_buffer[index] = buffer;
+   draw->mapped_feedback_buffer_size[index] = size; /* in bytes */
+}
+
index 7c4f1a129740ae0ae22144787a16b5dd65c5b17a..50315749693ba84f070cfa949832bee6c1ac4a97 100644 (file)
@@ -93,14 +93,11 @@ unsigned draw_prim_info( unsigned prim, unsigned *first, unsigned *incr );
 
 unsigned draw_trim( unsigned count, unsigned first, unsigned incr );
 
-void draw_set_mapped_element_buffer( struct draw_context *draw,
-                                     unsigned eltSize, void *elements );
 
-void draw_set_mapped_vertex_buffer(struct draw_context *draw,
-                                   unsigned attr, const void *buffer);
+void
+draw_set_vertex_shader(struct draw_context *draw,
+                       const struct pipe_shader_state *shader);
 
-void draw_set_mapped_constant_buffer(struct draw_context *draw,
-                                     const void *buffer);
 
 void
 draw_set_vertex_buffer(struct draw_context *draw,
@@ -112,10 +109,18 @@ draw_set_vertex_element(struct draw_context *draw,
                         unsigned attr,
                         const struct pipe_vertex_element *element);
 
-void
-draw_set_vertex_shader(struct draw_context *draw,
-                       const struct pipe_shader_state *shader);
+void draw_set_mapped_element_buffer( struct draw_context *draw,
+                                     unsigned eltSize, void *elements );
+
+void draw_set_mapped_vertex_buffer(struct draw_context *draw,
+                                   unsigned attr, const void *buffer);
 
+void draw_set_mapped_constant_buffer(struct draw_context *draw,
+                                     const void *buffer);
+
+void
+draw_set_mapped_feedback_buffer(struct draw_context *draw, uint index,
+                                void *buffer, uint size);
 
 void
 draw_arrays(struct draw_context *draw, unsigned prim,
index b68cca57064c55ab4b50914b14a44efabe17d283..a90d1df7f9f7bee9e88e6b890cc526491abfe4d8 100644 (file)
@@ -353,23 +353,6 @@ draw_set_prim( struct draw_context *draw, unsigned prim )
 }
 
 
-/**
- * Tell drawing context where to find mapped vertex buffers.
- */
-void draw_set_mapped_vertex_buffer(struct draw_context *draw,
-                                   unsigned attr, const void *buffer)
-{
-   draw->mapped_vbuffer[attr] = buffer;
-}
-
-
-void draw_set_mapped_constant_buffer(struct draw_context *draw,
-                                     const void *buffer)
-{
-   draw->mapped_constants = buffer;
-}
-
-
 unsigned
 draw_prim_info(unsigned prim, unsigned *first, unsigned *incr)
 {
index 9f90dc3e26a011e9e8f60b0cffbae4101eacb839..8bcc3717c4591627e1c9215ba6388ab1d9061c48 100644 (file)
@@ -126,6 +126,7 @@ struct draw_context
       struct draw_stage *first;  /**< one of the following */
 
       /* stages (in logical order) */
+      struct draw_stage *feedback;
       struct draw_stage *flatshade;
       struct draw_stage *clip;
       struct draw_stage *cull;
@@ -137,10 +138,13 @@ struct draw_context
 
    /* pipe state that we need: */
    struct pipe_setup_state setup;
+   struct pipe_feedback_state feedback;
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
    struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
    struct pipe_shader_state vertex_shader;
+   struct pipe_vertex_buffer feedback_buffer[PIPE_ATTRIB_MAX];
+   struct pipe_vertex_element feedback_element[PIPE_ATTRIB_MAX];
 
    /** The mapped vertex element/index buffer */
    const void *mapped_elts;
@@ -150,6 +154,10 @@ struct draw_context
    /** The mapped constant buffers (for vertex shader) */
    const void *mapped_constants;
 
+   /** The mapped vertex element/index buffer */
+   void *mapped_feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS];
+   uint mapped_feedback_buffer_size[PIPE_MAX_FEEDBACK_ATTRIBS]; /* in bytes */
+
    /* Clip derived state:
     */
    float plane[12][4];
@@ -203,6 +211,7 @@ struct draw_context
 
 
 
+extern struct draw_stage *draw_feedback_stage( struct draw_context *context );
 extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
 extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
 extern struct draw_stage *draw_offset_stage( struct draw_context *context );
index ec9973383c4be3181457fd1595c63aaf2d9722bf..c9246e883ad05b653f263d0271397547e66d3939 100644 (file)
@@ -138,14 +138,28 @@ struct pipe_context {
    void (*set_viewport_state)( struct pipe_context *,
                                const struct pipe_viewport_state * );
 
+   /*
+    * Vertex arrays
+    */
    void (*set_vertex_buffer)( struct pipe_context *,
                               unsigned index,
                               const struct pipe_vertex_buffer * );
-   
+
    void (*set_vertex_element)( struct pipe_context *,
                               unsigned index,
                               const struct pipe_vertex_element * );
-                              
+
+   /*
+    * Vertex feedback
+    */
+   void (*set_feedback_buffer)(struct pipe_context *,
+                               unsigned index,
+                               struct pipe_vertex_buffer *);
+   
+   void (*set_feedback_element)(struct pipe_context *,
+                                unsigned index,
+                                const struct pipe_vertex_element *);
+
    
    /*
     * Surface functions
index 25e5861e1e5c671f9324112dce3a545e617cacdc..cad96807df3b6d2f4323500d4faa01b2a7786403 100644 (file)
@@ -49,6 +49,7 @@
 #define PIPE_ATTRIB_MAX      32
 #define PIPE_MAX_COLOR_BUFS   8
 #define PIPE_MAX_TEXTURE_LEVELS  16
+#define PIPE_MAX_FEEDBACK_ATTRIBS 16
 
 
 /* fwd decl */
@@ -92,6 +93,20 @@ struct pipe_setup_state
    float offset_scale;
 };
 
+
+/**
+ * Post-transform vertex feeback
+ */
+struct pipe_feedback_state {
+   uint enabled:1;        /**< enable feedback? */
+   uint discard:1;        /**< discard primitives? */
+   uint interleaved:1;    /**< interleaved output? */
+   uint num_attribs;
+   uint attrib[PIPE_MAX_FEEDBACK_ATTRIBS];
+   uint size[PIPE_MAX_FEEDBACK_ATTRIBS];
+};
+
+
 struct pipe_poly_stipple {
    unsigned stipple[32];
 };
index 437af0f57b06c276aee5cfc91a55163937104de2..28f865f2eded6ccd877c6fe6ef6c7562add32ab3 100644 (file)
@@ -161,6 +161,7 @@ DRAW_SOURCES = \
        pipe/draw/draw_clip.c \
        pipe/draw/draw_context.c\
        pipe/draw/draw_cull.c \
+       pipe/draw/draw_feedback.c \
        pipe/draw/draw_flatshade.c \
        pipe/draw/draw_offset.c \
        pipe/draw/draw_prim.c \