1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
36 #include "pipe/p_inlines.h"
37 #include "pipe/p_util.h"
38 #include "pipe/cell/common.h"
39 #include "cell_clear.h"
40 #include "cell_context.h"
41 #include "cell_batch.h"
42 #include "cell_flush.h"
47 cell_clear_surface(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
50 struct cell_context
*cell
= cell_context(pipe
);
54 if (!cell
->cbuf_map
[0])
55 cell
->cbuf_map
[0] = pipe_surface_map(ps
);
57 if (ps
== cell
->framebuffer
.zsbuf
) {
65 for (i
= 0; i
< cell
->num_spus
; i
++) {
67 uint clr
= clearValue
;
69 /* XXX debug: clear color varied per-SPU to visualize tiles */
70 if ((clr
& 0xff) == 0)
72 if ((clr
& 0xff00) == 0)
73 clr
|= (64 + i
* 8) << 8;
74 if ((clr
& 0xff0000) == 0)
75 clr
|= (64 + i
* 8) << 16;
76 if ((clr
& 0xff000000) == 0)
77 clr
|= (64 + i
* 8) << 24;
79 cell_global
.command
[i
].clear
.value
= clr
;
81 cell_global
.command
[i
].clear
.value
= clearValue
;
83 cell_global
.command
[i
].clear
.surface
= surfIndex
;
84 send_mbox_message(cell_global
.spe_contexts
[i
], CELL_CMD_CLEAR_SURFACE
);
88 struct cell_command_clear_surface
*clr
89 = (struct cell_command_clear_surface
*)
90 cell_batch_alloc(cell
, sizeof(*clr
));
91 clr
->opcode
= CELL_CMD_CLEAR_SURFACE
;
92 clr
->surface
= surfIndex
;
93 clr
->value
= clearValue
;
98 cell_flush(&cell
->pipe
, 0x0);