cell_draw_arrays.c File Reference

Include dependency graph for cell_draw_arrays.c:

Go to the source code of this file.

Functions

static void cell_map_constant_buffers (struct cell_context *sp)
static void cell_unmap_constant_buffers (struct cell_context *sp)
static boolean cell_draw_range_elements (struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned min_index, unsigned max_index, unsigned mode, unsigned start, unsigned count)
 Draw vertex arrays, with optional indexing.
static boolean cell_draw_elements (struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count)
static boolean cell_draw_arrays (struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count)
static void cell_set_edgeflags (struct pipe_context *pipe, const unsigned *edgeflags)
void cell_init_draw_functions (struct cell_context *cell)


Function Documentation

static boolean cell_draw_arrays ( struct pipe_context pipe,
unsigned  mode,
unsigned  start,
unsigned  count 
) [static]

Definition at line 167 of file cell_draw_arrays.c.

References cell_draw_elements().

00169 {
00170    return cell_draw_elements(pipe, NULL, 0, mode, start, count);
00171 }

static boolean cell_draw_elements ( struct pipe_context pipe,
struct pipe_buffer indexBuffer,
unsigned  indexSize,
unsigned  mode,
unsigned  start,
unsigned  count 
) [static]

Definition at line 154 of file cell_draw_arrays.c.

References cell_draw_range_elements().

00158 {
00159    return cell_draw_range_elements( pipe, indexBuffer,
00160                                     indexSize,
00161                                     0, 0xffffffff,
00162                                     mode, start, count );
00163 }

static boolean cell_draw_range_elements ( struct pipe_context pipe,
struct pipe_buffer indexBuffer,
unsigned  indexSize,
unsigned  min_index,
unsigned  max_index,
unsigned  mode,
unsigned  start,
unsigned  count 
) [static]

Draw vertex arrays, with optional indexing.

Basically, map the vertex buffers (and drawing surfaces), then hand off the drawing to the 'draw' module.

XXX should the element buffer be specified/bound with a separate function?

Definition at line 89 of file cell_draw_arrays.c.

References pipe_vertex_buffer::buffer, cell_context(), cell_flush_buffer_range(), cell_map_constant_buffers(), cell_unmap_constant_buffers(), cell_update_derived(), cell_context::dirty, cell_context::draw, draw, draw_arrays(), draw_set_mapped_element_buffer(), draw_set_mapped_vertex_buffer(), cell_context::num_vertex_buffers, pipe_buffer_map(), pipe_buffer_unmap(), PIPE_BUFFER_USAGE_CPU_READ, pipe_context::screen, pipe_buffer::size, TRUE, and cell_context::vertex_buffer.

00095 {
00096    struct cell_context *sp = cell_context(pipe);
00097    struct draw_context *draw = sp->draw;
00098    unsigned i;
00099 
00100    if (sp->dirty)
00101       cell_update_derived( sp );
00102 
00103 #if 0
00104    cell_map_surfaces(sp);
00105 #endif
00106    cell_map_constant_buffers(sp);
00107 
00108    /*
00109     * Map vertex buffers
00110     */
00111    for (i = 0; i < sp->num_vertex_buffers; i++) {
00112       void *buf = pipe_buffer_map(pipe->screen,
00113                                            sp->vertex_buffer[i].buffer,
00114                                            PIPE_BUFFER_USAGE_CPU_READ);
00115       cell_flush_buffer_range(sp, buf, sp->vertex_buffer[i].buffer->size);
00116       draw_set_mapped_vertex_buffer(draw, i, buf);
00117    }
00118    /* Map index buffer, if present */
00119    if (indexBuffer) {
00120       void *mapped_indexes = pipe_buffer_map(pipe->screen,
00121                                                       indexBuffer,
00122                                                       PIPE_BUFFER_USAGE_CPU_READ);
00123       draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
00124    }
00125    else {
00126       /* no index/element buffer */
00127       draw_set_mapped_element_buffer(draw, 0, NULL);
00128    }
00129 
00130 
00131    /* draw! */
00132    draw_arrays(draw, mode, start, count);
00133 
00134    /*
00135     * unmap vertex/index buffers - will cause draw module to flush
00136     */
00137    for (i = 0; i < sp->num_vertex_buffers; i++) {
00138       draw_set_mapped_vertex_buffer(draw, i, NULL);
00139       pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
00140    }
00141    if (indexBuffer) {
00142       draw_set_mapped_element_buffer(draw, 0, NULL);
00143       pipe_buffer_unmap(pipe->screen, indexBuffer);
00144    }
00145 
00146    /* Note: leave drawing surfaces mapped */
00147    cell_unmap_constant_buffers(sp);
00148 
00149    return TRUE;
00150 }

void cell_init_draw_functions ( struct cell_context cell  ) 

Definition at line 184 of file cell_draw_arrays.c.

References cell_draw_arrays(), cell_draw_elements(), cell_draw_range_elements(), cell_set_edgeflags(), pipe_context::draw_arrays, pipe_context::draw_elements, pipe_context::draw_range_elements, cell_context::pipe, and pipe_context::set_edgeflags.

static void cell_map_constant_buffers ( struct cell_context sp  )  [static]

Definition at line 49 of file cell_draw_arrays.c.

References pipe_constant_buffer::buffer, pipe_winsys::buffer_map, cell_flush_buffer_range(), cell_context::constants, cell_context::draw, draw_set_mapped_constant_buffer(), cell_context::mapped_constants, cell_context::pipe, PIPE_BUFFER_USAGE_CPU_READ, PIPE_SHADER_VERTEX, pipe_buffer::size, pipe_constant_buffer::size, and pipe_context::winsys.

00050 {
00051    struct pipe_winsys *ws = sp->pipe.winsys;
00052    uint i;
00053    for (i = 0; i < 2; i++) {
00054       if (sp->constants[i].size) {
00055          sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
00056                                                   PIPE_BUFFER_USAGE_CPU_READ);
00057          cell_flush_buffer_range(sp, sp->mapped_constants[i], 
00058                                  sp->constants[i].buffer->size);
00059       }
00060    }
00061 
00062    draw_set_mapped_constant_buffer(sp->draw,
00063                                    sp->mapped_constants[PIPE_SHADER_VERTEX],
00064                                    sp->constants[PIPE_SHADER_VERTEX].size);
00065 }

static void cell_set_edgeflags ( struct pipe_context pipe,
const unsigned *  edgeflags 
) [static]

Definition at line 175 of file cell_draw_arrays.c.

References cell_context(), cell_context::draw, and draw_set_edgeflags().

00176 {
00177    struct cell_context *cell = cell_context(pipe);
00178    draw_set_edgeflags(cell->draw, edgeflags);
00179 }

static void cell_unmap_constant_buffers ( struct cell_context sp  )  [static]

Definition at line 68 of file cell_draw_arrays.c.

References pipe_constant_buffer::buffer, pipe_winsys::buffer_unmap, cell_context::constants, cell_context::mapped_constants, cell_context::pipe, pipe_constant_buffer::size, and pipe_context::winsys.

00069 {
00070    struct pipe_winsys *ws = sp->pipe.winsys;
00071    uint i;
00072    for (i = 0; i < 2; i++) {
00073       if (sp->constants[i].size)
00074          ws->buffer_unmap(ws, sp->constants[i].buffer);
00075       sp->mapped_constants[i] = NULL;
00076    }
00077 }


Generated on Tue Sep 29 06:25:30 2009 for Gallium3D by  doxygen 1.5.4