break;
case PIPE_PRIM_LINES:
- if (flatfirst) {
- for (i = 0; i+1 < count; i += 2) {
- do_line( draw,
- TRUE,
- start + i + 1,
- start + i + 0);
- }
- }
- else {
- for (i = 0; i+1 < count; i += 2) {
- do_line( draw,
- TRUE,
- start + i + 0,
- start + i + 1);
- }
+ for (i = 0; i+1 < count; i += 2) {
+ do_line( draw,
+ TRUE,
+ start + i + 0,
+ start + i + 1);
}
break;
break;
case PIPE_PRIM_LINE_STRIP:
- if (flatfirst) {
- for (i = 1; i < count; i++) {
- do_line( draw,
- i == 1,
- start + i,
- start + i - 1 );
- }
- }
- else {
- for (i = 1; i < count; i++) {
- do_line( draw,
- i == 1,
- start + i - 1,
- start + i );
- }
+ for (i = 1; i < count; i++) {
+ do_line( draw,
+ i == 1,
+ start + i - 1,
+ start + i );
}
break;
case PIPE_PRIM_TRIANGLES:
- if (flatfirst) {
- if (unfilled) {
- for (i = 0; i+2 < count; i += 3) {
- do_ef_triangle( draw,
- 1,
- ~0,
- start + i + 1,
- start + i + 2,
- start + i + 0 );
- }
- }
- else {
- for (i = 0; i+2 < count; i += 3) {
- do_triangle( draw,
- start + i + 1,
- start + i + 2,
- start + i + 0 );
- }
+ if (unfilled) {
+ for (i = 0; i+2 < count; i += 3) {
+ do_ef_triangle( draw,
+ 1,
+ ~0,
+ start + i + 0,
+ start + i + 1,
+ start + i + 2 );
}
- }
+ }
else {
- if (unfilled) {
- for (i = 0; i+2 < count; i += 3) {
- do_ef_triangle( draw,
- 1,
- ~0,
- start + i + 0,
- start + i + 1,
- start + i + 2 );
- }
- }
- else {
- for (i = 0; i+2 < count; i += 3) {
- do_triangle( draw,
- start + i + 0,
- start + i + 1,
- start + i + 2 );
- }
+ for (i = 0; i+2 < count; i += 3) {
+ do_triangle( draw,
+ start + i + 0,
+ start + i + 1,
+ start + i + 2 );
}
}
break;
for (i = 0; i+2 < count; i++) {
if (i & 1) {
do_triangle( draw,
+ start + i + 0,
start + i + 2,
- start + i + 1,
- start + i + 0 );
+ start + i + 1 );
}
else {
do_triangle( draw,
+ start + i + 0,
start + i + 1,
- start + i + 2,
- start + i + 0 );
+ start + i + 2 );
}
}
}
if (flatfirst) {
for (i = 0; i+2 < count; i++) {
do_triangle( draw,
+ start + i + 1,
start + i + 2,
- start + 0,
- start + i + 1 );
+ start + 0 );
}
}
else {
struct vcache_frontend {
struct draw_pt_front_end base;
+ struct draw_context *draw;
unsigned in[CACHE_MAX];
ushort out[CACHE_MAX];
}
-static void vcache_prepare( struct draw_pt_front_end *frontend,
- struct draw_pt_middle_end *middle )
-{
- struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
- vcache->middle = middle;
- middle->prepare( middle );
-}
-
static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = {
PIPE_PRIM_POINTS,
PIPE_PRIM_LINES,
};
-static void vcache_run( struct draw_pt_front_end *frontend,
- unsigned prim,
- pt_elt_func get_elt,
- const void *elts,
- unsigned count )
+static void vcache_run_pv2( struct draw_pt_front_end *frontend,
+ unsigned prim,
+ pt_elt_func get_elt,
+ const void *elts,
+ unsigned count )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
unsigned i;
vcache_flush( vcache );
}
+
+static void vcache_run_pv0( struct draw_pt_front_end *frontend,
+ unsigned prim,
+ pt_elt_func get_elt,
+ const void *elts,
+ unsigned count )
+{
+ struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
+ unsigned i;
+
+ /* These are for validation only:
+ */
+ vcache->elt_func = get_elt;
+ vcache->elt_ptr = elts;
+ vcache->output_prim = reduced_prim[prim];
+
+ switch (prim) {
+ case PIPE_PRIM_POINTS:
+ for (i = 0; i < count; i ++) {
+ vcache_point( vcache,
+ get_elt(elts, i) );
+ }
+ 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_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:
+ 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:
+ 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) );
+ }
+ }
+ break;
+
+ case PIPE_PRIM_TRIANGLE_FAN:
+ 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 );
+}
+
+static void vcache_prepare( struct draw_pt_front_end *frontend,
+ struct draw_pt_middle_end *middle )
+{
+ struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
+
+ if (vcache->draw->rasterizer->flatshade_first)
+ vcache->base.run = vcache_run_pv0;
+ else
+ vcache->base.run = vcache_run_pv2;
+
+ vcache->middle = middle;
+ middle->prepare( middle );
+}
+
+
+
+
static void vcache_finish( struct draw_pt_front_end *frontend )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
}
-struct draw_pt_front_end *draw_pt_vcache( void )
+struct draw_pt_front_end *draw_pt_vcache( struct draw_context *draw )
{
struct vcache_frontend *vcache = CALLOC_STRUCT( vcache_frontend );
vcache->base.prepare = vcache_prepare;
- vcache->base.run = vcache_run;
+ vcache->base.run = NULL;
vcache->base.finish = vcache_finish;
vcache->base.destroy = vcache_destroy;
+ vcache->draw = draw;
memset(vcache->in, ~0, sizeof(vcache->in));