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
00033 #include <stdio.h>
00034 #include <assert.h>
00035 #include <stdint.h>
00036 #include "pipe/p_inlines.h"
00037 #include "util/u_memory.h"
00038 #include "util/u_pack_color.h"
00039 #include "cell/common.h"
00040 #include "cell_clear.h"
00041 #include "cell_context.h"
00042 #include "cell_batch.h"
00043 #include "cell_flush.h"
00044 #include "cell_spu.h"
00045 #include "cell_state.h"
00046
00047
00051 static unsigned
00052 convert_color(enum pipe_format srcFormat, unsigned srcColor,
00053 enum pipe_format dstFormat)
00054 {
00055 ubyte r, g, b, a;
00056 unsigned dstColor;
00057
00058 util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
00059 util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
00060
00061 return dstColor;
00062 }
00063
00064
00065
00069 void
00070 cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
00071 unsigned clearValue)
00072 {
00073 struct pipe_screen *screen = pipe->screen;
00074 struct cell_context *cell = cell_context(pipe);
00075 uint surfIndex;
00076
00077 if (cell->dirty)
00078 cell_update_derived(cell);
00079
00080
00081 if (!cell->cbuf_map[0])
00082 cell->cbuf_map[0] = screen->surface_map(screen, ps,
00083 PIPE_BUFFER_USAGE_GPU_WRITE);
00084
00085 if (ps == cell->framebuffer.zsbuf) {
00086
00087 surfIndex = 1;
00088 }
00089 else {
00090
00091 surfIndex = 0;
00092
00093 if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
00094 clearValue = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
00095 ps->format);
00096 }
00097 }
00098
00099
00100
00101 {
00102 struct cell_command_clear_surface *clr
00103 = (struct cell_command_clear_surface *)
00104 cell_batch_alloc(cell, sizeof(*clr));
00105 clr->opcode = CELL_CMD_CLEAR_SURFACE;
00106 clr->surface = surfIndex;
00107 clr->value = clearValue;
00108 }
00109 }