diff options
author | Brian <[email protected]> | 2007-07-12 14:13:48 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-07-12 14:13:48 -0600 |
commit | a48d767cf2ec82d0c0f893a22d22e8593901b206 (patch) | |
tree | 732104c0465295a05709e4caf786b722b393769e /src/mesa/pipe/softpipe/sp_quad_bufloop.c | |
parent | e8ceb5a2eb174f5444eaf5f52925fa161ea7d0a9 (diff) |
Add a quad 'bufloop' stage to handle glDrawBuffer(GL_FRONT_AND_BACK).
This removes the notion of multiple color buffers from all other stages.
Will need a bit more work when shaders with multiple render targets arrive.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_quad_bufloop.c')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad_bufloop.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_quad_bufloop.c b/src/mesa/pipe/softpipe/sp_quad_bufloop.c new file mode 100644 index 00000000000..977cc74c263 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_quad_bufloop.c @@ -0,0 +1,59 @@ + + +#include "main/glheader.h" +#include "main/imports.h" +#include "sp_context.h" +#include "sp_headers.h" +#include "sp_surface.h" +#include "sp_quad.h" + + +/** + * Loop over colorbuffers, passing quad to next stage each time. + */ +static void +cbuf_loop_quad(struct quad_stage *qs, struct quad_header *quad) +{ + struct softpipe_context *softpipe = qs->softpipe; + const GLuint sz = sizeof(quad->outputs.color); + GLfloat tmp[4][QUAD_SIZE]; + GLuint i; + + assert(sz == sizeof(tmp)); + + /* make copy of original colors since they can get modified + * by blending and masking. + */ + memcpy(tmp, quad->outputs.color, sz); + + for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) { + /* set current cbuffer */ + softpipe->cbuf = softpipe->framebuffer.cbufs[i]; + + /* pass blended quad to next stage */ + qs->next->run(qs->next, quad); + + if (i + 1 < softpipe->framebuffer.num_cbufs) { + /* restore quad's colors for next buffer */ + memcpy(quad->outputs.color, tmp, sz); + } + } + + softpipe->cbuf = NULL; /* prevent accidental use */ +} + + +/** + * Create the colorbuffer loop stage. + * This is used to implement GL_FRONT_AND_BACK rendering. + */ +struct quad_stage *sp_quad_bufloop_stage( struct softpipe_context *softpipe ) +{ + struct quad_stage *stage = CALLOC_STRUCT(quad_stage); + + stage->softpipe = softpipe; + stage->run = cbuf_loop_quad; + + return stage; +} + |