summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2009-11-07 10:14:07 -0800
committerCorbin Simpson <MostAwesomeDude@gmail.com>2009-11-07 11:53:14 -0800
commit7da3cc4241b8550ccc1ec5ba3c93334094f5fb11 (patch)
tree4d26d3bf558caa360bff8727197a988791ece2e8
parent7518d9b1b7369f6e5ca1fdaf6a34e39a4acace9a (diff)
r300g: Clean up indexbuf render, switch to RELOC macro.
-rw-r--r--src/gallium/drivers/r300/r300_render.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index e28af7600a1..b4351d541d7 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -94,41 +94,43 @@ static void r300_emit_draw_elements(struct r300_context *r300,
unsigned start,
unsigned count)
{
+ uint32_t count_dwords;
+ uint32_t offset_dwords = indexSize * start / sizeof(uint32_t);
CS_LOCALS(r300);
+
+ /* XXX most of these are stupid */
assert(indexSize == 4 || indexSize == 2);
assert(count < 65536);
assert((start * indexSize) % 4 == 0);
-
- uint32_t size_dwords;
- uint32_t skip_dwords = indexSize * start / sizeof(uint32_t);
- assert(skip_dwords == 0);
+ assert(offset_dwords == 0);
BEGIN_CS(10);
OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, maxIndex);
OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
if (indexSize == 4) {
- size_dwords = count + start;
+ count_dwords = count + start;
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
R300_VAP_VF_CNTL__INDEX_SIZE_32bit |
r300_translate_primitive(mode));
} else {
- size_dwords = (count + start + 1) / 2;
+ count_dwords = (count + start + 1) / 2;
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
r300_translate_primitive(mode));
}
+ /* INDX_BUFFER is a truly special packet3.
+ * Unlike most other packet3, where the offset is after the count,
+ * the order is reversed, so the relocation ends up carrying the
+ * size of the indexbuf instead of the offset.
+ *
+ * XXX Fix offset
+ */
OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2);
OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2) |
(0 << R300_INDX_BUFFER_SKIP_SHIFT));
- OUT_CS(skip_dwords);
- OUT_CS(size_dwords);
- /* XXX hax */
- cs_winsys->write_cs_reloc(cs_winsys,
- indexBuffer,
- RADEON_GEM_DOMAIN_GTT,
- 0,
- 0);
- cs_count -= 2;
+ OUT_CS(offset_dwords);
+ OUT_CS_RELOC(indexBuffer, count_dwords,
+ RADEON_GEM_DOMAIN_GTT, 0, 0);
END_CS;
}