/** * Validate buffers and emit dirty state. * \param r300 The context. * \param flags See r300_prepare_flags. * \param index_buffer The index buffer to validate. The parameter may be NULL. * \param buffer_offset The offset passed to emit_vertex_arrays. * \param index_bias The index bias to emit. * \param instance_id Index of instance to render * \return TRUE if rendering should be skipped */ static boolean r300_emit_states(struct r300_context *r300, enum r300_prepare_flags flags, struct pipe_resource *index_buffer, int buffer_offset, int index_bias, int instance_id) { boolean emit_states = flags & PREP_EMIT_STATES; boolean emit_vertex_arrays = flags & PREP_EMIT_VARRAYS; boolean emit_vertex_arrays_swtcl = flags & PREP_EMIT_VARRAYS_SWTCL; boolean indexed = flags & PREP_INDEXED; boolean validate_vbos = flags & PREP_VALIDATE_VBOS; /* Validate buffers and emit dirty state if needed. */ if (emit_states || (emit_vertex_arrays && validate_vbos)) { 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; } } if (emit_states) r300_emit_dirty_state(r300); if (r300->screen->caps.is_r500) { if (r300->screen->caps.has_tcl) r500_emit_index_bias(r300, index_bias); else r500_emit_index_bias(r300, 0); } if (emit_vertex_arrays && (r300->vertex_arrays_dirty || r300->vertex_arrays_indexed != indexed || r300->vertex_arrays_offset != buffer_offset || r300->vertex_arrays_instance_id != instance_id)) { r300_emit_vertex_arrays(r300, buffer_offset, indexed, instance_id); r300->vertex_arrays_dirty = FALSE; r300->vertex_arrays_indexed = indexed; r300->vertex_arrays_offset = buffer_offset; r300->vertex_arrays_instance_id = instance_id; } if (emit_vertex_arrays_swtcl) r300_emit_vertex_arrays_swtcl(r300, indexed); return TRUE; }
static void r300_flush_and_cleanup(struct r300_context *r300, unsigned flags) { struct r300_atom *atom; r300_emit_hyperz_end(r300); r300_emit_query_end(r300); if (r300->screen->caps.is_r500) r500_emit_index_bias(r300, 0); r300->flush_counter++; r300->rws->cs_flush(r300->cs, flags); r300->dirty_hw = 0; /* New kitchen sink, baby. */ foreach_atom(r300, atom) { if (atom->state || atom->allow_null_state) { r300_mark_atom_dirty(r300, atom); } } r300->vertex_arrays_dirty = TRUE; /* Unmark HWTCL state for SWTCL. */ if (!r300->screen->caps.has_tcl) { r300->vs_state.dirty = FALSE; r300->vs_constants.dirty = FALSE; r300->clip_state.dirty = FALSE; } }
/** * Validate buffers and emit dirty state. * \param r300 The context. * \param flags See r300_prepare_flags. * \param index_buffer The index buffer to validate. The parameter may be NULL. * \param aos_offset The offset passed to emit_aos. * \param index_bias The index bias to emit. * \return TRUE if rendering should be skipped */ static boolean r300_emit_states(struct r300_context *r300, enum r300_prepare_flags flags, struct pipe_resource *index_buffer, int aos_offset, int index_bias) { boolean first_draw = flags & PREP_FIRST_DRAW; boolean emit_aos = flags & PREP_EMIT_AOS; boolean emit_aos_swtcl = flags & PREP_EMIT_AOS_SWTCL; boolean indexed = flags & PREP_INDEXED; boolean hw_index_bias = r500_index_bias_supported(r300); /* 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; } r300_emit_dirty_state(r300); if (hw_index_bias) { if (r300->screen->caps.has_tcl) r500_emit_index_bias(r300, index_bias); else r500_emit_index_bias(r300, 0); } if (emit_aos) r300_emit_aos(r300, aos_offset, indexed); if (emit_aos_swtcl) r300_emit_aos_swtcl(r300, indexed); } return TRUE; }
static void r300_flush_and_cleanup(struct r300_context *r300, unsigned flags, struct pipe_fence_handle **fence) { struct r300_atom *atom; r300_emit_hyperz_end(r300); r300_emit_query_end(r300); if (r300->screen->caps.is_r500) r500_emit_index_bias(r300, 0); /* The DDX doesn't set these regs. */ if (r300->screen->info.drm_minor >= 6) { CS_LOCALS(r300); OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2); OUT_CS(0x66666666); OUT_CS(0x6666666); } r300->flush_counter++; r300->rws->cs_flush(r300->cs, flags, fence, 0); r300->dirty_hw = 0; /* New kitchen sink, baby. */ foreach_atom(r300, atom) { if (atom->state || atom->allow_null_state) { r300_mark_atom_dirty(r300, atom); } } r300->vertex_arrays_dirty = TRUE; /* Unmark HWTCL state for SWTCL. */ if (!r300->screen->caps.has_tcl) { r300->vs_state.dirty = FALSE; r300->vs_constants.dirty = FALSE; r300->clip_state.dirty = FALSE; } }