boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode, unsigned start, unsigned count) { struct r300_context* r300 = r300_context(pipe); if (!u_trim_pipe_prim(mode, &count)) { return FALSE; } if (count > 65535) { return FALSE; } r300_update_derived_state(r300); if (!r300_setup_vertex_buffers(r300)) { return FALSE; } setup_vertex_attributes(r300); r300_emit_dirty_state(r300); r300_emit_aos(r300, start); r300_emit_draw_arrays(r300, mode, count); return TRUE; }
/** * 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_render_draw_arrays(struct vbuf_render* render, unsigned start, unsigned count) { struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; CS_LOCALS(r300); r300_emit_dirty_state(r300); DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count); BEGIN_CS(2); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | r300render->hwprim); END_CS; }
/* This is the fast-path drawing & emission for HW TCL. */ boolean r300_draw_range_elements(struct pipe_context* pipe, struct pipe_buffer* indexBuffer, unsigned indexSize, unsigned minIndex, unsigned maxIndex, unsigned mode, unsigned start, unsigned count) { struct r300_context* r300 = r300_context(pipe); if (!u_trim_pipe_prim(mode, &count)) { return FALSE; } if (count > 65535) { return FALSE; } r300_update_derived_state(r300); if (!r300_setup_vertex_buffers(r300)) { return FALSE; } setup_vertex_attributes(r300); setup_index_buffer(r300, indexBuffer, indexSize); r300_emit_dirty_state(r300); r300_emit_aos(r300, 0); r300_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); return TRUE; }
/** * 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_render_draw(struct vbuf_render* render, const ushort* indices, uint count) { struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; int i; CS_LOCALS(r300); r300_emit_dirty_state(r300); BEGIN_CS(2 + (count+1)/2); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | r300render->hwprim); for (i = 0; i < count-1; i += 2) { OUT_CS(indices[i+1] << 16 | indices[i]); } if (count % 2) { OUT_CS(indices[count-1]); } END_CS; }