ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

t_dd_vb.c
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@tungstengraphics.com>
00027  */
00028 #include "math/m_translate.h"
00029 
00030 #if (HAVE_HW_VIEWPORT)
00031 #define UNVIEWPORT_VARS
00032 #define UNVIEWPORT_X(x) x
00033 #define UNVIEWPORT_Y(x) x
00034 #define UNVIEWPORT_Z(x) x
00035 #endif
00036 
00037 #ifndef LOCALVARS
00038 #define LOCALVARS
00039 #endif
00040 
00041 #ifndef CHECK_HW_DIVIDE
00042 #define CHECK_HW_DIVIDE 1
00043 #endif
00044 
00045 /* These don't need to be duplicated, but there's currently nowhere
00046  * really convenient to put them.  Need to build some actual .o files in
00047  * this directory?
00048  */
00049 static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc )
00050 {
00051    LOCALVARS   
00052    GLubyte *verts = GET_VERTEX_STORE();
00053    GLuint size = GET_VERTEX_SIZE();
00054    GLuint *dst = (GLuint *)(verts + (edst * size));
00055    GLuint *src = (GLuint *)(verts + (esrc * size));
00056    dst[4] = src[4];
00057    dst[5] = src[5];
00058 }
00059 
00060 static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc )
00061 {
00062    LOCALVARS
00063    GLubyte *verts = GET_VERTEX_STORE();
00064    GLuint size = GET_VERTEX_SIZE();
00065    GLuint *dst = (GLuint *)(verts + (edst * size));
00066    GLuint *src = (GLuint *)(verts + (esrc * size));
00067    dst[4] = src[4];
00068 }
00069 
00070 static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc )
00071 {
00072    LOCALVARS
00073    GLubyte *verts = GET_VERTEX_STORE();
00074    GLuint size = GET_VERTEX_SIZE();
00075    GLuint *dst = (GLuint *)(verts + (edst * size));
00076    GLuint *src = (GLuint *)(verts + (esrc * size));
00077    dst[3] = src[3];
00078 }
00079 
00080 
00081 void TAG(translate_vertex)(GLcontext *ctx,
00082                const VERTEX *src,
00083                SWvertex *dst)
00084 {
00085    LOCALVARS
00086    GLuint format = GET_VERTEX_FORMAT();
00087    GLfloat *s = ctx->Viewport._WindowMap.m;
00088    UNVIEWPORT_VARS;
00089 
00090    if (format == TINY_VERTEX_FORMAT) {
00091       if (HAVE_HW_VIEWPORT) {
00092      dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0]  * src->v.x + s[12];
00093      dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5]  * src->v.y + s[13];
00094      dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z + s[14];
00095      dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
00096       } else {
00097      dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( src->v.x );
00098      dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( src->v.y );
00099      dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( src->v.z );
00100      dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
00101       }
00102 
00103       dst->color[0] = src->tv.color.red;
00104       dst->color[1] = src->tv.color.green;
00105       dst->color[2] = src->tv.color.blue;
00106       dst->color[3] = src->tv.color.alpha;
00107    }
00108    else {
00109       if (HAVE_HW_VIEWPORT) {
00110      if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
00111         GLfloat oow = 1.0 / src->v.w;
00112         dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0]  * src->v.x * oow + s[12];
00113         dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5]  * src->v.y * oow + s[13];
00114         dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z * oow + s[14];
00115         dst->attrib[FRAG_ATTRIB_WPOS][3] = oow;
00116      } else {
00117         dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0]  * src->v.x + s[12];
00118         dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5]  * src->v.y + s[13];
00119         dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z + s[14];
00120         dst->attrib[FRAG_ATTRIB_WPOS][3] = src->v.w;
00121      }
00122       } else {
00123      dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( src->v.x );
00124      dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( src->v.y );
00125      dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( src->v.z );
00126      dst->attrib[FRAG_ATTRIB_WPOS][3] = src->v.w;
00127       }
00128 
00129       dst->color[0] = src->v.color.red;
00130       dst->color[1] = src->v.color.green;
00131       dst->color[2] = src->v.color.blue;
00132       dst->color[3] = src->v.color.alpha;
00133 
00134       dst->attrib[FRAG_ATTRIB_COL1][0] = UBYTE_TO_FLOAT(src->v.specular.red);
00135       dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(src->v.specular.green);
00136       dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(src->v.specular.blue);
00137 
00138       dst->attrib[FRAG_ATTRIB_FOGC][0] = UBYTE_TO_FLOAT(src->v.specular.alpha);
00139 
00140       if (HAVE_PTEX_VERTICES &&
00141       ((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) ||
00142        (format == PROJ_TEX1_VERTEX_FORMAT))) {
00143 
00144      dst->attrib[FRAG_ATTRIB_TEX0][0] = src->pv.u0;
00145      dst->attrib[FRAG_ATTRIB_TEX0][1] = src->pv.v0;
00146      dst->attrib[FRAG_ATTRIB_TEX0][3] = src->pv.q0;
00147 
00148      dst->attrib[FRAG_ATTRIB_TEX1][0] = src->pv.u1;
00149      dst->attrib[FRAG_ATTRIB_TEX1][1] = src->pv.v1;
00150      dst->attrib[FRAG_ATTRIB_TEX1][3] = src->pv.q1;
00151 
00152      if (HAVE_TEX2_VERTICES) {
00153         dst->attrib[FRAG_ATTRIB_TEX2][0] = src->pv.u2;
00154         dst->attrib[FRAG_ATTRIB_TEX2][1] = src->pv.v2;
00155         dst->attrib[FRAG_ATTRIB_TEX2][3] = src->pv.q2;
00156      }
00157 
00158      if (HAVE_TEX3_VERTICES) {
00159         dst->attrib[FRAG_ATTRIB_TEX3][0] = src->pv.u3;
00160         dst->attrib[FRAG_ATTRIB_TEX3][1] = src->pv.v3;
00161         dst->attrib[FRAG_ATTRIB_TEX3][3] = src->pv.q3;
00162      }
00163       }
00164       else {
00165      dst->attrib[FRAG_ATTRIB_TEX0][0] = src->v.u0;
00166      dst->attrib[FRAG_ATTRIB_TEX0][1] = src->v.v0;
00167      dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
00168 
00169      dst->attrib[FRAG_ATTRIB_TEX1][0] = src->v.u1;
00170      dst->attrib[FRAG_ATTRIB_TEX1][1] = src->v.v1;
00171      dst->attrib[FRAG_ATTRIB_TEX1][3] = 1.0;
00172 
00173      if (HAVE_TEX2_VERTICES) {
00174         dst->attrib[FRAG_ATTRIB_TEX2][0] = src->v.u2;
00175         dst->attrib[FRAG_ATTRIB_TEX2][1] = src->v.v2;
00176         dst->attrib[FRAG_ATTRIB_TEX2][3] = 1.0;
00177      }
00178 
00179      if (HAVE_TEX3_VERTICES) {
00180         dst->attrib[FRAG_ATTRIB_TEX3][0] = src->v.u3;
00181         dst->attrib[FRAG_ATTRIB_TEX3][1] = src->v.v3;
00182         dst->attrib[FRAG_ATTRIB_TEX3][3] = 1.0;
00183      }
00184       }
00185    }
00186 
00187    dst->pointSize = ctx->Point.Size;
00188 }
00189 
00190 
00191 
00192 void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v )
00193 {
00194    LOCALVARS
00195    GLuint format = GET_VERTEX_FORMAT();
00196 
00197    fprintf(stderr, "(%x) ", format);
00198 
00199    switch (format) {
00200 #if HAVE_TINY_VERTICES
00201    case TINY_VERTEX_FORMAT:
00202       fprintf(stderr, "xyz %.4f,%.4f,%.4f rgba %x:%x:%x:%x\n",
00203           v->v.x, v->v.y, v->v.z,
00204           v->tv.color.red,
00205           v->tv.color.green,
00206           v->tv.color.blue,
00207           v->tv.color.alpha);
00208       break;
00209 #endif
00210 #if HAVE_NOTEX_VERTICES
00211    case NOTEX_VERTEX_FORMAT:
00212       fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x spec %x:%x:%x:%x\n",
00213           v->v.x, v->v.y, v->v.z, v->v.w,
00214           v->v.color.red,
00215           v->v.color.green,
00216           v->v.color.blue,
00217           v->v.color.alpha,
00218           v->v.specular.red,
00219           v->v.specular.green,
00220           v->v.specular.blue,
00221           v->v.specular.alpha);
00222       break;
00223 #endif
00224 #if HAVE_TEX0_VERTICES
00225    case TEX0_VERTEX_FORMAT:
00226       fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f\n",
00227           v->v.x, v->v.y, v->v.z, v->v.w,
00228           v->v.color.red,
00229           v->v.color.green,
00230           v->v.color.blue,
00231           v->v.color.alpha,
00232           v->v.u0,
00233           v->v.v0);
00234       break;
00235 #endif
00236 #if HAVE_TEX1_VERTICES
00237    case TEX1_VERTEX_FORMAT:
00238       fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f st %.4f,%.4f\n",
00239           v->v.x, v->v.y, v->v.z, v->v.w,
00240           v->v.color.red,
00241           v->v.color.green,
00242           v->v.color.blue,
00243           v->v.color.alpha,
00244           v->v.u0,
00245           v->v.v0,
00246           v->v.u1,
00247           v->v.u2);
00248       break;
00249 #endif
00250 #if HAVE_PTEX_VERTICES
00251    case PROJ_TEX1_VERTEX_FORMAT:
00252       fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x stq %.4f,%.4f,%.4f stq %.4f,%.4f,%.4f\n",
00253           v->v.x, v->v.y, v->v.z, v->v.w,
00254           v->v.color.red,
00255           v->v.color.green,
00256           v->v.color.blue,
00257           v->v.color.alpha,
00258           v->pv.u0,
00259           v->pv.v0,
00260           v->pv.q0,
00261           v->pv.u1,
00262           v->pv.v1,
00263           v->pv.q1);
00264       break;
00265 #endif      
00266    default:
00267       fprintf(stderr, "???\n");
00268       break;
00269    }
00270 
00271    fprintf(stderr, "\n");
00272 }
00273 
00274 
00275 
00276 /* Interpolate the elements of the VB not included in typical hardware
00277  * vertices.  
00278  *
00279  * NOTE: All these arrays are guarenteed by tnl to be writeable and
00280  * have good stride.
00281  */
00282 #ifndef INTERP_QUALIFIER 
00283 #define INTERP_QUALIFIER static
00284 #endif
00285 
00286 #define GET_COLOR(ptr, idx) ((ptr)->data[idx])
00287 
00288 
00289 INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
00290                       GLfloat t,
00291                       GLuint dst, GLuint out, GLuint in,
00292                       GLboolean force_boundary )
00293 {
00294    LOCALVARS
00295    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
00296 
00297    if (VB->ColorPtr[1]) {
00298       assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
00299 
00300       INTERP_4F( t,
00301             GET_COLOR(VB->ColorPtr[1], dst),
00302             GET_COLOR(VB->ColorPtr[1], out),
00303             GET_COLOR(VB->ColorPtr[1], in) );
00304 
00305       if (VB->SecondaryColorPtr[1]) {
00306      INTERP_3F( t,
00307                GET_COLOR(VB->SecondaryColorPtr[1], dst),
00308                GET_COLOR(VB->SecondaryColorPtr[1], out),
00309                GET_COLOR(VB->SecondaryColorPtr[1], in) );
00310       }
00311    }
00312 
00313    if (VB->EdgeFlag) {
00314       VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
00315    }
00316 
00317    INTERP_VERTEX(ctx, t, dst, out, in, force_boundary);
00318 }
00319 
00320 INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx, 
00321                        GLuint dst, GLuint src )
00322 {
00323    LOCALVARS
00324       struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
00325 
00326    if (VB->ColorPtr[1]) {
00327       COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), 
00328         GET_COLOR(VB->ColorPtr[1], src) );
00329 
00330       if (VB->SecondaryColorPtr[1]) {
00331      COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
00332            GET_COLOR(VB->SecondaryColorPtr[1], src) );
00333       }
00334    }
00335 
00336    COPY_PV_VERTEX(ctx, dst, src);
00337 }
00338 
00339 
00340 #undef INTERP_QUALIFIER
00341 #undef GET_COLOR
00342 
00343 #undef IND
00344 #undef TAG

Generated on Sun May 27 2012 04:20:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.