-/* $Id: m_debug_norm.c,v 1.7 2001/03/30 14:44:43 gareth Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 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"),
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
- * Gareth Hughes <gareth@valinux.com>
+ * Gareth Hughes
*/
#include "glheader.h"
#include "context.h"
#include "macros.h"
-#include "mem.h"
-#include "mmath.h"
+#include "imports.h"
#include "m_matrix.h"
#include "m_xform.h"
#include "m_debug_util.h"
-#ifdef DEBUG /* This code only used for debugging */
+#ifdef __UNIXOS2__
+/* The linker doesn't like empty files */
+static char dummy;
+#endif
+
+#ifdef DEBUG_MATH /* This code only used for debugging */
static int m_norm_identity[16] = {
static void ref_norm_transform_rescale( const GLmatrix *mat,
GLfloat scale,
- const GLvector3f *in,
+ const GLvector4f *in,
const GLfloat *lengths,
- GLvector3f *dest )
+ GLvector4f *dest )
{
GLuint i;
const GLfloat *s = in->start;
const GLfloat *m = mat->inv;
- GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+ GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start;
(void) lengths;
static void ref_norm_transform_normalize( const GLmatrix *mat,
GLfloat scale,
- const GLvector3f *in,
+ const GLvector4f *in,
const GLfloat *lengths,
- GLvector3f *dest )
+ GLvector4f *dest )
{
GLuint i;
const GLfloat *s = in->start;
const GLfloat *m = mat->inv;
- GLfloat (*out)[3] = (GLfloat (*)[3])dest->start;
+ GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start;
for ( i = 0 ; i < in->count ; i++ ) {
GLfloat t[3];
/* Hmmm, don't know how we could test the precalculated
* length case...
*/
- scale = 1.0 / sqrt( len );
+ scale = 1.0 / SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t );
} else {
out[i][0] = out[i][1] = out[i][2] = 0;
* Normal transformation tests
*/
+static void init_matrix( GLfloat *m )
+{
+ m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0;
+ m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0;
+ m[2] = 44.0; m[6] = 9.0; m[10] = 7.0; m[14] = 3.0;
+ m[3] = 11.0; m[7] = 23.0; m[11] = 91.0; m[15] = 9.0;
+}
+
+
static int test_norm_function( normal_func func, int mtype, long *cycles )
{
- GLvector3f source[1], dest[1], dest2[1], ref[1], ref2[1];
+ GLvector4f source[1], dest[1], dest2[1], ref[1], ref2[1];
GLmatrix mat[1];
- GLfloat s[TEST_COUNT][5], d[TEST_COUNT][3], r[TEST_COUNT][3];
- GLfloat d2[TEST_COUNT][3], r2[TEST_COUNT][3], length[TEST_COUNT];
+ GLfloat s[TEST_COUNT][5], d[TEST_COUNT][4], r[TEST_COUNT][4];
+ GLfloat d2[TEST_COUNT][4], r2[TEST_COUNT][4], length[TEST_COUNT];
GLfloat scale;
GLfloat *m;
int i, j;
case VAR:
break;
default:
- abort();
+ _mesa_exit(1);
}
}
}
ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
for ( j = 0 ; j < 3 ; j++ )
s[i][j] = rnd();
- length[i] = 1 / sqrt( LEN_SQUARED_3FV( s[i] ) );
+ length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
}
- source->data = (GLfloat(*)[3])s;
- source->start = (GLfloat *)s;
+ source->data = (GLfloat(*)[4]) s;
+ source->start = (GLfloat *) s;
source->count = TEST_COUNT;
source->stride = sizeof(s[0]);
source->flags = 0;
- dest->data = (GLfloat(*)[3])d;
- dest->start = (GLfloat *)d;
+ dest->data = d;
+ dest->start = (GLfloat *) d;
dest->count = TEST_COUNT;
- dest->stride = sizeof(float[3]);
+ dest->stride = sizeof(float[4]);
dest->flags = 0;
- dest2->data = (GLfloat(*)[3])d2;
- dest2->start = (GLfloat *)d2;
+ dest2->data = d2;
+ dest2->start = (GLfloat *) d2;
dest2->count = TEST_COUNT;
- dest2->stride = sizeof(float[3]);
+ dest2->stride = sizeof(float[4]);
dest2->flags = 0;
- ref->data = (GLfloat(*)[3])r;
- ref->start = (GLfloat *)r;
+ ref->data = r;
+ ref->start = (GLfloat *) r;
ref->count = TEST_COUNT;
- ref->stride = sizeof(float[3]);
+ ref->stride = sizeof(float[4]);
ref->flags = 0;
- ref2->data = (GLfloat(*)[3])r2;
- ref2->start = (GLfloat *)r2;
+ ref2->data = r2;
+ ref2->start = (GLfloat *) r2;
ref2->count = TEST_COUNT;
- ref2->stride = sizeof(float[3]);
+ ref2->stride = sizeof(float[4]);
ref2->flags = 0;
if ( norm_normalize_types[mtype] == 0 ) {
for ( i = 0 ; i < TEST_COUNT ; i++ ) {
for ( j = 0 ; j < 3 ; j++ ) {
if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) {
- printf( "-----------------------------\n" );
- printf( "(i = %i, j = %i)\n", i, j );
- printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ _mesa_printf( "-----------------------------\n" );
+ _mesa_printf( "(i = %i, j = %i)\n", i, j );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
d[i][0], r[i][0], r[i][0]/d[i][0],
MAX_PRECISION - significand_match( d[i][0], r[i][0] ) );
- printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
d[i][1], r[i][1], r[i][1]/d[i][1],
MAX_PRECISION - significand_match( d[i][1], r[i][1] ) );
- printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
d[i][2], r[i][2], r[i][2]/d[i][2],
MAX_PRECISION - significand_match( d[i][2], r[i][2] ) );
return 0;
if ( norm_normalize_types[mtype] != 0 ) {
if ( significand_match( d2[i][j], r2[i][j] ) < REQUIRED_PRECISION ) {
- printf( "------------------- precalculated length case ------\n" );
- printf( "(i = %i, j = %i)\n", i, j );
- printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ _mesa_printf( "------------------- precalculated length case ------\n" );
+ _mesa_printf( "(i = %i, j = %i)\n", i, j );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
d2[i][0], r2[i][0], r2[i][0]/d2[i][0],
MAX_PRECISION - significand_match( d2[i][0], r2[i][0] ) );
- printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
d2[i][1], r2[i][1], r2[i][1]/d2[i][1],
MAX_PRECISION - significand_match( d2[i][1], r2[i][1] ) );
- printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
d2[i][2], r2[i][2], r2[i][2]/d2[i][2],
MAX_PRECISION - significand_match( d2[i][2], r2[i][2] ) );
return 0;
if ( first_time ) {
first_time = 0;
- mesa_profile = getenv( "MESA_PROFILE" );
+ mesa_profile = _mesa_getenv( "MESA_PROFILE" );
}
#ifdef RUN_DEBUG_BENCHMARK
if ( mesa_profile ) {
if ( !counter_overhead ) {
INIT_COUNTER();
- printf( "counter overhead: %ld cycles\n\n", counter_overhead );
+ _mesa_printf( "counter overhead: %ld cycles\n\n", counter_overhead );
}
- printf( "normal transform results after hooking in %s functions:\n",
+ _mesa_printf( "normal transform results after hooking in %s functions:\n",
description );
- printf( "\n-------------------------------------------------------\n" );
+ _mesa_printf( "\n-------------------------------------------------------\n" );
}
#endif
if ( test_norm_function( func, mtype, cycles ) == 0 ) {
char buf[100];
- sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)",
+ _mesa_sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)",
norm_strings[mtype], description );
_mesa_problem( NULL, buf );
}
#ifdef RUN_DEBUG_BENCHMARK
if ( mesa_profile ) {
- printf( " %li\t", benchmark_tab[mtype] );
- printf( " | [%s]\n", norm_strings[mtype] );
+ _mesa_printf( " %li\t", benchmark_tab[mtype] );
+ _mesa_printf( " | [%s]\n", norm_strings[mtype] );
}
#endif
}
#ifdef RUN_DEBUG_BENCHMARK
if ( mesa_profile ) {
- printf( "\n" );
- fflush( stdout );
+ _mesa_printf( "\n" );
}
#endif
}
-#endif /* DEBUG */
+#endif /* DEBUG_MATH */