summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/i915simple
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2007-10-29 12:14:52 +0000
committerJosé Fonseca <[email protected]>2007-10-29 12:15:57 +0000
commit1039a755142e2fd45dc291d891c514fdfa7e033c (patch)
treec3fc9a2a512d7044fb59a7300e3b77d10efb1058 /src/mesa/pipe/i915simple
parenta9e1fcf98a871b182f82dc37c15d0f69bf1a3187 (diff)
Reuse hardware vertice representation.
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
index 33e532ad02e..0adf987721d 100644
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
@@ -139,8 +139,7 @@ emit_vertex( struct vbuf_stage *vbuf,
// fprintf(stderr, "emit vertex %d to %p\n",
// vbuf->nr_vertices, vbuf->vertex_ptr);
- /* TODO: reuse vertices */
- /* vertex->vertex_id = */ vbuf->nr_vertices++;
+ vertex->vertex_id = vbuf->nr_vertices++;
for (i = 0; i < vinfo->num_attribs; i++) {
switch (vinfo->format[i]) {
@@ -271,21 +270,17 @@ static void vbuf_first_point( struct draw_stage *stage,
}
-static void vbuf_draw( struct draw_stage *stage,
- unsigned prim,
- const ushort *elements,
- unsigned nr_elements,
- const void *vertex_buffer,
- unsigned nr )
+static void vbuf_draw( struct draw_stage *stage )
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
struct i915_context *i915 = vbuf->i915;
+ unsigned nr = vbuf->nr_elements;
unsigned vertex_size = i915->current.vertex_info.size * 4; /* in bytes */
unsigned hwprim;
unsigned *ptr;
- unsigned i;
+ unsigned i, j;
- switch(prim) {
+ switch(vbuf->prim) {
case PIPE_PRIM_POINTS:
hwprim = PRIM3D_POINTLIST;
break;
@@ -306,7 +301,7 @@ static void vbuf_draw( struct draw_stage *stage,
if (i915->hardware_dirty)
i915_emit_hardware_state( i915 );
- assert(vbuf->vertex_ptr - vbuf->vertex_map == nr * vertex_size / 4);
+ assert(vbuf->vertex_ptr - vbuf->vertex_map == vbuf->nr_vertices * vertex_size / 4);
ptr = BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 );
if (ptr == 0) {
@@ -329,8 +324,9 @@ static void vbuf_draw( struct draw_stage *stage,
hwprim |
((4 + vertex_size * nr)/4 - 2));
- for (i = 0; i < nr * vertex_size / 4; i++)
- OUT_BATCH(vbuf->vertex_map[i]);
+ for (i = 0; i < nr; i++)
+ for (j = 0; j < vertex_size / 4; j++)
+ OUT_BATCH(vbuf->vertex_map[vbuf->element_map[i]*vertex_size/4 + j]);
}
@@ -339,19 +335,16 @@ static void vbuf_flush_elements( struct draw_stage *stage )
struct vbuf_stage *vbuf = vbuf_stage( stage );
if (vbuf->nr_elements) {
+#if 0
fprintf(stderr, "%s (%d elts, %d verts)\n",
__FUNCTION__,
vbuf->nr_elements,
vbuf->nr_vertices);
+#endif
/* Draw now or add to list of primitives???
*/
- vbuf_draw( stage,
- vbuf->prim,
- vbuf->element_map,
- vbuf->nr_elements,
- vbuf->vertex_map,
- vbuf->nr_vertices );
+ vbuf_draw( stage );
vbuf->nr_elements = 0;