summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/evergreen_state.c
diff options
context:
space:
mode:
authorTom Stellard <[email protected]>2012-07-12 19:50:28 +0000
committerMarek Olšák <[email protected]>2012-07-15 02:00:27 +0200
commitc2f444c54db82a53f63fa7a103770ee5eedc3559 (patch)
tree6e97fbe9a7c2d3b4d511fb2c23b1eeafd9b1bde3 /src/gallium/drivers/r600/evergreen_state.c
parent9b76ee70b2ceebb52cc5edc574df9593cbac03b3 (diff)
r600g: Emit vertex buffers using the same method as constant buffers
Signed-off-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers/r600/evergreen_state.c')
-rw-r--r--src/gallium/drivers/r600/evergreen_state.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 923dea75da1..9a64f67e611 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1765,32 +1765,39 @@ static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct r600_
r600_write_context_reg(cs, R_02800C_DB_RENDER_OVERRIDE, db_render_override);
}
-static void evergreen_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom *atom,
- struct pipe_vertex_buffer *vb, unsigned vb_count, unsigned resource_offset,
- unsigned pkt_flags)
+static void evergreen_emit_vertex_buffers(struct r600_context *rctx,
+ struct r600_vertexbuf_state *state,
+ struct pipe_vertex_buffer *vertex_buffers,
+ unsigned vb_count,
+ unsigned resource_offset,
+ unsigned pkt_flags)
{
struct radeon_winsys_cs *cs = rctx->cs;
- unsigned i;
- uint64_t va;
+ uint32_t dirty_mask = state->dirty_mask;
- for (i = 0; i < vb_count; i++) {
- struct r600_resource *rbuffer = (struct r600_resource*)vb[i].buffer;
+ while (dirty_mask) {
+ struct pipe_vertex_buffer *vb;
+ struct r600_resource *rbuffer;
+ uint64_t va;
+ unsigned buffer_index = ffs(dirty_mask) - 1;
+ vb = &vertex_buffers[buffer_index];
+ rbuffer = (struct r600_resource*)vb->buffer;
if (!rbuffer) {
- continue;
+ goto next;
}
va = r600_resource_va(&rctx->screen->screen, &rbuffer->b.b);
- va += vb[i].buffer_offset;
+ va += vb->buffer_offset;
/* fetch resources start at index 992 */
r600_write_value(cs, PKT3(PKT3_SET_RESOURCE, 8, 0) | pkt_flags);
- r600_write_value(cs, (resource_offset + i) * 8);
+ r600_write_value(cs, (resource_offset + buffer_index) * 8);
r600_write_value(cs, va); /* RESOURCEi_WORD0 */
- r600_write_value(cs, rbuffer->buf->size - vb[i].buffer_offset - 1); /* RESOURCEi_WORD1 */
+ r600_write_value(cs, rbuffer->buf->size - vb->buffer_offset - 1); /* RESOURCEi_WORD1 */
r600_write_value(cs, /* RESOURCEi_WORD2 */
S_030008_ENDIAN_SWAP(r600_endian_swap(32)) |
- S_030008_STRIDE(vb[i].stride) |
+ S_030008_STRIDE(vb->stride) |
S_030008_BASE_ADDRESS_HI(va >> 32UL));
r600_write_value(cs, /* RESOURCEi_WORD3 */
S_03000C_DST_SEL_X(V_03000C_SQ_SEL_X) |
@@ -1804,18 +1811,24 @@ static void evergreen_emit_vertex_buffers(struct r600_context *rctx, struct r600
r600_write_value(cs, PKT3(PKT3_NOP, 0, 0) | pkt_flags);
r600_write_value(cs, r600_context_bo_reloc(rctx, rbuffer, RADEON_USAGE_READ));
+
+next:
+ dirty_mask &= ~(1 << buffer_index);
}
+ state->dirty_mask = 0;
}
static void evergreen_fs_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom * atom)
{
- evergreen_emit_vertex_buffers(rctx, atom, rctx->vertex_buffer,
+ evergreen_emit_vertex_buffers(rctx, &rctx->vertex_buffer_state,
+ rctx->vertex_buffer,
rctx->nr_vertex_buffers, 992, 0);
}
static void evergreen_cs_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom * atom)
{
- evergreen_emit_vertex_buffers(rctx, atom, rctx->cs_vertex_buffer,
+ evergreen_emit_vertex_buffers(rctx, &rctx->cs_vertex_buffer_state,
+ rctx->cs_vertex_buffer,
rctx->nr_cs_vertex_buffers, 816,
RADEON_CP_PACKET3_COMPUTE_MODE);
}
@@ -1895,8 +1908,8 @@ void evergreen_init_state_functions(struct r600_context *rctx)
r600_atom_dirty(rctx, &rctx->cb_misc_state.atom);
r600_init_atom(&rctx->db_misc_state.atom, evergreen_emit_db_misc_state, 6, 0);
r600_atom_dirty(rctx, &rctx->db_misc_state.atom);
- r600_init_atom(&rctx->vertex_buffer_state, evergreen_fs_emit_vertex_buffers, 0, 0);
- r600_init_atom(&rctx->cs_vertex_buffer_state, evergreen_cs_emit_vertex_buffers, 0, 0);
+ r600_init_atom(&rctx->vertex_buffer_state.atom, evergreen_fs_emit_vertex_buffers, 0, 0);
+ r600_init_atom(&rctx->cs_vertex_buffer_state.atom, evergreen_cs_emit_vertex_buffers, 0, 0);
r600_init_atom(&rctx->vs_constbuf_state.atom, evergreen_emit_vs_constant_buffers, 0, 0);
r600_init_atom(&rctx->ps_constbuf_state.atom, evergreen_emit_ps_constant_buffers, 0, 0);