MATH_DEBUG changes from bug #4468.
[mesa.git] / src / mesa / math / m_xform.c
index 7509a350d80671083148e5802fccab42a910ef63..fa3f57a8e5a8e7d458cf3f79e3c1f692b2bab9dd 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: m_xform.c,v 1.2 2000/11/17 21:01:49 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  5.1
  *
- * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * 3. Transformation of a point p by a matrix M is: p' = M * p
  */
 
-
 #include "glheader.h"
 #include "macros.h"
-#include "mmath.h"
 
+#include "m_eval.h"
 #include "m_matrix.h"
 #include "m_translate.h"
 #include "m_xform.h"
+#include "mathmod.h"
 
 
-#ifdef DEBUG
-#include "m_debug_xform.h"
+#ifdef DEBUG_MATH
+#include "m_debug.h"
 #endif
 
 #ifdef USE_X86_ASM
-#include "X86/common_x86_asm.h"
+#include "x86/common_x86_asm.h"
+#endif
+
+#ifdef USE_X86_64_ASM
+#include "x86-64/x86-64.h"
 #endif
 
-clip_func gl_clip_tab[5];
-dotprod_func gl_dotprod_tab[2][5];
-vec_copy_func gl_copy_tab[2][0x10];
-normal_func gl_normal_tab[0xf][0x4];
-transform_func **(gl_transform_tab[2]);
-static transform_func *cull_transform_tab[5];
-static transform_func *raw_transform_tab[5];
+#ifdef USE_SPARC_ASM
+#include "sparc/sparc.h"
+#endif
+
+#ifdef USE_PPC_ASM
+#include "ppc/common_ppc_features.h"
+#endif
+
+clip_func _mesa_clip_tab[5];
+clip_func _mesa_clip_np_tab[5];
+dotprod_func _mesa_dotprod_tab[5];
+vec_copy_func _mesa_copy_tab[0x10];
+normal_func _mesa_normal_tab[0xf];
+transform_func *_mesa_transform_tab[5];
 
 
 /* Raw data format used for:
@@ -68,14 +77,14 @@ static transform_func *raw_transform_tab[5];
  *    - Eye-to-clip transform (via the function above).
  *    - Cliptesting
  *    - And everything else too, if culling happens to be disabled.
+ *
+ * GH: It's used for everything now, as clipping/culling is done
+ *     elsewhere (most often by the driver itself).
  */
-#define TAG(x) x##_raw
-#define TAG2(x,y) x##y##_raw
-#define IDX 0
-#define STRIDE_LOOP for (i=0;i<count;i++, STRIDE_F(from, stride))
-#define LOOP for (i=0;i<n;i++)
-#define CULL_CHECK
-#define CLIP_CHECK
+#define TAG(x) x
+#define TAG2(x,y) x##y
+#define STRIDE_LOOP for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) )
+#define LOOP for ( i = 0 ; i < n ; i++ )
 #define ARGS
 #include "m_xform_tmp.h"
 #include "m_clip_tmp.h"
@@ -85,44 +94,13 @@ static transform_func *raw_transform_tab[5];
 #undef TAG
 #undef TAG2
 #undef LOOP
-#undef CULL_CHECK
-#undef CLIP_CHECK
-#undef ARGS
-#undef IDX
-
-/* Culled data used for:
- *    - texture transformations
- *    - viewport map transformation
- *    - normal transformations prior to lighting
- *    - user cliptests
- */
-#define TAG(x) x##_masked
-#define TAG2(x,y) x##y##_masked
-#define IDX 1
-#define STRIDE_LOOP for (i=0;i<count;i++, STRIDE_F(from, stride))
-#define LOOP for (i=0;i<n;i++)
-#define CULL_CHECK if (mask[i])
-#define CLIP_CHECK if ((mask[i] & flag) == 0)
-#define ARGS , const GLubyte mask[]
-#include "m_xform_tmp.h"
-#include "m_norm_tmp.h"
-#include "m_dotprod_tmp.h"
-#include "m_copy_tmp.h"
-#undef TAG
-#undef TAG2
-#undef LOOP
-#undef CULL_CHECK
-#undef CLIP_CHECK
 #undef ARGS
-#undef IDX
-
 
 
 
 
-
-GLvector4f *gl_project_points( GLvector4f *proj_vec,
-                              const GLvector4f *clip_vec )
+GLvector4f *_mesa_project_points( GLvector4f *proj_vec,
+                                 const GLvector4f *clip_vec )
 {
    const GLuint stride = clip_vec->stride;
    const GLfloat *from = (GLfloat *)clip_vec->start;
@@ -159,7 +137,7 @@ GLvector4f *gl_project_points( GLvector4f *proj_vec,
  *         m - transformation matrix
  * Output:  u - transformed vector
  */
-void gl_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] )
+void _mesa_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] )
 {
    GLfloat v0=v[0], v1=v[1], v2=v[2], v3=v[3];
 #define M(row,col)  m[row + col*4]
@@ -172,10 +150,10 @@ void gl_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16]
 
 
 /* Useful for one-off point transformations, as in clipping.
- * Note that because the matrix isn't analyzed we do too many
+ * Note that because the matrix isn't analysed we do too many
  * multiplies, and that the result is always 4-clean.
  */
-void gl_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
+void _mesa_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
                            const GLfloat P[4], GLuint sz )
 {
    if (Q == P)
@@ -215,31 +193,31 @@ void gl_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
 /*
  * This is called only once.  It initializes several tables with pointers
  * to optimized transformation functions.  This is where we can test for
- * AMD 3Dnow! capability, Intel Katmai, etc. and hook in the right code.
+ * AMD 3Dnow! capability, Intel SSE, etc. and hook in the right code.
  */
-void 
+void
 _math_init_transformation( void )
 {
-   gl_transform_tab[0] = raw_transform_tab;
-   gl_transform_tab[1] = cull_transform_tab;
-
-   init_c_transformations_raw();
-   init_c_transformations_masked();
-   init_c_norm_transform_raw();
-   init_c_norm_transform_masked();
-   init_c_cliptest_raw();
-   init_copy0_raw();
-   init_copy0_masked();
-   init_dotprod_raw();
-   init_dotprod_masked();
-
-#ifdef DEBUG
-   gl_test_all_transform_functions( "default" );
-   gl_test_all_normal_transform_functions( "default" );
+   init_c_transformations();
+   init_c_norm_transform();
+   init_c_cliptest();
+   init_copy0();
+   init_dotprod();
+
+#ifdef DEBUG_MATH
+   _math_test_all_transform_functions( "default" );
+   _math_test_all_normal_transform_functions( "default" );
+   _math_test_all_cliptest_functions( "default" );
 #endif
 
 #ifdef USE_X86_ASM
-   gl_init_all_x86_transform_asm();
+   _mesa_init_all_x86_transform_asm();
+#elif defined( USE_SPARC_ASM )
+   _mesa_init_all_sparc_transform_asm();
+#elif defined( USE_PPC_ASM )
+   _mesa_init_all_ppc_transform_asm();
+#elif defined( USE_X86_64_ASM )
+   _mesa_init_all_x86_64_transform_asm();
 #endif
 }
 
@@ -248,5 +226,5 @@ _math_init( void )
 {
    _math_init_transformation();
    _math_init_translate();
-   _math_init_vertices();
+   _math_init_eval();
 }