/** * Check if the requested number of dwords is available in the CS and * if not, flush. * \param r300 The context. * \param flags See r300_prepare_flags. * \param cs_dwords The number of dwords to reserve in CS. * \return TRUE if the CS was flushed */ static boolean r300_reserve_cs_dwords(struct r300_context *r300, enum r300_prepare_flags flags, unsigned cs_dwords) { boolean flushed = FALSE; 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; /* Add dirty state, index offset, and AOS. */ if (emit_states) cs_dwords += r300_get_num_dirty_dwords(r300); if (r300->screen->caps.is_r500) cs_dwords += 2; /* emit_index_offset */ if (emit_vertex_arrays) cs_dwords += 55; /* emit_vertex_arrays */ if (emit_vertex_arrays_swtcl) cs_dwords += 7; /* emit_vertex_arrays_swtcl */ cs_dwords += r300_get_num_cs_end_dwords(r300); /* Reserve requested CS space. */ if (cs_dwords > (r300->cs->max_dw - r300->cs->cdw)) { r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL); flushed = TRUE; } return flushed; }
/** * Check if the requested number of dwords is available in the CS and * if not, flush. * \param r300 The context. * \param flags See r300_prepare_flags. * \param cs_dwords The number of dwords to reserve in CS. * \return TRUE if the CS was flushed */ static boolean r300_reserve_cs_dwords(struct r300_context *r300, enum r300_prepare_flags flags, unsigned cs_dwords) { boolean flushed = FALSE; boolean first_draw = flags & PREP_FIRST_DRAW; boolean emit_aos = flags & PREP_EMIT_AOS; boolean emit_aos_swtcl = flags & PREP_EMIT_AOS_SWTCL; boolean hw_index_bias = r500_index_bias_supported(r300); /* Add dirty state, index offset, and AOS. */ if (first_draw) { cs_dwords += r300_get_num_dirty_dwords(r300); if (hw_index_bias) cs_dwords += 2; /* emit_index_offset */ if (emit_aos) cs_dwords += 55; /* emit_aos */ if (emit_aos_swtcl) cs_dwords += 7; /* emit_aos_swtcl */ } cs_dwords += r300_get_num_cs_end_dwords(r300); /* Reserve requested CS space. */ if (cs_dwords > (r300->cs->ndw - r300->cs->cdw)) { r300->context.flush(&r300->context, 0, NULL); flushed = TRUE; } return flushed; }