gallium: fix some compiler warnings
[mesa.git] / src / gallium / drivers / softpipe / sp_quad_output.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 #include "pipe/p_util.h"
29 #include "sp_context.h"
30 #include "sp_headers.h"
31 #include "sp_surface.h"
32 #include "sp_quad.h"
33 #include "sp_tile_cache.h"
34
35
36 /**
37 * Write quad to framebuffer, taking mask into account.
38 *
39 * Note that surfaces support only full quad reads and writes.
40 */
41 static void
42 output_quad(struct quad_stage *qs, struct quad_header *quad)
43 {
44 struct softpipe_context *softpipe = qs->softpipe;
45 struct softpipe_cached_tile *tile
46 = sp_get_cached_tile(softpipe,
47 softpipe->cbuf_cache[softpipe->current_cbuf],
48 quad->x0, quad->y0);
49 /* in-tile pos: */
50 const int itx = quad->x0 % TILE_SIZE;
51 const int ity = quad->y0 % TILE_SIZE;
52 float (*quadColor)[4] = quad->outputs.color;
53 int i, j;
54
55 /* get/swizzle dest colors */
56 for (j = 0; j < QUAD_SIZE; j++) {
57 if (quad->mask & (1 << j)) {
58 int x = itx + (j & 1);
59 int y = ity + (j >> 1);
60 for (i = 0; i < 4; i++) { /* loop over color chans */
61 tile->data.color[y][x][i] = quadColor[i][j];
62 }
63 }
64 }
65 }
66
67
68 static void output_begin(struct quad_stage *qs)
69 {
70 assert(qs->next == NULL);
71 }
72
73
74 static void output_destroy(struct quad_stage *qs)
75 {
76 FREE( qs );
77 }
78
79
80 struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe )
81 {
82 struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
83
84 stage->softpipe = softpipe;
85 stage->begin = output_begin;
86 stage->run = output_quad;
87 stage->destroy = output_destroy;
88
89 return stage;
90 }