summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/Makefile1
-rw-r--r--src/gallium/auxiliary/draw/SConscript1
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe.c19
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe.h11
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c16
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c13
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c56
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_flatshade.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c37
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_twoside.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_unfilled.c24
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h47
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c28
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h10
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_emit.c71
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch.c93
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c20
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_post_vs.c14
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray.c250
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray_tmp.h144
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c354
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h174
27 files changed, 863 insertions, 543 deletions
diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile
index bc6acfe458..da7eded21f 100644
--- a/src/gallium/auxiliary/draw/Makefile
+++ b/src/gallium/auxiliary/draw/Makefile
@@ -28,6 +28,7 @@ C_SOURCES = \
draw_pt_fetch_emit.c \
draw_pt_fetch_shade_pipeline.c \
draw_pt_post_vs.c \
+ draw_pt_varray.c \
draw_pt_vcache.c \
draw_vertex.c \
draw_vs.c \
diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript
index 0b9852f633..3b5d5ed492 100644
--- a/src/gallium/auxiliary/draw/SConscript
+++ b/src/gallium/auxiliary/draw/SConscript
@@ -27,6 +27,7 @@ draw = env.ConvenienceLibrary(
'draw_pt_fetch_emit.c',
'draw_pt_fetch_shade_pipeline.c',
'draw_pt_post_vs.c',
+ 'draw_pt_varray.c',
'draw_pt_vcache.c',
'draw_vertex.c',
'draw_vs.c',
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index f90187816b..98e23fa830 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -367,8 +367,10 @@ draw_set_mapped_element_buffer( struct draw_context *draw,
*/
void draw_do_flush( struct draw_context *draw, unsigned flags )
{
- if (!draw->flushing && !draw->vcache_flushing)
+ if (!draw->suspend_flushing)
{
+ assert(!draw->flushing); /* catch inadvertant recursion */
+
draw->flushing = TRUE;
draw_pipeline_flush( draw, flags );
diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c
index d0890203a5..46afb0f41f 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.c
+++ b/src/gallium/auxiliary/draw/draw_pipe.c
@@ -116,8 +116,7 @@ static void do_point( struct draw_context *draw,
{
struct prim_header prim;
- prim.reset_line_stipple = 0;
- prim.edgeflags = 1;
+ prim.flags = 0;
prim.pad = 0;
prim.v[0] = (struct vertex_header *)v0;
@@ -126,13 +125,13 @@ static void do_point( struct draw_context *draw,
static void do_line( struct draw_context *draw,
+ ushort flags,
const char *v0,
const char *v1 )
{
struct prim_header prim;
- prim.reset_line_stipple = 1; /* fixme */
- prim.edgeflags = 1;
+ prim.flags = flags;
prim.pad = 0;
prim.v[0] = (struct vertex_header *)v0;
prim.v[1] = (struct vertex_header *)v1;
@@ -142,6 +141,7 @@ static void do_line( struct draw_context *draw,
static void do_triangle( struct draw_context *draw,
+ ushort flags,
char *v0,
char *v1,
char *v2 )
@@ -151,10 +151,7 @@ static void do_triangle( struct draw_context *draw,
prim.v[0] = (struct vertex_header *)v0;
prim.v[1] = (struct vertex_header *)v1;
prim.v[2] = (struct vertex_header *)v2;
- prim.reset_line_stipple = 1;
- prim.edgeflags = ((prim.v[0]->edgeflag) |
- (prim.v[1]->edgeflag << 1) |
- (prim.v[2]->edgeflag << 2));
+ prim.flags = flags;
prim.pad = 0;
draw->pipeline.first->tri( draw->pipeline.first, &prim );
@@ -197,13 +194,15 @@ void draw_pipeline_run( struct draw_context *draw,
case PIPE_PRIM_LINES:
for (i = 0; i+1 < count; i += 2)
do_line( draw,
- verts + stride * elts[i+0],
+ elts[i+0], /* flags */
+ verts + stride * (elts[i+0] & ~DRAW_PIPE_FLAG_MASK),
verts + stride * elts[i+1]);
break;
case PIPE_PRIM_TRIANGLES:
for (i = 0; i+2 < count; i += 3)
do_triangle( draw,
- verts + stride * elts[i+0],
+ elts[i+0], /* flags */
+ verts + stride * (elts[i+0] & ~DRAW_PIPE_FLAG_MASK),
verts + stride * elts[i+1],
verts + stride * elts[i+2]);
break;
diff --git a/src/gallium/auxiliary/draw/draw_pipe.h b/src/gallium/auxiliary/draw/draw_pipe.h
index 2476abb2b2..f1cb0891ca 100644
--- a/src/gallium/auxiliary/draw/draw_pipe.h
+++ b/src/gallium/auxiliary/draw/draw_pipe.h
@@ -37,6 +37,17 @@
#include "draw_private.h" /* for sizeof(vertex_header) */
+/**
+ * Basic info for a point/line/triangle primitive.
+ */
+struct prim_header {
+ float det; /**< front/back face determinant */
+ ushort flags;
+ ushort pad;
+ struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */
+};
+
+
/**
* Base class for all primitive drawing stages.
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 7e5f8bd281..f05641dee6 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -485,11 +485,16 @@ aaline_create_sampler(struct aaline_stage *aaline)
static boolean
bind_aaline_fragment_shader(struct aaline_stage *aaline)
{
+ struct draw_context *draw = aaline->stage.draw;
+
if (!aaline->fs->aaline_fs &&
!generate_aaline_fs(aaline))
return FALSE;
+ draw->suspend_flushing = TRUE;
aaline->driver_bind_fs_state(aaline->pipe, aaline->fs->aaline_fs);
+ draw->suspend_flushing = FALSE;
+
return TRUE;
}
@@ -663,8 +668,10 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
pipe_texture_reference(&aaline->state.texture[aaline->fs->sampler_unit],
aaline->texture);
+ draw->suspend_flushing = TRUE;
aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
aaline->driver_set_sampler_textures(pipe, num_samplers, aaline->state.texture);
+ draw->suspend_flushing = FALSE;
/* now really draw first line */
stage->line = aaline_line;
@@ -682,14 +689,14 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
stage->line = aaline_first_line;
stage->next->flush( stage->next, flags );
- /* restore original frag shader */
+ /* restore original frag shader, texture, sampler state */
+ draw->suspend_flushing = TRUE;
aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
-
- /* XXX restore original texture, sampler state */
aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
aaline->state.sampler);
aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
aaline->state.texture);
+ draw->suspend_flushing = FALSE;
draw->extra_vp_outputs.slot = 0;
}
@@ -783,6 +790,7 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
+
/* save current */
aaline->fs = aafs;
/* pass-through */
@@ -807,9 +815,11 @@ aaline_bind_sampler_states(struct pipe_context *pipe,
unsigned num, void **sampler)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
+
/* save current */
memcpy(aaline->state.sampler, sampler, num * sizeof(void *));
aaline->num_samplers = num;
+
/* pass-through */
aaline->driver_bind_sampler_states(aaline->pipe, num, sampler);
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index ac0aa4cd7c..122a48660a 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -481,7 +481,7 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
/**
- * Generate the frag shader we'll use for drawing AA lines.
+ * Generate the frag shader we'll use for drawing AA points.
* This will be the user's shader plus some texture/modulate instructions.
*/
static boolean
@@ -531,17 +531,22 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
/**
- * When we're about to draw our first AA line in a batch, this function is
+ * When we're about to draw our first AA point in a batch, this function is
* called to tell the driver to bind our modified fragment shader.
*/
static boolean
bind_aapoint_fragment_shader(struct aapoint_stage *aapoint)
{
+ struct draw_context *draw = aapoint->stage.draw;
+
if (!aapoint->fs->aapoint_fs &&
!generate_aapoint_fs(aapoint))
return FALSE;
+ draw->suspend_flushing = TRUE;
aapoint->driver_bind_fs_state(aapoint->pipe, aapoint->fs->aapoint_fs);
+ draw->suspend_flushing = FALSE;
+
return TRUE;
}
@@ -697,7 +702,7 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
}
}
- /* now really draw first line */
+ /* now really draw first point */
stage->point = aapoint_point;
stage->point(stage, header);
}
@@ -714,7 +719,9 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
stage->next->flush( stage->next, flags );
/* restore original frag shader */
+ draw->suspend_flushing = TRUE;
aapoint->driver_bind_fs_state(pipe, aapoint->fs->driver_fs);
+ draw->suspend_flushing = FALSE;
draw->extra_vp_outputs.slot = 0;
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index 21216addea..ce80c94163 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -119,7 +119,7 @@ static void interp( const struct clipper *clip,
*/
{
dst->clipmask = 0;
- dst->edgeflag = 0;
+ dst->edgeflag = 0; /* will get overwritten later */
dst->pad = 0;
dst->vertex_id = UNDEFINED_VERTEX_ID;
}
@@ -162,45 +162,39 @@ static void emit_poly( struct draw_stage *stage,
struct prim_header header;
unsigned i;
+ const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2;
+ const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0;
+ const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1;
+
/* later stages may need the determinant, but only the sign matters */
header.det = origPrim->det;
+ header.flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
+ header.pad = 0;
- for (i = 2; i < n; i++) {
+ for (i = 2; i < n; i++, header.flags = 0) {
header.v[0] = inlist[i-1];
header.v[1] = inlist[i];
header.v[2] = inlist[0]; /* keep in v[2] for flatshading */
-
- {
- unsigned tmp1 = header.v[1]->edgeflag;
- unsigned tmp2 = header.v[2]->edgeflag;
-
- if (i != n-1) header.v[1]->edgeflag = 0;
- if (i != 2) header.v[2]->edgeflag = 0;
-
- header.edgeflags = ((header.v[0]->edgeflag << 0) |
- (header.v[1]->edgeflag << 1) |
- (header.v[2]->edgeflag << 2));
-
- if (0) {
- const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
- uint j, k;
- debug_printf("Clipped tri:\n");
- for (j = 0; j < 3; j++) {
- for (k = 0; k < vs->info.num_outputs; k++) {
- debug_printf(" Vert %d: Attr %d: %f %f %f %f\n", j, k,
- header.v[j]->data[k][0],
- header.v[j]->data[k][1],
- header.v[j]->data[k][2],
- header.v[j]->data[k][3]);
- }
+
+ if (i == n-1)
+ header.flags |= edge_last;
+
+ if (0) {
+ const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
+ uint j, k;
+ debug_printf("Clipped tri:\n");
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < vs->info.num_outputs; k++) {
+ debug_printf(" Vert %d: Attr %d: %f %f %f %f\n", j, k,
+ header.v[j]->data[k][0],
+ header.v[j]->data[k][1],
+ header.v[j]->data[k][2],
+ header.v[j]->data[k][3]);
}
}
-
- stage->next->tri( stage->next, &header );
-
- header.v[1]->edgeflag = tmp1;
- header.v[2]->edgeflag = tmp2;
}
+
+ stage->next->tri( stage->next, &header );
}
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
index 205000cbea..09b68c4559 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
@@ -91,7 +91,8 @@ static void flatshade_tri_0( struct draw_stage *stage,
struct prim_header tmp;
tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
+ tmp.flags = header->flags;
+ tmp.pad = header->pad;
tmp.v[0] = header->v[0];
tmp.v[1] = dup_vert(stage, header->v[1], 0);
tmp.v[2] = dup_vert(stage, header->v[2], 1);
@@ -108,7 +109,8 @@ static void flatshade_tri_2( struct draw_stage *stage,
struct prim_header tmp;
tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
+ tmp.flags = header->flags;
+ tmp.pad = header->pad;
tmp.v[0] = dup_vert(stage, header->v[0], 0);
tmp.v[1] = dup_vert(stage, header->v[1], 1);
tmp.v[2] = header->v[2];
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index ffec85ccdd..ea6de8c571 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -106,7 +106,8 @@ static void offset_tri( struct draw_stage *stage,
struct prim_header tmp;
tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
+ tmp.flags = header->flags;
+ tmp.pad = header->pad;
tmp.v[0] = dup_vert(stage, header->v[0], 0);
tmp.v[1] = dup_vert(stage, header->v[1], 1);
tmp.v[2] = dup_vert(stage, header->v[2], 2);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index aec485a6e7..d1d63d73be 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -433,9 +433,7 @@ pstip_create_texture(struct pstip_stage *pstip)
/**
- * Create the sampler CSO that'll be used for antialiasing.
- * By using a mipmapped texture, we don't have to generate a different
- * texture image for each line size.
+ * Create the sampler CSO that'll be used for stippling.
*/
static boolean
pstip_create_sampler(struct pstip_stage *pstip)
@@ -463,22 +461,24 @@ pstip_create_sampler(struct pstip_stage *pstip)
/**
- * When we're about to draw our first AA line in a batch, this function is
- * called to tell the driver to bind our modified fragment shader.
+ * When we're about to draw our first stipple polygon in a batch, this function
+ * is called to tell the driver to bind our modified fragment shader.
*/
static boolean
bind_pstip_fragment_shader(struct pstip_stage *pstip)
{
+ struct draw_context *draw = pstip->stage.draw;
if (!pstip->fs->pstip_fs &&
!generate_pstip_fs(pstip))
return FALSE;
+ draw->suspend_flushing = TRUE;
pstip->driver_bind_fs_state(pstip->pipe, pstip->fs->pstip_fs);
+ draw->suspend_flushing = FALSE;
return TRUE;
}
-
static INLINE struct pstip_stage *
pstip_stage( struct draw_stage *stage )
{
@@ -486,14 +486,12 @@ pstip_stage( struct draw_stage *stage )
}
-
-
-
static void
pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
{
struct pstip_stage *pstip = pstip_stage(stage);
struct pipe_context *pipe = pstip->pipe;
+ struct draw_context *draw = stage->draw;
uint num_samplers;
assert(stage->draw->rasterizer->poly_stipple_enable);
@@ -518,10 +516,12 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
assert(num_samplers <= PIPE_MAX_SAMPLERS);
+ draw->suspend_flushing = TRUE;
pstip->driver_bind_sampler_states(pipe, num_samplers, pstip->state.samplers);
pstip->driver_set_sampler_textures(pipe, num_samplers, pstip->state.textures);
+ draw->suspend_flushing = FALSE;
- /* now really draw first line */
+ /* now really draw first triangle */
stage->tri = draw_pipe_passthrough_tri;
stage->tri(stage, header);
}
@@ -530,21 +530,21 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
static void
pstip_flush(struct draw_stage *stage, unsigned flags)
{
- /*struct draw_context *draw = stage->draw;*/
+ struct draw_context *draw = stage->draw;
struct pstip_stage *pstip = pstip_stage(stage);
struct pipe_context *pipe = pstip->pipe;
stage->tri = pstip_first_tri;
stage->next->flush( stage->next, flags );
- /* restore original frag shader */
+ /* restore original frag shader, texture, sampler state */
+ draw->suspend_flushing = TRUE;
pstip->driver_bind_fs_state(pipe, pstip->fs->driver_fs);
-
- /* XXX restore original texture, sampler state */
pstip->driver_bind_sampler_states(pipe, pstip->num_samplers,
pstip->state.samplers);
pstip->driver_set_sampler_textures(pipe, pstip->num_textures,
pstip->state.textures);
+ draw->suspend_flushing = FALSE;
}
@@ -689,8 +689,10 @@ pstip_set_polygon_stipple(struct pipe_context *pipe,
const struct pipe_poly_stipple *stipple)
{
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
+
/* save current */
pstip->state.stipple = stipple;
+
/* pass-through */
pstip->driver_set_polygon_stipple(pstip->pipe, stipple);
@@ -698,11 +700,10 @@ pstip_set_polygon_stipple(struct pipe_context *pipe,
}
-
/**
- * Called by drivers that want to install this AA line prim stage
+ * Called by drivers that want to install this polygon stipple stage
* into the draw module's pipeline. This will not be used if the
- * hardware has native support for AA lines.
+ * hardware has native support for polygon stipple.
*/
boolean
draw_install_pstipple_stage(struct draw_context *draw,
@@ -713,7 +714,7 @@ draw_install_pstipple_stage(struct draw_context *draw,
pipe->draw = (void *) draw;
/*
- * Create / install AA line drawing / prim stage
+ * Create / install pgon stipple drawing / prim stage
*/
pstip = draw_pstip_stage( draw );
if (pstip == NULL)
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index 9cf5840cce..3cbced362e 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -135,6 +135,10 @@ stipple_line(struct draw_stage *stage, struct prim_header *header)
float length = MAX2(dx, dy);
int i;
+ if (header->flags & DRAW_PIPE_RESET_STIPPLE)
+ stipple->counter = 0;
+
+
/* XXX ToDo: intead of iterating pixel-by-pixel, use a look-up table.
*/
for (i = 0; i < length; i++) {
diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
index 5910dccc43..50872fdbe9 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
@@ -85,7 +85,8 @@ static void twoside_tri( struct draw_stage *stage,
struct prim_header tmp;
tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
+ tmp.flags = header->flags;
+ tmp.pad = header->pad;
/* copy back attribs to front attribs */
tmp.v[0] = copy_bfc(twoside, header->v[0], 0);
tmp.v[1] = copy_bfc(twoside, header->v[1], 1);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
index eeb2bc43f9..8f97fdedaa 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
@@ -83,9 +83,9 @@ static void points( struct draw_stage *stage,
struct vertex_header *v1 = header->v[1];
struct vertex_header *v2 = header->v[2];
- if (header->edgeflags & 0x1) point( stage, v0 );
- if (header->edgeflags & 0x2) point( stage, v1 );
- if (header->edgeflags & 0x4) point( stage, v2 );
+ if ((header->flags & DRAW_PIPE_EDGE_FLAG_0) && v0->edgeflag) point( stage, v0 );
+ if ((header->flags & DRAW_PIPE_EDGE_FLAG_1) && v1->edgeflag) point( stage, v1 );
+ if ((header->flags & DRAW_PIPE_EDGE_FLAG_2) && v2->edgeflag) point( stage, v2 );
}
@@ -96,22 +96,22 @@ static void lines( struct draw_stage *stage,
struct vertex_header *v1 = header->v[1];
struct vertex_header *v2 = header->v[2];
-#if 0
- assert(((header->edgeflags & 0x1) >> 0) == header->v[0]->edgeflag);
- assert(((header->edgeflags & 0x2) >> 1) == header->v[1]->edgeflag);
- assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
-#endif
+ if (header->flags & DRAW_PIPE_RESET_STIPPLE)
+ stage->next->reset_stipple_counter( stage->next );
- if (header->edgeflags & 0x4) line( stage, v2, v0 );
- if (header->edgeflags & 0x1) line( stage, v0, v1 );
- if (header->edgeflags & 0x2) line( stage, v1, v2 );
+ if ((header->flags & DRAW_PIPE_EDGE_FLAG_2) && v2->edgeflag) line( stage, v2, v0 );
+ if ((header->flags & DRAW_PIPE_EDGE_FLAG_0) && v0->edgeflag) line( stage, v0, v1 );
+ if ((header->flags & DRAW_PIPE_EDGE_FLAG_1) && v1->edgeflag) line( stage, v1, v2 );
}
/* Unfilled tri:
*
* Note edgeflags in the vertex struct is not sufficient as we will
- * need to manipulate them when decomposing primitives???
+ * need to manipulate them when decomposing primitives.
+ *
+ * We currently keep the vertex edgeflag and primitive edgeflag mask
+ * separate until the last possible moment.
*/
static void unfilled_tri( struct draw_stage *stage,
struct prim_header *header )
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index afd5f5544d..2a19e6916a 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -254,6 +254,7 @@ vbuf_set_prim( struct vbuf_stage *vbuf, uint prim )
case EMIT_4UB:
output_format = PIPE_FORMAT_B8G8R8A8_UNORM;
emit_sz = 4 * sizeof(ubyte);
+ break;
default:
assert(0);
output_format = PIPE_FORMAT_NONE;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index 452732e662..878c9c7169 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -169,7 +169,7 @@ struct draw_stage *draw_wide_line_stage( struct draw_context *draw )
wide->stage.next = NULL;
wide->stage.point = draw_pipe_passthrough_point;
wide->stage.line = wideline_line;
- wide->stage.tri = draw_pipe_passthrough_point;
+ wide->stage.tri = draw_pipe_passthrough_tri;
wide->stage.flush = wideline_flush;
wide->stage.reset_stipple_counter = wideline_reset_stipple_counter;
wide->stage.destroy = wideline_destroy;
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 39aa81b43c..cee58bbf73 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -79,25 +79,6 @@ struct vertex_header {
/**
- * Basic info for a point/line/triangle primitive.
- */
-struct prim_header {
- float det; /**< front/back face determinant */
- unsigned reset_line_stipple:1;
- unsigned edgeflags:3;
- unsigned pad:28;
- struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */
-};
-
-
-
-
-#define PT_SHADE 0x1
-#define PT_CLIPTEST 0x2
-#define PT_PIPELINE 0x4
-#define PT_MAX_MIDDLE 0x8
-
-/**
* Private context for the drawing module.
*/
struct draw_context
@@ -148,6 +129,7 @@ struct draw_context
struct {
struct draw_pt_front_end *vcache;
+ struct draw_pt_front_end *varray;
} front;
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
@@ -178,9 +160,9 @@ struct draw_context
boolean bypass_clipping;
} driver;
- boolean flushing;
- boolean vcache_flushing;
- boolean bypass_clipping; /* set if either api or driver bypass_clipping true */
+ boolean flushing; /**< debugging/sanity */
+ boolean suspend_flushing; /**< internally set */
+ boolean bypass_clipping; /**< set if either api or driver bypass_clipping true */
/* pipe state that we need: */
const struct pipe_rasterizer_state *rasterizer;
@@ -238,6 +220,25 @@ void draw_pt_reset_vertex_ids( struct draw_context *draw );
boolean draw_pipeline_init( struct draw_context *draw );
void draw_pipeline_destroy( struct draw_context *draw );
+
+
+
+
+/* We use the top few bits in the elts[] parameter to convey a little
+ * API information. This limits the number of vertices we can address
+ * to only 4096 -- if that becomes a problem, we can switch to 32-bit
+ * draw indices.
+ *
+ * These flags expected at first vertex of lines & triangles when
+ * unfilled and/or line stipple modes are operational.
+ */
+#define DRAW_PIPE_EDGE_FLAG_0 (0x1<<12)
+#define DRAW_PIPE_EDGE_FLAG_1 (0x2<<12)
+#define DRAW_PIPE_EDGE_FLAG_2 (0x4<<12)
+#define DRAW_PIPE_EDGE_FLAG_ALL (0x7<<12)
+#define DRAW_PIPE_RESET_STIPPLE (0x8<<12)
+#define DRAW_PIPE_FLAG_MASK (0xf<<12)
+
void draw_pipeline_run( struct draw_context *draw,
unsigned prim,
struct vertex_header *vertices,
@@ -246,6 +247,8 @@ void draw_pipeline_run( struct draw_context *draw,
const ushort *elts,
unsigned count );
+
+
void draw_pipeline_flush( struct draw_context *draw,
unsigned flags );
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index f5a3bf390e..c9c5d18313 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -58,7 +58,7 @@ draw_pt_arrays(struct draw_context *draw,
opt |= PT_PIPELINE;
}
- if (draw_need_pipeline(draw,
+ if (draw_need_pipeline(draw,
draw->rasterizer,
prim)) {
opt |= PT_PIPELINE;
@@ -78,16 +78,21 @@ draw_pt_arrays(struct draw_context *draw,
middle = draw->pt.middle.fetch_emit;
- /* May create a short-circuited version of this for small primitives:
+ /* Pick the right frontend
*/
- frontend = draw->pt.front.vcache;
+ if (draw->pt.user.elts ||
+ count >= 256) {
+ frontend = draw->pt.front.vcache;
+ } else {
+ frontend = draw->pt.front.varray;
+ }
frontend->prepare( frontend, prim, middle, opt );
- frontend->run( frontend,
- draw_pt_elt_func( draw ),
- draw_pt_elt_ptr( draw, start ),
- count );
+ frontend->run(frontend,
+ draw_pt_elt_func(draw),
+ draw_pt_elt_ptr(draw, start),
+ count);
frontend->finish( frontend );
@@ -101,6 +106,10 @@ boolean draw_pt_init( struct draw_context *draw )
if (!draw->pt.front.vcache)
return FALSE;
+ draw->pt.front.varray = draw_pt_varray(draw);
+ if (!draw->pt.front.varray)
+ return FALSE;
+
draw->pt.middle.fetch_emit = draw_pt_fetch_emit( draw );
if (!draw->pt.middle.fetch_emit)
return FALSE;
@@ -129,6 +138,11 @@ void draw_pt_destroy( struct draw_context *draw )
draw->pt.front.vcache->destroy( draw->pt.front.vcache );
draw->pt.front.vcache = NULL;
}
+
+ if (draw->pt.front.varray) {
+ draw->pt.front.varray->destroy( draw->pt.front.varray );
+ draw->pt.front.varray = NULL;
+ }
}
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index fd0d158fcf..2dec376cee 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -40,15 +40,6 @@ typedef unsigned (*pt_elt_func)( const void *elts, unsigned idx );
struct draw_pt_middle_end;
struct draw_context;
-/* We use the top couple of bits in the vertex fetch index to convey a
- * little API information. This limits the number of vertices we can
- * address to only 1 billion -- if that becomes a problem, these could
- * be moved out & passed separately.
- */
-#define DRAW_PT_EDGEFLAG (1<<30)
-#define DRAW_PT_RESET_STIPPLE (1<<31)
-#define DRAW_PT_FLAG_MASK (3<<30)
-
#define PT_SHADE 0x1
#define PT_CLIPTEST 0x2
@@ -124,6 +115,7 @@ const void *draw_pt_elt_ptr( struct draw_context *draw,
* a special case for tiny vertex buffers.
*/
struct draw_pt_front_end *draw_pt_vcache( struct draw_context *draw );
+struct draw_pt_front_end *draw_pt_varray(struct draw_context *draw);
/* Middle-ends:
*
diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c
index d35329aba0..35707af8a8 100644
--- a/src/gallium/auxiliary/draw/draw_pt_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_emit.c
@@ -32,68 +32,16 @@
#include "draw/draw_vertex.h"
#include "draw/draw_pt.h"
#include "translate/translate.h"
-
-#include "cso_cache/cso_cache.h"
-#include "cso_cache/cso_hash.h"
+#include "translate/translate_cache.h"
struct pt_emit {
struct draw_context *draw;
struct translate *translate;
- struct cso_hash *hash;
+ struct translate_cache *cache;
};
-static INLINE unsigned translate_hash_key_size(struct translate_key *key)
-{
- unsigned size = sizeof(struct translate_key) -
- sizeof(struct translate_element) * (PIPE_MAX_ATTRIBS - key->nr_elements);
- return size;
-}
-
-static INLINE unsigned create_key(struct translate_key *key)
-{
- unsigned hash_key;
- unsigned size = translate_hash_key_size(key);
- /*debug_printf("key size = %d, (els = %d)\n",
- size, key->nr_elements);*/
- hash_key = cso_construct_key(key, size);
- return hash_key;
-}
-
-static struct translate *cached_translate(struct pt_emit *emit,
- struct translate_key *key)
-{
- unsigned hash_key = create_key(key);
- struct cso_hash_iter iter = cso_hash_find(emit->hash, hash_key);
- struct translate *translate = 0;
-
- if (cso_hash_iter_is_null(iter)) {
- translate = translate_create(key);
- cso_hash_insert(emit->hash, hash_key, translate);
- /*debug_printf("\tCREATED with %d\n", hash_key);*/
- } else {
- translate = cso_hash_iter_data(iter);
- /*debug_printf("\tOK with %d\n", hash_key);*/
- }
-
- return translate;
-}
-
-
-static INLINE void delete_translates(struct pt_emit *emit)
-{
- struct cso_hash *hash = emit->hash;
- struct cso_hash_iter iter = cso_hash_first_node(hash);
- while (!cso_hash_iter_is_null(iter)) {
- struct translate *state = (struct translate*)cso_hash_iter_data(iter);
- iter = cso_hash_iter_next(iter);
- if (state) {
- state->release(state);
- }
- }
-}
-
void draw_pt_emit_prepare( struct pt_emit *emit,
unsigned prim )
{
@@ -171,12 +119,10 @@ void draw_pt_emit_prepare( struct pt_emit *emit,
hw_key.nr_elements = vinfo->num_attribs;
hw_key.output_stride = vinfo->size * 4;
- /* Don't bother with caching at this stage:
- */
if (!emit->translate ||
- memcmp(&emit->translate->key, &hw_key, sizeof(hw_key)) != 0)
+ memcmp(&emit->translate->key, &hw_key, sizeof(hw_key)) != 0)
{
- emit->translate = cached_translate(emit, &hw_key);
+ emit->translate = translate_cache_find(emit->cache, &hw_key);
}
}
@@ -238,15 +184,18 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw )
return NULL;
emit->draw = draw;
- emit->hash = cso_hash_create();
+ emit->cache = translate_cache_create();
+ if (!emit->cache) {
+ FREE(emit);
+ return NULL;
+ }
return emit;
}
void draw_pt_emit_destroy( struct pt_emit *emit )
{
- delete_translates(emit);
- cso_hash_delete(emit->hash);
+ translate_cache_destroy(emit->cache);
FREE(emit);
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 93da811ed8..1f765b73ad 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -32,9 +32,8 @@
#include "draw/draw_vertex.h"
#include "draw/draw_pt.h"
#include "translate/translate.h"
+#include "translate/translate_cache.h"
-#include "cso_cache/cso_cache.h"
-#include "cso_cache/cso_hash.h"
struct pt_fetch {
struct draw_context *draw;
@@ -42,59 +41,11 @@ struct pt_fetch {
struct translate *translate;
unsigned vertex_size;
+ boolean need_edgeflags;
- struct cso_hash *hash;
+ struct translate_cache *cache;
};
-static INLINE unsigned translate_hash_key_size(struct translate_key *key)
-{
- unsigned size = sizeof(struct translate_key) -
- sizeof(struct translate_element) * (PIPE_MAX_ATTRIBS - key->nr_elements);
- return size;
-}
-
-static INLINE unsigned create_key(struct translate_key *key)
-{
- unsigned hash_key;
- unsigned size = translate_hash_key_size(key);
- /*debug_printf("key size = %d, (els = %d)\n",
- size, key->nr_elements);*/
- hash_key = cso_construct_key(key, size);
- return hash_key;
-}
-
-static struct translate *cached_translate(struct pt_fetch *fetch,
- struct translate_key *key)
-{
- unsigned hash_key = create_key(key);
- struct cso_hash_iter iter = cso_hash_find(fetch->hash, hash_key);
- struct translate *translate = 0;
-
- if (cso_hash_iter_is_null(iter)) {
- translate = translate_create(key);
- cso_hash_insert(fetch->hash, hash_key, translate);
- /*debug_printf("\tCREATED with %d\n", hash_key);*/
- } else {
- translate = cso_hash_iter_data(iter);
- /*debug_printf("\tOK with %d\n", hash_key);*/
- }
-
- return translate;
-}
-
-static INLINE void delete_translates(struct pt_fetch *fetch)
-{
- struct cso_hash *hash = fetch->hash;
- struct cso_hash_iter iter = cso_hash_first_node(hash);
- while (!cso_hash_iter_is_null(iter)) {
- struct translate *state = (struct translate*)cso_hash_iter_data(iter);
- iter = cso_hash_iter_next(iter);
- if (state) {
- state->release(state);
- }
- }
-}
-
/* Perform the fetch from API vertex elements & vertex buffers, to a
* contiguous set of float[4] attributes as required for the
* vertex_shader->run_linear() method.
@@ -158,21 +109,23 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
key.output_stride = vertex_size;
- /* Don't bother with caching at this stage:
- */
if (!fetch->translate ||
- memcmp(&fetch->translate->key, &key, sizeof(key)) != 0)
+ memcmp(&fetch->translate->key, &key, sizeof(key)) != 0)
{
- fetch->translate = cached_translate(fetch, &key);
+ fetch->translate = translate_cache_find(fetch->cache, &key);
{
- static struct vertex_header vh = { 0, 0, 0, 0xffff };
- fetch->translate->set_buffer(fetch->translate,
- draw->pt.nr_vertex_buffers,
+ static struct vertex_header vh = { 0, 1, 0, 0xffff };
+ fetch->translate->set_buffer(fetch->translate,
+ draw->pt.nr_vertex_buffers,
&vh,
0);
}
}
+
+ fetch->need_edgeflags = ((draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
+ draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) &&
+ draw->pt.user.edgeflag);
}
@@ -199,6 +152,18 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
elts,
count,
verts );
+
+ /* Edgeflags are hard to fit into a translate program, populate
+ * them separately if required. In the setup above they are
+ * defaulted to one, so only need this if there is reason to change
+ * that default:
+ */
+ if (fetch->need_edgeflags) {
+ for (i = 0; i < count; i++) {
+ struct vertex_header *vh = (struct vertex_header *)(verts + i * fetch->vertex_size);
+ vh->edgeflag = draw_pt_get_edgeflag( draw, elts[i] );
+ }
+ }
}
@@ -209,14 +174,18 @@ struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw )
return NULL;
fetch->draw = draw;
- fetch->hash = cso_hash_create();
+ fetch->cache = translate_cache_create();
+ if (!fetch->cache) {
+ FREE(fetch);
+ return NULL;
+ }
+
return fetch;
}
void draw_pt_fetch_destroy( struct pt_fetch *fetch )
{
- delete_translates(fetch);
- cso_hash_delete(fetch->hash);
+ translate_cache_destroy(fetch->cache);
FREE(fetch);
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index 68b2c5b1e3..a4de341df8 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -37,6 +37,7 @@
#include "draw/draw_vertex.h"
#include "draw/draw_pt.h"
#include "translate/translate.h"
+#include "translate/translate_cache.h"
/* The simplest 'middle end' in the new vertex code.
*
@@ -81,6 +82,7 @@ struct fetch_emit_middle_end {
*/
float point_size;
+ struct translate_cache *cache;
};
@@ -174,10 +176,9 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
if (!feme->translate ||
memcmp(&feme->translate->key, &key, sizeof(key)) != 0)
{
- if (feme->translate)
- feme->translate->release(feme->translate);
+ feme->translate = translate_cache_find(feme->cache,
+ &key);
- feme->translate = translate_create( &key );
feme->translate->set_buffer(feme->translate,
draw->pt.nr_vertex_buffers,
@@ -266,9 +267,8 @@ static void fetch_emit_destroy( struct draw_pt_middle_end *middle )
{
struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle;
- if (feme->translate)
- feme->translate->release( feme->translate );
-
+ translate_cache_destroy(feme->cache);
+
FREE(middle);
}
@@ -278,7 +278,13 @@ struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw )
struct fetch_emit_middle_end *fetch_emit = CALLOC_STRUCT( fetch_emit_middle_end );
if (fetch_emit == NULL)
return NULL;
-
+
+ fetch_emit->cache = translate_cache_create();
+ if (!fetch_emit->cache) {
+ FREE(fetch_emit);
+ return NULL;
+ }
+
fetch_emit->base.prepare = fetch_emit_prepare;
fetch_emit->base.run = fetch_emit_run;
fetch_emit->base.finish = fetch_emit_finish;
diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
index f98e130ed6..c4a67c8289 100644
--- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c
+++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c
@@ -61,6 +61,12 @@ compute_clipmask_gl(const float *clip, /*const*/ float plane[][4], unsigned nr)
unsigned mask = 0x0;
unsigned i;
+#if 0
+ debug_printf("compute clipmask %f %f %f %f\n",
+ clip[0], clip[1], clip[2], clip[3]);
+ assert(clip[3] != 0.0);
+#endif
+
/* Do the hardwired planes first:
*/
if (-clip[0] + clip[3] < 0) mask |= (1<<0);
@@ -106,7 +112,6 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
out->clip[3] = out->data[0][3];
out->vertex_id = 0xffff;
- out->edgeflag = 1;
out->clipmask = compute_clipmask_gl(out->clip,
pvs->draw->plane,
pvs->draw->nr_planes);
@@ -122,6 +127,13 @@ static boolean post_vs_cliptest_viewport_gl( struct pt_post_vs *pvs,
out->data[0][1] = out->data[0][1] * w * scale[1] + trans[1];
out->data[0][2] = out->data[0][2] * w * scale[2] + trans[2];
out->data[0][3] = w;
+#if 0
+ debug_printf("post viewport: %f %f %f %f\n",
+ out->data[0][0],
+ out->data[0][1],
+ out->data[0][2],
+ out->data[0][3]);
+#endif
}
out = (struct vertex_header *)( (char *)out + stride );
diff --git a/src/gallium/auxiliary/draw/draw_pt_varray.c b/src/gallium/auxiliary/draw/draw_pt_varray.c
new file mode 100644
index 0000000000..c85d8ded50
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_pt_varray.c
@@ -0,0 +1,250 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_util.h"
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
+#include "draw/draw_pt.h"
+
+#define FETCH_MAX 256
+#define DRAW_MAX (16*FETCH_MAX)
+
+struct varray_frontend {
+ struct draw_pt_front_end base;
+ struct draw_context *draw;
+
+ ushort draw_elts[DRAW_MAX];
+ unsigned fetch_elts[FETCH_MAX];
+
+ unsigned draw_count;
+ unsigned fetch_count;
+
+ struct draw_pt_middle_end *middle;
+
+ unsigned input_prim;
+ unsigned output_prim;
+};
+
+static void varray_flush(struct varray_frontend *varray)
+{
+ if (varray->draw_count) {
+#if 0
+ debug_printf("FLUSH fc = %d, dc = %d\n",
+ varray->fetch_count,
+ varray->draw_count);
+#endif
+ varray->middle->run(varray->middle,
+ varray->fetch_elts,
+ varray->fetch_count,
+ varray->draw_elts,
+ varray->draw_count);
+ }
+
+ varray->fetch_count = 0;
+ varray->draw_count = 0;
+}
+
+#if 0
+static void varray_check_flush(struct varray_frontend *varray)
+{
+ if (varray->draw_count + 6 >= DRAW_MAX/* ||
+ varray->fetch_count + 4 >= FETCH_MAX*/) {
+ varray_flush(varray);
+ }
+}
+#endif
+
+static INLINE void add_draw_el(struct varray_frontend *varray,
+ int idx, ushort flags)
+{
+ varray->draw_elts[varray->draw_count++] = idx | flags;
+}
+
+
+static INLINE void varray_triangle( struct varray_frontend *varray,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2 )
+{
+ add_draw_el(varray, i0, 0);
+ add_draw_el(varray, i1, 0);
+ add_draw_el(varray, i2, 0);
+}
+
+static INLINE void varray_triangle_flags( struct varray_frontend *varray,
+ ushort flags,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2 )
+{
+ add_draw_el(varray, i0, flags);
+ add_draw_el(varray, i1, 0);
+ add_draw_el(varray, i2, 0);
+}
+
+static INLINE void varray_line( struct varray_frontend *varray,
+ unsigned i0,
+ unsigned i1 )
+{
+ add_draw_el(varray, i0, 0);
+ add_draw_el(varray, i1, 0);
+}
+
+
+static INLINE void varray_line_flags( struct varray_frontend *varray,
+ ushort flags,
+ unsigned i0,
+ unsigned i1 )
+{
+ add_draw_el(varray, i0, flags);
+ add_draw_el(varray, i1, 0);
+}
+
+
+static INLINE void varray_point( struct varray_frontend *varray,
+ unsigned i0 )
+{
+ add_draw_el(varray, i0, 0);
+}
+
+static INLINE void varray_quad( struct varray_frontend *varray,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2,
+ unsigned i3 )
+{
+ varray_triangle( varray, i0, i1, i3 );
+ varray_triangle( varray, i1, i2, i3 );
+}
+
+static INLINE void varray_ef_quad( struct varray_frontend *varray,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2,
+ unsigned i3 )
+{
+ const unsigned omitEdge1 = DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_2;
+ const unsigned omitEdge2 = DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_1;
+
+ varray_triangle_flags( varray,
+ DRAW_PIPE_RESET_STIPPLE | omitEdge1,
+ i0, i1, i3 );
+
+ varray_triangle_flags( varray,
+ omitEdge2,
+ i1, i2, i3 );
+}
+
+/* At least for now, we're back to using a template include file for
+ * this. The two paths aren't too different though - it may be
+ * possible to reunify them.
+ */
+#define TRIANGLE(vc,flags,i0,i1,i2) varray_triangle_flags(vc,flags,i0,i1,i2)
+#define QUAD(vc,i0,i1,i2,i3) varray_ef_quad(vc,i0,i1,i2,i3)
+#define LINE(vc,flags,i0,i1) varray_line_flags(vc,flags,i0,i1)
+#define POINT(vc,i0) varray_point(vc,i0)
+#define FUNC varray_run_extras
+#include "draw_pt_varray_tmp.h"
+
+#define TRIANGLE(vc,flags,i0,i1,i2) varray_triangle(vc,i0,i1,i2)
+#define QUAD(vc,i0,i1,i2,i3) varray_quad(vc,i0,i1,i2,i3)
+#define LINE(vc,flags,i0,i1) varray_line(vc,i0,i1)
+#define POINT(vc,i0) varray_point(vc,i0)
+#define FUNC varray_run
+#include "draw_pt_varray_tmp.h"
+
+
+
+static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = {
+ PIPE_PRIM_POINTS,
+ PIPE_PRIM_LINES,
+ PIPE_PRIM_LINES,
+ PIPE_PRIM_LINES,
+ PIPE_PRIM_TRIANGLES,
+ PIPE_PRIM_TRIANGLES,
+ PIPE_PRIM_TRIANGLES,
+ PIPE_PRIM_TRIANGLES,
+ PIPE_PRIM_TRIANGLES,
+ PIPE_PRIM_TRIANGLES
+};
+
+
+
+static void varray_prepare(struct draw_pt_front_end *frontend,
+ unsigned prim,
+ struct draw_pt_middle_end *middle,
+ unsigned opt)
+{
+ struct varray_frontend *varray = (struct varray_frontend *)frontend;
+ const struct pipe_rasterizer_state *rasterizer = varray->draw->rasterizer;
+
+ if (opt & PT_PIPELINE)
+ {
+ varray->base.run = varray_run_extras;
+ }
+ else
+ {
+ varray->base.run = varray_run;
+ }
+
+ varray->input_prim = prim;
+ varray->output_prim = reduced_prim[prim];
+
+ varray->middle = middle;
+ middle->prepare(middle, varray->output_prim, opt);
+}
+
+
+
+
+static void varray_finish(struct draw_pt_front_end *frontend)
+{
+ struct varray_frontend *varray = (struct varray_frontend *)frontend;
+ varray->middle->finish(varray->middle);
+ varray->middle = NULL;
+}
+
+static void varray_destroy(struct draw_pt_front_end *frontend)
+{
+ FREE(frontend);
+}
+
+
+struct draw_pt_front_end *draw_pt_varray(struct draw_context *draw)
+{
+ struct varray_frontend *varray = CALLOC_STRUCT(varray_frontend);
+ if (varray == NULL)
+ return NULL;
+
+ varray->base.prepare = varray_prepare;
+ varray->base.run = NULL;
+ varray->base.finish = varray_finish;
+ varray->base.destroy = varray_destroy;
+ varray->draw = draw;
+
+ return &varray->base;
+}
diff --git a/src/gallium/auxiliary/draw/draw_pt_varray_tmp.h b/src/gallium/auxiliary/draw/draw_pt_varray_tmp.h
new file mode 100644
index 0000000000..b9a319b253
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_pt_varray_tmp.h
@@ -0,0 +1,144 @@
+
+static void FUNC(struct draw_pt_front_end *frontend,
+ pt_elt_func get_elt,
+ const void *elts,
+ unsigned count)
+{
+ struct varray_frontend *varray = (struct varray_frontend *)frontend;
+ struct draw_context *draw = varray->draw;
+ unsigned start = (unsigned)elts;
+
+ boolean flatfirst = (draw->rasterizer->flatshade &&
+ draw->rasterizer->flatshade_first);
+ unsigned i, flags;
+
+#if 0
+ debug_printf("%s (%d) %d/%d\n", __FUNCTION__, draw->prim, start, count);
+#endif
+#if 0
+ debug_printf("INPUT PRIM = %d (start = %d, count = %d)\n", varray->input_prim,
+ start, count);
+#endif
+
+ for (i = 0; i < count; ++i) {
+ varray->fetch_elts[i] = start + i;
+ }
+ varray->fetch_count = count;
+
+ switch (varray->input_prim) {
+ case PIPE_PRIM_POINTS:
+ for (i = 0; i < count; i ++) {
+ POINT(varray, i + 0);
+ }
+ break;
+
+ case PIPE_PRIM_LINES:
+ for (i = 0; i+1 < count; i += 2) {
+ LINE(varray, DRAW_PIPE_RESET_STIPPLE,
+ i + 0, i + 1);
+ }
+ break;
+
+ case PIPE_PRIM_LINE_LOOP:
+ if (count >= 2) {
+ flags = DRAW_PIPE_RESET_STIPPLE;
+
+ for (i = 1; i < count; i++, flags = 0) {
+ LINE(varray, flags, i - 1, i);
+ }
+ LINE(varray, flags, i - 1, 0);
+ }
+ break;
+
+ case PIPE_PRIM_LINE_STRIP:
+ flags = DRAW_PIPE_RESET_STIPPLE;
+ for (i = 1; i < count; i++, flags = 0) {
+ LINE(varray, flags, i - 1, i);
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLES:
+ for (i = 0; i+2 < count; i += 3) {
+ TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ i + 0, i + 1, i + 2);
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ if (flatfirst) {
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ i + 0, i + 1 + (i&1), i + 2 - (i&1));
+ }
+ }
+ else {
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE(varray, DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ i + 0 + (i&1), i + 1 - (i&1), i + 2);
+ }
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLE_FAN:
+ if (count >= 3) {
+ if (flatfirst) {
+ flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL;
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE(varray, flags, i + 1, i + 2, 0);
+ }
+ }
+ else {
+ flags = DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL;
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE(varray, flags, 0, i + 1, i + 2);
+ }
+ }
+ }
+ break;
+
+ case PIPE_PRIM_QUADS:
+ for (i = 0; i+3 < count; i += 4) {
+ QUAD(varray, i + 0, i + 1, i + 2, i + 3);
+ }
+ break;
+
+ case PIPE_PRIM_QUAD_STRIP:
+ for (i = 0; i+3 < count; i += 2) {
+ QUAD(varray, i + 2, i + 0, i + 1, i + 3);
+ }
+ break;
+
+ case PIPE_PRIM_POLYGON:
+ {
+ /* These bitflags look a little odd because we submit the
+ * vertices as (1,2,0) to satisfy flatshade requirements.
+ */
+ const unsigned edge_first = DRAW_PIPE_EDGE_FLAG_2;
+ const unsigned edge_middle = DRAW_PIPE_EDGE_FLAG_0;
+ const unsigned edge_last = DRAW_PIPE_EDGE_FLAG_1;
+
+ flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
+
+ for (i = 0; i+2 < count; i++, flags = edge_middle) {
+
+ if (i + 3 == count)
+ flags |= edge_last;
+
+ TRIANGLE(varray, flags, i + 1, i + 2, 0);
+ }
+ }
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+
+ varray_flush(varray);
+}
+
+#undef TRIANGLE
+#undef QUAD
+#undef POINT
+#undef LINE
+#undef FUNC
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index afcff41043..2f9775814f 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -33,8 +33,6 @@
#include "pipe/p_util.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
-//#include "draw/draw_vbuf.h"
-//#include "draw/draw_vertex.h"
#include "draw/draw_pt.h"
@@ -63,7 +61,6 @@ struct vcache_frontend {
static void vcache_flush( struct vcache_frontend *vcache )
{
- vcache->draw->vcache_flushing = TRUE;
if (vcache->draw_count) {
vcache->middle->run( vcache->middle,
vcache->fetch_elts,
@@ -75,7 +72,6 @@ static void vcache_flush( struct vcache_frontend *vcache )
memset(vcache->in, ~0, sizeof(vcache->in));
vcache->fetch_count = 0;
vcache->draw_count = 0;
- vcache->draw->vcache_flushing = FALSE;
}
static void vcache_check_flush( struct vcache_frontend *vcache )
@@ -88,8 +84,9 @@ static void vcache_check_flush( struct vcache_frontend *vcache )
}
-static void vcache_elt( struct vcache_frontend *vcache,
- unsigned felt )
+static INLINE void vcache_elt( struct vcache_frontend *vcache,
+ unsigned felt,
+ ushort flags )
{
unsigned idx = felt % CACHE_MAX;
@@ -101,28 +98,9 @@ static void vcache_elt( struct vcache_frontend *vcache,
vcache->fetch_elts[vcache->fetch_count++] = felt;
}
- vcache->draw_elts[vcache->draw_count++] = vcache->out[idx];
+ vcache->draw_elts[vcache->draw_count++] = vcache->out[idx] | flags;
}
-static unsigned add_edgeflag( struct vcache_frontend *vcache,
- unsigned idx,
- unsigned mask )
-{
- if (0 && mask && draw_pt_get_edgeflag(vcache->draw, idx))
- return idx | DRAW_PT_EDGEFLAG;
- else
- return idx;
-}
-
-
-static unsigned add_reset_stipple( unsigned idx,
- unsigned reset )
-{
- if (0 && reset)
- return idx | DRAW_PT_RESET_STIPPLE;
- else
- return idx;
-}
static void vcache_triangle( struct vcache_frontend *vcache,
@@ -130,49 +108,42 @@ static void vcache_triangle( struct vcache_frontend *vcache,
unsigned i1,
unsigned i2 )
{
- vcache_elt(vcache, i0 /* | DRAW_PT_EDGEFLAG | DRAW_PT_RESET_STIPPLE */ );
- vcache_elt(vcache, i1 /* | DRAW_PT_EDGEFLAG */);
- vcache_elt(vcache, i2 /* | DRAW_PT_EDGEFLAG */);
+ vcache_elt(vcache, i0, 0);
+ vcache_elt(vcache, i1, 0);
+ vcache_elt(vcache, i2, 0);
vcache_check_flush(vcache);
}
-static void vcache_ef_triangle( struct vcache_frontend *vcache,
- boolean reset_stipple,
- unsigned ef_mask,
- unsigned i0,
- unsigned i1,
- unsigned i2 )
+static void vcache_triangle_flags( struct vcache_frontend *vcache,
+ ushort flags,
+ unsigned i0,
+ unsigned i1,
+ unsigned i2 )
{
-/*
- i0 = add_edgeflag( vcache, i0, (ef_mask >> 0) & 1 );
- i1 = add_edgeflag( vcache, i1, (ef_mask >> 1) & 1 );
- i2 = add_edgeflag( vcache, i2, (ef_mask >> 2) & 1 );
- i0 = add_reset_stipple( i0, reset_stipple );
-*/
-
- vcache_elt(vcache, i0);
- vcache_elt(vcache, i1);
- vcache_elt(vcache, i2);
+ vcache_elt(vcache, i0, flags);
+ vcache_elt(vcache, i1, 0);
+ vcache_elt(vcache, i2, 0);
vcache_check_flush(vcache);
-
- if (0) debug_printf("emit tri ef: %d %d %d\n",
- !!(i0 & DRAW_PT_EDGEFLAG),
- !!(i1 & DRAW_PT_EDGEFLAG),
- !!(i2 & DRAW_PT_EDGEFLAG));
-
}
-
static void vcache_line( struct vcache_frontend *vcache,
- boolean reset_stipple,
unsigned i0,
unsigned i1 )
{
- i0 = add_reset_stipple( i0, reset_stipple );
+ vcache_elt(vcache, i0, 0);
+ vcache_elt(vcache, i1, 0);
+ vcache_check_flush(vcache);
+}
+
- vcache_elt(vcache, i0);
- vcache_elt(vcache, i1);
+static void vcache_line_flags( struct vcache_frontend *vcache,
+ ushort flags,
+ unsigned i0,
+ unsigned i1 )
+{
+ vcache_elt(vcache, i0, flags);
+ vcache_elt(vcache, i1, 0);
vcache_check_flush(vcache);
}
@@ -180,7 +151,7 @@ static void vcache_line( struct vcache_frontend *vcache,
static void vcache_point( struct vcache_frontend *vcache,
unsigned i0 )
{
- vcache_elt(vcache, i0);
+ vcache_elt(vcache, i0, 0);
vcache_check_flush(vcache);
}
@@ -200,237 +171,36 @@ static void vcache_ef_quad( struct vcache_frontend *vcache,
unsigned i2,
unsigned i3 )
{
- const unsigned omitEdge2 = ~(1 << 1);
- const unsigned omitEdge3 = ~(1 << 2);
- vcache_ef_triangle( vcache, 1, omitEdge2, i0, i1, i3 );
- vcache_ef_triangle( vcache, 0, omitEdge3, i1, i2, i3 );
-}
+ const unsigned omitEdge1 = DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_2;
+ const unsigned omitEdge2 = DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_1;
+ vcache_triangle_flags( vcache,
+ DRAW_PIPE_RESET_STIPPLE | omitEdge1,
+ i0, i1, i3 );
+ vcache_triangle_flags( vcache,
+ omitEdge2,
+ i1, i2, i3 );
+}
+/* At least for now, we're back to using a template include file for
+ * this. The two paths aren't too different though - it may be
+ * possible to reunify them.
+ */
+#define TRIANGLE(vc,flags,i0,i1,i2) vcache_triangle_flags(vc,flags,i0,i1,i2)
+#define QUAD(vc,i0,i1,i2,i3) vcache_ef_quad(vc,i0,i1,i2,i3)
+#define LINE(vc,flags,i0,i1) vcache_line_flags(vc,flags,i0,i1)
+#define POINT(vc,i0) vcache_point(vc,i0)
+#define FUNC vcache_run_extras
+#include "draw_pt_vcache_tmp.h"
+
+#define TRIANGLE(vc,flags,i0,i1,i2) vcache_triangle(vc,i0,i1,i2)
+#define QUAD(vc,i0,i1,i2,i3) vcache_quad(vc,i0,i1,i2,i3)
+#define LINE(vc,flags,i0,i1) vcache_line(vc,i0,i1)
+#define POINT(vc,i0) vcache_point(vc,i0)
+#define FUNC vcache_run
+#include "draw_pt_vcache_tmp.h"
-static void vcache_run( struct draw_pt_front_end *frontend,
- pt_elt_func get_elt,
- const void *elts,
- unsigned count )
-{
- struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
- struct draw_context *draw = vcache->draw;
-
- boolean unfilled = (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
- draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL);
-
- boolean flatfirst = (draw->rasterizer->flatshade &&
- draw->rasterizer->flatshade_first);
- unsigned i;
-
-// debug_printf("%s (%d) %d/%d\n", __FUNCTION__, draw->prim, start, count );
-
- switch (vcache->input_prim) {
- case PIPE_PRIM_POINTS:
- for (i = 0; i < count; i ++) {
- vcache_point( vcache,
- get_elt(elts, i + 0) );
- }
- break;
-
- case PIPE_PRIM_LINES:
- for (i = 0; i+1 < count; i += 2) {
- vcache_line( vcache,
- TRUE,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1));
- }
- break;
-
- case PIPE_PRIM_LINE_LOOP:
- if (count >= 2) {
- for (i = 1; i < count; i++) {
- vcache_line( vcache,
- i == 1, /* XXX: only if vb not split */
- get_elt(elts, i - 1),
- get_elt(elts, i ));
- }
-
- vcache_line( vcache,
- 0,
- get_elt(elts, count - 1),
- get_elt(elts, 0 ));
- }
- break;
-
- case PIPE_PRIM_LINE_STRIP:
- for (i = 1; i < count; i++) {
- vcache_line( vcache,
- i == 1,
- get_elt(elts, i - 1),
- get_elt(elts, i ));
- }
- break;
-
- case PIPE_PRIM_TRIANGLES:
- if (unfilled) {
- for (i = 0; i+2 < count; i += 3) {
- vcache_ef_triangle( vcache,
- 1,
- ~0,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2 ));
- }
- }
- else {
- for (i = 0; i+2 < count; i += 3) {
- vcache_triangle( vcache,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2 ));
- }
- }
- break;
-
- case PIPE_PRIM_TRIANGLE_STRIP:
- if (flatfirst) {
- for (i = 0; i+2 < count; i++) {
- if (i & 1) {
- vcache_triangle( vcache,
- get_elt(elts, i + 0),
- get_elt(elts, i + 2),
- get_elt(elts, i + 1 ));
- }
- else {
- vcache_triangle( vcache,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2 ));
- }
- }
- }
- else {
- for (i = 0; i+2 < count; i++) {
- if (i & 1) {
- vcache_triangle( vcache,
- get_elt(elts, i + 1),
- get_elt(elts, i + 0),
- get_elt(elts, i + 2 ));
- }
- else {
- vcache_triangle( vcache,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2 ));
- }
- }
- }
- break;
-
- case PIPE_PRIM_TRIANGLE_FAN:
- if (count >= 3) {
- if (flatfirst) {
- for (i = 0; i+2 < count; i++) {
- vcache_triangle( vcache,
- get_elt(elts, i + 1),
- get_elt(elts, i + 2),
- get_elt(elts, 0 ));
- }
- }
- else {
- for (i = 0; i+2 < count; i++) {
- vcache_triangle( vcache,
- get_elt(elts, 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2 ));
- }
- }
- }
- break;
-
-
- case PIPE_PRIM_QUADS:
- if (unfilled) {
- for (i = 0; i+3 < count; i += 4) {
- vcache_ef_quad( vcache,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2),
- get_elt(elts, i + 3));
- }
- }
- else {
- for (i = 0; i+3 < count; i += 4) {
- vcache_quad( vcache,
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 2),
- get_elt(elts, i + 3));
- }
- }
- break;
-
- case PIPE_PRIM_QUAD_STRIP:
- if (unfilled) {
- for (i = 0; i+3 < count; i += 2) {
- vcache_ef_quad( vcache,
- get_elt(elts, i + 2),
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 3));
- }
- }
- else {
- for (i = 0; i+3 < count; i += 2) {
- vcache_quad( vcache,
- get_elt(elts, i + 2),
- get_elt(elts, i + 0),
- get_elt(elts, i + 1),
- get_elt(elts, i + 3));
- }
- }
- break;
-
- case PIPE_PRIM_POLYGON:
- if (unfilled) {
- /* These bitflags look a little odd because we submit the
- * vertices as (1,2,0) to satisfy flatshade requirements.
- */
- const unsigned edge_first = (1<<2);
- const unsigned edge_middle = (1<<0);
- const unsigned edge_last = (1<<1);
-
- for (i = 0; i+2 < count; i++) {
- unsigned ef_mask = edge_middle;
-
- if (i == 0)
- ef_mask |= edge_first;
-
- if (i + 3 == count)
- ef_mask |= edge_last;
-
- vcache_ef_triangle( vcache,
- i == 0,
- ef_mask,
- get_elt(elts, i + 1),
- get_elt(elts, i + 2),
- get_elt(elts, 0));
- }
- }
- else {
- for (i = 0; i+2 < count; i++) {
- vcache_triangle( vcache,
- get_elt(elts, i + 1),
- get_elt(elts, i + 2),
- get_elt(elts, 0));
- }
- }
- break;
-
- default:
- assert(0);
- break;
- }
-
- vcache_flush( vcache );
-}
@@ -455,15 +225,17 @@ static void vcache_prepare( struct draw_pt_front_end *frontend,
unsigned opt )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
+ const struct pipe_rasterizer_state *rasterizer = vcache->draw->rasterizer;
-/*
- if (vcache->draw->rasterizer->flatshade_first)
- vcache->base.run = vcache_run_pv0;
- else
- vcache->base.run = vcache_run_pv2;
-*/
+ if (opt & PT_PIPELINE)
+ {
+ vcache->base.run = vcache_run_extras;
+ }
+ else
+ {
+ vcache->base.run = vcache_run;
+ }
- vcache->base.run = vcache_run;
vcache->input_prim = prim;
vcache->output_prim = reduced_prim[prim];
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
new file mode 100644
index 0000000000..cf9f394aa3
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
@@ -0,0 +1,174 @@
+
+
+static void FUNC( struct draw_pt_front_end *frontend,
+ pt_elt_func get_elt,
+ const void *elts,
+ unsigned count )
+{
+ struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
+ struct draw_context *draw = vcache->draw;
+
+ boolean flatfirst = (draw->rasterizer->flatshade &&
+ draw->rasterizer->flatshade_first);
+ unsigned i, flags;
+
+
+ switch (vcache->input_prim) {
+ case PIPE_PRIM_POINTS:
+ for (i = 0; i < count; i ++) {
+ POINT( vcache,
+ get_elt(elts, i + 0) );
+ }
+ break;
+
+ case PIPE_PRIM_LINES:
+ for (i = 0; i+1 < count; i += 2) {
+ LINE( vcache,
+ DRAW_PIPE_RESET_STIPPLE,
+ get_elt(elts, i + 0),
+ get_elt(elts, i + 1));
+ }
+ break;
+
+ case PIPE_PRIM_LINE_LOOP:
+ if (count >= 2) {
+ flags = DRAW_PIPE_RESET_STIPPLE;
+
+ for (i = 1; i < count; i++, flags = 0) {
+ LINE( vcache,
+ flags,
+ get_elt(elts, i - 1),
+ get_elt(elts, i ));
+ }
+
+ LINE( vcache,
+ flags,
+ get_elt(elts, i - 1),
+ get_elt(elts, 0 ));
+ }
+ break;
+
+ case PIPE_PRIM_LINE_STRIP:
+ flags = DRAW_PIPE_RESET_STIPPLE;
+ for (i = 1; i < count; i++, flags = 0) {
+ LINE( vcache,
+ flags,
+ get_elt(elts, i - 1),
+ get_elt(elts, i ));
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLES:
+ for (i = 0; i+2 < count; i += 3) {
+ TRIANGLE( vcache,
+ DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ get_elt(elts, i + 0),
+ get_elt(elts, i + 1),
+ get_elt(elts, i + 2 ));
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ if (flatfirst) {
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE( vcache,
+ DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ get_elt(elts, i + 0),
+ get_elt(elts, i + 1 + (i&1)),
+ get_elt(elts, i + 2 - (i&1)));
+ }
+ }
+ else {
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE( vcache,
+ DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ get_elt(elts, i + 0 + (i&1)),
+ get_elt(elts, i + 1 - (i&1)),
+ get_elt(elts, i + 2 ));
+ }
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLE_FAN:
+ if (count >= 3) {
+ if (flatfirst) {
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE( vcache,
+ DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ get_elt(elts, i + 1),
+ get_elt(elts, i + 2),
+ get_elt(elts, 0 ));
+ }
+ }
+ else {
+ for (i = 0; i+2 < count; i++) {
+ TRIANGLE( vcache,
+ DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL,
+ get_elt(elts, 0),
+ get_elt(elts, i + 1),
+ get_elt(elts, i + 2 ));
+ }
+ }
+ }
+ break;
+
+
+ case PIPE_PRIM_QUADS:
+ for (i = 0; i+3 < count; i += 4) {
+ QUAD( vcache,
+ get_elt(elts, i + 0),
+ get_elt(elts, i + 1),
+ get_elt(elts, i + 2),
+ get_elt(elts, i + 3));
+ }
+ break;
+
+ case PIPE_PRIM_QUAD_STRIP:
+ for (i = 0; i+3 < count; i += 2) {
+ QUAD( vcache,
+ get_elt(elts, i + 2),
+ get_elt(elts, i + 0),
+ get_elt(elts, i + 1),
+ get_elt(elts, i + 3));
+ }
+ break;
+
+ case PIPE_PRIM_POLYGON:
+ {
+ /* These bitflags look a little odd because we submit the
+ * vertices as (1,2,0) to satisfy flatshade requirements.
+ */
+ const unsigned edge_first = DRAW_PIPE_EDGE_FLAG_2;
+ const unsigned edge_middle = DRAW_PIPE_EDGE_FLAG_0;
+ const unsigned edge_last = DRAW_PIPE_EDGE_FLAG_1;
+
+ flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
+
+ for (i = 0; i+2 < count; i++, flags = edge_middle) {
+
+ if (i + 3 == count)
+ flags |= edge_last;
+
+ TRIANGLE( vcache,
+ flags,
+ get_elt(elts, i + 1),
+ get_elt(elts, i + 2),
+ get_elt(elts, 0));
+ }
+ }
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+
+ vcache_flush( vcache );
+}
+
+
+#undef TRIANGLE
+#undef QUAD
+#undef POINT
+#undef LINE
+#undef FUNC