cell_render.c File Reference

Include dependency graph for cell_render.c:

Go to the source code of this file.

Data Structures

struct  render_stage
 Last stage of 'draw' pipeline: send tris to SPUs. More...

Functions

static struct render_stagerender_stage (struct draw_stage *stage)
static void render_begin (struct draw_stage *stage)
static void render_end (struct draw_stage *stage)
static void reset_stipple_counter (struct draw_stage *stage)
static void render_point (struct draw_stage *stage, struct prim_header *prim)
static void render_line (struct draw_stage *stage, struct prim_header *prim)
static void save_vertex (struct cell_prim_buffer *buf, uint pos, const struct vertex_header *vert)
 Write a vertex into the prim buffer.
static void render_tri (struct draw_stage *stage, struct prim_header *prim)
void cell_flush_prim_buffer (struct cell_context *cell)
 Send the a RENDER command to all SPUs to have them render the prims in the current prim_buffer.
static void render_destroy (struct draw_stage *stage)
struct draw_stagecell_draw_render_stage (struct cell_context *cell)
 Create a new draw/render stage.


Function Documentation

struct draw_stage* cell_draw_render_stage ( struct cell_context cell  )  [read]

Create a new draw/render stage.

This will be plugged into the draw module as the last pipeline stage.

Definition at line 190 of file cell_render.c.

References CALLOC_STRUCT, render_stage::cell, draw_stage::destroy, cell_context::draw, draw_stage::draw, draw_stage::line, draw_stage::point, render_begin(), render_destroy(), render_end(), render_line(), render_point(), render_tri(), reset_stipple_counter(), draw_stage::reset_stipple_counter, render_stage::stage, and draw_stage::tri.

00191 {
00192    struct render_stage *render = CALLOC_STRUCT(render_stage);
00193 
00194    render->cell = cell;
00195    render->stage.draw = cell->draw;
00196    render->stage.begin = render_begin;
00197    render->stage.point = render_point;
00198    render->stage.line = render_line;
00199    render->stage.tri = render_tri;
00200    render->stage.end = render_end;
00201    render->stage.reset_stipple_counter = reset_stipple_counter;
00202    render->stage.destroy = render_destroy;
00203 
00204    /*
00205    render->quad.coef = render->coef;
00206    render->quad.posCoef = &render->posCoef;
00207    */
00208 
00209    return &render->stage;
00210 }

void cell_flush_prim_buffer ( struct cell_context cell  ) 

Send the a RENDER command to all SPUs to have them render the prims in the current prim_buffer.

Definition at line 144 of file cell_render.c.

References ASSERT_ALIGN16, CELL_CMD_RENDER, cell_flush(), cell_global, cell_global_info::command, cell_context::num_spus, cell_command_render::num_verts, cell_context::pipe, PIPE_PRIM_TRIANGLES, cell_command_render::prim_type, send_mbox_message(), vertex_info::size, cell_global_info::spe_contexts, cell_context::vertex_info, cell_command_render::vertex_size, cell_command_render::xmax, cell_command_render::xmin, cell_command_render::ymax, and cell_command_render::ymin.

00145 {
00146    uint i;
00147 
00148    if (cell->prim_buffer.num_verts == 0)
00149       return;
00150 
00151    for (i = 0; i < cell->num_spus; i++) {
00152       struct cell_command_render *render = &cell_global.command[i].render;
00153       render->prim_type = PIPE_PRIM_TRIANGLES;
00154       render->num_verts = cell->prim_buffer.num_verts;
00155       render->vertex_size = cell->vertex_info->size * 4;
00156       render->xmin = cell->prim_buffer.xmin;
00157       render->ymin = cell->prim_buffer.ymin;
00158       render->xmax = cell->prim_buffer.xmax;
00159       render->ymax = cell->prim_buffer.ymax;
00160       render->vertex_data = &cell->prim_buffer.vertex;
00161       ASSERT_ALIGN16(render->vertex_data);
00162       send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER);
00163    }
00164 
00165    cell->prim_buffer.num_verts = 0;
00166 
00167    cell->prim_buffer.xmin = 1e100;
00168    cell->prim_buffer.ymin = 1e100;
00169    cell->prim_buffer.xmax = -1e100;
00170    cell->prim_buffer.ymax = -1e100;
00171 
00172    /* XXX temporary, need to double-buffer the prim buffer until we get
00173     * a real command buffer/list system.
00174     */
00175    cell_flush(&cell->pipe, 0x0);
00176 }

static void render_begin ( struct draw_stage stage  )  [static]

Definition at line 54 of file cell_render.c.

References render_stage::cell, cell_context::fs, render_stage(), and cell_fragment_shader_state::shader.

00055 {
00056 #if 0
00057    struct render_stage *render = render_stage(stage);
00058    struct cell_context *sp = render->cell;
00059    const struct pipe_shader_state *fs = &render->cell->fs->shader;
00060    render->quad.nr_attrs = render->cell->nr_frag_attrs;
00061 
00062    render->firstFpInput = fs->input_semantic_name[0];
00063 
00064    sp->quad.first->begin(sp->quad.first);
00065 #endif
00066 }

static void render_destroy ( struct draw_stage stage  )  [static]

Definition at line 180 of file cell_render.c.

References FREE.

00181 {
00182    FREE( stage );
00183 }

static void render_end ( struct draw_stage stage  )  [static]

Definition at line 69 of file cell_render.c.

00070 {
00071 }

static void render_line ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 88 of file cell_render.c.

00089 {
00090 }

static void render_point ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 82 of file cell_render.c.

00083 {
00084 }

static struct render_stage* render_stage ( struct draw_stage stage  )  [static, read]

Definition at line 48 of file cell_render.c.

00049 {
00050    return (struct render_stage *) stage;
00051 }

static void render_tri ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 119 of file cell_render.c.

References assert, render_stage::cell, cell_flush_prim_buffer(), render_stage(), save_vertex(), and prim_header::v.

00120 {
00121    struct render_stage *rs = render_stage(stage);
00122    struct cell_context *cell = rs->cell;
00123    struct cell_prim_buffer *buf = &cell->prim_buffer;
00124    uint i;
00125 
00126    if (buf->num_verts + 3 > CELL_MAX_VERTS) {
00127       cell_flush_prim_buffer(cell);
00128    }
00129 
00130    i = buf->num_verts;
00131    assert(i+2 <= CELL_MAX_VERTS);
00132    save_vertex(buf, i+0, prim->v[0]);
00133    save_vertex(buf, i+1, prim->v[1]);
00134    save_vertex(buf, i+2, prim->v[2]);
00135    buf->num_verts += 3;
00136 }

static void reset_stipple_counter ( struct draw_stage stage  )  [static]

Definition at line 74 of file cell_render.c.

References render_stage().

00075 {
00076    struct render_stage *render = render_stage(stage);
00077    /*render->cell->line_stipple_counter = 0;*/
00078 }

static void save_vertex ( struct cell_prim_buffer *  buf,
uint  pos,
const struct vertex_header vert 
) [static]

Write a vertex into the prim buffer.

Definition at line 95 of file cell_render.c.

References vertex_header::data.

00097 {
00098    uint attr, j;
00099 
00100    for (attr = 0; attr < 2; attr++) {
00101       for (j = 0; j < 4; j++) {
00102          buf->vertex[pos][attr][j] = vert->data[attr][j];
00103       }
00104    }
00105 
00106    /* update bounding box */
00107    if (vert->data[0][0] < buf->xmin)
00108       buf->xmin = vert->data[0][0];
00109    if (vert->data[0][0] > buf->xmax)
00110       buf->xmax = vert->data[0][0];
00111    if (vert->data[0][1] < buf->ymin)
00112       buf->ymin = vert->data[0][1];
00113    if (vert->data[0][1] > buf->ymax)
00114       buf->ymax = vert->data[0][1];
00115 }


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