a421c95c8e88c03b59792167675e2c8cc4db9339
[mesa.git] / src / gallium / drivers / cell / ppu / cell_clear.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * Authors
30 * Brian Paul
31 */
32
33 #include <stdio.h>
34 #include <assert.h>
35 #include <stdint.h>
36 #include "pipe/p_inlines.h"
37 #include "util/u_memory.h"
38 #include "cell/common.h"
39 #include "cell_clear.h"
40 #include "cell_context.h"
41 #include "cell_batch.h"
42 #include "cell_flush.h"
43 #include "cell_spu.h"
44 #include "cell_state.h"
45
46
47 void
48 cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
49 unsigned clearValue)
50 {
51 struct pipe_screen *screen = pipe->screen;
52 struct cell_context *cell = cell_context(pipe);
53 uint surfIndex;
54
55 if (cell->dirty)
56 cell_update_derived(cell);
57
58
59 if (!cell->cbuf_map[0])
60 cell->cbuf_map[0] = screen->surface_map(screen, ps,
61 PIPE_BUFFER_USAGE_GPU_WRITE);
62
63 if (ps == cell->framebuffer.zsbuf) {
64 surfIndex = 1;
65 }
66 else {
67 surfIndex = 0;
68 }
69
70
71 {
72 struct cell_command_clear_surface *clr
73 = (struct cell_command_clear_surface *)
74 cell_batch_alloc(cell, sizeof(*clr));
75 clr->opcode = CELL_CMD_CLEAR_SURFACE;
76 clr->surface = surfIndex;
77 clr->value = clearValue;
78 }
79 }