summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2009-02-18 06:38:21 -0800
committerCorbin Simpson <MostAwesomeDude@gmail.com>2009-02-18 06:40:38 -0800
commit922000d38a6e90c525328b381f04fea1244f616f (patch)
treeae0d1c49ddf1a4b5a7de07129cef9ab90151c1c3 /src/gallium/drivers/r300
parentb6779056a108675b04ec8b57d7f84b5582f3144f (diff)
r300-gallium: Factor out common functionality in vbuf emit.
Diffstat (limited to 'src/gallium/drivers/r300')
-rw-r--r--src/gallium/drivers/r300/r300_swtcl_emit.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/gallium/drivers/r300/r300_swtcl_emit.c b/src/gallium/drivers/r300/r300_swtcl_emit.c
index fb009247a5..327d4ac2e1 100644
--- a/src/gallium/drivers/r300/r300_swtcl_emit.c
+++ b/src/gallium/drivers/r300/r300_swtcl_emit.c
@@ -174,13 +174,9 @@ static boolean r300_swtcl_render_set_primitive(struct vbuf_render* render,
return true;
}
-static void r300_swtcl_render_draw_arrays(struct vbuf_render* render,
- unsigned start,
- unsigned count)
+static void prepare_render(struct r300_swtcl_render* render)
{
- struct r300_swtcl_render* r300render = r300_swtcl_render(render);
- struct r300_context* r300 = r300render->r300;
- struct pipe_screen* screen = r300->context.screen;
+ struct r300_context* r300 = render->r300;
CS_LOCALS(r300);
@@ -188,7 +184,7 @@ static void r300_swtcl_render_draw_arrays(struct vbuf_render* render,
r300_update_derived_state(r300);
r300_emit_dirty_state(r300);
- /* Take care of vertex formats and routes */
+ /* Take care of vertex formats and routes. */
BEGIN_CS(3);
OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
OUT_CS(r300->vertex_info.hwfmt[0]);
@@ -196,10 +192,39 @@ static void r300_swtcl_render_draw_arrays(struct vbuf_render* render,
END_CS;
/* Draw stuff! */
+ BEGIN_CS(6);
+
+ /* Set the pointer to our vertex buffer. The emitted values are this:
+ * PACKET3 [3D_LOAD_VBPNTR]
+ * COUNT [1]
+ * FORMAT [size | stride << 8]
+ * VBPNTR [relocated BO]
+ *
+ * And of course that extra dword is space for the relocation. */
+ OUT_CS(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 3));
+ OUT_CS(1);
+ OUT_CS(r300->vertex_info.size | (r300->vertex_info.size << 8));
+ OUT_CS(0);
+ OUT_CS_RELOC(render->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
+}
+
+static void r300_swtcl_render_draw_arrays(struct vbuf_render* render,
+ unsigned start,
+ unsigned count)
+{
+ struct r300_swtcl_render* r300render = r300_swtcl_render(render);
+ struct r300_context* r300 = r300render->r300;
+ struct pipe_screen* screen = r300->context.screen;
+
+ CS_LOCALS(r300);
+
+ prepare_render(r300render);
+
BEGIN_CS(2);
OUT_CS(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0));
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
+ END_CS;
}
static void r300_swtcl_render_draw(struct vbuf_render* render,
@@ -214,9 +239,7 @@ static void r300_swtcl_render_draw(struct vbuf_render* render,
CS_LOCALS(r300);
- /* Make sure that all possible state is emitted. */
- r300_update_derived_state(r300);
- r300_emit_dirty_state(r300);
+ prepare_render(r300render);
/* Send our indices into an index buffer. */
index_buffer = pipe_buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX,
@@ -230,15 +253,7 @@ static void r300_swtcl_render_draw(struct vbuf_render* render,
memcpy(index_map, indices, count * 4);
pipe_buffer_unmap(screen, index_buffer);
- /* Take care of vertex formats and routes */
- BEGIN_CS(3);
- OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);
- OUT_CS(r300->vertex_info.hwfmt[0]);
- OUT_CS(r300->vertex_info.hwfmt[1]);
- END_CS;
-
- /* Draw stuff! */
- BEGIN_CS(10);
+ BEGIN_CS(5);
OUT_CS(CP_PACKET3(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);