sp_quad_bufloop.c

Go to the documentation of this file.
00001 
00002 #include "util/u_memory.h"
00003 #include "sp_context.h"
00004 #include "sp_headers.h"
00005 #include "sp_surface.h"
00006 #include "sp_quad.h"
00007 
00008 
00012 static void
00013 cbuf_loop_quad(struct quad_stage *qs, struct quad_header *quad)
00014 {
00015    struct softpipe_context *softpipe = qs->softpipe;
00016    float tmp[PIPE_MAX_COLOR_BUFS][4][QUAD_SIZE];
00017    unsigned i;
00018 
00019    assert(sizeof(quad->outputs.color) == sizeof(tmp));
00020    assert(softpipe->framebuffer.num_cbufs <= PIPE_MAX_COLOR_BUFS);
00021 
00022    /* make copy of original colors since they can get modified
00023     * by blending and masking.
00024     * XXX we won't have to do this if the fragment program actually emits
00025     * N separate colors and we're drawing to N color buffers (MRT).
00026     * But if we emitted one color and glDrawBuffer(GL_FRONT_AND_BACK) is
00027     * in effect, we need to save/restore colors like this.
00028     */
00029    memcpy(tmp, quad->outputs.color, sizeof(tmp));
00030 
00031    for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
00032       /* set current cbuffer */
00033 #if 0 /* obsolete & going away */
00034       softpipe->current_cbuf = i;
00035 #endif
00036 
00037       /* pass blended quad to next stage */
00038       qs->next->run(qs->next, quad);
00039 
00040       /* restore quad's colors for next buffer */
00041       memcpy(quad->outputs.color, tmp, sizeof(tmp));
00042    }
00043 }
00044 
00045 
00046 static void cbuf_loop_begin(struct quad_stage *qs)
00047 {
00048    qs->next->begin(qs->next);
00049 }
00050 
00051 
00052 static void cbuf_loop_destroy(struct quad_stage *qs)
00053 {
00054    FREE( qs );
00055 }
00056 
00057 
00063 struct quad_stage *sp_quad_bufloop_stage( struct softpipe_context *softpipe )
00064 {
00065    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00066 
00067    stage->softpipe = softpipe;
00068    stage->begin = cbuf_loop_begin;
00069    stage->run = cbuf_loop_quad;
00070    stage->destroy = cbuf_loop_destroy;
00071 
00072    return stage;
00073 }
00074 

Generated on Tue Sep 29 06:25:17 2009 for Gallium3D by  doxygen 1.5.4