2 #include "util/u_memory.h"
3 #include "sp_context.h"
4 #include "sp_headers.h"
5 #include "sp_surface.h"
10 * Loop over colorbuffers, passing quad to next stage each time.
13 cbuf_loop_quad(struct quad_stage
*qs
, struct quad_header
*quad
)
15 struct softpipe_context
*softpipe
= qs
->softpipe
;
16 float tmp
[PIPE_MAX_COLOR_BUFS
][4][QUAD_SIZE
];
19 assert(sizeof(quad
->outputs
.color
) == sizeof(tmp
));
20 assert(softpipe
->framebuffer
.num_cbufs
<= PIPE_MAX_COLOR_BUFS
);
22 /* make copy of original colors since they can get modified
23 * by blending and masking.
24 * XXX we won't have to do this if the fragment program actually emits
25 * N separate colors and we're drawing to N color buffers (MRT).
26 * But if we emitted one color and glDrawBuffer(GL_FRONT_AND_BACK) is
27 * in effect, we need to save/restore colors like this.
29 memcpy(tmp
, quad
->outputs
.color
, sizeof(tmp
));
31 for (i
= 0; i
< softpipe
->framebuffer
.num_cbufs
; i
++) {
32 /* set current cbuffer */
33 #if 0 /* obsolete & going away */
34 softpipe
->current_cbuf
= i
;
37 /* pass blended quad to next stage */
38 qs
->next
->run(qs
->next
, quad
);
40 /* restore quad's colors for next buffer */
41 memcpy(quad
->outputs
.color
, tmp
, sizeof(tmp
));
46 static void cbuf_loop_begin(struct quad_stage
*qs
)
48 qs
->next
->begin(qs
->next
);
52 static void cbuf_loop_destroy(struct quad_stage
*qs
)
59 * Create the colorbuffer loop stage.
60 * This is used to implement multiple render targets and GL_FRONT_AND_BACK
63 struct quad_stage
*sp_quad_bufloop_stage( struct softpipe_context
*softpipe
)
65 struct quad_stage
*stage
= CALLOC_STRUCT(quad_stage
);
67 stage
->softpipe
= softpipe
;
68 stage
->begin
= cbuf_loop_begin
;
69 stage
->run
= cbuf_loop_quad
;
70 stage
->destroy
= cbuf_loop_destroy
;