示例#1
0
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;
}
示例#2
0
/* 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;
}