cell_pipe_state.c File Reference

Include dependency graph for cell_pipe_state.c:

Go to the source code of this file.

Functions

static void * cell_create_blend_state (struct pipe_context *pipe, const struct pipe_blend_state *blend)
static void cell_bind_blend_state (struct pipe_context *pipe, void *state)
static void cell_delete_blend_state (struct pipe_context *pipe, void *blend)
static void cell_set_blend_color (struct pipe_context *pipe, const struct pipe_blend_color *blend_color)
static void * cell_create_depth_stencil_alpha_state (struct pipe_context *pipe, const struct pipe_depth_stencil_alpha_state *depth_stencil)
static void cell_bind_depth_stencil_alpha_state (struct pipe_context *pipe, void *depth_stencil)
static void cell_delete_depth_stencil_alpha_state (struct pipe_context *pipe, void *depth)
static void cell_set_clip_state (struct pipe_context *pipe, const struct pipe_clip_state *clip)
static void cell_set_viewport_state (struct pipe_context *pipe, const struct pipe_viewport_state *viewport)
static void cell_set_scissor_state (struct pipe_context *pipe, const struct pipe_scissor_state *scissor)
static void cell_set_polygon_stipple (struct pipe_context *pipe, const struct pipe_poly_stipple *stipple)
static void * cell_create_rasterizer_state (struct pipe_context *pipe, const struct pipe_rasterizer_state *setup)
static void cell_bind_rasterizer_state (struct pipe_context *pipe, void *setup)
static void cell_delete_rasterizer_state (struct pipe_context *pipe, void *rasterizer)
static void * cell_create_sampler_state (struct pipe_context *pipe, const struct pipe_sampler_state *sampler)
static void cell_bind_sampler_states (struct pipe_context *pipe, unsigned num, void **samplers)
static void cell_delete_sampler_state (struct pipe_context *pipe, void *sampler)
static void cell_set_sampler_textures (struct pipe_context *pipe, unsigned num, struct pipe_texture **texture)
static void cell_set_framebuffer_state (struct pipe_context *pipe, const struct pipe_framebuffer_state *fb)
void cell_init_state_functions (struct cell_context *cell)


Function Documentation

static void cell_bind_blend_state ( struct pipe_context pipe,
void *  state 
) [static]

Definition at line 59 of file cell_pipe_state.c.

References cell_context::blend, cell_context(), CELL_NEW_BLEND, cell_context::dirty, cell_context::draw, and draw_flush().

00060 {
00061    struct cell_context *cell = cell_context(pipe);
00062 
00063    draw_flush(cell->draw);
00064 
00065    cell->blend = (struct cell_blend_state *) state;
00066    cell->dirty |= CELL_NEW_BLEND;
00067 }

static void cell_bind_depth_stencil_alpha_state ( struct pipe_context pipe,
void *  depth_stencil 
) [static]

Definition at line 112 of file cell_pipe_state.c.

References cell_context(), CELL_NEW_DEPTH_STENCIL, cell_context::depth_stencil, cell_context::dirty, cell_context::draw, and draw_flush().

00114 {
00115    struct cell_context *cell = cell_context(pipe);
00116 
00117    draw_flush(cell->draw);
00118 
00119    cell->depth_stencil =
00120        (struct cell_depth_stencil_alpha_state *) depth_stencil;
00121    cell->dirty |= CELL_NEW_DEPTH_STENCIL;
00122 }

static void cell_bind_rasterizer_state ( struct pipe_context pipe,
void *  setup 
) [static]

Definition at line 204 of file cell_pipe_state.c.

References cell_context(), CELL_NEW_RASTERIZER, cell_context::dirty, cell_context::draw, draw_set_rasterizer_state(), and cell_context::rasterizer.

00205 {
00206    struct cell_context *cell = cell_context(pipe);
00207 
00208    /* pass-through to draw module */
00209    draw_set_rasterizer_state(cell->draw, setup);
00210 
00211    cell->rasterizer = (struct pipe_rasterizer_state *)setup;
00212 
00213    cell->dirty |= CELL_NEW_RASTERIZER;
00214 }

static void cell_bind_sampler_states ( struct pipe_context pipe,
unsigned  num,
void **  samplers 
) [static]

Definition at line 234 of file cell_pipe_state.c.

References assert, cell_context(), CELL_MAX_SAMPLERS, CELL_NEW_SAMPLER, cell_context::dirty, cell_context::draw, draw_flush(), cell_context::num_samplers, and cell_context::sampler.

00236 {
00237    struct cell_context *cell = cell_context(pipe);
00238 
00239    assert(num <= CELL_MAX_SAMPLERS);
00240 
00241    draw_flush(cell->draw);
00242 
00243    memcpy(cell->sampler, samplers, num * sizeof(void *));
00244    memset(&cell->sampler[num], 0, (CELL_MAX_SAMPLERS - num) *
00245           sizeof(void *));
00246    cell->num_samplers = num;
00247 
00248    cell->dirty |= CELL_NEW_SAMPLER;
00249 }

static void* cell_create_blend_state ( struct pipe_context pipe,
const struct pipe_blend_state blend 
) [static]

Definition at line 45 of file cell_pipe_state.c.

References cell_generate_alpha_blend(), and MALLOC.

00047 {
00048    struct cell_blend_state *cb = MALLOC(sizeof(struct cell_blend_state));
00049 
00050    (void) memcpy(cb, blend, sizeof(*blend));
00051 #if 0
00052    cell_generate_alpha_blend(cb);
00053 #endif
00054    return cb;
00055 }

static void* cell_create_depth_stencil_alpha_state ( struct pipe_context pipe,
const struct pipe_depth_stencil_alpha_state depth_stencil 
) [static]

Definition at line 97 of file cell_pipe_state.c.

References cell_generate_depth_stencil_test(), and MALLOC.

00099 {
00100    struct cell_depth_stencil_alpha_state *cdsa =
00101        MALLOC(sizeof(struct cell_depth_stencil_alpha_state));
00102 
00103    (void) memcpy(cdsa, depth_stencil, sizeof(*depth_stencil));
00104 #if 0
00105    cell_generate_depth_stencil_test(cdsa);
00106 #endif
00107    return cdsa;
00108 }

static void* cell_create_rasterizer_state ( struct pipe_context pipe,
const struct pipe_rasterizer_state setup 
) [static]

Definition at line 193 of file cell_pipe_state.c.

References MALLOC.

00195 {
00196    struct pipe_rasterizer_state *state
00197       = MALLOC(sizeof(struct pipe_rasterizer_state));
00198    memcpy(state, setup, sizeof(struct pipe_rasterizer_state));
00199    return state;
00200 }

static void* cell_create_sampler_state ( struct pipe_context pipe,
const struct pipe_sampler_state sampler 
) [static]

Definition at line 226 of file cell_pipe_state.c.

References mem_dup().

00228 {
00229    return mem_dup(sampler, sizeof(*sampler));
00230 }

static void cell_delete_blend_state ( struct pipe_context pipe,
void *  blend 
) [static]

Definition at line 71 of file cell_pipe_state.c.

References cell_blend_state::code, FREE, and spe_release_func().

00072 {
00073    struct cell_blend_state *cb = (struct cell_blend_state *) blend;
00074 
00075    spe_release_func(& cb->code);
00076    FREE(cb);
00077 }

static void cell_delete_depth_stencil_alpha_state ( struct pipe_context pipe,
void *  depth 
) [static]

Definition at line 126 of file cell_pipe_state.c.

References cell_depth_stencil_alpha_state::code, FREE, and spe_release_func().

00127 {
00128    struct cell_depth_stencil_alpha_state *cdsa =
00129        (struct cell_depth_stencil_alpha_state *) depth;
00130 
00131    spe_release_func(& cdsa->code);
00132    FREE(cdsa);
00133 }

static void cell_delete_rasterizer_state ( struct pipe_context pipe,
void *  rasterizer 
) [static]

Definition at line 218 of file cell_pipe_state.c.

References FREE.

00219 {
00220    FREE(rasterizer);
00221 }

static void cell_delete_sampler_state ( struct pipe_context pipe,
void *  sampler 
) [static]

Definition at line 253 of file cell_pipe_state.c.

References FREE.

00255 {
00256    FREE( sampler );
00257 }

void cell_init_state_functions ( struct cell_context cell  ) 

Definition at line 347 of file cell_pipe_state.c.

References pipe_context::bind_blend_state, pipe_context::bind_depth_stencil_alpha_state, pipe_context::bind_rasterizer_state, pipe_context::bind_sampler_states, cell_bind_blend_state(), cell_bind_depth_stencil_alpha_state(), cell_bind_rasterizer_state(), cell_bind_sampler_states(), cell_create_blend_state(), cell_create_depth_stencil_alpha_state(), cell_create_rasterizer_state(), cell_create_sampler_state(), cell_delete_blend_state(), cell_delete_depth_stencil_alpha_state(), cell_delete_rasterizer_state(), cell_delete_sampler_state(), cell_set_blend_color(), cell_set_clip_state(), cell_set_framebuffer_state(), cell_set_polygon_stipple(), cell_set_sampler_textures(), cell_set_scissor_state(), cell_set_viewport_state(), pipe_context::create_blend_state, pipe_context::create_depth_stencil_alpha_state, pipe_context::create_rasterizer_state, pipe_context::create_sampler_state, pipe_context::delete_blend_state, pipe_context::delete_depth_stencil_alpha_state, pipe_context::delete_rasterizer_state, pipe_context::delete_sampler_state, cell_context::pipe, pipe_context::set_blend_color, pipe_context::set_clip_state, pipe_context::set_framebuffer_state, pipe_context::set_polygon_stipple, pipe_context::set_sampler_textures, pipe_context::set_scissor_state, and pipe_context::set_viewport_state.

static void cell_set_blend_color ( struct pipe_context pipe,
const struct pipe_blend_color blend_color 
) [static]

Definition at line 81 of file cell_pipe_state.c.

References cell_context::blend_color, cell_context(), CELL_NEW_BLEND, cell_context::dirty, cell_context::draw, and draw_flush().

00083 {
00084    struct cell_context *cell = cell_context(pipe);
00085 
00086    draw_flush(cell->draw);
00087 
00088    cell->blend_color = *blend_color;
00089 
00090    cell->dirty |= CELL_NEW_BLEND;
00091 }

static void cell_set_clip_state ( struct pipe_context pipe,
const struct pipe_clip_state clip 
) [static]

Definition at line 137 of file cell_pipe_state.c.

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

00139 {
00140    struct cell_context *cell = cell_context(pipe);
00141 
00142    /* pass the clip state to the draw module */
00143    draw_set_clip_state(cell->draw, clip);
00144 }

static void cell_set_framebuffer_state ( struct pipe_context pipe,
const struct pipe_framebuffer_state fb 
) [static]

Definition at line 292 of file cell_pipe_state.c.

References cell_context::cbuf_map, pipe_framebuffer_state::cbufs, cell_context(), cell_flush_int(), CELL_FLUSH_WAIT, CELL_NEW_FRAMEBUFFER, cell_context::dirty, cell_context::framebuffer, pipe_framebuffer_state::height, pipe_framebuffer_state::num_cbufs, PIPE_BUFFER_USAGE_GPU_READ, PIPE_BUFFER_USAGE_GPU_WRITE, PIPE_MAX_COLOR_BUFS, pipe_surface_map(), pipe_surface_reference(), pipe_surface_unmap(), pipe_framebuffer_state::width, pipe_framebuffer_state::zsbuf, and cell_context::zsbuf_map.

00294 {
00295    struct cell_context *cell = cell_context(pipe);
00296 
00297    if (1 /*memcmp(&cell->framebuffer, fb, sizeof(*fb))*/) {
00298       struct pipe_surface *csurf = fb->cbufs[0];
00299       struct pipe_surface *zsurf = fb->zsbuf;
00300       uint i;
00301       uint flags = (PIPE_BUFFER_USAGE_GPU_WRITE |
00302                     PIPE_BUFFER_USAGE_GPU_READ);
00303 
00304       /* unmap old surfaces */
00305       for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
00306          if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) {
00307             pipe_surface_unmap(cell->framebuffer.cbufs[i]);
00308             cell->cbuf_map[i] = NULL;
00309          }
00310       }
00311 
00312       if (cell->framebuffer.zsbuf && cell->zsbuf_map) {
00313          pipe_surface_unmap(cell->framebuffer.zsbuf);
00314          cell->zsbuf_map = NULL;
00315       }
00316 
00317       /* Finish any pending rendering to the current surface before
00318        * installing a new surface!
00319        */
00320       cell_flush_int(cell, CELL_FLUSH_WAIT);
00321 
00322       /* update my state
00323        * (this is also where old surfaces will finally get freed)
00324        */
00325       cell->framebuffer.width = fb->width;
00326       cell->framebuffer.height = fb->height;
00327       cell->framebuffer.num_cbufs = fb->num_cbufs;
00328       for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
00329          pipe_surface_reference(&cell->framebuffer.cbufs[i], fb->cbufs[i]);
00330       }
00331       pipe_surface_reference(&cell->framebuffer.zsbuf, fb->zsbuf);
00332 
00333       /* map new surfaces */
00334       if (csurf)
00335          cell->cbuf_map[0] = pipe_surface_map(csurf, flags);
00336 
00337       if (zsurf)
00338          cell->zsbuf_map = pipe_surface_map(zsurf, flags);
00339 
00340       cell->dirty |= CELL_NEW_FRAMEBUFFER;
00341    }
00342 }

static void cell_set_polygon_stipple ( struct pipe_context pipe,
const struct pipe_poly_stipple stipple 
) [static]

Definition at line 181 of file cell_pipe_state.c.

References cell_context(), CELL_NEW_STIPPLE, cell_context::dirty, and cell_context::poly_stipple.

00183 {
00184    struct cell_context *cell = cell_context(pipe);
00185 
00186    memcpy( &cell->poly_stipple, stipple, sizeof(*stipple) );
00187    cell->dirty |= CELL_NEW_STIPPLE;
00188 }

static void cell_set_sampler_textures ( struct pipe_context pipe,
unsigned  num,
struct pipe_texture **  texture 
) [static]

Definition at line 262 of file cell_pipe_state.c.

References assert, cell_context(), CELL_MAX_SAMPLERS, CELL_NEW_TEXTURE, cell_update_texture_mapping(), cell_context::dirty, cell_context::draw, draw_flush(), cell_context::num_textures, pipe_texture_reference(), and cell_context::texture.

00264 {
00265    struct cell_context *cell = cell_context(pipe);
00266    uint i;
00267 
00268    assert(num <= CELL_MAX_SAMPLERS);
00269 
00270    /* Check for no-op */
00271    if (num == cell->num_textures &&
00272        !memcmp(cell->texture, texture, num * sizeof(struct pipe_texture *)))
00273       return;
00274 
00275    draw_flush(cell->draw);
00276 
00277    for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
00278       struct pipe_texture *tex = i < num ? texture[i] : NULL;
00279 
00280       pipe_texture_reference((struct pipe_texture **) &cell->texture[i], tex);
00281    }
00282    cell->num_textures = num;
00283 
00284    cell_update_texture_mapping(cell);
00285 
00286    cell->dirty |= CELL_NEW_TEXTURE;
00287 }

static void cell_set_scissor_state ( struct pipe_context pipe,
const struct pipe_scissor_state scissor 
) [static]

Definition at line 170 of file cell_pipe_state.c.

References cell_context(), CELL_NEW_SCISSOR, cell_context::dirty, and cell_context::scissor.

00172 {
00173    struct cell_context *cell = cell_context(pipe);
00174 
00175    memcpy( &cell->scissor, scissor, sizeof(*scissor) );
00176    cell->dirty |= CELL_NEW_SCISSOR;
00177 }

static void cell_set_viewport_state ( struct pipe_context pipe,
const struct pipe_viewport_state viewport 
) [static]

Definition at line 152 of file cell_pipe_state.c.

References cell_context(), CELL_NEW_VIEWPORT, cell_context::dirty, cell_context::draw, draw_set_viewport_state(), and cell_context::viewport.

00154 {
00155    struct cell_context *cell = cell_context(pipe);
00156 
00157    cell->viewport = *viewport; /* struct copy */
00158    cell->dirty |= CELL_NEW_VIEWPORT;
00159 
00160    /* pass the viewport info to the draw module */
00161    draw_set_viewport_state(cell->draw, viewport);
00162 
00163    /* Using tnl/ and vf/ modules is temporary while getting started.
00164     * Full pipe will have vertex shader, vertex fetch of its own.
00165     */
00166 }


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