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

m_clip_tmp.h
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.2
00004  *
00005  * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 /*
00026  * New (3.1) transformation code written by Keith Whitwell.
00027  */
00028 
00029 
00030 /* KW: a clever asm implementation would nestle integer versions
00031  * of the outcode calculation underneath the division.  Gcc won't
00032  * do this, strangely enough, so I only do the divide in
00033  * the case where the cliptest passes.  This isn't essential,
00034  * and an asm implementation needn't replicate that behaviour.
00035  *
00036  * \param clip_vec vector of incoming clip-space coords
00037  * \param proj_vec vector of resultant NDC-space projected coords
00038  * \param clipMask resulting array of clip flags
00039  * \param orMask bitwise-OR of clipMask values
00040  * \param andMask bitwise-AND of clipMask values
00041  * \return proj_vec pointer
00042  */
00043 static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec,
00044                                                      GLvector4f *proj_vec,
00045                                                      GLubyte clipMask[],
00046                                                      GLubyte *orMask,
00047                                                      GLubyte *andMask )
00048 {
00049    const GLuint stride = clip_vec->stride;
00050    const GLfloat *from = (GLfloat *)clip_vec->start;
00051    const GLuint count = clip_vec->count;
00052    GLuint c = 0;
00053    GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start;
00054    GLubyte tmpAndMask = *andMask;
00055    GLubyte tmpOrMask = *orMask;
00056    GLuint i;
00057    STRIDE_LOOP {
00058       const GLfloat cx = from[0];
00059       const GLfloat cy = from[1];
00060       const GLfloat cz = from[2];
00061       const GLfloat cw = from[3];
00062 #if defined(macintosh) || defined(__powerpc__)
00063       /* on powerpc cliptest is 17% faster in this way. */
00064       GLuint mask;
00065       mask = (((cw < cx) << CLIP_RIGHT_SHIFT));
00066       mask |= (((cw < -cx) << CLIP_LEFT_SHIFT));
00067       mask |= (((cw < cy) << CLIP_TOP_SHIFT));
00068       mask |= (((cw < -cy) << CLIP_BOTTOM_SHIFT));
00069       mask |= (((cw < cz) << CLIP_FAR_SHIFT));
00070       mask |= (((cw < -cz) << CLIP_NEAR_SHIFT));
00071 #else /* !defined(macintosh)) */
00072       GLubyte mask = 0;
00073       if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT;
00074       if ( cx + cw < 0) mask |= CLIP_LEFT_BIT;
00075       if (-cy + cw < 0) mask |= CLIP_TOP_BIT;
00076       if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT;
00077       if (-cz + cw < 0) mask |= CLIP_FAR_BIT;
00078       if ( cz + cw < 0) mask |= CLIP_NEAR_BIT;
00079 #endif /* defined(macintosh) */
00080 
00081       clipMask[i] = mask;
00082       if (mask) {
00083      c++;
00084      tmpAndMask &= mask;
00085      tmpOrMask |= mask;
00086      vProj[i][0] = 0;
00087      vProj[i][1] = 0;
00088      vProj[i][2] = 0;
00089      vProj[i][3] = 1;
00090       } else {
00091      GLfloat oow = 1.0F / cw;
00092      vProj[i][0] = cx * oow;
00093      vProj[i][1] = cy * oow;
00094      vProj[i][2] = cz * oow;
00095      vProj[i][3] = oow;
00096       }
00097    }
00098 
00099    *orMask = tmpOrMask;
00100    *andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
00101 
00102    proj_vec->flags |= VEC_SIZE_4;
00103    proj_vec->size = 4;
00104    proj_vec->count = clip_vec->count;
00105    return proj_vec;
00106 }
00107 
00108 
00109 
00110 /*
00111  * \param clip_vec vector of incoming clip-space coords
00112  * \param proj_vec vector of resultant NDC-space projected coords
00113  * \param clipMask resulting array of clip flags
00114  * \param orMask bitwise-OR of clipMask values
00115  * \param andMask bitwise-AND of clipMask values
00116  * \return clip_vec pointer
00117  */
00118 static GLvector4f * _XFORMAPI TAG(cliptest_np_points4)( GLvector4f *clip_vec,
00119                             GLvector4f *proj_vec,
00120                             GLubyte clipMask[],
00121                             GLubyte *orMask,
00122                             GLubyte *andMask )
00123 {
00124    const GLuint stride = clip_vec->stride;
00125    const GLuint count = clip_vec->count;
00126    const GLfloat *from = (GLfloat *)clip_vec->start;
00127    GLuint c = 0;
00128    GLubyte tmpAndMask = *andMask;
00129    GLubyte tmpOrMask = *orMask;
00130    GLuint i;
00131    (void) proj_vec;
00132    STRIDE_LOOP {
00133       const GLfloat cx = from[0];
00134       const GLfloat cy = from[1];
00135       const GLfloat cz = from[2];
00136       const GLfloat cw = from[3];
00137 #if defined(macintosh) || defined(__powerpc__)
00138       /* on powerpc cliptest is 17% faster in this way. */
00139       GLuint mask;
00140       mask = (((cw < cx) << CLIP_RIGHT_SHIFT));
00141       mask |= (((cw < -cx) << CLIP_LEFT_SHIFT));
00142       mask |= (((cw < cy) << CLIP_TOP_SHIFT));
00143       mask |= (((cw < -cy) << CLIP_BOTTOM_SHIFT));
00144       mask |= (((cw < cz) << CLIP_FAR_SHIFT));
00145       mask |= (((cw < -cz) << CLIP_NEAR_SHIFT));
00146 #else /* !defined(macintosh)) */
00147       GLubyte mask = 0;
00148       if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT;
00149       if ( cx + cw < 0) mask |= CLIP_LEFT_BIT;
00150       if (-cy + cw < 0) mask |= CLIP_TOP_BIT;
00151       if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT;
00152       if (-cz + cw < 0) mask |= CLIP_FAR_BIT;
00153       if ( cz + cw < 0) mask |= CLIP_NEAR_BIT;
00154 #endif /* defined(macintosh) */
00155 
00156       clipMask[i] = mask;
00157       if (mask) {
00158      c++;
00159      tmpAndMask &= mask;
00160      tmpOrMask |= mask;
00161       }
00162    }
00163 
00164    *orMask = tmpOrMask;
00165    *andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
00166    return clip_vec;
00167 }
00168 
00169 
00170 static GLvector4f * _XFORMAPI TAG(cliptest_points3)( GLvector4f *clip_vec,
00171                                                      GLvector4f *proj_vec,
00172                                                      GLubyte clipMask[],
00173                                                      GLubyte *orMask,
00174                                                      GLubyte *andMask )
00175 {
00176    const GLuint stride = clip_vec->stride;
00177    const GLuint count = clip_vec->count;
00178    const GLfloat *from = (GLfloat *)clip_vec->start;
00179    GLubyte tmpOrMask = *orMask;
00180    GLubyte tmpAndMask = *andMask;
00181    GLuint i;
00182    (void) proj_vec;
00183    STRIDE_LOOP {
00184       const GLfloat cx = from[0], cy = from[1], cz = from[2];
00185       GLubyte mask = 0;
00186       if (cx >  1.0)       mask |= CLIP_RIGHT_BIT;
00187       else if (cx < -1.0)  mask |= CLIP_LEFT_BIT;
00188       if (cy >  1.0)       mask |= CLIP_TOP_BIT;
00189       else if (cy < -1.0)  mask |= CLIP_BOTTOM_BIT;
00190       if (cz >  1.0)       mask |= CLIP_FAR_BIT;
00191       else if (cz < -1.0)  mask |= CLIP_NEAR_BIT;
00192       clipMask[i] = mask;
00193       tmpOrMask |= mask;
00194       tmpAndMask &= mask;
00195    }
00196 
00197    *orMask = tmpOrMask;
00198    *andMask = tmpAndMask;
00199    return clip_vec;
00200 }
00201 
00202 
00203 static GLvector4f * _XFORMAPI TAG(cliptest_points2)( GLvector4f *clip_vec,
00204                                                      GLvector4f *proj_vec,
00205                                                      GLubyte clipMask[],
00206                                                      GLubyte *orMask,
00207                                                      GLubyte *andMask )
00208 {
00209    const GLuint stride = clip_vec->stride;
00210    const GLuint count = clip_vec->count;
00211    const GLfloat *from = (GLfloat *)clip_vec->start;
00212    GLubyte tmpOrMask = *orMask;
00213    GLubyte tmpAndMask = *andMask;
00214    GLuint i;
00215    (void) proj_vec;
00216    STRIDE_LOOP {
00217       const GLfloat cx = from[0], cy = from[1];
00218       GLubyte mask = 0;
00219       if (cx >  1.0)       mask |= CLIP_RIGHT_BIT;
00220       else if (cx < -1.0)  mask |= CLIP_LEFT_BIT;
00221       if (cy >  1.0)       mask |= CLIP_TOP_BIT;
00222       else if (cy < -1.0)  mask |= CLIP_BOTTOM_BIT;
00223       clipMask[i] = mask;
00224       tmpOrMask |= mask;
00225       tmpAndMask &= mask;
00226    }
00227 
00228    *orMask = tmpOrMask;
00229    *andMask = tmpAndMask;
00230    return clip_vec;
00231 }
00232 
00233 
00234 static void TAG(init_c_cliptest)( void )
00235 {
00236    _mesa_clip_tab[4] = TAG(cliptest_points4);
00237    _mesa_clip_tab[3] = TAG(cliptest_points3);
00238    _mesa_clip_tab[2] = TAG(cliptest_points2);
00239 
00240    _mesa_clip_np_tab[4] = TAG(cliptest_np_points4);
00241    _mesa_clip_np_tab[3] = TAG(cliptest_points3);
00242    _mesa_clip_np_tab[2] = TAG(cliptest_points2);
00243 }

Generated on Sat May 26 2012 04:19:17 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.