gallium: remove some debug assertions in vertex format validation
[mesa.git] / src / mesa / pipe / softpipe / sp_quad_colormask.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 * \brief quad colormask stage
30 * \author Brian Paul
31 */
32
33 #include "pipe/p_defines.h"
34 #include "pipe/p_util.h"
35 #include "sp_context.h"
36 #include "sp_headers.h"
37 #include "sp_surface.h"
38 #include "sp_quad.h"
39 #include "sp_tile_cache.h"
40
41
42
43 /**
44 * XXX colormask could be rolled into blending...
45 */
46 static void
47 colormask_quad(struct quad_stage *qs, struct quad_header *quad)
48 {
49 struct softpipe_context *softpipe = qs->softpipe;
50 float dest[4][QUAD_SIZE];
51 struct softpipe_cached_tile *tile
52 = sp_get_cached_tile(softpipe,
53 softpipe->cbuf_cache[softpipe->current_cbuf],
54 quad->x0, quad->y0);
55 float (*quadColor)[4] = quad->outputs.color;
56 uint i, j;
57
58 /* get/swizzle dest colors */
59 for (j = 0; j < QUAD_SIZE; j++) {
60 int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
61 int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
62 for (i = 0; i < 4; i++) {
63 dest[i][j] = tile->data.color[y][x][i];
64 }
65 }
66
67 /* R */
68 if (!(softpipe->blend->colormask & PIPE_MASK_R))
69 COPY_4V(quadColor[0], dest[0]);
70
71 /* G */
72 if (!(softpipe->blend->colormask & PIPE_MASK_G))
73 COPY_4V(quadColor[1], dest[1]);
74
75 /* B */
76 if (!(softpipe->blend->colormask & PIPE_MASK_B))
77 COPY_4V(quadColor[2], dest[2]);
78
79 /* A */
80 if (!(softpipe->blend->colormask & PIPE_MASK_A))
81 COPY_4V(quadColor[3], dest[3]);
82
83 /* pass quad to next stage */
84 qs->next->run(qs->next, quad);
85 }
86
87
88 static void colormask_begin(struct quad_stage *qs)
89 {
90 qs->next->begin(qs->next);
91 }
92
93
94 static void colormask_destroy(struct quad_stage *qs)
95 {
96 FREE( qs );
97 }
98
99
100 struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe )
101 {
102 struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
103
104 stage->softpipe = softpipe;
105 stage->begin = colormask_begin;
106 stage->run = colormask_quad;
107 stage->destroy = colormask_destroy;
108
109 return stage;
110 }