r300-gallium: Properly emit indexbufs.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 8 Apr 2009 21:54:17 +0000 (14:54 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 8 Apr 2009 22:31:04 +0000 (15:31 -0700)
This fixes hardlocks with anything using elts.

src/gallium/drivers/r300/r300_cs.h
src/gallium/drivers/r300/r300_render.c

index 9913678d272d3feacd4c555d84800e5c49138eb8..5d9799dd7239b7e994fdc7fa78beba834f013590 100644 (file)
     OUT_CS(CP_PACKET3(op, count)); \
 } while (0)
 
+#define OUT_CS_INDEX_RELOC(bo, offset, count, rd, wd, flags) do { \
+    debug_printf("r300: writing relocation for index buffer %p," \
+            "offset %d\n", bo, offset); \
+    assert(bo); \
+    OUT_CS(offset); \
+    OUT_CS(count); \
+    cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \
+    cs_count -= 2; \
+} while (0)
+
 #endif /* R300_CS_H */
index 57bbc7a9944673a38751d6ce2fa4fa89ebcb2408..b7ee8fb8a94fd257777e2e3b42bc048c86be2ab3 100644 (file)
@@ -241,7 +241,7 @@ static void r300_render_draw(struct vbuf_render* render,
 
     /* Send our indices into an index buffer. */
     index_buffer = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX,
-                                      count);
+                                      count * 2);
     if (!index_buffer) {
         return;
     }
@@ -253,14 +253,13 @@ static void r300_render_draw(struct vbuf_render* render,
 
     debug_printf("r300: Doing indexbuf render, count %d\n", count);
 
-    BEGIN_CS(5);
+    BEGIN_CS(6);
     OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
     OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
-           r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
-
+           r300render->hwprim);
     OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2);
     OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2));
-    OUT_CS_RELOC(index_buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
+    OUT_CS_INDEX_RELOC(index_buffer, 0, count, RADEON_GEM_DOMAIN_GTT, 0, 0);
     END_CS;
 }