struct cell_context *cell = cvbr->cell;
float xmin, ymin, xmax, ymax;
uint i;
- uint nr_vertices = 0;
+ uint nr_vertices = 0, min_index = ~0;
const void *vertices = cvbr->vertex_buffer;
const uint vertex_size = cvbr->vertex_size;
for (i = 0; i < nr_indices; i++) {
if (indices[i] > nr_vertices)
nr_vertices = indices[i];
+ if (indices[i] < min_index)
+ min_index = indices[i];
}
nr_vertices++;
+#if 0
+ /*if (min_index > 0)*/
+ printf("%s min_index = %u\n", __FUNCTION__, min_index);
+#endif
+
#if 0
printf("cell_vbuf_draw() nr_indices = %u nr_verts = %u\n",
nr_indices, nr_vertices);
/* compute x/y bounding box */
xmin = ymin = 1e50;
xmax = ymax = -1e50;
- for (i = 0; i < nr_vertices; i++) {
+ for (i = min_index; i < nr_vertices; i++) {
const float *v = (float *) ((ubyte *) vertices + i * vertex_size);
if (v[0] < xmin)
xmin = v[0];
render->prim_type = cvbr->prim;
render->num_indexes = nr_indices;
+ render->min_index = min_index;
/* append indices after render command */
memcpy(render + 1, indices, nr_indices * 2);
render->vertex_size = 4 * cell->vertex_info.size;
render->num_verts = nr_vertices;
if (ALLOW_INLINE_VERTS &&
+ min_index == 0 &&
vertex_bytes <= cell_batch_free_space(cell)) {
/* vertex data inlined, after indices */
void *dst = cell_batch_alloc(cell, vertex_bytes);
/* we'll DMA into these buffers */
ubyte vertex_data[CELL_BUFFER_SIZE] ALIGN16_ATTRIB;
const uint vertex_size = render->vertex_size; /* in bytes */
- const uint total_vertex_bytes = render->num_verts * vertex_size;
+ /*const*/ uint total_vertex_bytes = render->num_verts * vertex_size;
const ubyte *vertices;
const ushort *indexes;
uint i, j;
}
else {
/* Begin DMA fetch of vertex buffer */
- void *src = spu.init.buffers[render->vertex_buf];
- mfc_get(vertex_data, /* dest */
- (unsigned int) src,
+ ubyte *src = spu.init.buffers[render->vertex_buf];
+ ubyte *dest = vertex_data;
+
+ /* skip vertex data we won't use */
+#if 01
+ src += render->min_index * vertex_size;
+ dest += render->min_index * vertex_size;
+ total_vertex_bytes -= render->min_index * vertex_size;
+#endif
+ ASSERT(total_vertex_bytes % 16 == 0);
+ ASSERT_ALIGN16(dest);
+ ASSERT_ALIGN16(src);
+
+ mfc_get(dest, /* in vertex_data[] array */
+ (unsigned int) src, /* src in main memory */
total_vertex_bytes, /* size */
TAG_VERTEX_BUFFER,
0, /* tid */