00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "pipe/p_defines.h"
00034 #include "util/u_pack_color.h"
00035 #include "sp_clear.h"
00036 #include "sp_context.h"
00037 #include "sp_surface.h"
00038 #include "sp_state.h"
00039 #include "sp_tile_cache.h"
00040
00041
00045 static unsigned
00046 convert_color(enum pipe_format srcFormat, unsigned srcColor,
00047 enum pipe_format dstFormat)
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 }
00057
00058
00059
00066 void
00067 softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
00068 unsigned clearValue)
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);
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
00105 pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
00106 #endif
00107 }