2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 /* Vertices are just an array of floats, with all the attributes
26 * packed. We currently assume a layout like:
28 * attr[0][0..3] - window position
29 * attr[1..n][0..3] - remaining attributes.
31 * Attributes are assumed to be 4 floats wide but are packed so that
32 * all the enabled attributes run contiguously.
37 #include "sp_context.h"
38 #include "sp_headers.h"
39 #include "sp_surface.h"
43 static void mask_copy( GLfloat (*dest
)[4],
49 for (i
= 0; i
< 4; i
++) {
51 for (j
= 0; j
< 4; j
++) {
52 dest
[j
][i
] = src
[j
][i
];
60 * Write quad to framebuffer, taking mask into account.
62 * Note that surfaces support only full quad reads and writes.
65 output_quad(struct quad_stage
*qs
, struct quad_header
*quad
)
67 struct softpipe_context
*softpipe
= qs
->softpipe
;
68 struct softpipe_surface
*sps
= softpipe_surface(softpipe
->cbuf
);
70 if (quad
->mask
!= MASK_ALL
) {
71 GLfloat tmp
[4][QUAD_SIZE
];
73 /* XXX probably add a masked-write function someday */
75 sps
->read_quad_f_swz(sps
, quad
->x0
, quad
->y0
, tmp
);
77 mask_copy( tmp
, quad
->outputs
.color
, quad
->mask
);
79 sps
->write_quad_f_swz(sps
, quad
->x0
, quad
->y0
, tmp
);
81 else if (quad
->mask
) {
82 sps
->write_quad_f_swz(sps
, quad
->x0
, quad
->y0
, quad
->outputs
.color
);
87 struct quad_stage
*sp_quad_output_stage( struct softpipe_context
*softpipe
)
89 struct quad_stage
*stage
= CALLOC_STRUCT(quad_stage
);
91 stage
->softpipe
= softpipe
;
92 stage
->run
= output_quad
;