{
uint i;
const unsigned size = (MAX_VERTEX_SIZE + 0x0f) & ~0x0f;
- char *tmp = align_malloc(Elements(draw->vcache.vertex) * size, 16);
+ char *tmp = align_malloc(Elements(draw->vs.queue) * size, 16);
- for (i = 0; i < Elements(draw->vcache.vertex); i++)
- draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * size);
+ for (i = 0; i < Elements(draw->vs.queue); i++)
+ draw->vs.queue[i].vertex = (struct vertex_header *)(tmp + i * size);
}
draw->shader_queue_flush = draw_vertex_shader_queue_flush;
if (draw->pipeline.rasterize)
draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
tgsi_exec_machine_free_data(&draw->machine);
- align_free( draw->vcache.vertex[0] ); /* Frees all the vertices. */
+ align_free( draw->vs.queue[0].vertex ); /* Frees all the vertices. */
FREE( draw );
}
};
-#define PRIM_QUEUE_LENGTH 16
+#define PRIM_QUEUE_LENGTH 32
#define VCACHE_SIZE 32
#define VCACHE_OVERFLOW 4
#define VS_QUEUE_LENGTH (VCACHE_SIZE + VCACHE_OVERFLOW + 1) /* can never fill up */
*/
struct {
unsigned referenced; /**< bitfield */
- unsigned idx[VCACHE_SIZE + VCACHE_OVERFLOW];
- struct vertex_header *vertex[VCACHE_SIZE + VCACHE_OVERFLOW];
+
+ struct {
+ unsigned in; /* client array element */
+ unsigned out; /* index in vs queue/array */
+ } idx[VCACHE_SIZE + VCACHE_OVERFLOW];
+
unsigned overflow;
/** To find space in the vertex cache: */
struct {
struct {
unsigned elt; /**< index into the user's vertex arrays */
- struct vertex_header *dest; /**< points into vcache.vertex[] array */
+ struct vertex_header *vertex;
} queue[VS_QUEUE_LENGTH];
unsigned queue_nr;
+ unsigned post_nr;
} vs;
/**
assert(draw->vs.queue_nr == 0);
assert(draw->vcache.referenced == 0);
- memset(draw->vcache.idx, ~0, sizeof(draw->vcache.idx));
+// memset(draw->vcache.idx, ~0, sizeof(draw->vcache.idx));
}
assert(slot < 32); /* so we don't exceed the bitfield size below */
- /* Cache miss?
- */
- if (draw->vcache.idx[slot] != i) {
-
- /* If slot is in use, use the overflow area:
+ if (draw->vcache.referenced & (1<<slot))
+ {
+ /* Cache hit?
*/
- if (draw->vcache.referenced & (1 << slot)) {
- slot = VCACHE_SIZE + draw->vcache.overflow++;
+ if (draw->vcache.idx[slot].in == i) {
+// _mesa_printf("HIT %d %d\n", slot, i);
+ assert(draw->vcache.idx[slot].out < draw->vs.queue_nr);
+ return draw->vs.queue[draw->vcache.idx[slot].out].vertex;
}
+ /* Otherwise a collision
+ */
+ slot = VCACHE_SIZE + draw->vcache.overflow++;
+// _mesa_printf("XXX %d --> %d\n", i, slot);
+ }
+
+ /* Deal with the cache miss:
+ */
+ {
+ unsigned out;
+
assert(slot < Elements(draw->vcache.idx));
- draw->vcache.idx[slot] = i;
+// _mesa_printf("NEW %d %d\n", slot, i);
+ draw->vcache.idx[slot].in = i;
+ draw->vcache.idx[slot].out = out = draw->vs.queue_nr++;
+ draw->vcache.referenced |= (1 << slot);
+
/* Add to vertex shader queue:
*/
assert(draw->vs.queue_nr < VS_QUEUE_LENGTH);
- draw->vs.queue[draw->vs.queue_nr].dest = draw->vcache.vertex[slot];
- draw->vs.queue[draw->vs.queue_nr].elt = i;
- draw->vs.queue_nr++;
+
+ draw->vs.queue[out].elt = i;
+ draw->vs.queue[out].vertex->clipmask = 0;
+ draw->vs.queue[out].vertex->edgeflag = 1; /*XXX use user's edge flag! */
+ draw->vs.queue[out].vertex->pad = 0;
+ draw->vs.queue[out].vertex->vertex_id = UNDEFINED_VERTEX_ID;
/* Need to set the vertex's edge flag here. If we're being called
* by do_ef_triangle(), that function needs edge flag info!
*/
- draw->vcache.vertex[slot]->clipmask = 0;
- draw->vcache.vertex[slot]->edgeflag = 1; /*XXX use user's edge flag! */
- draw->vcache.vertex[slot]->pad = 0;
- draw->vcache.vertex[slot]->vertex_id = UNDEFINED_VERTEX_ID;
- }
-
- /* primitive flushing may have cleared the bitfield but did not
- * clear the idx[] array values. Set the bit now. This fixes a
- * bug found when drawing long triangle fans.
- */
- draw->vcache.referenced |= (1 << slot);
- return draw->vcache.vertex[slot];
+ return draw->vs.queue[draw->vcache.idx[slot].out].vertex;
+ }
}
{
unsigned i;
- for (i = 0; i < Elements(draw->vcache.vertex); i++)
- draw->vcache.vertex[i]->vertex_id = UNDEFINED_VERTEX_ID;
+ for (i = 0; i < draw->vs.post_nr; i++)
+ draw->vs.queue[i].vertex->vertex_id = UNDEFINED_VERTEX_ID;
}
*/
shader->prepare( shader, draw );
-// fprintf(stderr, " q(%d) ", draw->vs.queue_nr );
+// fprintf(stderr, "%s %d\n", __FUNCTION__, draw->vs.queue_nr );
/* run vertex shader on vertex cache entries, four per invokation */
for (i = 0; i < draw->vs.queue_nr; i += 4) {
for (j = 0; j < n; j++) {
elts[j] = draw->vs.queue[i + j].elt;
- dests[j] = draw->vs.queue[i + j].dest;
+ dests[j] = draw->vs.queue[i + j].vertex;
}
for ( ; j < 4; j++) {
elts[j] = elts[0];
- dests[j] = dests[0];
+ dests[j] = draw->vs.queue[i + j].vertex;
}
assert(n > 0);
shader->run(shader, draw, elts, n, dests);
}
+ draw->vs.post_nr = draw->vs.queue_nr;
draw->vs.queue_nr = 0;
}