This prevents needless buffer validation (CS space checking).
/* AOS (PACKET3_3D_LOAD_VBPNTR) command buffer for the case offset=0. */
uint32_t aos_cb[(16 * 3 + 1) / 2];
boolean aos_dirty;
+
+ /* Whether any buffer (FB, textures, VBOs) has been set, but buffers
+ * haven't been validated yet. */
+ boolean validate_buffers;
};
#define foreach_atom(r300, atom) \
struct pipe_resource *pbuf;
unsigned i;
- /* upload buffers first */
- if (r300->screen->caps.has_tcl && r300->any_user_vbs) {
- r300_upload_user_buffers(r300);
- r300->any_user_vbs = false;
- }
-
/* Clean out BOs. */
r300->rws->cs_reset_buffers(r300->cs);
if (do_validate_vertex_buffers) {
for (i = 0; i < r300->velems->count; i++) {
pbuf = vbuf[velem[i].vertex_buffer_index].buffer;
+ if (!pbuf)
+ continue;
r300->rws->cs_add_buffer(r300->cs, r300_buffer(pbuf)->cs_buf,
r300_buffer(pbuf)->domain, 0);
r300->vs_state.dirty = FALSE;
r300->vs_constants.dirty = FALSE;
}
+
+ r300->validate_buffers = TRUE;
}
/* reset flushed query */
boolean emit_aos = flags & PREP_EMIT_AOS;
boolean emit_aos_swtcl = flags & PREP_EMIT_AOS_SWTCL;
boolean indexed = flags & PREP_INDEXED;
+ boolean validate_vbos = flags & PREP_VALIDATE_VBOS;
/* Validate buffers and emit dirty state if needed. */
if (first_draw) {
- if (!r300_emit_buffer_validate(r300, flags & PREP_VALIDATE_VBOS,
- index_buffer)) {
- fprintf(stderr, "r300: CS space validation failed. "
- "(not enough memory?) Skipping rendering.\n");
- return FALSE;
+ /* upload buffers first */
+ if (r300->screen->caps.has_tcl && r300->any_user_vbs) {
+ r300_upload_user_buffers(r300);
+ r300->any_user_vbs = false;
+ }
+
+ if (r300->validate_buffers) {
+ if (!r300_emit_buffer_validate(r300, validate_vbos,
+ index_buffer)) {
+ fprintf(stderr, "r300: CS space validation failed. "
+ "(not enough memory?) Skipping rendering.\n");
+ return FALSE;
+ }
+
+ /* Consider the validation done only if everything was validated. */
+ if (validate_vbos) {
+ r300->validate_buffers = FALSE;
+ }
}
r300_emit_dirty_state(r300);
const float zeros[4] = {0, 0, 0, 0};
CS_LOCALS(r300);
+ r300->context.set_vertex_buffers(&r300->context, 0, NULL);
+
if (type == UTIL_BLITTER_ATTRIB_TEXCOORD)
r300->sprite_coord_enable = 1;
vb->max_index = num_verts - 1;
vb->stride = key.output_stride;
r300->tran.vb_slot = i;
+ r300->validate_buffers = TRUE;
break;
}
}
util_shorten_ubyte_elts(&r300->context, index_buffer, index_offset, *start, count);
*index_size = 2;
*start = 0;
+ r300->validate_buffers = TRUE;
break;
case 2:
if (*start % 2 != 0 || index_offset) {
util_rebuild_ushort_elts(&r300->context, index_buffer, index_offset, *start, count);
*start = 0;
+ r300->validate_buffers = TRUE;
}
break;
if (index_offset) {
util_rebuild_uint_elts(&r300->context, index_buffer, index_offset, *start, count);
*start = 0;
+ r300->validate_buffers = TRUE;
}
break;
}
pipe_resource_reference(&vb->buffer, NULL);
vb->buffer = upload_buffer;
vb->buffer_offset = upload_offset;
+ r300->validate_buffers = TRUE;
}
}
return ret;
util_copy_framebuffer_state(r300->fb_state.state, state);
r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE);
+ r300->validate_buffers = TRUE;
r300->z_compression = false;
state->sampler_view_count = count;
r300_mark_atom_dirty(r300, &r300->textures_state);
+ r300->validate_buffers = TRUE;
if (dirty_tex) {
r300_mark_atom_dirty(r300, &r300->texture_cache_inval);
r300->any_user_vbs = any_user_buffer;
r300->vertex_buffer_max_index = max_index;
r300->aos_dirty = TRUE;
+ r300->validate_buffers = TRUE;
} else {
/* SW TCL. */
draw_set_vertex_buffers(r300->draw, count, buffers);
}
if (r300->screen->caps.has_tcl) {
- /* TODO make this more like a state */
+ r300->validate_buffers = TRUE;
}
else {
- draw_set_index_buffer(r300->draw, ib);
+ draw_set_index_buffer(r300->draw, ib);
}
}