17117f1b4Smrg/*
27117f1b4Smrg * Mesa 3-D graphics library
37117f1b4Smrg *
47117f1b4Smrg * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
57117f1b4Smrg *
67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
77117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
87117f1b4Smrg * to deal in the Software without restriction, including without limitation
97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
117117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
127117f1b4Smrg *
137117f1b4Smrg * The above copyright notice and this permission notice shall be included
147117f1b4Smrg * in all copies or substantial portions of the Software.
157117f1b4Smrg *
167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
237117f1b4Smrg */
247117f1b4Smrg
257117f1b4Smrg
267117f1b4Smrg/*
277117f1b4Smrg * Matrix/vertex/vector transformation stuff
287117f1b4Smrg *
297117f1b4Smrg *
307117f1b4Smrg * NOTES:
317117f1b4Smrg * 1. 4x4 transformation matrices are stored in memory in column major order.
327117f1b4Smrg * 2. Points/vertices are to be thought of as column vectors.
337117f1b4Smrg * 3. Transformation of a point p by a matrix M is: p' = M * p
347117f1b4Smrg */
357117f1b4Smrg
3601e04c3fSmrg#include "c99_math.h"
37c1f859d4Smrg#include "main/glheader.h"
38c1f859d4Smrg#include "main/macros.h"
397117f1b4Smrg
407117f1b4Smrg#include "m_eval.h"
417117f1b4Smrg#include "m_matrix.h"
427117f1b4Smrg#include "m_translate.h"
437117f1b4Smrg#include "m_xform.h"
447117f1b4Smrg
457117f1b4Smrg
467117f1b4Smrg#ifdef DEBUG_MATH
477117f1b4Smrg#include "m_debug.h"
487117f1b4Smrg#endif
497117f1b4Smrg
507117f1b4Smrg#ifdef USE_X86_ASM
517117f1b4Smrg#include "x86/common_x86_asm.h"
527117f1b4Smrg#endif
537117f1b4Smrg
547117f1b4Smrg#ifdef USE_X86_64_ASM
557117f1b4Smrg#include "x86-64/x86-64.h"
567117f1b4Smrg#endif
577117f1b4Smrg
587117f1b4Smrg#ifdef USE_SPARC_ASM
597117f1b4Smrg#include "sparc/sparc.h"
607117f1b4Smrg#endif
617117f1b4Smrg
627117f1b4Smrgclip_func _mesa_clip_tab[5];
637117f1b4Smrgclip_func _mesa_clip_np_tab[5];
647117f1b4Smrgdotprod_func _mesa_dotprod_tab[5];
657117f1b4Smrgvec_copy_func _mesa_copy_tab[0x10];
667117f1b4Smrgnormal_func _mesa_normal_tab[0xf];
677117f1b4Smrgtransform_func *_mesa_transform_tab[5];
687117f1b4Smrg
697117f1b4Smrg
707117f1b4Smrg/* Raw data format used for:
717117f1b4Smrg *    - Object-to-eye transform prior to culling, although this too
727117f1b4Smrg *      could be culled under some circumstances.
737117f1b4Smrg *    - Eye-to-clip transform (via the function above).
747117f1b4Smrg *    - Cliptesting
757117f1b4Smrg *    - And everything else too, if culling happens to be disabled.
767117f1b4Smrg *
777117f1b4Smrg * GH: It's used for everything now, as clipping/culling is done
787117f1b4Smrg *     elsewhere (most often by the driver itself).
797117f1b4Smrg */
807117f1b4Smrg#define TAG(x) x
817117f1b4Smrg#define TAG2(x,y) x##y
827117f1b4Smrg#define STRIDE_LOOP for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) )
837117f1b4Smrg#define LOOP for ( i = 0 ; i < n ; i++ )
847117f1b4Smrg#define ARGS
857117f1b4Smrg#include "m_xform_tmp.h"
867117f1b4Smrg#include "m_clip_tmp.h"
877117f1b4Smrg#include "m_norm_tmp.h"
887117f1b4Smrg#include "m_dotprod_tmp.h"
897117f1b4Smrg#include "m_copy_tmp.h"
907117f1b4Smrg#undef TAG
917117f1b4Smrg#undef TAG2
927117f1b4Smrg#undef LOOP
937117f1b4Smrg#undef ARGS
947117f1b4Smrg
957117f1b4Smrg
967117f1b4Smrg/*
977117f1b4Smrg * This is called only once.  It initializes several tables with pointers
987117f1b4Smrg * to optimized transformation functions.  This is where we can test for
997117f1b4Smrg * AMD 3Dnow! capability, Intel SSE, etc. and hook in the right code.
1007117f1b4Smrg */
1017117f1b4Smrgvoid
1027117f1b4Smrg_math_init_transformation( void )
1037117f1b4Smrg{
1047117f1b4Smrg   init_c_transformations();
1057117f1b4Smrg   init_c_norm_transform();
1067117f1b4Smrg   init_c_cliptest();
1077117f1b4Smrg   init_copy0();
1087117f1b4Smrg   init_dotprod();
1097117f1b4Smrg
1107117f1b4Smrg#ifdef DEBUG_MATH
1117117f1b4Smrg   _math_test_all_transform_functions( "default" );
1127117f1b4Smrg   _math_test_all_normal_transform_functions( "default" );
1137117f1b4Smrg   _math_test_all_cliptest_functions( "default" );
1147117f1b4Smrg#endif
1157117f1b4Smrg
1167117f1b4Smrg#ifdef USE_X86_ASM
1177117f1b4Smrg   _mesa_init_all_x86_transform_asm();
1187117f1b4Smrg#elif defined( USE_SPARC_ASM )
1197117f1b4Smrg   _mesa_init_all_sparc_transform_asm();
1207117f1b4Smrg#elif defined( USE_X86_64_ASM )
1217117f1b4Smrg   _mesa_init_all_x86_64_transform_asm();
1227117f1b4Smrg#endif
1237117f1b4Smrg}
124