More work on vertex feedback / glRasterPos. Basic rasterpos works now.
authorBrian <brian.paul@tungstengraphics.com>
Mon, 10 Sep 2007 22:29:23 +0000 (16:29 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Mon, 10 Sep 2007 22:29:23 +0000 (16:29 -0600)
src/mesa/pipe/draw/draw_context.c
src/mesa/pipe/draw/draw_context.h
src/mesa/pipe/draw/draw_feedback.c
src/mesa/pipe/p_context.h
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/Makefile
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_draw_arrays.c
src/mesa/pipe/softpipe/sp_state.h

index 3c095810e55510a9453901100c5e4236c78c7bf5..4498293e92b33aca34443bb5763f1365bd95c47d 100644 (file)
@@ -48,6 +48,7 @@ struct draw_context *draw_create( void )
    draw->pipeline.clip      = draw_clip_stage( draw );
    draw->pipeline.flatshade = draw_flatshade_stage( draw );
    draw->pipeline.cull      = draw_cull_stage( draw );
+   draw->pipeline.feedback  = draw_feedback_stage( draw );
 
    ASSIGN_4V( draw->plane[0], -1,  0,  0, 1 );
    ASSIGN_4V( draw->plane[1],  1,  0,  0, 1 );
@@ -147,6 +148,14 @@ static void validate_pipeline( struct draw_context *draw )
 }
 
 
+void draw_set_feedback_state( struct draw_context *draw,
+                              const struct pipe_feedback_state *feedback )
+{
+   draw->feedback = *feedback;
+   validate_pipeline( draw );
+}
+
+
 /**
  * Register new primitive setup/rendering state.
  * This causes the drawing pipeline to be rebuilt.
@@ -245,6 +254,7 @@ void
 draw_set_mapped_feedback_buffer(struct draw_context *draw, uint index,
                                 void *buffer, uint size)
 {
+   assert(index < PIPE_MAX_FEEDBACK_ATTRIBS);
    draw->mapped_feedback_buffer[index] = buffer;
    draw->mapped_feedback_buffer_size[index] = size; /* in bytes */
 }
index 50315749693ba84f070cfa949832bee6c1ac4a97..2babc02f45f578ad968e0e9a773486c56c906cfe 100644 (file)
@@ -83,6 +83,9 @@ void draw_set_viewport_state( struct draw_context *draw,
 void draw_set_clip_state( struct draw_context *pipe,
                           const struct pipe_clip_state *clip );
 
+void draw_set_feedback_state( struct draw_context *draw,
+                              const struct pipe_feedback_state * );
+
 void draw_set_setup_state( struct draw_context *draw,
                            const struct pipe_setup_state *setup );
 
index 2729f44dc6909d1f7c96de113b5520147489e274..ecdd98e83d75ddf1ecbf10428990220a27f8ce0c 100644 (file)
@@ -81,7 +81,8 @@ feedback_vertex(struct draw_stage *stage, const struct vertex_header *vertex)
 
    for (i = 0; i < feedback->num_attribs; i++) {
       const uint attr = feedback->attrib[i];
-      const float *src = attr ? vertex->data[attr] : vertex->clip;
+      const uint slot = stage->draw->vertex_info.attrib_to_slot[attr];
+      const float *src = attr ? vertex->data[slot] : vertex->clip;
       const uint size = feedback->size[i];
       float *dest = fs->dest[i * select];
 
index c9246e883ad05b653f263d0271397547e66d3939..27a1128365e59c758a93f1aa9fc9a248b3166483 100644 (file)
@@ -106,6 +106,9 @@ struct pipe_context {
    void (*set_depth_state)( struct pipe_context *,
                             const struct pipe_depth_state * );
 
+   void (*set_feedback_state)( struct pipe_context *,
+                               const struct pipe_feedback_state *);
+
    void (*set_framebuffer_state)( struct pipe_context *,
                                   const struct pipe_framebuffer_state * );
 
@@ -154,13 +157,8 @@ struct pipe_context {
     */
    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 *);
+                               const struct pipe_feedback_buffer *);
 
-   
    /*
     * Surface functions
     * This might go away...
index cad96807df3b6d2f4323500d4faa01b2a7786403..ccd40d39e6651c0b4f382d42c35a3d0faca29322 100644 (file)
@@ -371,5 +371,14 @@ struct pipe_vertex_element
 };
 
 
+/**
+ * Vertex feedback buffer
+ */
+struct pipe_feedback_buffer {
+   struct pipe_buffer_handle *buffer;
+   unsigned size;
+   unsigned start_offset;
+};
+
 
 #endif
index ffa31102d55cce390a1bc71cacc2d02a3f60abfc..401df1cfb76fb3a5d6752c73259f6c1b493bf6e7 100644 (file)
@@ -26,6 +26,7 @@ DRIVER_SOURCES = \
        sp_state_blend.c \
        sp_state_clip.c \
        sp_state_derived.c \
+       sp_state_feedback.c \
        sp_state_fs.c \
        sp_state_sampler.c \
        sp_state_setup.c \
index 5404b7f79057a4d731f6c2095227265fd4017565..26453d97852952cdb5713d4d727b064cd5c7a32b 100644 (file)
@@ -239,6 +239,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state;
    softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
    softpipe->pipe.set_depth_state = softpipe_set_depth_test_state;
+   softpipe->pipe.set_feedback_state = softpipe_set_feedback_state;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_fs_state = softpipe_set_fs_state;
    softpipe->pipe.set_vs_state = softpipe_set_vs_state;
@@ -249,8 +250,10 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    softpipe->pipe.set_stencil_state = softpipe_set_stencil_state;
    softpipe->pipe.set_texture_state = softpipe_set_texture_state;
    softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
+
    softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer;
    softpipe->pipe.set_vertex_element = softpipe_set_vertex_element;
+   softpipe->pipe.set_feedback_buffer = softpipe_set_feedback_buffer;
 
    softpipe->pipe.draw_arrays = softpipe_draw_arrays;
    softpipe->pipe.draw_elements = softpipe_draw_elements;
index fd0af6f727dcbdedcddb0879fe15bbf4bb7a93b2..2a6b932523a163205daba374f6bfecd27ff83a21 100644 (file)
@@ -78,6 +78,7 @@ struct softpipe_context {
    struct pipe_clip_state clip;
    struct pipe_constant_buffer constants[2];
    struct pipe_depth_state depth_test;
+   struct pipe_feedback_state feedback;
    struct pipe_framebuffer_state framebuffer;
    struct pipe_shader_state fs;
    struct pipe_shader_state vs;
@@ -107,6 +108,9 @@ struct softpipe_context {
    boolean need_z;  /**< produce quad/fragment Z values? */
    boolean need_w;  /**< produce quad/fragment W values? */
 
+   /** Feedback buffers */
+   struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS];
+
 #if 0
    /* Stipple derived state:
     */
index 5198a493da30464c2da9aa4f07742b8e22b31cc1..7ea29a0a2696989369d04baebfde98828176ba4d 100644 (file)
@@ -135,6 +135,19 @@ softpipe_draw_elements(struct pipe_context *pipe,
       draw_set_mapped_element_buffer(draw, 0, NULL);
    }
 
+   /* Map feedback buffers if enabled */
+   if (sp->feedback.enabled) {
+      const uint n = sp->feedback.interleaved ? 1 : sp->feedback.num_attribs;
+      for (i = 0; i < n; i++) {
+         void *ptr = pipe->winsys->buffer_map(pipe->winsys,
+                                              sp->feedback_buffer[i].buffer,
+                                              PIPE_BUFFER_FLAG_WRITE);
+         draw_set_mapped_feedback_buffer(draw, i, ptr,
+                                         sp->feedback_buffer[i].size);
+      }
+   }
+
+
    /* draw! */
    draw_arrays(draw, mode, start, count);
 
@@ -152,6 +165,17 @@ softpipe_draw_elements(struct pipe_context *pipe,
       draw_set_mapped_element_buffer(draw, 0, NULL);
    }
 
+   /* Unmap feedback buffers if enabled */
+   if (sp->feedback.enabled) {
+      const uint n = sp->feedback.interleaved ? 1 : sp->feedback.num_attribs;
+      for (i = 0; i < n; i++) {
+         pipe->winsys->buffer_unmap(pipe->winsys,
+                                    sp->feedback_buffer[i].buffer);
+         draw_set_mapped_feedback_buffer(draw, i, NULL, 0);
+      }
+   }
+
+
    softpipe_unmap_surfaces(sp);
    softpipe_unmap_constant_buffers(sp);
 
index 354580b2a5a5a4e9f2c96796fdc767e756f8577d..f40ebe3e2b83a19bddeced7e362603e8a7947fb8 100644 (file)
@@ -59,6 +59,9 @@ void softpipe_set_constant_buffer(struct pipe_context *,
 void softpipe_set_depth_test_state( struct pipe_context *,
                                     const struct pipe_depth_state * );
 
+void softpipe_set_feedback_state( struct pipe_context *,
+                                  const struct pipe_feedback_state * );
+
 void softpipe_set_fs_state( struct pipe_context *,
                             const struct pipe_shader_state * );
 
@@ -96,6 +99,12 @@ void softpipe_set_vertex_buffer(struct pipe_context *,
                                 unsigned index,
                                 const struct pipe_vertex_buffer *);
 
+void softpipe_set_feedback_buffer(struct pipe_context *,
+                                  uint index,
+                                  const struct pipe_feedback_buffer *);
+
+
+
 void softpipe_update_derived( struct softpipe_context *softpipe );