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 **************************************************************************/
28 #include "pipe/p_util.h"
29 #include "sp_context.h"
30 #include "sp_headers.h"
31 #include "sp_surface.h"
33 #include "sp_tile_cache.h"
37 * Last step of quad processing: write quad colors to the framebuffer,
38 * taking mask into account.
41 output_quad(struct quad_stage
*qs
, struct quad_header
*quad
)
44 const int itx
= quad
->x0
% TILE_SIZE
;
45 const int ity
= quad
->y0
% TILE_SIZE
;
47 struct softpipe_context
*softpipe
= qs
->softpipe
;
50 /* loop over colorbuffer outputs */
51 for (cbuf
= 0; cbuf
< softpipe
->framebuffer
.num_cbufs
; cbuf
++) {
52 struct softpipe_cached_tile
*tile
53 = sp_get_cached_tile(softpipe
,
54 softpipe
->cbuf_cache
[cbuf
],
56 float (*quadColor
)[4] = quad
->outputs
.color
[cbuf
];
59 /* get/swizzle dest colors */
60 for (j
= 0; j
< QUAD_SIZE
; j
++) {
61 if (quad
->mask
& (1 << j
)) {
62 int x
= itx
+ (j
& 1);
63 int y
= ity
+ (j
>> 1);
64 for (i
= 0; i
< 4; i
++) { /* loop over color chans */
65 tile
->data
.color
[y
][x
][i
] = quadColor
[i
][j
];
73 static void output_begin(struct quad_stage
*qs
)
75 assert(qs
->next
== NULL
);
79 static void output_destroy(struct quad_stage
*qs
)
85 struct quad_stage
*sp_quad_output_stage( struct softpipe_context
*softpipe
)
87 struct quad_stage
*stage
= CALLOC_STRUCT(quad_stage
);
89 stage
->softpipe
= softpipe
;
90 stage
->begin
= output_begin
;
91 stage
->run
= output_quad
;
92 stage
->destroy
= output_destroy
;