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 "util/u_inlines.h"
37 #include "util/u_memory.h"
38 #include "util/u_pack_color.h"
39 #include "cell/common.h"
40 #include "cell_clear.h"
41 #include "cell_context.h"
42 #include "cell_batch.h"
43 #include "cell_flush.h"
45 #include "cell_state.h"
49 * Called via pipe->clear()
52 cell_clear(struct pipe_context
*pipe
, unsigned buffers
, const float *rgba
,
53 double depth
, unsigned stencil
)
55 struct cell_context
*cell
= cell_context(pipe
);
58 cell_update_derived(cell
);
60 if (buffers
& PIPE_CLEAR_COLOR
) {
64 util_pack_color(rgba
, cell
->framebuffer
.cbufs
[0]->format
, &uc
);
66 /* Build a CLEAR command and place it in the current batch buffer */
67 STATIC_ASSERT(sizeof(struct cell_command_clear_surface
) % 16 == 0);
68 struct cell_command_clear_surface
*clr
69 = (struct cell_command_clear_surface
*)
70 cell_batch_alloc16(cell
, sizeof(*clr
));
71 clr
->opcode
[0] = CELL_CMD_CLEAR_SURFACE
;
72 clr
->surface
= surfIndex
;
76 if (buffers
& PIPE_CLEAR_DEPTHSTENCIL
) {
80 clearValue
= util_pack_z_stencil(cell
->framebuffer
.zsbuf
->format
,
83 /* Build a CLEAR command and place it in the current batch buffer */
84 STATIC_ASSERT(sizeof(struct cell_command_clear_surface
) % 16 == 0);
85 struct cell_command_clear_surface
*clr
86 = (struct cell_command_clear_surface
*)
87 cell_batch_alloc16(cell
, sizeof(*clr
));
88 clr
->opcode
[0] = CELL_CMD_CLEAR_SURFACE
;
89 clr
->surface
= surfIndex
;
90 clr
->value
= clearValue
;