sp_clear.c File Reference

Include dependency graph for sp_clear.c:

Go to the source code of this file.

Functions

static unsigned convert_color (enum pipe_format srcFormat, unsigned srcColor, enum pipe_format dstFormat)
 Convert packed pixel from one format to another.
void softpipe_clear (struct pipe_context *pipe, struct pipe_surface *ps, unsigned clearValue)
 Clear the given surface to the specified value.


Function Documentation

static unsigned convert_color ( enum pipe_format  srcFormat,
unsigned  srcColor,
enum pipe_format  dstFormat 
) [static]

Convert packed pixel from one format to another.

Definition at line 46 of file sp_clear.c.

References util_pack_color_ub(), and util_unpack_color_ub().

00048 {
00049    ubyte r, g, b, a;
00050    unsigned dstColor;
00051 
00052    util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
00053    util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
00054 
00055    return dstColor;
00056 }

void softpipe_clear ( struct pipe_context pipe,
struct pipe_surface ps,
unsigned  clearValue 
)

Clear the given surface to the specified value.

No masking, no scissor (clear entire buffer). Note: when clearing a color buffer, the clearValue is always encoded as PIPE_FORMAT_A8R8G8B8_UNORM.

Definition at line 67 of file sp_clear.c.

References softpipe_context::cbuf_cache, pipe_framebuffer_state::cbufs, convert_color(), pipe_surface::format, softpipe_context::framebuffer, pipe_surface::height, softpipe_context::no_rast, pipe_framebuffer_state::num_cbufs, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_SURFACE_STATUS_CLEAR, softpipe_context(), softpipe_update_derived(), sp_tile_cache_clear(), sp_tile_cache_get_surface(), pipe_surface::status, pipe_context::surface_fill, pipe_surface::width, pipe_framebuffer_state::zsbuf, and softpipe_context::zsbuf_cache.

00069 {
00070    struct softpipe_context *softpipe = softpipe_context(pipe);
00071    uint i;
00072 
00073    if (softpipe->no_rast)
00074       return;
00075 
00076 #if 0
00077    softpipe_update_derived(softpipe); /* not needed?? */
00078 #endif
00079 
00080    if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) {
00081       sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue);
00082       softpipe->framebuffer.zsbuf->status = PIPE_SURFACE_STATUS_CLEAR;
00083 #if TILE_CLEAR_OPTIMIZATION
00084       return;
00085 #endif
00086    }
00087 
00088    for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
00089       if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) {
00090          unsigned cv;
00091          if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
00092             cv = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
00093                                ps->format);
00094          }
00095          else {
00096             cv = clearValue;
00097          }
00098          sp_tile_cache_clear(softpipe->cbuf_cache[i], cv);
00099          softpipe->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_CLEAR;
00100       }
00101    }
00102 
00103 #if !TILE_CLEAR_OPTIMIZATION
00104    /* non-cached surface */
00105    pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
00106 #endif
00107 }


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