feedback/rasterpos fix-ups
authorBrian <brian.paul@tungstengraphics.com>
Mon, 15 Oct 2007 17:28:25 +0000 (11:28 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Mon, 15 Oct 2007 17:28:25 +0000 (11:28 -0600)
src/mesa/pipe/i915simple/i915_context.c
src/mesa/pipe/i915simple/i915_context.h
src/mesa/pipe/i915simple/i915_state.c

index 5d97eed247e1763a947aea6e8eb79b3b9487df83..8150fcfbf5e0fa7143d178b456c9d24023196631 100644 (file)
@@ -212,6 +212,19 @@ static boolean i915_draw_elements( struct pipe_context *pipe,
       draw_set_mapped_element_buffer(draw, 0, NULL);
    }
 
+   /* Map feedback buffers if enabled */
+   if (i915->feedback.enabled) {
+      const uint n = i915->feedback.interleaved ? 1 : i915->feedback.num_attribs;
+      for (i = 0; i < n; i++) {
+         void *ptr = pipe->winsys->buffer_map(pipe->winsys,
+                                              i915->feedback_buffer[i].buffer,
+                                              PIPE_BUFFER_FLAG_WRITE);
+         draw_set_mapped_feedback_buffer(draw, i, ptr,
+                                         i915->feedback_buffer[i].size);
+      }
+   }
+
+
    draw_set_mapped_constant_buffer(draw,
                                 i915->current.constants[PIPE_SHADER_VERTEX]);
 
@@ -232,6 +245,16 @@ static boolean i915_draw_elements( struct pipe_context *pipe,
       draw_set_mapped_element_buffer(draw, 0, NULL);
    }
 
+   /* Unmap feedback buffers if enabled */
+   if (i915->feedback.enabled) {
+      const uint n = i915->feedback.interleaved ? 1 : i915->feedback.num_attribs;
+      for (i = 0; i < n; i++) {
+         pipe->winsys->buffer_unmap(pipe->winsys,
+                                    i915->feedback_buffer[i].buffer);
+         draw_set_mapped_feedback_buffer(draw, i, NULL, 0);
+      }
+   }
+
    return TRUE;
 }
 
index dc19b6efeb9e627a9ee54a6fa0541571575cd645..a3dd392e755b27edf3d8b3593fb1f5d8d0fa2121 100644 (file)
@@ -169,6 +169,7 @@ struct i915_context
    struct pipe_clear_color_state clear_color;
    struct pipe_clip_state clip;
    struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
+   struct pipe_feedback_state feedback;
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
@@ -176,6 +177,9 @@ struct i915_context
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
 
+   /** Feedback buffers */
+   struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS];
+
    unsigned dirty;
 
    unsigned *batch_start;
index 19ca5e575fb098b7a48a2a4c136b09b46785090c..4a31747fe85ab809a3c588fd1ed62ae2995803de 100644 (file)
@@ -550,6 +550,33 @@ static void i915_set_framebuffer_state(struct pipe_context *pipe,
 }
 
 
+static void
+i915_set_feedback_state(struct pipe_context *pipe,
+                        const struct pipe_feedback_state *feedback)
+{
+   struct i915_context *i915 = i915_context(pipe);
+   i915->feedback = *feedback;
+   draw_set_feedback_state(i915->draw, feedback);
+}
+
+
+static void
+i915_set_feedback_buffer(struct pipe_context *pipe,
+                             unsigned index,
+                             const struct pipe_feedback_buffer *feedback)
+{
+   struct i915_context *i915 = i915_context(pipe);
+
+   assert(index < PIPE_MAX_FEEDBACK_ATTRIBS);
+
+   /* Need to be careful with referencing */
+   pipe->winsys->buffer_reference(pipe->winsys,
+                                  &i915->feedback_buffer[index].buffer,
+                                  feedback->buffer);
+   i915->feedback_buffer[index].size = feedback->size;
+   i915->feedback_buffer[index].start_offset = feedback->start_offset;
+}
+
 
 
 static void i915_set_clear_color_state(struct pipe_context *pipe,
@@ -731,6 +758,9 @@ i915_init_state_functions( struct i915_context *i915 )
    i915->pipe.set_clear_color_state = i915_set_clear_color_state;
    i915->pipe.set_constant_buffer = i915_set_constant_buffer;
    i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
+   i915->pipe.set_feedback_state = i915_set_feedback_state;
+   i915->pipe.set_feedback_buffer = i915_set_feedback_buffer;
+
    i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
    i915->pipe.set_scissor_state = i915_set_scissor_state;
    i915->pipe.set_texture_state = i915_set_texture_state;