summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/pipe/cell/ppu/cell_draw_arrays.c9
-rw-r--r--src/mesa/pipe/draw/draw_clip.c17
-rw-r--r--src/mesa/pipe/draw/draw_cull.c31
-rw-r--r--src/mesa/pipe/draw/draw_flatshade.c67
-rw-r--r--src/mesa/pipe/draw/draw_offset.c37
-rw-r--r--src/mesa/pipe/draw/draw_prim.c23
-rw-r--r--src/mesa/pipe/draw/draw_private.h5
-rw-r--r--src/mesa/pipe/draw/draw_stipple.c16
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c99
-rw-r--r--src/mesa/pipe/draw/draw_unfilled.c33
-rw-r--r--src/mesa/pipe/draw/draw_validate.c54
-rw-r--r--src/mesa/pipe/draw/draw_vbuf.c5
-rw-r--r--src/mesa/pipe/draw/draw_wide_prims.c51
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_emit.c11
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c9
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c43
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_vbuf.c4
-rw-r--r--src/mesa/state_tracker/st_cb_feedback.c24
-rw-r--r--src/mesa/state_tracker/st_cb_rasterpos.c11
19 files changed, 309 insertions, 240 deletions
diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
index 8286da712c4..9c41b4a523c 100644
--- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
+++ b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
@@ -143,21 +143,18 @@ cell_draw_elements(struct pipe_context *pipe,
/* draw! */
draw_arrays(draw, mode, start, count);
- /* always flush for now */
- draw_flush(draw);
-
/*
- * unmap vertex/index buffers
+ * unmap vertex/index buffers - will cause draw module to flush
*/
for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
if (sp->vertex_buffer[i].buffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
draw_set_mapped_vertex_buffer(draw, i, NULL);
+ pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
}
}
if (indexBuffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
draw_set_mapped_element_buffer(draw, 0, NULL);
+ pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
}
/* Note: leave drawing surfaces mapped */
diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c
index e0eb656364d..2d410e32447 100644
--- a/src/mesa/pipe/draw/draw_clip.c
+++ b/src/mesa/pipe/draw/draw_clip.c
@@ -346,15 +346,6 @@ do_clip_line( struct draw_stage *stage,
}
-static void clip_begin( struct draw_stage *stage )
-{
- /* should always have position, at least */
- assert(stage->draw->num_vs_outputs > 0);
-
- stage->next->begin( stage->next );
-}
-
-
static void
clip_point( struct draw_stage *stage,
struct prim_header *header )
@@ -402,10 +393,9 @@ clip_tri( struct draw_stage *stage,
}
}
-
-static void clip_end( struct draw_stage *stage )
+static void clip_flush( struct draw_stage *stage, unsigned flags )
{
- stage->next->end( stage->next );
+ stage->next->flush( stage->next, flags );
}
@@ -433,11 +423,10 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw )
draw_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES );
clipper->stage.draw = draw;
- clipper->stage.begin = clip_begin;
clipper->stage.point = clip_point;
clipper->stage.line = clip_line;
clipper->stage.tri = clip_tri;
- clipper->stage.end = clip_end;
+ clipper->stage.flush = clip_flush;
clipper->stage.reset_stipple_counter = clip_reset_stipple_counter;
clipper->stage.destroy = clip_destroy;
diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c
index 9bd53f45f26..05c274e4dc2 100644
--- a/src/mesa/pipe/draw/draw_cull.c
+++ b/src/mesa/pipe/draw/draw_cull.c
@@ -50,14 +50,6 @@ static INLINE struct cull_stage *cull_stage( struct draw_stage *stage )
}
-static void cull_begin( struct draw_stage *stage )
-{
- struct cull_stage *cull = cull_stage(stage);
-
- cull->winding = stage->draw->rasterizer->cull_mode;
-
- stage->next->begin( stage->next );
-}
static void cull_tri( struct draw_stage *stage,
@@ -90,6 +82,18 @@ static void cull_tri( struct draw_stage *stage,
}
}
+static void cull_first_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct cull_stage *cull = cull_stage(stage);
+
+ cull->winding = stage->draw->rasterizer->cull_mode;
+
+ stage->tri = cull_tri;
+ stage->tri( stage, header );
+}
+
+
static void cull_line( struct draw_stage *stage,
struct prim_header *header )
@@ -105,12 +109,12 @@ static void cull_point( struct draw_stage *stage,
}
-static void cull_end( struct draw_stage *stage )
+static void cull_flush( struct draw_stage *stage, unsigned flags )
{
- stage->next->end( stage->next );
+ stage->tri = cull_first_tri;
+ stage->next->flush( stage->next, flags );
}
-
static void cull_reset_stipple_counter( struct draw_stage *stage )
{
stage->next->reset_stipple_counter( stage->next );
@@ -135,11 +139,10 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw )
cull->stage.draw = draw;
cull->stage.next = NULL;
- cull->stage.begin = cull_begin;
cull->stage.point = cull_point;
cull->stage.line = cull_line;
- cull->stage.tri = cull_tri;
- cull->stage.end = cull_end;
+ cull->stage.tri = cull_first_tri;
+ cull->stage.flush = cull_flush;
cull->stage.reset_stipple_counter = cull_reset_stipple_counter;
cull->stage.destroy = cull_destroy;
diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c
index 8444c533106..1419f287d2c 100644
--- a/src/mesa/pipe/draw/draw_flatshade.c
+++ b/src/mesa/pipe/draw/draw_flatshade.c
@@ -50,25 +50,6 @@ flat_stage(struct draw_stage *stage)
}
-static void flatshade_begin( struct draw_stage *stage )
-{
- struct flat_stage *flat = flat_stage(stage);
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
- uint i;
-
- /* Find which vertex shader outputs are colors, make a list */
- flat->num_color_attribs = 0;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
- vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- flat->color_attribs[flat->num_color_attribs++] = i;
- }
- }
-
- stage->next->begin( stage->next );
-}
-
-
/** Copy all the color attributes from 'src' vertex to 'dst' vertex */
static INLINE void copy_colors( struct draw_stage *stage,
struct vertex_header *dst,
@@ -144,9 +125,46 @@ static void flatshade_point( struct draw_stage *stage,
}
-static void flatshade_end( struct draw_stage *stage )
+static void flatshade_init_state( struct draw_stage *stage )
+{
+ struct flat_stage *flat = flat_stage(stage);
+ const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ uint i;
+
+ /* Find which vertex shader outputs are colors, make a list */
+ flat->num_color_attribs = 0;
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
+ vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ flat->color_attribs[flat->num_color_attribs++] = i;
+ }
+ }
+
+ stage->line = flatshade_line;
+ stage->tri = flatshade_tri;
+}
+
+static void flatshade_first_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ flatshade_init_state( stage );
+ stage->tri( stage, header );
+}
+
+static void flatshade_first_line( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ flatshade_init_state( stage );
+ stage->line( stage, header );
+}
+
+
+static void flatshade_flush( struct draw_stage *stage,
+ unsigned flags )
{
- stage->next->end( stage->next );
+ stage->tri = flatshade_first_tri;
+ stage->line = flatshade_first_line;
+ stage->next->flush( stage->next, flags );
}
@@ -174,11 +192,10 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
flatshade->stage.draw = draw;
flatshade->stage.next = NULL;
- flatshade->stage.begin = flatshade_begin;
flatshade->stage.point = flatshade_point;
- flatshade->stage.line = flatshade_line;
- flatshade->stage.tri = flatshade_tri;
- flatshade->stage.end = flatshade_end;
+ flatshade->stage.line = flatshade_first_line;
+ flatshade->stage.tri = flatshade_first_tri;
+ flatshade->stage.flush = flatshade_flush;
flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter;
flatshade->stage.destroy = flatshade_destroy;
diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c
index f8a01db3dd8..a2990ee8a88 100644
--- a/src/mesa/pipe/draw/draw_offset.c
+++ b/src/mesa/pipe/draw/draw_offset.c
@@ -52,16 +52,7 @@ static INLINE struct offset_stage *offset_stage( struct draw_stage *stage )
}
-static void offset_begin( struct draw_stage *stage )
-{
- struct offset_stage *offset = offset_stage(stage);
- float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */
- offset->units = stage->draw->rasterizer->offset_units * mrd;
- offset->scale = stage->draw->rasterizer->offset_scale;
-
- stage->next->begin( stage->next );
-}
/**
@@ -124,24 +115,39 @@ static void offset_tri( struct draw_stage *stage,
}
+static void offset_first_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct offset_stage *offset = offset_stage(stage);
+ float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */
+
+ offset->units = stage->draw->rasterizer->offset_units * mrd;
+ offset->scale = stage->draw->rasterizer->offset_scale;
+
+ stage->tri = offset_tri;
+ stage->tri( stage, header );
+}
+
static void offset_line( struct draw_stage *stage,
- struct prim_header *header )
+ struct prim_header *header )
{
stage->next->line( stage->next, header );
}
static void offset_point( struct draw_stage *stage,
- struct prim_header *header )
+ struct prim_header *header )
{
stage->next->point( stage->next, header );
}
-static void offset_end( struct draw_stage *stage )
+static void offset_flush( struct draw_stage *stage,
+ unsigned flags )
{
- stage->next->end( stage->next );
+ stage->tri = offset_first_tri;
+ stage->next->flush( stage->next, flags );
}
@@ -169,11 +175,10 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw )
offset->stage.draw = draw;
offset->stage.next = NULL;
- offset->stage.begin = offset_begin;
offset->stage.point = offset_point;
offset->stage.line = offset_line;
- offset->stage.tri = offset_tri;
- offset->stage.end = offset_end;
+ offset->stage.tri = offset_first_tri;
+ offset->stage.flush = offset_flush;
offset->stage.reset_stipple_counter = offset_reset_stipple_counter;
offset->stage.destroy = offset_destroy;
diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c
index f8fc23b5101..5703f5f0b0c 100644
--- a/src/mesa/pipe/draw/draw_prim.c
+++ b/src/mesa/pipe/draw/draw_prim.c
@@ -57,7 +57,7 @@ static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = {
static void draw_prim_queue_flush( struct draw_context *draw )
{
- struct draw_stage *first = draw->pipeline.first;
+ // struct draw_stage *first = draw->pipeline.first;
unsigned i;
if (0)
@@ -69,27 +69,31 @@ static void draw_prim_queue_flush( struct draw_context *draw )
if (draw->vs.queue_nr)
draw_vertex_shader_queue_flush(draw);
+ /* NOTE: we cannot save draw->pipeline->first in a local var because
+ * draw->pipeline->first is often changed by the first call to tri(),
+ * line(), etc.
+ */
switch (draw->reduced_prim) {
case RP_TRI:
for (i = 0; i < draw->pq.queue_nr; i++) {
if (draw->pq.queue[i].reset_line_stipple)
- first->reset_stipple_counter( first );
+ draw->pipeline.first->reset_stipple_counter( draw->pipeline.first );
- first->tri( first, &draw->pq.queue[i] );
+ draw->pipeline.first->tri( draw->pipeline.first, &draw->pq.queue[i] );
}
break;
case RP_LINE:
for (i = 0; i < draw->pq.queue_nr; i++) {
if (draw->pq.queue[i].reset_line_stipple)
- first->reset_stipple_counter( first );
+ draw->pipeline.first->reset_stipple_counter( draw->pipeline.first );
- first->line( first, &draw->pq.queue[i] );
+ draw->pipeline.first->line( draw->pipeline.first, &draw->pq.queue[i] );
}
break;
case RP_POINT:
- first->reset_stipple_counter( first );
+ draw->pipeline.first->reset_stipple_counter( draw->pipeline.first );
for (i = 0; i < draw->pq.queue_nr; i++)
- first->point( first, &draw->pq.queue[i] );
+ draw->pipeline.first->point( draw->pipeline.first, &draw->pq.queue[i] );
break;
}
@@ -119,7 +123,7 @@ void draw_do_flush( struct draw_context *draw,
if ((flush & DRAW_FLUSH_DRAW) &&
draw->drawing)
{
- draw->pipeline.first->end( draw->pipeline.first );
+ draw->pipeline.first->flush( draw->pipeline.first, ~0 );
draw->drawing = FALSE;
draw->prim = ~0;
draw->pipeline.first = draw->pipeline.validate;
@@ -415,9 +419,6 @@ draw_arrays(struct draw_context *draw, unsigned prim,
{
if (!draw->drawing) {
draw->drawing = TRUE;
-
- /* tell drawing pipeline we're beginning drawing */
- draw->pipeline.first->begin( draw->pipeline.first );
}
if (draw->prim != prim) {
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index 685ec4a6443..e393fa5fe2a 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -101,8 +101,6 @@ struct draw_stage
struct vertex_header **tmp; /**< temp vert storage, such as for clipping */
unsigned nr_tmps;
- void (*begin)( struct draw_stage * );
-
void (*point)( struct draw_stage *,
struct prim_header * );
@@ -112,7 +110,8 @@ struct draw_stage
void (*tri)( struct draw_stage *,
struct prim_header * );
- void (*end)( struct draw_stage * );
+ void (*flush)( struct draw_stage *,
+ unsigned flags );
void (*reset_stipple_counter)( struct draw_stage * );
diff --git a/src/mesa/pipe/draw/draw_stipple.c b/src/mesa/pipe/draw/draw_stipple.c
index 2a47eb7be23..90291019165 100644
--- a/src/mesa/pipe/draw/draw_stipple.c
+++ b/src/mesa/pipe/draw/draw_stipple.c
@@ -173,7 +173,8 @@ reset_stipple_counter(struct draw_stage *stage)
static void
-stipple_begin(struct draw_stage *stage)
+stipple_first_line(struct draw_stage *stage,
+ struct prim_header *header)
{
struct stipple_stage *stipple = stipple_stage(stage);
struct draw_context *draw = stage->draw;
@@ -181,14 +182,16 @@ stipple_begin(struct draw_stage *stage)
stipple->pattern = draw->rasterizer->line_stipple_pattern;
stipple->factor = draw->rasterizer->line_stipple_factor + 1;
- stage->next->begin( stage->next );
+ stage->line = stipple_line;
+ stage->line( stage, header );
}
static void
-stipple_end(struct draw_stage *stage)
+stipple_flush(struct draw_stage *stage, unsigned flags)
{
- stage->next->end( stage->next );
+ stage->line = stipple_first_line;
+ stage->next->flush( stage->next, flags );
}
@@ -224,12 +227,11 @@ struct draw_stage *draw_stipple_stage( struct draw_context *draw )
stipple->stage.draw = draw;
stipple->stage.next = NULL;
- stipple->stage.begin = stipple_begin;
stipple->stage.point = passthrough_point;
- stipple->stage.line = stipple_line;
+ stipple->stage.line = stipple_first_line;
stipple->stage.tri = passthrough_tri;
stipple->stage.reset_stipple_counter = reset_stipple_counter;
- stipple->stage.end = stipple_end;
+ stipple->stage.flush = stipple_flush;
stipple->stage.destroy = stipple_destroy;
return &stipple->stage;
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
index 75c51ec6a90..ad2aaf10bb9 100644
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ b/src/mesa/pipe/draw/draw_twoside.c
@@ -48,48 +48,6 @@ static INLINE struct twoside_stage *twoside_stage( struct draw_stage *stage )
}
-static void twoside_begin( struct draw_stage *stage )
-{
- struct twoside_stage *twoside = twoside_stage(stage);
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
- uint i;
-
- twoside->attrib_front0 = 0;
- twoside->attrib_front1 = 0;
- twoside->attrib_back0 = 0;
- twoside->attrib_back1 = 0;
-
- /* Find which vertex shader outputs are front/back colors */
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
- if (vs->output_semantic_index[i] == 0)
- twoside->attrib_front0 = i;
- else
- twoside->attrib_front1 = i;
- }
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- if (vs->output_semantic_index[i] == 0)
- twoside->attrib_back0 = i;
- else
- twoside->attrib_back1 = i;
- }
- }
-
- if (!twoside->attrib_back0)
- twoside->attrib_front0 = 0;
-
- if (!twoside->attrib_back1)
- twoside->attrib_front1 = 0;
-
- /*
- * We'll multiply the primitive's determinant by this sign to determine
- * if the triangle is back-facing (negative).
- * sign = -1 for CCW, +1 for CW
- */
- twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f;
-
- stage->next->begin( stage->next );
-}
/**
@@ -157,10 +115,56 @@ static void twoside_point( struct draw_stage *stage,
}
-static void twoside_end( struct draw_stage *stage )
+static void twoside_first_tri( struct draw_stage *stage,
+ struct prim_header *header )
{
- /* pass-through */
- stage->next->end( stage->next );
+ struct twoside_stage *twoside = twoside_stage(stage);
+ const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ uint i;
+
+ twoside->attrib_front0 = 0;
+ twoside->attrib_front1 = 0;
+ twoside->attrib_back0 = 0;
+ twoside->attrib_back1 = 0;
+
+ /* Find which vertex shader outputs are front/back colors */
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+ if (vs->output_semantic_index[i] == 0)
+ twoside->attrib_front0 = i;
+ else
+ twoside->attrib_front1 = i;
+ }
+ if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ if (vs->output_semantic_index[i] == 0)
+ twoside->attrib_back0 = i;
+ else
+ twoside->attrib_back1 = i;
+ }
+ }
+
+ if (!twoside->attrib_back0)
+ twoside->attrib_front0 = 0;
+
+ if (!twoside->attrib_back1)
+ twoside->attrib_front1 = 0;
+
+ /*
+ * We'll multiply the primitive's determinant by this sign to determine
+ * if the triangle is back-facing (negative).
+ * sign = -1 for CCW, +1 for CW
+ */
+ twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f;
+
+ stage->tri = twoside_tri;
+ stage->tri( stage, header );
+}
+
+
+static void twoside_flush( struct draw_stage *stage, unsigned flags )
+{
+ stage->tri = twoside_first_tri;
+ stage->next->flush( stage->next, flags );
}
@@ -188,11 +192,10 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw )
twoside->stage.draw = draw;
twoside->stage.next = NULL;
- twoside->stage.begin = twoside_begin;
twoside->stage.point = twoside_point;
twoside->stage.line = twoside_line;
- twoside->stage.tri = twoside_tri;
- twoside->stage.end = twoside_end;
+ twoside->stage.tri = twoside_first_tri;
+ twoside->stage.flush = twoside_flush;
twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter;
twoside->stage.destroy = twoside_destroy;
diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c
index 786826b33c1..364bda8b791 100644
--- a/src/mesa/pipe/draw/draw_unfilled.c
+++ b/src/mesa/pipe/draw/draw_unfilled.c
@@ -55,15 +55,6 @@ static INLINE struct unfilled_stage *unfilled_stage( struct draw_stage *stage )
}
-static void unfilled_begin( struct draw_stage *stage )
-{
- struct unfilled_stage *unfilled = unfilled_stage(stage);
-
- unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */
- unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */
-
- stage->next->begin( stage->next );
-}
static void point( struct draw_stage *stage,
struct vertex_header *v0 )
@@ -142,6 +133,20 @@ static void unfilled_tri( struct draw_stage *stage,
}
}
+
+static void unfilled_first_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct unfilled_stage *unfilled = unfilled_stage(stage);
+
+ unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */
+ unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */
+
+ stage->tri = unfilled_tri;
+ stage->tri( stage, header );
+}
+
+
static void unfilled_line( struct draw_stage *stage,
struct prim_header *header )
{
@@ -156,9 +161,10 @@ static void unfilled_point( struct draw_stage *stage,
}
-static void unfilled_end( struct draw_stage *stage )
+static void unfilled_flush( struct draw_stage *stage,
+ unsigned flags )
{
- stage->next->end( stage->next );
+ stage->next->flush( stage->next, flags );
}
@@ -187,11 +193,10 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
unfilled->stage.draw = draw;
unfilled->stage.next = NULL;
unfilled->stage.tmp = NULL;
- unfilled->stage.begin = unfilled_begin;
unfilled->stage.point = unfilled_point;
unfilled->stage.line = unfilled_line;
- unfilled->stage.tri = unfilled_tri;
- unfilled->stage.end = unfilled_end;
+ unfilled->stage.tri = unfilled_first_tri;
+ unfilled->stage.flush = unfilled_flush;
unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
unfilled->stage.destroy = unfilled_destroy;
diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c
index 3b1f5179a93..a626fb1fba5 100644
--- a/src/mesa/pipe/draw/draw_validate.c
+++ b/src/mesa/pipe/draw/draw_validate.c
@@ -39,7 +39,7 @@
/**
* Rebuild the rendering pipeline.
*/
-static void validate_begin( struct draw_stage *stage )
+static struct draw_stage *validate_pipeline( struct draw_stage *stage )
{
struct draw_context *draw = stage->draw;
struct draw_stage *next = draw->pipeline.rasterize;
@@ -106,7 +106,45 @@ static void validate_begin( struct draw_stage *stage )
}
draw->pipeline.first = next;
- draw->pipeline.first->begin( draw->pipeline.first );
+ //BP draw->pipeline.first->begin( draw->pipeline.first );
+ return next;
+}
+
+
+static void validate_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct draw_stage *pipeline = validate_pipeline( stage );
+ pipeline->tri( pipeline, header );
+}
+
+static void validate_line( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct draw_stage *pipeline = validate_pipeline( stage );
+ pipeline->line( pipeline, header );
+}
+
+static void validate_point( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct draw_stage *pipeline = validate_pipeline( stage );
+ pipeline->point( pipeline, header );
+}
+
+static void validate_reset_stipple_counter( struct draw_stage *stage )
+{
+ struct draw_stage *pipeline = validate_pipeline( stage );
+ pipeline->reset_stipple_counter( pipeline );
+}
+
+static void validate_flush( struct draw_stage *stage,
+ unsigned flags )
+{
+ /* May need to pass a backend flush on to the rasterize stage.
+ */
+ if (stage->next)
+ stage->next->flush( stage->next, flags );
}
@@ -124,13 +162,13 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw )
struct draw_stage *stage = CALLOC_STRUCT(draw_stage);
stage->draw = draw;
+
stage->next = NULL;
- stage->begin = validate_begin;
- stage->point = NULL;
- stage->line = NULL;
- stage->tri = NULL;
- stage->end = NULL;
- stage->reset_stipple_counter = NULL;
+ stage->point = validate_point;
+ stage->line = validate_line;
+ stage->tri = validate_tri;
+ stage->flush = validate_flush;
+ stage->reset_stipple_counter = validate_reset_stipple_counter;
stage->destroy = validate_destroy;
return stage;
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c
index 82051d2e65b..d827f51d567 100644
--- a/src/mesa/pipe/draw/draw_vbuf.c
+++ b/src/mesa/pipe/draw/draw_vbuf.c
@@ -395,7 +395,7 @@ vbuf_begin( struct draw_stage *stage )
static void
-vbuf_end( struct draw_stage *stage )
+vbuf_flush( struct draw_stage *stage, unsigned flags )
{
// vbuf_flush_indices( stage );
/* XXX: Overkill */
@@ -432,11 +432,10 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage);
vbuf->stage.draw = draw;
- vbuf->stage.begin = vbuf_begin;
vbuf->stage.point = vbuf_first_point;
vbuf->stage.line = vbuf_first_line;
vbuf->stage.tri = vbuf_first_tri;
- vbuf->stage.end = vbuf_end;
+ vbuf->stage.flush = vbuf_flush;
vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter;
vbuf->stage.destroy = vbuf_destroy;
diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c
index f71a38efbaa..26f5d10dc03 100644
--- a/src/mesa/pipe/draw/draw_wide_prims.c
+++ b/src/mesa/pipe/draw/draw_wide_prims.c
@@ -262,26 +262,19 @@ static void wide_point( struct draw_stage *stage,
}
-static void wide_begin( struct draw_stage *stage )
+static void wide_first_point( struct draw_stage *stage,
+ struct prim_header *header )
{
struct wide_stage *wide = wide_stage(stage);
struct draw_context *draw = stage->draw;
wide->half_point_size = 0.5f * draw->rasterizer->point_size;
- wide->half_line_width = 0.5f * draw->rasterizer->line_width;
-
- if (draw->rasterizer->line_width != 1.0) {
- wide->stage.line = wide_line;
- }
- else {
- wide->stage.line = passthrough_line;
- }
if (draw->rasterizer->point_size != 1.0) {
- wide->stage.point = wide_point;
+ stage->point = wide_point;
}
else {
- wide->stage.point = passthrough_point;
+ stage->point = passthrough_point;
}
if (draw->rasterizer->point_sprite) {
@@ -299,6 +292,7 @@ static void wide_begin( struct draw_stage *stage )
}
wide->psize_slot = -1;
+
if (draw->rasterizer->point_size_per_vertex) {
/* find PSIZ vertex output */
const struct draw_vertex_shader *vs = draw->vertex_shader;
@@ -311,13 +305,35 @@ static void wide_begin( struct draw_stage *stage )
}
}
- stage->next->begin( stage->next );
+ stage->point( stage, header );
+}
+
+
+
+static void wide_first_line( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct wide_stage *wide = wide_stage(stage);
+ struct draw_context *draw = stage->draw;
+
+ wide->half_line_width = 0.5f * draw->rasterizer->line_width;
+
+ if (draw->rasterizer->line_width != 1.0) {
+ wide->stage.line = wide_line;
+ }
+ else {
+ wide->stage.line = passthrough_line;
+ }
+
+ stage->line( stage, header );
}
-static void wide_end( struct draw_stage *stage )
+static void wide_flush( struct draw_stage *stage, unsigned flags )
{
- stage->next->end( stage->next );
+ stage->line = wide_first_line;
+ stage->point = wide_first_point;
+ stage->next->flush( stage->next, flags );
}
@@ -342,11 +358,10 @@ struct draw_stage *draw_wide_stage( struct draw_context *draw )
wide->stage.draw = draw;
wide->stage.next = NULL;
- wide->stage.begin = wide_begin;
- wide->stage.point = wide_point;
- wide->stage.line = wide_line;
+ wide->stage.point = wide_first_point;
+ wide->stage.line = wide_first_line;
wide->stage.tri = passthrough_tri;
- wide->stage.end = wide_end;
+ wide->stage.flush = wide_flush;
wide->stage.reset_stipple_counter = draw_reset_stipple_counter;
wide->stage.destroy = wide_destroy;
diff --git a/src/mesa/pipe/i915simple/i915_prim_emit.c b/src/mesa/pipe/i915simple/i915_prim_emit.c
index f74671b39ce..c4a706c37d8 100644
--- a/src/mesa/pipe/i915simple/i915_prim_emit.c
+++ b/src/mesa/pipe/i915simple/i915_prim_emit.c
@@ -180,13 +180,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
}
-
-static void setup_begin( struct draw_stage *stage )
-{
-}
-
-
-static void setup_end( struct draw_stage *stage )
+static void setup_flush( struct draw_stage *stage, unsigned flags )
{
}
@@ -210,11 +204,10 @@ struct draw_stage *i915_draw_render_stage( struct i915_context *i915 )
setup->i915 = i915;
setup->stage.draw = i915->draw;
- setup->stage.begin = setup_begin;
setup->stage.point = setup_point;
setup->stage.line = setup_line;
setup->stage.tri = setup_tri;
- setup->stage.end = setup_end;
+ setup->stage.flush = setup_flush;
setup->stage.reset_stipple_counter = reset_stipple_counter;
setup->stage.destroy = render_destroy;
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
index 423c91d4b8e..71a303a8b58 100644
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c
@@ -142,21 +142,18 @@ softpipe_draw_elements(struct pipe_context *pipe,
/* draw! */
draw_arrays(draw, mode, start, count);
- /* always flush for now */
- draw_flush(draw);
-
/*
- * unmap vertex/index buffers
+ * unmap vertex/index buffers - will cause draw module to flush
*/
for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
if (sp->vertex_buffer[i].buffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
draw_set_mapped_vertex_buffer(draw, i, NULL);
+ pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
}
}
if (indexBuffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
draw_set_mapped_element_buffer(draw, 0, NULL);
+ pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
}
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 478ecff2fb5..088d8a4c07e 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -1170,11 +1170,43 @@ static void setup_begin( struct draw_stage *stage )
setup->quad.nr_attrs = fs->num_inputs;
sp->quad.first->begin(sp->quad.first);
+
+ stage->point = setup_point;
+ stage->line = setup_line;
+ stage->tri = setup_tri;
}
-static void setup_end( struct draw_stage *stage )
+static void setup_first_point( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ setup_begin(stage);
+ stage->point( stage, header );
+}
+
+static void setup_first_line( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ setup_begin(stage);
+ stage->line( stage, header );
+}
+
+
+static void setup_first_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ setup_begin(stage);
+ stage->tri( stage, header );
+}
+
+
+
+static void setup_flush( struct draw_stage *stage,
+ unsigned flags )
{
+ stage->point = setup_first_point;
+ stage->line = setup_first_line;
+ stage->tri = setup_first_tri;
}
@@ -1198,11 +1230,10 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe )
setup->softpipe = softpipe;
setup->stage.draw = softpipe->draw;
- setup->stage.begin = setup_begin;
- setup->stage.point = setup_point;
- setup->stage.line = setup_line;
- setup->stage.tri = setup_tri;
- setup->stage.end = setup_end;
+ setup->stage.point = setup_first_point;
+ setup->stage.line = setup_first_line;
+ setup->stage.tri = setup_first_tri;
+ setup->stage.flush = setup_flush;
setup->stage.reset_stipple_counter = reset_stipple_counter;
setup->stage.destroy = render_destroy;
diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
index dfabae83025..c9089e7eb22 100644
--- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c
+++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
@@ -149,8 +149,6 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices)
prim.edgeflags = 0;
prim.pad = 0;
- setup->begin( setup );
-
switch (cvbr->prim) {
case PIPE_PRIM_TRIANGLES:
for (i = 0; i < nr_indices; i += 3) {
@@ -182,7 +180,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices)
break;
}
- setup->end( setup );
+ setup->flush( setup, 0 );
}
diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index 43543df1a88..31744151f1d 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -159,14 +159,7 @@ feedback_point( struct draw_stage *stage, struct prim_header *prim )
static void
-feedback_end( struct draw_stage *stage )
-{
- /* no-op */
-}
-
-
-static void
-feedback_begin( struct draw_stage *stage )
+feedback_flush( struct draw_stage *stage, unsigned flags )
{
/* no-op */
}
@@ -190,11 +183,10 @@ draw_glfeedback_stage(GLcontext *ctx, struct draw_context *draw)
fs->stage.draw = draw;
fs->stage.next = NULL;
- fs->stage.begin = feedback_begin;
fs->stage.point = feedback_point;
fs->stage.line = feedback_line;
fs->stage.tri = feedback_tri;
- fs->stage.end = feedback_end;
+ fs->stage.flush = feedback_flush;
fs->stage.reset_stipple_counter = feedback_reset_stipple_counter;
fs->ctx = ctx;
@@ -234,14 +226,7 @@ select_point( struct draw_stage *stage, struct prim_header *prim )
static void
-select_begin( struct draw_stage *stage )
-{
- /* no-op */
-}
-
-
-static void
-select_end( struct draw_stage *stage )
+select_flush( struct draw_stage *stage, unsigned flags )
{
/* no-op */
}
@@ -264,11 +249,10 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw)
fs->stage.draw = draw;
fs->stage.next = NULL;
- fs->stage.begin = select_begin;
fs->stage.point = select_point;
fs->stage.line = select_line;
fs->stage.tri = select_tri;
- fs->stage.end = select_end;
+ fs->stage.flush = select_flush;
fs->stage.reset_stipple_counter = select_reset_stipple_counter;
fs->ctx = ctx;
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 9e20e94dc7c..7e347c48938 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -73,13 +73,7 @@ rastpos_stage( struct draw_stage *stage )
}
static void
-rastpos_begin( struct draw_stage *stage )
-{
- /* no-op */
-}
-
-static void
-rastpos_end( struct draw_stage *stage )
+rastpos_flush( struct draw_stage *stage, unsigned flags )
{
/* no-op */
}
@@ -183,11 +177,10 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
rs->stage.draw = draw;
rs->stage.next = NULL;
- rs->stage.begin = rastpos_begin;
rs->stage.point = rastpos_point;
rs->stage.line = rastpos_line;
rs->stage.tri = rastpos_tri;
- rs->stage.end = rastpos_end;
+ rs->stage.flush = rastpos_flush;
rs->stage.destroy = rastpos_destroy;
rs->stage.reset_stipple_counter = rastpos_reset_stipple_counter;
rs->stage.destroy = rastpos_destroy;