Exemplo n.º 1
0
/**
 * 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;
}
Exemplo n.º 2
0
/**
 * 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;
}