struct pipe_resource * buffer)
{
struct pipe_vertex_buffer *vb = &rctx->cs_vertex_buffer[vb_index];
+ struct r600_vertexbuf_state * state = &rctx->cs_vertex_buffer_state;
vb->stride = 1;
vb->buffer_offset = offset;
vb->buffer = buffer;
vb->user_buffer = NULL;
r600_inval_vertex_cache(rctx);
- r600_atom_dirty(rctx, &rctx->cs_vertex_buffer_state);
+ state->dirty_mask |= 1 << vb_index;
+ r600_atom_dirty(rctx, &state->atom);
}
const struct u_resource_vtbl r600_global_buffer_vtbl =
r600_context_pipe_state_emit(ctx, cb_state, RADEON_CP_PACKET3_COMPUTE_MODE);
/* Emit vertex buffer state */
- ctx->cs_vertex_buffer_state.num_dw = 12 * ctx->nr_cs_vertex_buffers;
- r600_emit_atom(ctx, &ctx->cs_vertex_buffer_state);
+ ctx->cs_vertex_buffer_state.atom.num_dw = 12 * ctx->nr_cs_vertex_buffers;
+ r600_emit_atom(ctx, &ctx->cs_vertex_buffer_state.atom);
for (i = 0; i < get_compute_resource_num(); i++) {
if (ctx->cs_shader->resources[i].enabled) {
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) |
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);
}
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);