brw_clip.h

Go to the documentation of this file.
00001 /*
00002  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
00003  Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
00004  develop this 3D driver.
00005  
00006  Permission is hereby granted, free of charge, to any person obtaining
00007  a 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, sublicense, 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
00016  portions of the Software.
00017  
00018  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00021  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
00022  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00023  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00024  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  
00026  **********************************************************************/
00027  /*
00028   * Authors:
00029   *   Keith Whitwell <keith@tungstengraphics.com>
00030   */
00031 
00032 #ifndef BRW_CLIP_H
00033 #define BRW_CLIP_H
00034 
00035 
00036 #include "brw_context.h"
00037 #include "brw_eu.h"
00038 
00039 #define MAX_VERTS (3+6+6)       
00040 
00041 /* Note that if unfilled primitives are being emitted, we have to fix
00042  * up polygon offset and flatshading at this point:
00043  */
00044 struct brw_clip_prog_key {
00045    unsigned attrs:32;           
00046    unsigned primitive:4;
00047    unsigned nr_userclip:3;
00048    unsigned do_flat_shading:1;
00049    unsigned do_unfilled:1;
00050    unsigned fill_cw:2;          /* includes cull information */
00051    unsigned fill_ccw:2;         /* includes cull information */
00052    unsigned offset_cw:1;
00053    unsigned offset_ccw:1;
00054    unsigned pad0:17;
00055 
00056    unsigned copy_bfc_cw:1;
00057    unsigned copy_bfc_ccw:1;
00058    unsigned clip_mode:3;
00059    unsigned pad1:27;
00060    
00061    float offset_factor;
00062    float offset_units;
00063 };
00064 
00065 
00066 #define CLIP_LINE   0
00067 #define CLIP_POINT  1
00068 #define CLIP_FILL   2
00069 #define CLIP_CULL   3
00070 
00071 
00072 #define PRIM_MASK  (0x1f)
00073 
00074 struct brw_clip_compile {
00075    struct brw_compile func;
00076    struct brw_clip_prog_key key;
00077    struct brw_clip_prog_data prog_data;
00078    
00079    struct {
00080       struct brw_reg R0;
00081       struct brw_reg vertex[MAX_VERTS];
00082 
00083       struct brw_reg t;
00084       struct brw_reg t0, t1;
00085       struct brw_reg dp0, dp1;
00086 
00087       struct brw_reg dpPrev;
00088       struct brw_reg dp;
00089       struct brw_reg loopcount;
00090       struct brw_reg nr_verts;
00091       struct brw_reg planemask;
00092 
00093       struct brw_reg inlist;
00094       struct brw_reg outlist;
00095       struct brw_reg freelist;
00096 
00097       struct brw_reg dir;
00098       struct brw_reg tmp0, tmp1;
00099       struct brw_reg offset;
00100       
00101       struct brw_reg fixed_planes;
00102       struct brw_reg plane_equation;
00103    } reg;
00104 
00105    /* 3 different ways of expressing vertex size:
00106     */
00107    unsigned nr_attrs;
00108    unsigned nr_regs;
00109    unsigned nr_bytes;
00110 
00111    unsigned first_tmp;
00112    unsigned last_tmp;
00113 
00114    boolean need_direction;
00115 
00116    unsigned last_mrf;
00117 
00118    unsigned header_position_offset;
00119    unsigned offset[PIPE_MAX_ATTRIBS];
00120 };
00121 
00122 #define ATTR_SIZE  (4*4)
00123 
00124 /* Points are only culled, so no need for a clip routine, however it
00125  * works out easier to have a dummy one.
00126  */
00127 void brw_emit_unfilled_clip( struct brw_clip_compile *c );
00128 void brw_emit_tri_clip( struct brw_clip_compile *c );
00129 void brw_emit_line_clip( struct brw_clip_compile *c );
00130 void brw_emit_point_clip( struct brw_clip_compile *c );
00131 
00132 /* brw_clip_tri.c, for use by the unfilled clip routine:
00133  */
00134 void brw_clip_tri_init_vertices( struct brw_clip_compile *c );
00135 void brw_clip_tri_flat_shade( struct brw_clip_compile *c );
00136 void brw_clip_tri( struct brw_clip_compile *c );
00137 void brw_clip_tri_emit_polygon( struct brw_clip_compile *c );
00138 void brw_clip_tri_alloc_regs( struct brw_clip_compile *c, 
00139                               unsigned nr_verts );
00140 
00141 
00142 /* Utils:
00143  */
00144 
00145 void brw_clip_interp_vertex( struct brw_clip_compile *c,
00146                              struct brw_indirect dest_ptr,
00147                              struct brw_indirect v0_ptr, /* from */
00148                              struct brw_indirect v1_ptr, /* to */
00149                              struct brw_reg t0,
00150                              boolean force_edgeflag );
00151 
00152 void brw_clip_init_planes( struct brw_clip_compile *c );
00153 
00154 void brw_clip_emit_vue(struct brw_clip_compile *c, 
00155                        struct brw_indirect vert,
00156                        boolean allocate,
00157                        boolean eot,
00158                        unsigned header);
00159 
00160 void brw_clip_kill_thread(struct brw_clip_compile *c);
00161 
00162 struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c );
00163 struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c );
00164 
00165 void brw_clip_copy_colors( struct brw_clip_compile *c,
00166                            unsigned to, unsigned from );
00167 
00168 void brw_clip_init_clipmask( struct brw_clip_compile *c );
00169 
00170 #endif

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