struct translate_cache *translate_cache;
struct cso_cache *cso_cache;
+ /* Vertex buffers for the driver.
+ * There are no user buffers. */
+ struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
+ int nr_real_vertex_buffers;
+
/* The index buffer. */
struct pipe_index_buffer index_buffer;
void (*driver_set_index_buffer)(struct pipe_context *pipe,
const struct pipe_index_buffer *);
+ void (*driver_set_vertex_buffers)(struct pipe_context *,
+ unsigned num_buffers,
+ const struct pipe_vertex_buffer *);
};
static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
}
- for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+ for (i = 0; i < mgr->nr_real_vertex_buffers; i++) {
+ pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
}
translate_cache_destroy(mgr->translate_cache);
}
/* Setup the new vertex buffer. */
- mgr->b.real_vertex_buffer[out_vb].buffer_offset = out_offset;
- mgr->b.real_vertex_buffer[out_vb].stride = key->output_stride;
+ mgr->real_vertex_buffer[out_vb].buffer_offset = out_offset;
+ mgr->real_vertex_buffer[out_vb].stride = key->output_stride;
/* Move the buffer reference. */
pipe_resource_reference(
- &mgr->b.real_vertex_buffer[out_vb].buffer, NULL);
- mgr->b.real_vertex_buffer[out_vb].buffer = out_buffer;
+ &mgr->real_vertex_buffer[out_vb].buffer, NULL);
+ mgr->real_vertex_buffer[out_vb].buffer = out_buffer;
}
static boolean
/*printf("found slot=%i for type=%i\n", i, type);*/
fallback_vbs[type] = i;
i++;
- if (i > mgr->b.nr_real_vertex_buffers) {
- mgr->b.nr_real_vertex_buffers = i;
+ if (i > mgr->nr_real_vertex_buffers) {
+ mgr->nr_real_vertex_buffers = i;
}
break;
}
}
if (i == PIPE_MAX_ATTRIBS) {
/* fail, reset the number to its original value */
- mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+ mgr->nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
return FALSE;
}
}
/* Fixup the stride for constant attribs. */
if (type == VB_CONST) {
- mgr->b.real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
+ mgr->real_vertex_buffer[mgr->fallback_vbs[VB_CONST]].stride = 0;
}
}
}
for (i = 0; i < VB_NUM; i++) {
unsigned vb = mgr->fallback_vbs[i];
if (vb != ~0) {
- pipe_resource_reference(&mgr->b.real_vertex_buffer[vb].buffer, NULL);
+ pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer, NULL);
mgr->fallback_vbs[i] = ~0;
}
}
- mgr->b.nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
+ mgr->nr_real_vertex_buffers = mgr->b.nr_vertex_buffers;
}
#define FORMAT_REPLACE(what, withwhat) \
FREE(ve);
}
-void u_vbuf_set_vertex_buffers(struct u_vbuf *mgrb,
- unsigned count,
- const struct pipe_vertex_buffer *bufs)
+static void u_vbuf_set_vertex_buffers(struct pipe_context *pipe,
+ unsigned count,
+ const struct pipe_vertex_buffer *bufs)
{
- struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
+ struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)pipe->draw;
unsigned i;
mgr->any_user_vbs = FALSE;
pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
- mgr->b.real_vertex_buffer[i].buffer_offset =
+ mgr->real_vertex_buffer[i].buffer_offset =
mgr->b.vertex_buffer[i].buffer_offset = vb->buffer_offset;
- mgr->b.real_vertex_buffer[i].stride =
+ mgr->real_vertex_buffer[i].stride =
mgr->b.vertex_buffer[i].stride = vb->stride;
if (!vb->buffer ||
mgr->incompatible_vb[i]) {
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+ pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
continue;
}
if (u_vbuf_resource(vb->buffer)->user_ptr) {
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+ pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
mgr->any_user_vbs = TRUE;
continue;
}
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, vb->buffer);
+ pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, vb->buffer);
}
for (i = count; i < mgr->b.nr_vertex_buffers; i++) {
pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
}
- for (i = count; i < mgr->b.nr_real_vertex_buffers; i++) {
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i].buffer, NULL);
+ for (i = count; i < mgr->nr_real_vertex_buffers; i++) {
+ pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL);
}
mgr->b.nr_vertex_buffers = count;
- mgr->b.nr_real_vertex_buffers = count;
+ mgr->nr_real_vertex_buffers = count;
+
+ if (!mgr->any_user_vbs && !mgr->incompatible_vb_layout) {
+ mgr->driver_set_vertex_buffers(pipe, mgr->nr_real_vertex_buffers,
+ mgr->real_vertex_buffer);
+ }
}
static void u_vbuf_set_index_buffer(struct pipe_context *pipe,
start = start_offset[i];
assert(start < end);
- real_vb = &mgr->b.real_vertex_buffer[i];
+ real_vb = &mgr->real_vertex_buffer[i];
ptr = u_vbuf_resource(mgr->b.vertex_buffer[i].buffer)->user_ptr;
u_upload_data(mgr->b.uploader, start, end - start, ptr + start,
for (i = 0; i < nr; i++) {
struct pipe_vertex_buffer *vb =
- &mgr->b.real_vertex_buffer[velems[i].vertex_buffer_index];
+ &mgr->real_vertex_buffer[velems[i].vertex_buffer_index];
unsigned size, max_count, value;
/* We're not interested in constant and per-instance attribs. */
}
}
-enum u_vbuf_return_flags
-u_vbuf_draw_begin(struct u_vbuf *mgrb,
- struct pipe_draw_info *info)
+void u_vbuf_draw_begin(struct u_vbuf *mgrb,
+ struct pipe_draw_info *info)
{
struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
int start_vertex, min_index;
if (!mgr->incompatible_vb_layout &&
!mgr->ve->incompatible_layout &&
!mgr->any_user_vbs) {
- return 0;
+ return;
}
if (info->indexed) {
util_dump_vertex_buffer(stdout, mgr->b.vertex_buffer+i);
printf("\n");
}
- for (i = 0; i < mgr->b.nr_real_vertex_buffers; i++) {
+ for (i = 0; i < mgr->nr_real_vertex_buffers; i++) {
printf("real %i: ", i);
- util_dump_vertex_buffer(stdout, mgr->b.real_vertex_buffer+i);
+ util_dump_vertex_buffer(stdout, mgr->real_vertex_buffer+i);
printf("\n");
}
*/
info->start = 0;
}
- return U_VBUF_BUFFERS_UPDATED;
+ mgr->driver_set_vertex_buffers(mgr->pipe, mgr->nr_real_vertex_buffers,
+ mgr->real_vertex_buffer);
}
void u_vbuf_draw_end(struct u_vbuf *mgrb)
pipe->draw = mgr;
mgr->driver_set_index_buffer = pipe->set_index_buffer;
+ mgr->driver_set_vertex_buffers = pipe->set_vertex_buffers;
pipe->set_index_buffer = u_vbuf_set_index_buffer;
+ pipe->set_vertex_buffers = u_vbuf_set_vertex_buffers;
}
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
unsigned nr_vertex_buffers;
- /* Contains only real vertex buffers.
- * Hardware drivers should use real_vertex_buffers[i]
- * instead of vertex_buffers[i].buffer. */
- struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
- int nr_real_vertex_buffers;
-
/* This uploader can optionally be used by the driver.
*
* Allowed functions:
U_VERTEX_FETCH_DWORD_ALIGNED
};
-enum u_vbuf_return_flags {
- U_VBUF_BUFFERS_UPDATED = 1
-};
-
struct u_vbuf *
u_vbuf_create(struct pipe_context *pipe,
void u_vbuf_destroy_vertex_elements(struct u_vbuf *mgr,
struct u_vbuf_elements *ve);
-void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
- unsigned count,
- const struct pipe_vertex_buffer *bufs);
-
-enum u_vbuf_return_flags u_vbuf_draw_begin(struct u_vbuf *mgr,
- struct pipe_draw_info *info);
+void u_vbuf_draw_begin(struct u_vbuf *mgr,
+ struct pipe_draw_info *info);
unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers,
r300->vbuf_mgr->vertex_buffer);
} else {
- util_blitter_save_vertex_buffers(r300->blitter, r300->swtcl_nr_vertex_buffers,
- r300->swtcl_vertex_buffer);
+ util_blitter_save_vertex_buffers(r300->blitter, r300->nr_vertex_buffers,
+ r300->vertex_buffer);
}
if (op & R300_SAVE_FRAMEBUFFER) {
}
/* Manually-created vertex buffers. */
- pipe_resource_reference(&r300->dummy_vb, NULL);
+ pipe_resource_reference(&r300->dummy_vb.buffer, NULL);
pipe_resource_reference(&r300->vbo, NULL);
r300->context.delete_depth_stencil_alpha_state(&r300->context,
vb.height0 = 1;
vb.depth0 = 1;
- r300->dummy_vb = screen->resource_create(screen, &vb);
+ r300->dummy_vb.buffer = screen->resource_create(screen, &vb);
}
{
/* When no vertex buffer is set, this one is used instead to prevent
* hardlocks. */
- struct pipe_resource *dummy_vb;
+ struct pipe_vertex_buffer dummy_vb;
/* The currently active query. */
struct r300_query *query_current;
struct u_vbuf *vbuf_mgr;
struct pipe_index_buffer index_buffer;
- struct pipe_vertex_buffer swtcl_vertex_buffer[PIPE_MAX_ATTRIBS];
- unsigned swtcl_nr_vertex_buffers;
+ struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+ unsigned nr_vertex_buffers;
struct util_slab_mempool pool_transfers;
void r300_emit_vertex_arrays(struct r300_context* r300, int offset,
boolean indexed, int instance_id)
{
- struct pipe_vertex_buffer *vbuf = r300->vbuf_mgr->real_vertex_buffer;
+ struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
struct pipe_vertex_element *velem = r300->velems->velem;
struct r300_resource *buf;
int i;
r300_resource(r300->vbo)->domain);
/* ...vertex buffers for HWTCL path... */
if (do_validate_vertex_buffers && r300->vertex_arrays_dirty) {
- struct pipe_vertex_buffer *vbuf = r300->vbuf_mgr->real_vertex_buffer;
- struct pipe_vertex_buffer *last = r300->vbuf_mgr->real_vertex_buffer +
- r300->vbuf_mgr->nr_real_vertex_buffers;
+ struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
+ struct pipe_vertex_buffer *last = r300->vertex_buffer +
+ r300->nr_vertex_buffers;
struct pipe_resource *buf;
+
for (; vbuf != last; vbuf++) {
buf = vbuf->buffer;
if (!buf)
static void r300_split_index_bias(struct r300_context *r300, int index_bias,
int *buffer_offset, int *index_offset)
{
- struct pipe_vertex_buffer *vb, *vbufs = r300->vbuf_mgr->real_vertex_buffer;
+ struct pipe_vertex_buffer *vb, *vbufs = r300->vertex_buffer;
struct pipe_vertex_element *velem = r300->velems->velem;
unsigned i, size;
int max_neg_bias;
velem = &r300->velems->velem[i];
size[i] = r300->velems->format_size[i] / 4;
vbi = velem->vertex_buffer_index;
- vbuf = &r300->vbuf_mgr->real_vertex_buffer[vbi];
+ vbuf = &r300->vertex_buffer[vbi];
stride[i] = vbuf->stride / 4;
/* Map the buffer. */
vbi = r300->velems->velem[i].vertex_buffer_index;
if (map[vbi]) {
- r300->rws->buffer_unmap(r300_resource(r300->vbuf_mgr->real_vertex_buffer[vbi].buffer)->buf);
+ r300->rws->buffer_unmap(r300_resource(r300->vertex_buffer[vbi].buffer)->buf);
map[vbi] = NULL;
}
}
}
r300_update_derived_state(r300);
-
- /* Start the vbuf manager and update buffers if needed. */
- if (u_vbuf_draw_begin(r300->vbuf_mgr, &info) & U_VBUF_BUFFERS_UPDATED) {
- r300->vertex_arrays_dirty = TRUE;
- }
+ u_vbuf_draw_begin(r300->vbuf_mgr, &info);
/* Draw. */
if (info.indexed) {
(indexed ? PREP_INDEXED : 0),
indexed ? 256 : 6);
- for (i = 0; i < r300->swtcl_nr_vertex_buffers; i++) {
- if (r300->swtcl_vertex_buffer[i].buffer) {
+ for (i = 0; i < r300->nr_vertex_buffers; i++) {
+ if (r300->vertex_buffer[i].buffer) {
void *buf = pipe_buffer_map(pipe,
- r300->swtcl_vertex_buffer[i].buffer,
+ r300->vertex_buffer[i].buffer,
PIPE_TRANSFER_READ |
PIPE_TRANSFER_UNSYNCHRONIZED,
&vb_transfer[i]);
draw_flush(r300->draw);
r300->draw_vbo_locked = FALSE;
- for (i = 0; i < r300->swtcl_nr_vertex_buffers; i++) {
- if (r300->swtcl_vertex_buffer[i].buffer) {
+ for (i = 0; i < r300->nr_vertex_buffers; i++) {
+ if (r300->vertex_buffer[i].buffer) {
pipe_buffer_unmap(pipe, vb_transfer[i]);
draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
}
const struct pipe_vertex_buffer* buffers)
{
struct r300_context* r300 = r300_context(pipe);
- struct pipe_vertex_buffer dummy_vb = {0};
/* There must be at least one vertex buffer set, otherwise it locks up. */
if (!count) {
- dummy_vb.buffer = r300->dummy_vb;
- buffers = &dummy_vb;
+ buffers = &r300->dummy_vb;
count = 1;
}
+ util_copy_vertex_buffers(r300->vertex_buffer,
+ &r300->nr_vertex_buffers,
+ buffers, count);
+
if (r300->screen->caps.has_tcl) {
- u_vbuf_set_vertex_buffers(r300->vbuf_mgr, count, buffers);
r300->vertex_arrays_dirty = TRUE;
} else {
- util_copy_vertex_buffers(r300->swtcl_vertex_buffer,
- &r300->swtcl_nr_vertex_buffers,
- buffers, count);
draw_set_vertex_buffers(r300->draw, count, buffers);
}
}
static void evergreen_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom *atom)
{
struct radeon_winsys_cs *cs = rctx->cs;
- struct pipe_vertex_buffer *vb = rctx->vbuf_mgr->real_vertex_buffer;
- unsigned count = rctx->vbuf_mgr->nr_real_vertex_buffers;
+ struct pipe_vertex_buffer *vb = rctx->vertex_buffer;
+ unsigned count = rctx->nr_vertex_buffers;
unsigned i;
uint64_t va;
unsigned color0_format;
struct pipe_index_buffer index_buffer;
+ struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+ unsigned nr_vertex_buffers;
};
static INLINE void r600_emit_atom(struct r600_context *rctx, struct r600_atom *atom)
static void r600_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom *atom)
{
struct radeon_winsys_cs *cs = rctx->cs;
- struct pipe_vertex_buffer *vb = rctx->vbuf_mgr->real_vertex_buffer;
- unsigned count = rctx->vbuf_mgr->nr_real_vertex_buffers;
+ struct pipe_vertex_buffer *vb = rctx->vertex_buffer;
+ unsigned count = rctx->nr_vertex_buffers;
unsigned i, offset;
for (i = 0; i < count; i++) {
{
struct r600_context *rctx = (struct r600_context *)ctx;
- u_vbuf_set_vertex_buffers(rctx->vbuf_mgr, count, buffers);
+ util_copy_vertex_buffers(rctx->vertex_buffer, &rctx->nr_vertex_buffers, buffers, count);
rctx->vertex_buffers_dirty = true;
}
r600_update_derived_state(rctx);
/* Update vertex buffers. */
- if ((u_vbuf_draw_begin(rctx->vbuf_mgr, &info) & U_VBUF_BUFFERS_UPDATED) ||
- rctx->vertex_buffers_dirty) {
+ u_vbuf_draw_begin(rctx->vbuf_mgr, &info);
+ if (rctx->vertex_buffers_dirty) {
r600_inval_vertex_cache(rctx);
rctx->vertex_buffer_state.num_dw = (rctx->chip_class >= EVERGREEN ? 12 : 10) *
- rctx->vbuf_mgr->nr_real_vertex_buffers;
+ rctx->nr_vertex_buffers;
r600_atom_dirty(rctx, &rctx->vertex_buffer_state);
rctx->vertex_buffers_dirty = FALSE;
}