sp_state_surface.c File Reference

Include dependency graph for sp_state_surface.c:

Go to the source code of this file.

Functions

void softpipe_set_framebuffer_state (struct pipe_context *pipe, const struct pipe_framebuffer_state *fb)
 XXX this might get moved someday Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.


Function Documentation

void softpipe_set_framebuffer_state ( struct pipe_context pipe,
const struct pipe_framebuffer_state fb 
)

XXX this might get moved someday Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.

Here, we flush the old surfaces and update the tile cache to point to the new surfaces.

Definition at line 47 of file sp_state_surface.c.

References softpipe_context::cbuf_cache, pipe_framebuffer_state::cbufs, softpipe_context::dirty, softpipe_context::draw, draw_set_mrd(), pipe_surface::format, softpipe_context::framebuffer, pipe_framebuffer_state::height, pipe_framebuffer_state::num_cbufs, pf_get_component_bits(), PIPE_FORMAT_COMP_Z, PIPE_MAX_COLOR_BUFS, softpipe_context(), sp_flush_tile_cache(), SP_NEW_FRAMEBUFFER, sp_tile_cache_set_surface(), pipe_framebuffer_state::width, pipe_framebuffer_state::zsbuf, and softpipe_context::zsbuf_cache.

00049 {
00050    struct softpipe_context *sp = softpipe_context(pipe);
00051    uint i;
00052 
00053    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
00054       /* check if changing cbuf */
00055       if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
00056          /* flush old */
00057          sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
00058 
00059          /* assign new */
00060          sp->framebuffer.cbufs[i] = fb->cbufs[i];
00061 
00062          /* update cache */
00063          sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]);
00064       }
00065    }
00066 
00067    sp->framebuffer.num_cbufs = fb->num_cbufs;
00068 
00069    /* zbuf changing? */
00070    if (sp->framebuffer.zsbuf != fb->zsbuf) {
00071       /* flush old */
00072       sp_flush_tile_cache(sp, sp->zsbuf_cache);
00073 
00074       /* assign new */
00075       sp->framebuffer.zsbuf = fb->zsbuf;
00076 
00077       /* update cache */
00078       sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf);
00079    }
00080 
00081 #if 0
00082    /* XXX combined depth/stencil here */
00083 
00084    /* sbuf changing? */
00085    if (sp->framebuffer.sbuf != fb->sbuf) {
00086       /* flush old */
00087       sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
00088 
00089       /* assign new */
00090       sp->framebuffer.sbuf = fb->sbuf;
00091 
00092       /* update cache */
00093       if (fb->sbuf != fb->zbuf) {
00094          /* separate stencil buf */
00095          sp->sbuf_cache = sp->sbuf_cache_sep;
00096          sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
00097       }
00098       else {
00099          /* combined depth/stencil */
00100          sp->sbuf_cache = sp->zbuf_cache;
00101          sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
00102       }
00103    }
00104 #endif
00105 
00106    /* Tell draw module how deep the Z/depth buffer is */
00107    {
00108       int depth_bits;
00109       double mrd;
00110       if (sp->framebuffer.zsbuf) {
00111          depth_bits = pf_get_component_bits(sp->framebuffer.zsbuf->format,
00112                                             PIPE_FORMAT_COMP_Z);
00113       }
00114       else {
00115          depth_bits = 0;
00116       }
00117       if (depth_bits > 16) {
00118          mrd = 0.0000001;
00119       }
00120       else {
00121          mrd = 0.00002;
00122       }
00123       draw_set_mrd(sp->draw, mrd);
00124    }
00125 
00126    sp->framebuffer.width = fb->width;
00127    sp->framebuffer.height = fb->height;
00128 
00129    sp->dirty |= SP_NEW_FRAMEBUFFER;
00130 }


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