sp_quad_earlyz.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 
00032 #include "pipe/p_defines.h"
00033 #include "util/u_memory.h"
00034 #include "sp_headers.h"
00035 #include "sp_quad.h"
00036 
00037 
00043 static void
00044 earlyz_quad(
00045    struct quad_stage    *qs,
00046    struct quad_header   *quad )
00047 {
00048    const float fx = (float) quad->input.x0;
00049    const float fy = (float) quad->input.y0;
00050    const float dzdx = quad->posCoef->dadx[2];
00051    const float dzdy = quad->posCoef->dady[2];
00052    const float z0 = quad->posCoef->a0[2] + dzdx * fx + dzdy * fy;
00053 
00054    quad->output.depth[0] = z0;
00055    quad->output.depth[1] = z0 + dzdx;
00056    quad->output.depth[2] = z0 + dzdy;
00057    quad->output.depth[3] = z0 + dzdx + dzdy;
00058 
00059    qs->next->run( qs->next, quad );
00060 }
00061 
00062 static void
00063 earlyz_begin(
00064    struct quad_stage *qs )
00065 {
00066    qs->next->begin( qs->next );
00067 }
00068 
00069 static void
00070 earlyz_destroy(
00071    struct quad_stage *qs )
00072 {
00073    FREE( qs );
00074 }
00075 
00076 struct quad_stage *
00077 sp_quad_earlyz_stage(
00078    struct softpipe_context *softpipe )
00079 {
00080    struct quad_stage *stage = CALLOC_STRUCT( quad_stage );
00081 
00082    stage->softpipe = softpipe;
00083    stage->begin = earlyz_begin;
00084    stage->run = earlyz_quad;
00085    stage->destroy = earlyz_destroy;
00086 
00087    return stage;
00088 }

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