Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygent_dd_imm_vbtmp.h
Go to the documentation of this file.
00001 00002 /* 00003 * Mesa 3-D graphics library 00004 * Version: 3.5 00005 * 00006 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a 00009 * copy of this software and associated documentation files (the "Software"), 00010 * to deal in the Software without restriction, including without limitation 00011 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00012 * and/or sell copies of the Software, and to permit persons to whom the 00013 * Software is furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included 00016 * in all copies or substantial portions 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 MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00021 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00022 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00023 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 * 00025 * Authors: 00026 * Keith Whitwell <keith_whitwell@yahoo.com> 00027 */ 00028 00029 /* Template to build support for t_dd_imm_* tnl module using vertices 00030 * as defined in t_dd_vertex.h. 00031 * 00032 * See t_dd_vbtmp.h for definitions of arguments to this file. 00033 * Unfortunately it seems necessary to duplicate a lot of that code. 00034 */ 00035 00036 #ifndef LOCALVARS 00037 #define LOCALVARS 00038 #endif 00039 00040 00041 00042 /* COPY_VERTEX_FROM_CURRENT in t_dd_imm_vapi.c 00043 */ 00044 static void TAG(emit_vfmt)( GLcontext *ctx, VERTEX *v ) 00045 { 00046 LOCALVARS 00047 ; 00048 00049 /* This template assumes (like t_dd_vbtmp.h) that color is ubyte. 00050 */ 00051 if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES) 00052 { 00053 const GLubyte *col = GET_HARDWARE_COLOR(); 00054 if (HAVE_RGBA_COLOR) { 00055 v->v.ui[4] = *(GLuint *)&col; 00056 } else { 00057 v->v.color.blue = col[2]; 00058 v->v.color.green = col[1]; 00059 v->v.color.red = col[0]; 00060 v->v.color.alpha = col[3]; 00061 } 00062 } 00063 else { 00064 if (HAVE_RGBA_COLOR) { 00065 v->v.ui[3] = *(GLuint *)col; 00066 } 00067 else { 00068 v->tv.color.blue = col[2]; 00069 v->tv.color.green = col[1]; 00070 v->tv.color.red = col[0]; 00071 v->tv.color.alpha = col[3]; 00072 } 00073 } 00074 00075 if (DO_TEX0) { 00076 GLfloat *tc = ctx->Current.Texture[0]; 00077 v->v.u0 = tc[0]; 00078 v->v.v0 = tc[1]; 00079 if (DO_PTEX) { 00080 if (HAVE_PTEX_VERTICES) { 00081 v->pv.q0 = tc[3]; 00082 } 00083 else { 00084 float rhw = 1.0 / tc[3]; 00085 v->v.w *= tc[3]; 00086 v->v.u0 *= rhw; 00087 v->v.v0 *= rhw; 00088 } 00089 } 00090 } 00091 if (DO_TEX1) { 00092 GLfloat *tc = ctx->Current.Texture[1]; 00093 if (DO_PTEX) { 00094 v->pv.u1 = tc[0]; 00095 v->pv.v1 = tc[1]; 00096 v->pv.q1 = tc[3]; 00097 } 00098 else { 00099 v->v.u1 = tc[0]; 00100 v->v.v1 = tc[1]; 00101 } 00102 } 00103 else if (DO_PTEX) { 00104 *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */ 00105 } 00106 if (DO_TEX2) { 00107 GLfloat *tc = ctx->Current.Texture[2]; 00108 if (DO_PTEX) { 00109 v->pv.u2 = tc[0]; 00110 v->pv.v2 = tc[1]; 00111 v->pv.q2 = tc[3]; 00112 } 00113 else { 00114 v->v.u2 = tc[0]; 00115 v->v.v2 = tc[1]; 00116 } 00117 } 00118 if (DO_TEX3) { 00119 GLfloat *tc = ctx->Current.Texture[3]; 00120 if (DO_PTEX) { 00121 v->pv.u3 = tc[0]; 00122 v->pv.v3 = tc[1]; 00123 v->pv.q3 = tc[3]; 00124 } 00125 else { 00126 v->v.u3 = tc[0]; 00127 v->v.v3 = tc[1]; 00128 } 00129 } 00130 } 00131 00132 00133 00134 00135 static void TAG(interp)( GLcontext *ctx, 00136 GLfloat t, 00137 TNL_VERTEX *dst, 00138 TNL_VERTEX *in, 00139 TNL_VERTEX *out ) 00140 { 00141 LOCALVARS 00142 const GLfloat *s = GET_VIEWPORT_MAT(); 00143 GLfloat w; 00144 00145 (void)s; 00146 00147 if (HAVE_HW_DIVIDE) { 00148 VIEWPORT_X( dst->v.v.x, dst->clip[0] ); 00149 VIEWPORT_Y( dst->v.v.y, dst->clip[1] ); 00150 VIEWPORT_Z( dst->v.v.z, dst->clip[2] ); 00151 w = dstclip[3]; 00152 } 00153 else { 00154 w = 1.0 / dst->clip[3]; 00155 VIEWPORT_X( dst->v.v.x, dst->clip[0] * w ); 00156 VIEWPORT_Y( dst->v.v.y, dst->clip[1] * w ); 00157 VIEWPORT_Z( dst->v.v.z, dst->clip[2] * w ); 00158 } 00159 00160 if (HAVE_HW_DIVIDE || DO_TEX0) { 00161 00162 dst->v.v.w = w; 00163 00164 INTERP_UB( t, dst->v.ub4[4][0], out->v.ub4[4][0], in->v.ub4[4][0] ); 00165 INTERP_UB( t, dst->v.ub4[4][1], out->v.ub4[4][1], in->v.ub4[4][1] ); 00166 INTERP_UB( t, dst->v.ub4[4][2], out->v.ub4[4][2], in->v.ub4[4][2] ); 00167 INTERP_UB( t, dst->v.ub4[4][3], out->v.ub4[4][3], in->v.ub4[4][3] ); 00168 00169 if (DO_TEX0) { 00170 if (DO_PTEX) { 00171 if (HAVE_PTEX_VERTICES) { 00172 INTERP_F( t, dst->v.pv.u0, out->v.pv.u0, in->v.pv.u0 ); 00173 INTERP_F( t, dst->v.pv.v0, out->v.pv.v0, in->v.pv.v0 ); 00174 INTERP_F( t, dst->v.pv.q0, out->v.pv.q0, in->v.pv.q0 ); 00175 } else { 00176 GLfloat wout = out->clip[3]; /* projected clip */ 00177 GLfloat win = in->clip[3]; /* projected clip */ 00178 GLfloat qout = out->v.pv.w / wout; 00179 GLfloat qin = in->v.pv.w / win; 00180 GLfloat qdst, rqdst; 00181 00182 ASSERT( !HAVE_HW_DIVIDE ); /* assert win, wout projected clip */ 00183 00184 INTERP_F( t, dst->v.v.u0, out->v.v.u0 * qout, in->v.v.u0 * qin ); 00185 INTERP_F( t, dst->v.v.v0, out->v.v.v0 * qout, in->v.v.v0 * qin ); 00186 INTERP_F( t, qdst, qout, qin ); 00187 00188 rqdst = 1.0 / qdst; 00189 dst->v.v.u0 *= rqdst; 00190 dst->v.v.v0 *= rqdst; 00191 dst->v.v.w *= rqdst; 00192 } 00193 } 00194 else { 00195 INTERP_F( t, dst->v.v.u0, out->v.v.u0, in->v.v.u0 ); 00196 INTERP_F( t, dst->v.v.v0, out->v.v.v0, in->v.v.v0 ); 00197 } 00198 } 00199 if (DO_TEX1) { 00200 if (DO_PTEX) { 00201 INTERP_F( t, dst->v.pv.u1, out->v.pv.u1, in->v.pv.u1 ); 00202 INTERP_F( t, dst->v.pv.v1, out->v.pv.v1, in->v.pv.v1 ); 00203 INTERP_F( t, dst->v.pv.q1, out->v.pv.q1, in->v.pv.q1 ); 00204 } else { 00205 INTERP_F( t, dst->v.v.u1, out->v.v.u1, in->v.v.u1 ); 00206 INTERP_F( t, dst->v.v.v1, out->v.v.v1, in->v.v.v1 ); 00207 } 00208 } 00209 else if (DO_PTEX) { 00210 dst->v.pv.q0 = 0.0; /* must be a valid float on radeon */ 00211 } 00212 if (DO_TEX2) { 00213 if (DO_PTEX) { 00214 INTERP_F( t, dst->v.pv.u2, out->v.pv.u2, in->v.pv.u2 ); 00215 INTERP_F( t, dst->v.pv.v2, out->v.pv.v2, in->v.pv.v2 ); 00216 INTERP_F( t, dst->v.pv.q2, out->v.pv.q2, in->v.pv.q2 ); 00217 } else { 00218 INTERP_F( t, dst->v.v.u2, out->v.v.u2, in->v.v.u2 ); 00219 INTERP_F( t, dst->v.v.v2, out->v.v.v2, in->v.v.v2 ); 00220 } 00221 } 00222 if (DO_TEX3) { 00223 if (DO_PTEX) { 00224 INTERP_F( t, dst->v.pv.u3, out->v.pv.u3, in->v.pv.u3 ); 00225 INTERP_F( t, dst->v.pv.v3, out->v.pv.v3, in->v.pv.v3 ); 00226 INTERP_F( t, dst->v.pv.q3, out->v.pv.q3, in->v.pv.q3 ); 00227 } else { 00228 INTERP_F( t, dst->v.v.u3, out->v.v.u3, in->v.v.u3 ); 00229 INTERP_F( t, dst->v.v.v3, out->v.v.v3, in->v.v.v3 ); 00230 } 00231 } 00232 } else { 00233 /* 4-dword vertex. Color is in v[3] and there is no oow coordinate. 00234 */ 00235 INTERP_UB( t, dst->v.ub4[3][0], out->v.ub4[3][0], in->v.ub4[3][0] ); 00236 INTERP_UB( t, dst->v.ub4[3][1], out->v.ub4[3][1], in->v.ub4[3][1] ); 00237 INTERP_UB( t, dst->v.ub4[3][2], out->v.ub4[3][2], in->v.ub4[3][2] ); 00238 INTERP_UB( t, dst->v.ub4[3][3], out->v.ub4[3][3], in->v.ub4[3][3] ); 00239 } 00240 } 00241 00242 00243 static __inline void TAG(copy_pv)( GLcontext *ctx, 00244 TNL_VERTEX *dst, 00245 TNL_VERTEX *src ) 00246 { 00247 if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES) { 00248 dst->v.v.ui[4] = src->v.v.ui[4]; 00249 } 00250 else { 00251 dst->v.v.ui[3] = src->v.v.ui[3]; 00252 } 00253 } 00254 00255 00256 00257 static void TAG(init)( void ) 00258 { 00259 setup_tab[IND].emit = TAG(emit_vfmt); 00260 setup_tab[IND].interp = TAG(interp_vfmt); 00261 } 00262 00263 00264 #undef IND 00265 #undef TAG 00266 00267 00268 Generated on Wed May 23 2012 04:18:56 for ReactOS by
1.7.6.1
|