sp_quad_colormask.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00033 #include "pipe/p_defines.h"
00034 #include "util/u_math.h"
00035 #include "util/u_memory.h"
00036 #include "sp_context.h"
00037 #include "sp_headers.h"
00038 #include "sp_surface.h"
00039 #include "sp_quad.h"
00040 #include "sp_tile_cache.h"
00041 
00042 
00043 
00047 static void
00048 colormask_quad(struct quad_stage *qs, struct quad_header *quad)
00049 {
00050    struct softpipe_context *softpipe = qs->softpipe;
00051    uint cbuf;
00052 
00053    /* loop over colorbuffer outputs */
00054    for (cbuf = 0; cbuf < softpipe->framebuffer.num_cbufs; cbuf++) {
00055       float dest[4][QUAD_SIZE];
00056       struct softpipe_cached_tile *tile
00057          = sp_get_cached_tile(softpipe,
00058                               softpipe->cbuf_cache[cbuf],
00059                               quad->input.x0, quad->input.y0);
00060       float (*quadColor)[4] = quad->output.color[cbuf];
00061       uint i, j;
00062 
00063       /* get/swizzle dest colors */
00064       for (j = 0; j < QUAD_SIZE; j++) {
00065          int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
00066          int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
00067          for (i = 0; i < 4; i++) {
00068             dest[i][j] = tile->data.color[y][x][i];
00069          }
00070       }
00071 
00072       /* R */
00073       if (!(softpipe->blend->colormask & PIPE_MASK_R))
00074           COPY_4V(quadColor[0], dest[0]);
00075 
00076       /* G */
00077       if (!(softpipe->blend->colormask & PIPE_MASK_G))
00078           COPY_4V(quadColor[1], dest[1]);
00079 
00080       /* B */
00081       if (!(softpipe->blend->colormask & PIPE_MASK_B))
00082           COPY_4V(quadColor[2], dest[2]);
00083 
00084       /* A */
00085       if (!(softpipe->blend->colormask & PIPE_MASK_A))
00086           COPY_4V(quadColor[3], dest[3]);
00087    }
00088 
00089    /* pass quad to next stage */
00090    qs->next->run(qs->next, quad);
00091 }
00092 
00093 
00094 static void colormask_begin(struct quad_stage *qs)
00095 {
00096    qs->next->begin(qs->next);
00097 }
00098 
00099 
00100 static void colormask_destroy(struct quad_stage *qs)
00101 {
00102    FREE( qs );
00103 }
00104 
00105 
00106 struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe )
00107 {
00108    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00109 
00110    stage->softpipe = softpipe;
00111    stage->begin = colormask_begin;
00112    stage->run = colormask_quad;
00113    stage->destroy = colormask_destroy;
00114 
00115    return stage;
00116 }

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