diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-01-28 18:03:45 -0700 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2008-02-15 13:50:24 +1100 |
commit | 7012dd9b76328b4b1f54404df1948e50f23c1fe3 (patch) | |
tree | ea029c14fed33424024e4d7e0a2effc0e0be3f65 | |
parent | 5f54cfaba16c2ac268472e148f1e788a9d7b2a6a (diff) |
Cell: compute min index referenced in draw command, use it to reduce size of vertex data payload
-rw-r--r-- | src/mesa/pipe/cell/common.h | 2 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_vbuf.c | 13 | ||||
-rw-r--r-- | src/mesa/pipe/cell/spu/spu_main.c | 20 |
3 files changed, 29 insertions, 6 deletions
diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h index f0d48ff403..90aa46a534 100644 --- a/src/mesa/pipe/cell/common.h +++ b/src/mesa/pipe/cell/common.h @@ -124,6 +124,8 @@ struct cell_command_render uint num_indexes; uint vertex_buf; /**< which cell->buffer[] contains the vertex data */ float xmin, dummy2, ymin, xmax, ymax; /* XXX another dummy field */ + uint dummy3; + uint min_index; boolean inline_verts; } ALIGN16_ATTRIB; diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c index 9f737287ad..e63b34cf52 100644 --- a/src/mesa/pipe/cell/ppu/cell_vbuf.c +++ b/src/mesa/pipe/cell/ppu/cell_vbuf.c @@ -138,17 +138,24 @@ cell_vbuf_draw(struct vbuf_render *vbr, 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); printf(" "); @@ -169,7 +176,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, /* 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]; @@ -204,6 +211,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, 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); @@ -214,6 +222,7 @@ cell_vbuf_draw(struct vbuf_render *vbr, 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); diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c index 5a5b17dd89..3c9efb4741 100644 --- a/src/mesa/pipe/cell/spu/spu_main.c +++ b/src/mesa/pipe/cell/spu/spu_main.c @@ -253,7 +253,7 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr) /* 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; @@ -289,9 +289,21 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr) } 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 */ |