m_xform.c revision 23caf20169ac38436ee9c13914f1d6aa7cf6bb5e
123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* $Id: m_xform.c,v 1.1 2000/11/16 21:05:41 keithw Exp $ */ 223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Mesa 3-D graphics library 523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Version: 3.5 623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. 823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 1023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * copy of this software and associated documentation files (the "Software"), 1123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * to deal in the Software without restriction, including without limitation 1223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 1423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Software is furnished to do so, subject to the following conditions: 1523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 1623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * The above copyright notice and this permission notice shall be included 1723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * in all copies or substantial portions of the Software. 1823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 1923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 2023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 2623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 2923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Matrix/vertex/vector transformation stuff 3023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 3123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 3223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * NOTES: 3323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 1. 4x4 transformation matrices are stored in memory in column major order. 3423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 2. Points/vertices are to be thought of as column vectors. 3523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * 3. Transformation of a point p by a matrix M is: p' = M * p 3623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 3723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 3823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 3923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "glheader.h" 4023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "macros.h" 4123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "mmath.h" 4223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 4323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_matrix.h" 4423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_xform.h" 4523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 4623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 4723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#ifdef DEBUG 4823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_debug_xform.h" 4923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#endif 5023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 5123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#ifdef USE_X86_ASM 5223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "X86/common_x86_asm.h" 5323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#endif 5423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 5523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellclip_func gl_clip_tab[5]; 5623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwelldotprod_func gl_dotprod_tab[2][5]; 5723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellvec_copy_func gl_copy_tab[2][0x10]; 5823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellnormal_func gl_normal_tab[0xf][0x4]; 5923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwelltransform_func **(gl_transform_tab[2]); 6023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellstatic transform_func *cull_transform_tab[5]; 6123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellstatic transform_func *raw_transform_tab[5]; 6223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 6323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 6423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* Raw data format used for: 6523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - Object-to-eye transform prior to culling, although this too 6623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * could be culled under some circumstances. 6723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - Eye-to-clip transform (via the function above). 6823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - Cliptesting 6923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - And everything else too, if culling happens to be disabled. 7023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 7123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define TAG(x) x##_raw 7223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define TAG2(x,y) x##y##_raw 7323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define IDX 0 7423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define STRIDE_LOOP for (i=0;i<count;i++, STRIDE_F(from, stride)) 7523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define LOOP for (i=0;i<n;i++) 7623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define CULL_CHECK 7723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define CLIP_CHECK 7823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define ARGS 7923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_xform_tmp.h" 8023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_clip_tmp.h" 8123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_norm_tmp.h" 8223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_dotprod_tmp.h" 8323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_copy_tmp.h" 8423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef TAG 8523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef TAG2 8623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef LOOP 8723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef CULL_CHECK 8823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef CLIP_CHECK 8923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef ARGS 9023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef IDX 9123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 9223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* Culled data used for: 9323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - texture transformations 9423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - viewport map transformation 9523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - normal transformations prior to lighting 9623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * - user cliptests 9723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 9823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define TAG(x) x##_masked 9923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define TAG2(x,y) x##y##_masked 10023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define IDX 1 10123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define STRIDE_LOOP for (i=0;i<count;i++, STRIDE_F(from, stride)) 10223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define LOOP for (i=0;i<n;i++) 10323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define CULL_CHECK if (mask[i]) 10423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define CLIP_CHECK if ((mask[i] & flag) == 0) 10523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define ARGS , const GLubyte mask[] 10623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_xform_tmp.h" 10723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_norm_tmp.h" 10823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_dotprod_tmp.h" 10923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "m_copy_tmp.h" 11023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef TAG 11123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef TAG2 11223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef LOOP 11323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef CULL_CHECK 11423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef CLIP_CHECK 11523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef ARGS 11623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef IDX 11723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 11823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 11923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 12023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 12123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 12223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 12323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith WhitwellGLvector4f *gl_project_points( GLvector4f *proj_vec, 12423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell const GLvector4f *clip_vec ) 12523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell{ 12623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell const GLuint stride = clip_vec->stride; 12723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell const GLfloat *from = (GLfloat *)clip_vec->start; 12823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell const GLuint count = clip_vec->count; 12923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start; 13023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell GLuint i; 13123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 13223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell for (i = 0 ; i < count ; i++, STRIDE_F(from, stride)) 13323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell { 13423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell GLfloat oow = 1.0F / from[3]; 13523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell vProj[i][3] = oow; 13623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell vProj[i][0] = from[0] * oow; 13723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell vProj[i][1] = from[1] * oow; 13823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell vProj[i][2] = from[2] * oow; 13923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell } 14023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 14123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell proj_vec->flags |= VEC_SIZE_4; 14223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell proj_vec->size = 3; 14323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell proj_vec->count = clip_vec->count; 14423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell return proj_vec; 14523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} 14623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 14723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 14823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 14923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 15023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 15123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 15223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 15323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Transform a 4-element row vector (1x4 matrix) by a 4x4 matrix. This 15423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * function is used for transforming clipping plane equations and spotlight 15523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * directions. 15623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Mathematically, u = v * m. 15723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Input: v - input vector 15823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * m - transformation matrix 15923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Output: u - transformed vector 16023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 16123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellvoid gl_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] ) 16223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell{ 16323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell GLfloat v0=v[0], v1=v[1], v2=v[2], v3=v[3]; 16423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define M(row,col) m[row + col*4] 16523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell u[0] = v0 * M(0,0) + v1 * M(1,0) + v2 * M(2,0) + v3 * M(3,0); 16623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell u[1] = v0 * M(0,1) + v1 * M(1,1) + v2 * M(2,1) + v3 * M(3,1); 16723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell u[2] = v0 * M(0,2) + v1 * M(1,2) + v2 * M(2,2) + v3 * M(3,2); 16823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell u[3] = v0 * M(0,3) + v1 * M(1,3) + v2 * M(2,3) + v3 * M(3,3); 16923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#undef M 17023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} 17123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 17223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 17323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* Useful for one-off point transformations, as in clipping. 17423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Note that because the matrix isn't analyzed we do too many 17523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * multiplies, and that the result is always 4-clean. 17623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 17723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellvoid gl_transform_point_sz( GLfloat Q[4], const GLfloat M[16], 17823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell const GLfloat P[4], GLuint sz ) 17923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell{ 18023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell if (Q == P) 18123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell return; 18223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 18323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell if (sz == 4) 18423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell { 18523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3]; 18623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3]; 18723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3]; 18823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3]; 18923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell } 19023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell else if (sz == 3) 19123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell { 19223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12]; 19323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13]; 19423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14]; 19523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15]; 19623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell } 19723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell else if (sz == 2) 19823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell { 19923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[0] = M[0] * P[0] + M[4] * P[1] + M[12]; 20023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[1] = M[1] * P[0] + M[5] * P[1] + M[13]; 20123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[2] = M[2] * P[0] + M[6] * P[1] + M[14]; 20223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[3] = M[3] * P[0] + M[7] * P[1] + M[15]; 20323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell } 20423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell else if (sz == 1) 20523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell { 20623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[0] = M[0] * P[0] + M[12]; 20723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[1] = M[1] * P[0] + M[13]; 20823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[2] = M[2] * P[0] + M[14]; 20923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell Q[3] = M[3] * P[0] + M[15]; 21023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell } 21123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} 21223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 21323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 21423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 21523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * This is called only once. It initializes several tables with pointers 21623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * to optimized transformation functions. This is where we can test for 21723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * AMD 3Dnow! capability, Intel Katmai, etc. and hook in the right code. 21823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 21923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellvoid 22023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell_math_init_transformation( void ) 22123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell{ 22223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell gl_transform_tab[0] = raw_transform_tab; 22323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell gl_transform_tab[1] = cull_transform_tab; 22423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 22523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_c_transformations_raw(); 22623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_c_transformations_masked(); 22723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_c_norm_transform_raw(); 22823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_c_norm_transform_masked(); 22923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_c_cliptest_raw(); 23023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_copy0_raw(); 23123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_copy0_masked(); 23223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_dotprod_raw(); 23323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell init_dotprod_masked(); 23423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 23523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#ifdef DEBUG 23623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell gl_test_all_transform_functions( "default" ); 23723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell gl_test_all_normal_transform_functions( "default" ); 23823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#endif 23923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 24023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#ifdef USE_X86_ASM 24123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell gl_init_all_x86_transform_asm(); 24223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#endif 24323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} 24423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 24523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwellvoid 24623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell_math_init( void ) 24723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell{ 24823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell _math_init_transformation(); 24923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell _math_init_translate(); 25023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell _math_init_vertices(); 25123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} 252