sp_quad.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 
00028 
00029 #include "sp_context.h"
00030 #include "sp_state.h"
00031 #include "pipe/p_shader_tokens.h"
00032 
00033 static void
00034 sp_push_quad_first(
00035    struct softpipe_context *sp,
00036    struct quad_stage *quad,
00037    uint i )
00038 {
00039    quad->next = sp->quad[i].first;
00040    sp->quad[i].first = quad;
00041 }
00042 
00043 static void
00044 sp_build_depth_stencil(
00045    struct softpipe_context *sp,
00046    uint i )
00047 {
00048    if (sp->depth_stencil->stencil[0].enabled ||
00049        sp->depth_stencil->stencil[1].enabled) {
00050       sp_push_quad_first( sp, sp->quad[i].stencil_test, i );
00051    }
00052    else if (sp->depth_stencil->depth.enabled &&
00053             sp->framebuffer.zsbuf) {
00054       sp_push_quad_first( sp, sp->quad[i].depth_test, i );
00055    }
00056 }
00057 
00058 void
00059 sp_build_quad_pipeline(struct softpipe_context *sp)
00060 {
00061    uint i;
00062 
00063    boolean early_depth_test =
00064                sp->depth_stencil->depth.enabled &&
00065                sp->framebuffer.zsbuf &&
00066                !sp->depth_stencil->alpha.enabled &&
00067                !sp->fs->info.uses_kill &&
00068                !sp->fs->info.writes_z;
00069 
00070    /* build up the pipeline in reverse order... */
00071    for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
00072       sp->quad[i].first = sp->quad[i].output;
00073 
00074       if (sp->blend->colormask != 0xf) {
00075          sp_push_quad_first( sp, sp->quad[i].colormask, i );
00076       }
00077 
00078       if (sp->blend->blend_enable ||
00079           sp->blend->logicop_enable) {
00080          sp_push_quad_first( sp, sp->quad[i].blend, i );
00081       }
00082 
00083       if (sp->depth_stencil->depth.occlusion_count) {
00084          sp_push_quad_first( sp, sp->quad[i].occlusion, i );
00085       }
00086 
00087       if (sp->rasterizer->poly_smooth ||
00088           sp->rasterizer->line_smooth ||
00089           sp->rasterizer->point_smooth) {
00090          sp_push_quad_first( sp, sp->quad[i].coverage, i );
00091       }
00092 
00093       if (!early_depth_test) {
00094          sp_build_depth_stencil( sp, i );
00095       }
00096 
00097       if (sp->depth_stencil->alpha.enabled) {
00098          sp_push_quad_first( sp, sp->quad[i].alpha_test, i );
00099       }
00100 
00101       /* XXX always enable shader? */
00102       if (1) {
00103          sp_push_quad_first( sp, sp->quad[i].shade, i );
00104       }
00105 
00106       if (early_depth_test) {
00107          sp_build_depth_stencil( sp, i );
00108          sp_push_quad_first( sp, sp->quad[i].earlyz, i );
00109       }
00110 
00111 #if !USE_DRAW_STAGE_PSTIPPLE
00112       if (sp->rasterizer->poly_stipple_enable) {
00113          sp_push_quad_first( sp, sp->quad[i].polygon_stipple, i );
00114       }
00115 #endif
00116    }
00117 }
00118 

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