summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-09-10 16:29:23 -0600
committerBrian <[email protected]>2007-09-10 16:29:23 -0600
commitd56a3adc30c19c8f00cb7dc585e86babfd3a79a7 (patch)
tree38004b2d716a1383978ceca10ff5f93084d1a03b
parentb2dfe2be6cc91c330e7fe21ea663cacfc220582d (diff)
More work on vertex feedback / glRasterPos. Basic rasterpos works now.
-rw-r--r--src/mesa/pipe/draw/draw_context.c10
-rw-r--r--src/mesa/pipe/draw/draw_context.h3
-rw-r--r--src/mesa/pipe/draw/draw_feedback.c3
-rw-r--r--src/mesa/pipe/p_context.h10
-rw-r--r--src/mesa/pipe/p_state.h9
-rw-r--r--src/mesa/pipe/softpipe/Makefile1
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c3
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h4
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c24
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h9
10 files changed, 69 insertions, 7 deletions
diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c
index 3c095810e55..4498293e92b 100644
--- a/src/mesa/pipe/draw/draw_context.c
+++ b/src/mesa/pipe/draw/draw_context.c
@@ -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 */
}
diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h
index 50315749693..2babc02f45f 100644
--- a/src/mesa/pipe/draw/draw_context.h
+++ b/src/mesa/pipe/draw/draw_context.h
@@ -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 );
diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c
index 2729f44dc69..ecdd98e83d7 100644
--- a/src/mesa/pipe/draw/draw_feedback.c
+++ b/src/mesa/pipe/draw/draw_feedback.c
@@ -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];
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index c9246e883ad..27a1128365e 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -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...
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index cad96807df3..ccd40d39e66 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -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
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
index ffa31102d55..401df1cfb76 100644
--- a/src/mesa/pipe/softpipe/Makefile
+++ b/src/mesa/pipe/softpipe/Makefile
@@ -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 \
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 5404b7f7905..26453d97852 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -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;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index fd0af6f727d..2a6b932523a 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -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:
*/
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
index 5198a493da3..7ea29a0a269 100644
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c
@@ -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);
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index 354580b2a5a..f40ebe3e2b8 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -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 );