/shark/trunk/ports/mesa/src/math/m_debug_xform.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/math/m_xform_tmp.h |
---|
File deleted |
/shark/trunk/ports/mesa/src/math/m_debug_norm.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/math/m_debug_clip.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/math/m_xform.c |
---|
1,4 → 1,4 |
/* $Id: m_xform.c,v 1.2 2003-03-13 12:20:29 giacomo Exp $ */ |
/* $Id: m_xform.c,v 1.3 2003-04-24 13:37:47 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
81,7 → 81,7 |
#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_tmp_xform.h" |
#include "m_clip_tmp.h" |
#include "m_norm_tmp.h" |
#include "m_dotprod_tmp.h" |
/shark/trunk/ports/mesa/src/math/m_clip_debug.c |
---|
0,0 → 1,367 |
/* $Id: m_clip_debug.c,v 1.1 2003-04-24 13:37:46 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 5.0 |
* |
* Copyright (C) 1999-2001 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"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
* |
* Authors: |
* Gareth Hughes |
*/ |
#include "glheader.h" |
#include "context.h" |
#include "macros.h" |
#include "imports.h" |
#include "m_matrix.h" |
#include "m_xform.h" |
#include "m_debug.h" |
#include "m_debug_util.h" |
#ifdef DEBUG /* This code only used for debugging */ |
static clip_func *clip_tab[2] = { |
_mesa_clip_tab, |
_mesa_clip_np_tab |
}; |
static char *cnames[2] = { |
"_mesa_clip_tab", |
"_mesa_clip_np_tab" |
}; |
#ifdef RUN_DEBUG_BENCHMARK |
static char *cstrings[2] = { |
"clip, perspective divide", |
"clip, no divide" |
}; |
#endif |
/* ============================================================= |
* Reference cliptests |
*/ |
static GLvector4f *ref_cliptest_points4( GLvector4f *clip_vec, |
GLvector4f *proj_vec, |
GLubyte clipMask[], |
GLubyte *orMask, |
GLubyte *andMask ) |
{ |
const GLuint stride = clip_vec->stride; |
const GLuint count = clip_vec->count; |
const GLfloat *from = (GLfloat *)clip_vec->start; |
GLuint c = 0; |
GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start; |
GLubyte tmpAndMask = *andMask; |
GLubyte tmpOrMask = *orMask; |
GLuint i; |
for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) { |
const GLfloat cx = from[0]; |
const GLfloat cy = from[1]; |
const GLfloat cz = from[2]; |
const GLfloat cw = from[3]; |
GLubyte mask = 0; |
if ( -cx + cw < 0 ) mask |= CLIP_RIGHT_BIT; |
if ( cx + cw < 0 ) mask |= CLIP_LEFT_BIT; |
if ( -cy + cw < 0 ) mask |= CLIP_TOP_BIT; |
if ( cy + cw < 0 ) mask |= CLIP_BOTTOM_BIT; |
if ( -cz + cw < 0 ) mask |= CLIP_FAR_BIT; |
if ( cz + cw < 0 ) mask |= CLIP_NEAR_BIT; |
clipMask[i] = mask; |
if ( mask ) { |
c++; |
tmpAndMask &= mask; |
tmpOrMask |= mask; |
vProj[i][0] = 0; |
vProj[i][1] = 0; |
vProj[i][2] = 0; |
vProj[i][3] = 1; |
} else { |
GLfloat oow = 1.0F / cw; |
vProj[i][0] = cx * oow; |
vProj[i][1] = cy * oow; |
vProj[i][2] = cz * oow; |
vProj[i][3] = oow; |
} |
} |
*orMask = tmpOrMask; |
*andMask = (GLubyte) (c < count ? 0 : tmpAndMask); |
proj_vec->flags |= VEC_SIZE_4; |
proj_vec->size = 4; |
proj_vec->count = clip_vec->count; |
return proj_vec; |
} |
/* Keep these here for now, even though we don't use them... |
*/ |
static GLvector4f *ref_cliptest_points3( GLvector4f *clip_vec, |
GLvector4f *proj_vec, |
GLubyte clipMask[], |
GLubyte *orMask, |
GLubyte *andMask ) |
{ |
const GLuint stride = clip_vec->stride; |
const GLuint count = clip_vec->count; |
const GLfloat *from = (GLfloat *)clip_vec->start; |
GLubyte tmpOrMask = *orMask; |
GLubyte tmpAndMask = *andMask; |
GLuint i; |
for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) { |
const GLfloat cx = from[0], cy = from[1], cz = from[2]; |
GLubyte mask = 0; |
if ( cx > 1.0 ) mask |= CLIP_RIGHT_BIT; |
else if ( cx < -1.0 ) mask |= CLIP_LEFT_BIT; |
if ( cy > 1.0 ) mask |= CLIP_TOP_BIT; |
else if ( cy < -1.0 ) mask |= CLIP_BOTTOM_BIT; |
if ( cz > 1.0 ) mask |= CLIP_FAR_BIT; |
else if ( cz < -1.0 ) mask |= CLIP_NEAR_BIT; |
clipMask[i] = mask; |
tmpOrMask |= mask; |
tmpAndMask &= mask; |
} |
*orMask = tmpOrMask; |
*andMask = tmpAndMask; |
return clip_vec; |
} |
static GLvector4f * ref_cliptest_points2( GLvector4f *clip_vec, |
GLvector4f *proj_vec, |
GLubyte clipMask[], |
GLubyte *orMask, |
GLubyte *andMask ) |
{ |
const GLuint stride = clip_vec->stride; |
const GLuint count = clip_vec->count; |
const GLfloat *from = (GLfloat *)clip_vec->start; |
GLubyte tmpOrMask = *orMask; |
GLubyte tmpAndMask = *andMask; |
GLuint i; |
for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) { |
const GLfloat cx = from[0], cy = from[1]; |
GLubyte mask = 0; |
if ( cx > 1.0 ) mask |= CLIP_RIGHT_BIT; |
else if ( cx < -1.0 ) mask |= CLIP_LEFT_BIT; |
if ( cy > 1.0 ) mask |= CLIP_TOP_BIT; |
else if ( cy < -1.0 ) mask |= CLIP_BOTTOM_BIT; |
clipMask[i] = mask; |
tmpOrMask |= mask; |
tmpAndMask &= mask; |
} |
*orMask = tmpOrMask; |
*andMask = tmpAndMask; |
return clip_vec; |
} |
static clip_func ref_cliptest[5] = { |
0, |
0, |
ref_cliptest_points2, |
ref_cliptest_points3, |
ref_cliptest_points4 |
}; |
/* ============================================================= |
* Cliptest tests |
*/ |
static GLfloat s[TEST_COUNT][4] ALIGN16; |
static GLfloat d[TEST_COUNT][4] ALIGN16; |
static GLfloat r[TEST_COUNT][4] ALIGN16; |
static int test_cliptest_function( clip_func func, int np, |
int psize, long *cycles ) |
{ |
GLvector4f source[1], dest[1], ref[1]; |
GLubyte dm[TEST_COUNT], dco, dca; |
GLubyte rm[TEST_COUNT], rco, rca; |
int i, j; |
#ifdef RUN_DEBUG_BENCHMARK |
int cycle_i; /* the counter for the benchmarks we run */ |
#endif |
(void) cycles; |
if ( psize > 4 ) { |
_mesa_problem( NULL, "test_cliptest_function called with psize > 4\n" ); |
return 0; |
} |
for ( i = 0 ; i < TEST_COUNT ; i++) { |
ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 ); |
ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 ); |
for ( j = 0 ; j < psize ; j++ ) |
s[i][j] = rnd(); |
} |
source->data = (GLfloat(*)[4])s; |
source->start = (GLfloat *)s; |
source->count = TEST_COUNT; |
source->stride = sizeof(s[0]); |
source->size = 4; |
source->flags = 0; |
dest->data = (GLfloat(*)[4])d; |
dest->start = (GLfloat *)d; |
dest->count = TEST_COUNT; |
dest->stride = sizeof(float[4]); |
dest->size = 0; |
dest->flags = 0; |
ref->data = (GLfloat(*)[4])r; |
ref->start = (GLfloat *)r; |
ref->count = TEST_COUNT; |
ref->stride = sizeof(float[4]); |
ref->size = 0; |
ref->flags = 0; |
dco = rco = 0; |
dca = rca = CLIP_ALL_BITS; |
ref_cliptest[psize]( source, ref, rm, &rco, &rca ); |
if ( mesa_profile ) { |
BEGIN_RACE( *cycles ); |
func( source, dest, dm, &dco, &dca ); |
END_RACE( *cycles ); |
} |
else { |
func( source, dest, dm, &dco, &dca ); |
} |
if ( dco != rco ) { |
_mesa_printf(NULL, "\n-----------------------------\n" ); |
_mesa_printf(NULL, "dco = 0x%02x rco = 0x%02x\n", dco, rco ); |
return 0; |
} |
if ( dca != rca ) { |
_mesa_printf(NULL, "\n-----------------------------\n" ); |
_mesa_printf(NULL, "dca = 0x%02x rca = 0x%02x\n", dca, rca ); |
return 0; |
} |
for ( i = 0 ; i < TEST_COUNT ; i++ ) { |
if ( dm[i] != rm[i] ) { |
_mesa_printf(NULL, "\n-----------------------------\n" ); |
_mesa_printf(NULL, "(i = %i)\n", i ); |
_mesa_printf(NULL, "dm = 0x%02x rm = 0x%02x\n", dm[i], rm[i] ); |
return 0; |
} |
} |
/* Only verify output on projected points4 case. FIXME: Do we need |
* to test other cases? |
*/ |
if ( np || psize < 4 ) |
return 1; |
for ( i = 0 ; i < TEST_COUNT ; i++ ) { |
for ( j = 0 ; j < 4 ; j++ ) { |
if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { |
_mesa_printf(NULL, "\n-----------------------------\n" ); |
_mesa_printf(NULL, "(i = %i, j = %i) dm = 0x%02x rm = 0x%02x\n", |
i, j, dm[i], rm[i] ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %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] ) ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %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] ) ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %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] ) ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %e - %i bit missed]\n", |
d[i][3], r[i][3], r[i][3]-d[i][3], |
MAX_PRECISION - significand_match( d[i][3], r[i][3] ) ); |
return 0; |
} |
} |
} |
return 1; |
} |
void _math_test_all_cliptest_functions( char *description ) |
{ |
int np, psize; |
long benchmark_tab[2][4]; |
static int first_time = 1; |
if ( first_time ) { |
first_time = 0; |
mesa_profile = _mesa_getenv( "MESA_PROFILE" ); |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
if ( !counter_overhead ) { |
INIT_COUNTER(); |
_mesa_printf(NULL, "counter overhead: %ld cycles\n\n", counter_overhead ); |
} |
_mesa_printf(NULL, "cliptest results after hooking in %s functions:\n", description ); |
} |
#endif |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
_mesa_printf(NULL, "\n\t" ); |
for ( psize = 2 ; psize <= 4 ; psize++ ) { |
_mesa_printf(NULL, " p%d\t", psize ); |
} |
_mesa_printf(NULL, "\n--------------------------------------------------------\n\t" ); |
} |
#endif |
for ( np = 0 ; np < 2 ; np++ ) { |
for ( psize = 2 ; psize <= 4 ; psize++ ) { |
clip_func func = clip_tab[np][psize]; |
long *cycles = &(benchmark_tab[np][psize-1]); |
if ( test_cliptest_function( func, np, psize, cycles ) == 0 ) { |
char buf[100]; |
_mesa_sprintf(NULL, buf, "%s[%d] failed test (%s)", |
cnames[np], psize, description ); |
_mesa_problem( NULL, buf ); |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) |
_mesa_printf(NULL, " %li\t", benchmark_tab[np][psize-1] ); |
#endif |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) |
_mesa_printf(NULL, " | [%s]\n\t", cstrings[np] ); |
#endif |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) |
_mesa_printf(NULL, "\n" ); |
#endif |
} |
#endif /* DEBUG */ |
/shark/trunk/ports/mesa/src/math/m_xform_debug.c |
---|
0,0 → 1,335 |
/* $Id: m_xform_debug.c,v 1.1 2003-04-24 13:37:47 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 3.5 |
* |
* Copyright (C) 1999-2001 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"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
*/ |
/* |
* Updated for P6 architecture by Gareth Hughes. |
*/ |
#include "glheader.h" |
#include "context.h" |
#include "macros.h" |
#include "imports.h" |
#include "m_matrix.h" |
#include "m_xform.h" |
#include "m_debug.h" |
#include "m_debug_util.h" |
#ifdef DEBUG /* This code only used for debugging */ |
/* Overhead of profiling counter in cycles. Automatically adjusted to |
* your machine at run time - counter initialization should give very |
* consistent results. |
*/ |
long counter_overhead = 0; |
/* This is the value of the environment variable MESA_PROFILE, and is |
* used to determine if we should benchmark the functions as well as |
* verify their correctness. |
*/ |
char *mesa_profile = NULL; |
static int m_general[16] = { |
VAR, VAR, VAR, VAR, |
VAR, VAR, VAR, VAR, |
VAR, VAR, VAR, VAR, |
VAR, VAR, VAR, VAR |
}; |
static int m_identity[16] = { |
ONE, NIL, NIL, NIL, |
NIL, ONE, NIL, NIL, |
NIL, NIL, ONE, NIL, |
NIL, NIL, NIL, ONE |
}; |
static int m_2d[16] = { |
VAR, VAR, NIL, VAR, |
VAR, VAR, NIL, VAR, |
NIL, NIL, ONE, NIL, |
NIL, NIL, NIL, ONE |
}; |
static int m_2d_no_rot[16] = { |
VAR, NIL, NIL, VAR, |
NIL, VAR, NIL, VAR, |
NIL, NIL, ONE, NIL, |
NIL, NIL, NIL, ONE |
}; |
static int m_3d[16] = { |
VAR, VAR, VAR, VAR, |
VAR, VAR, VAR, VAR, |
VAR, VAR, VAR, VAR, |
NIL, NIL, NIL, ONE |
}; |
static int m_3d_no_rot[16] = { |
VAR, NIL, NIL, VAR, |
NIL, VAR, NIL, VAR, |
NIL, NIL, VAR, VAR, |
NIL, NIL, NIL, ONE |
}; |
static int m_perspective[16] = { |
VAR, NIL, VAR, NIL, |
NIL, VAR, VAR, NIL, |
NIL, NIL, VAR, VAR, |
NIL, NIL, NEG, NIL |
}; |
static int *templates[7] = { |
m_general, |
m_identity, |
m_3d_no_rot, |
m_perspective, |
m_2d, |
m_2d_no_rot, |
m_3d |
}; |
static int mtypes[7] = { |
MATRIX_GENERAL, |
MATRIX_IDENTITY, |
MATRIX_3D_NO_ROT, |
MATRIX_PERSPECTIVE, |
MATRIX_2D, |
MATRIX_2D_NO_ROT, |
MATRIX_3D |
}; |
static char *mstrings[7] = { |
"MATRIX_GENERAL", |
"MATRIX_IDENTITY", |
"MATRIX_3D_NO_ROT", |
"MATRIX_PERSPECTIVE", |
"MATRIX_2D", |
"MATRIX_2D_NO_ROT", |
"MATRIX_3D" |
}; |
/* ============================================================= |
* Reference transformations |
*/ |
static void ref_transform( GLvector4f *dst, |
const GLmatrix *mat, |
const GLvector4f *src ) |
{ |
GLuint i; |
GLfloat *s = (GLfloat *)src->start; |
GLfloat (*d)[4] = (GLfloat (*)[4])dst->start; |
const GLfloat *m = mat->m; |
for ( i = 0 ; i < src->count ; i++ ) { |
TRANSFORM_POINT( d[i], m, s ); |
s = (GLfloat *)((char *)s + src->stride); |
} |
} |
/* ============================================================= |
* Vertex 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 GLfloat s[TEST_COUNT][4] ALIGN16; |
static GLfloat d[TEST_COUNT][4] ALIGN16; |
static GLfloat r[TEST_COUNT][4] ALIGN16; |
static int test_transform_function( transform_func func, int psize, |
int mtype, long *cycles ) |
{ |
GLvector4f source[1], dest[1], ref[1]; |
GLmatrix mat[1]; |
GLfloat *m; |
int i, j; |
#ifdef RUN_DEBUG_BENCHMARK |
int cycle_i; /* the counter for the benchmarks we run */ |
#endif |
(void) cycles; |
if ( psize > 4 ) { |
_mesa_problem( NULL, "test_transform_function called with psize > 4\n" ); |
return 0; |
} |
mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 ); |
mat->type = mtypes[mtype]; |
m = mat->m; |
ASSERT( ((GLuint)m & 15) == 0 ); |
init_matrix( m ); |
for ( i = 0 ; i < 4 ; i++ ) { |
for ( j = 0 ; j < 4 ; j++ ) { |
switch ( templates[mtype][i * 4 + j] ) { |
case NIL: |
m[j * 4 + i] = 0.0; |
break; |
case ONE: |
m[j * 4 + i] = 1.0; |
break; |
case NEG: |
m[j * 4 + i] = -1.0; |
break; |
case VAR: |
break; |
default: |
abort(); |
} |
} |
} |
for ( i = 0 ; i < TEST_COUNT ; i++) { |
ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 ); |
ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 ); |
for ( j = 0 ; j < psize ; j++ ) |
s[i][j] = rnd(); |
} |
source->data = (GLfloat(*)[4])s; |
source->start = (GLfloat *)s; |
source->count = TEST_COUNT; |
source->stride = sizeof(s[0]); |
source->size = 4; |
source->flags = 0; |
dest->data = (GLfloat(*)[4])d; |
dest->start = (GLfloat *)d; |
dest->count = TEST_COUNT; |
dest->stride = sizeof(float[4]); |
dest->size = 0; |
dest->flags = 0; |
ref->data = (GLfloat(*)[4])r; |
ref->start = (GLfloat *)r; |
ref->count = TEST_COUNT; |
ref->stride = sizeof(float[4]); |
ref->size = 0; |
ref->flags = 0; |
ref_transform( ref, mat, source ); |
if ( mesa_profile ) { |
BEGIN_RACE( *cycles ); |
func( dest, mat->m, source ); |
END_RACE( *cycles ); |
} |
else { |
func( dest, mat->m, source ); |
} |
for ( i = 0 ; i < TEST_COUNT ; i++ ) { |
for ( j = 0 ; j < 4 ; j++ ) { |
if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { |
_mesa_printf(NULL, "-----------------------------\n" ); |
_mesa_printf(NULL, "(i = %i, j = %i)\n", i, j ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %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] ) ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %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] ) ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %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] ) ); |
_mesa_printf(NULL, "%f \t %f \t [diff = %e - %i bit missed]\n", |
d[i][3], r[i][3], r[i][3]-d[i][3], |
MAX_PRECISION - significand_match( d[i][3], r[i][3] ) ); |
return 0; |
} |
} |
} |
ALIGN_FREE( mat->m ); |
return 1; |
} |
void _math_test_all_transform_functions( char *description ) |
{ |
int psize, mtype; |
long benchmark_tab[4][7]; |
static int first_time = 1; |
if ( first_time ) { |
first_time = 0; |
mesa_profile = getenv( "MESA_PROFILE" ); |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
if ( !counter_overhead ) { |
INIT_COUNTER(); |
_mesa_printf(NULL, "counter overhead: %ld cycles\n\n", counter_overhead ); |
} |
_mesa_printf(NULL, "transform results after hooking in %s functions:\n", description ); |
} |
#endif |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
_mesa_printf(NULL, "\n" ); |
for ( psize = 1 ; psize <= 4 ; psize++ ) { |
_mesa_printf(NULL, " p%d\t", psize ); |
} |
_mesa_printf(NULL, "\n--------------------------------------------------------\n" ); |
} |
#endif |
for ( mtype = 0 ; mtype < 7 ; mtype++ ) { |
for ( psize = 1 ; psize <= 4 ; psize++ ) { |
transform_func func = _mesa_transform_tab[psize][mtypes[mtype]]; |
long *cycles = &(benchmark_tab[psize-1][mtype]); |
if ( test_transform_function( func, psize, mtype, cycles ) == 0 ) { |
char buf[100]; |
_mesa_sprintf(NULL, buf, "_mesa_transform_tab[0][%d][%s] failed test (%s)", |
psize, mstrings[mtype], description ); |
_mesa_problem( NULL, buf ); |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) |
_mesa_printf(NULL, " %li\t", benchmark_tab[psize-1][mtype] ); |
#endif |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) |
_mesa_printf(NULL, " | [%s]\n", mstrings[mtype] ); |
#endif |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) |
_mesa_printf(NULL, "\n" ); |
#endif |
} |
#endif /* DEBUG */ |
/shark/trunk/ports/mesa/src/math/m_tmp_xform.h |
---|
0,0 → 1,807 |
/* $Id: m_tmp_xform.h,v 1.1 2003-04-24 13:37:47 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 3.5 |
* |
* Copyright (C) 1999-2001 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"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
*/ |
/* |
* New (3.1) transformation code written by Keith Whitwell. |
*/ |
/*---------------------------------------------------------------------- |
* Begin Keith's new code |
* |
*---------------------------------------------------------------------- |
*/ |
/* KW: Fixed stride, now measured in bytes as is the OpenGL array stride. |
*/ |
/* KW: These are now parameterized to produce two versions, one |
* which transforms all incoming points, and a second which |
* takes notice of a cullmask array, and only transforms |
* unculled vertices. |
*/ |
/* KW: 1-vectors can sneak into the texture pipeline via the array |
* interface. These functions are here because I want consistant |
* treatment of the vertex sizes and a lazy strategy for |
* cleaning unused parts of the vector, and so as not to exclude |
* them from the vertex array interface. |
* |
* Under our current analysis of matrices, there is no way that |
* the product of a matrix and a 1-vector can remain a 1-vector, |
* with the exception of the identity transform. |
*/ |
/* KW: No longer zero-pad outgoing vectors. Now that external |
* vectors can get into the pipeline we cannot ever assume |
* that there is more to a vector than indicated by its |
* size. |
*/ |
/* KW: Now uses clipmask and a flag to allow us to skip both/either |
* cliped and/or culled vertices. |
*/ |
/* GH: Not any more -- it's easier (and faster) to just process the |
* entire vector. Clipping and culling are handled further down |
* the pipe, most often during or after the conversion to some |
* driver-specific vertex format. |
*/ |
static void _XFORMAPI |
TAG(transform_points1_general)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m12 = m[12]; |
const GLfloat m1 = m[1], m13 = m[13]; |
const GLfloat m2 = m[2], m14 = m[14]; |
const GLfloat m3 = m[3], m15 = m[15]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m1 * ox + m13; |
to[i][2] = m2 * ox + m14; |
to[i][3] = m3 * ox + m15; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points1_identity)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLuint count = from_vec->count; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint i; |
if (to_vec == from_vec) return; |
STRIDE_LOOP { |
to[i][0] = from[0]; |
} |
to_vec->size = 1; |
to_vec->flags |= VEC_SIZE_1; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points1_2d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1]; |
const GLfloat m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m1 * ox + m13; |
} |
to_vec->size = 2; |
to_vec->flags |= VEC_SIZE_2; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m13; |
} |
to_vec->size = 2; |
to_vec->flags |= VEC_SIZE_2; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points1_3d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2]; |
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m1 * ox + m13; |
to[i][2] = m2 * ox + m14; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0]; |
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m13; |
to[i][2] = m14; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points1_perspective)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0]; |
to[i][0] = m0 * ox ; |
to[i][1] = 0 ; |
to[i][2] = m14; |
to[i][3] = 0; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
/* 2-vectors, which are a lot more relevant than 1-vectors, are |
* present early in the geometry pipeline and throughout the |
* texture pipeline. |
*/ |
static void _XFORMAPI |
TAG(transform_points2_general)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m4 = m[4], m12 = m[12]; |
const GLfloat m1 = m[1], m5 = m[5], m13 = m[13]; |
const GLfloat m2 = m[2], m6 = m[6], m14 = m[14]; |
const GLfloat m3 = m[3], m7 = m[7], m15 = m[15]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1]; |
to[i][0] = m0 * ox + m4 * oy + m12; |
to[i][1] = m1 * ox + m5 * oy + m13; |
to[i][2] = m2 * ox + m6 * oy + m14; |
to[i][3] = m3 * ox + m7 * oy + m15; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points2_identity)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
GLuint i; |
if (to_vec == from_vec) return; |
STRIDE_LOOP { |
to[i][0] = from[0]; |
to[i][1] = from[1]; |
} |
to_vec->size = 2; |
to_vec->flags |= VEC_SIZE_2; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points2_2d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; |
const GLfloat m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1]; |
to[i][0] = m0 * ox + m4 * oy + m12; |
to[i][1] = m1 * ox + m5 * oy + m13; |
} |
to_vec->size = 2; |
to_vec->flags |= VEC_SIZE_2; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m5 * oy + m13; |
} |
to_vec->size = 2; |
to_vec->flags |= VEC_SIZE_2; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points2_3d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; |
const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1]; |
to[i][0] = m0 * ox + m4 * oy + m12; |
to[i][1] = m1 * ox + m5 * oy + m13; |
to[i][2] = m2 * ox + m6 * oy + m14; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
/* I would actually say this was a fairly important function, from |
* a texture transformation point of view. |
*/ |
static void _XFORMAPI |
TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5]; |
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1]; |
to[i][0] = m0 * ox + m12; |
to[i][1] = m5 * oy + m13; |
to[i][2] = m14; |
} |
if (m14 == 0) { |
to_vec->size = 2; |
to_vec->flags |= VEC_SIZE_2; |
} else { |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
} |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points2_perspective)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1]; |
to[i][0] = m0 * ox ; |
to[i][1] = m5 * oy ; |
to[i][2] = m14; |
to[i][3] = 0; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points3_general)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; |
const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; |
const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; |
const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2]; |
to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12; |
to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13; |
to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14; |
to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points3_identity)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
GLuint i; |
if (to_vec == from_vec) return; |
STRIDE_LOOP { |
to[i][0] = from[0]; |
to[i][1] = from[1]; |
to[i][2] = from[2]; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points3_2d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; |
const GLfloat m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2]; |
to[i][0] = m0 * ox + m4 * oy + m12 ; |
to[i][1] = m1 * ox + m5 * oy + m13 ; |
to[i][2] = + oz ; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2]; |
to[i][0] = m0 * ox + m12 ; |
to[i][1] = m5 * oy + m13 ; |
to[i][2] = + oz ; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points3_3d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; |
const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; |
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2]; |
to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 ; |
to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 ; |
to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 ; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
/* previously known as ortho... |
*/ |
static void _XFORMAPI |
TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5]; |
const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2]; |
to[i][0] = m0 * ox + m12 ; |
to[i][1] = m5 * oy + m13 ; |
to[i][2] = m10 * oz + m14 ; |
} |
to_vec->size = 3; |
to_vec->flags |= VEC_SIZE_3; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points3_perspective)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9]; |
const GLfloat m10 = m[10], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2]; |
to[i][0] = m0 * ox + m8 * oz ; |
to[i][1] = m5 * oy + m9 * oz ; |
to[i][2] = m10 * oz + m14 ; |
to[i][3] = -oz ; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_general)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12]; |
const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13]; |
const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14]; |
const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; |
to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow; |
to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow; |
to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow; |
to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15 * ow; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_identity)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
GLuint i; |
if (to_vec == from_vec) return; |
STRIDE_LOOP { |
to[i][0] = from[0]; |
to[i][1] = from[1]; |
to[i][2] = from[2]; |
to[i][3] = from[3]; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_2d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5]; |
const GLfloat m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; |
to[i][0] = m0 * ox + m4 * oy + m12 * ow; |
to[i][1] = m1 * ox + m5 * oy + m13 * ow; |
to[i][2] = + oz ; |
to[i][3] = ow; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; |
to[i][0] = m0 * ox + m12 * ow; |
to[i][1] = m5 * oy + m13 * ow; |
to[i][2] = + oz ; |
to[i][3] = ow; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_3d)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5]; |
const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10]; |
const GLfloat m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; |
to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow; |
to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow; |
to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow; |
to[i][3] = ow; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5]; |
const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; |
to[i][0] = m0 * ox + m12 * ow; |
to[i][1] = m5 * oy + m13 * ow; |
to[i][2] = m10 * oz + m14 * ow; |
to[i][3] = ow; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static void _XFORMAPI |
TAG(transform_points4_perspective)( GLvector4f *to_vec, |
const GLfloat m[16], |
const GLvector4f *from_vec ) |
{ |
const GLuint stride = from_vec->stride; |
GLfloat *from = from_vec->start; |
GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start; |
GLuint count = from_vec->count; |
const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9]; |
const GLfloat m10 = m[10], m14 = m[14]; |
GLuint i; |
STRIDE_LOOP { |
const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3]; |
to[i][0] = m0 * ox + m8 * oz ; |
to[i][1] = m5 * oy + m9 * oz ; |
to[i][2] = m10 * oz + m14 * ow ; |
to[i][3] = -oz ; |
} |
to_vec->size = 4; |
to_vec->flags |= VEC_SIZE_4; |
to_vec->count = from_vec->count; |
} |
static transform_func _XFORMAPI TAG(transform_tab_1)[7]; |
static transform_func _XFORMAPI TAG(transform_tab_2)[7]; |
static transform_func _XFORMAPI TAG(transform_tab_3)[7]; |
static transform_func _XFORMAPI TAG(transform_tab_4)[7]; |
/* Similar functions could be called several times, with more highly |
* optimized routines overwriting the arrays. This only occurs during |
* startup. |
*/ |
static void _XFORMAPI TAG(init_c_transformations)( void ) |
{ |
#define TAG_TAB _mesa_transform_tab |
#define TAG_TAB_1 TAG(transform_tab_1) |
#define TAG_TAB_2 TAG(transform_tab_2) |
#define TAG_TAB_3 TAG(transform_tab_3) |
#define TAG_TAB_4 TAG(transform_tab_4) |
TAG_TAB[1] = TAG_TAB_1; |
TAG_TAB[2] = TAG_TAB_2; |
TAG_TAB[3] = TAG_TAB_3; |
TAG_TAB[4] = TAG_TAB_4; |
/* 1-D points (ie texcoords) */ |
TAG_TAB_1[MATRIX_GENERAL] = TAG(transform_points1_general); |
TAG_TAB_1[MATRIX_IDENTITY] = TAG(transform_points1_identity); |
TAG_TAB_1[MATRIX_3D_NO_ROT] = TAG(transform_points1_3d_no_rot); |
TAG_TAB_1[MATRIX_PERSPECTIVE] = TAG(transform_points1_perspective); |
TAG_TAB_1[MATRIX_2D] = TAG(transform_points1_2d); |
TAG_TAB_1[MATRIX_2D_NO_ROT] = TAG(transform_points1_2d_no_rot); |
TAG_TAB_1[MATRIX_3D] = TAG(transform_points1_3d); |
/* 2-D points */ |
TAG_TAB_2[MATRIX_GENERAL] = TAG(transform_points2_general); |
TAG_TAB_2[MATRIX_IDENTITY] = TAG(transform_points2_identity); |
TAG_TAB_2[MATRIX_3D_NO_ROT] = TAG(transform_points2_3d_no_rot); |
TAG_TAB_2[MATRIX_PERSPECTIVE] = TAG(transform_points2_perspective); |
TAG_TAB_2[MATRIX_2D] = TAG(transform_points2_2d); |
TAG_TAB_2[MATRIX_2D_NO_ROT] = TAG(transform_points2_2d_no_rot); |
TAG_TAB_2[MATRIX_3D] = TAG(transform_points2_3d); |
/* 3-D points */ |
TAG_TAB_3[MATRIX_GENERAL] = TAG(transform_points3_general); |
TAG_TAB_3[MATRIX_IDENTITY] = TAG(transform_points3_identity); |
TAG_TAB_3[MATRIX_3D_NO_ROT] = TAG(transform_points3_3d_no_rot); |
TAG_TAB_3[MATRIX_PERSPECTIVE] = TAG(transform_points3_perspective); |
TAG_TAB_3[MATRIX_2D] = TAG(transform_points3_2d); |
TAG_TAB_3[MATRIX_2D_NO_ROT] = TAG(transform_points3_2d_no_rot); |
TAG_TAB_3[MATRIX_3D] = TAG(transform_points3_3d); |
/* 4-D points */ |
TAG_TAB_4[MATRIX_GENERAL] = TAG(transform_points4_general); |
TAG_TAB_4[MATRIX_IDENTITY] = TAG(transform_points4_identity); |
TAG_TAB_4[MATRIX_3D_NO_ROT] = TAG(transform_points4_3d_no_rot); |
TAG_TAB_4[MATRIX_PERSPECTIVE] = TAG(transform_points4_perspective); |
TAG_TAB_4[MATRIX_2D] = TAG(transform_points4_2d); |
TAG_TAB_4[MATRIX_2D_NO_ROT] = TAG(transform_points4_2d_no_rot); |
TAG_TAB_4[MATRIX_3D] = TAG(transform_points4_3d); |
#undef TAG_TAB |
#undef TAG_TAB_1 |
#undef TAG_TAB_2 |
#undef TAG_TAB_3 |
#undef TAG_TAB_4 |
} |
/shark/trunk/ports/mesa/src/math/m_norm_debug.c |
---|
0,0 → 1,381 |
/* $Id: m_norm_debug.c,v 1.1 2003-04-24 13:37:47 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 4.1 |
* |
* Copyright (C) 1999-2002 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"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
* |
* Authors: |
* Gareth Hughes |
*/ |
#include "glheader.h" |
#include "context.h" |
#include "macros.h" |
#include "imports.h" |
#include "mmath.h" |
#include "m_matrix.h" |
#include "m_xform.h" |
#include "m_debug.h" |
#include "m_debug_util.h" |
#ifdef DEBUG /* This code only used for debugging */ |
static int m_norm_identity[16] = { |
ONE, NIL, NIL, NIL, |
NIL, ONE, NIL, NIL, |
NIL, NIL, ONE, NIL, |
NIL, NIL, NIL, NIL |
}; |
static int m_norm_general[16] = { |
VAR, VAR, VAR, NIL, |
VAR, VAR, VAR, NIL, |
VAR, VAR, VAR, NIL, |
NIL, NIL, NIL, NIL |
}; |
static int m_norm_no_rot[16] = { |
VAR, NIL, NIL, NIL, |
NIL, VAR, NIL, NIL, |
NIL, NIL, VAR, NIL, |
NIL, NIL, NIL, NIL |
}; |
static int *norm_templates[8] = { |
m_norm_no_rot, |
m_norm_no_rot, |
m_norm_no_rot, |
m_norm_general, |
m_norm_general, |
m_norm_general, |
m_norm_identity, |
m_norm_identity |
}; |
static int norm_types[8] = { |
NORM_TRANSFORM_NO_ROT, |
NORM_TRANSFORM_NO_ROT | NORM_RESCALE, |
NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE, |
NORM_TRANSFORM, |
NORM_TRANSFORM | NORM_RESCALE, |
NORM_TRANSFORM | NORM_NORMALIZE, |
NORM_RESCALE, |
NORM_NORMALIZE |
}; |
static int norm_scale_types[8] = { /* rescale factor */ |
NIL, /* NIL disables rescaling */ |
VAR, |
NIL, |
NIL, |
VAR, |
NIL, |
VAR, |
NIL |
}; |
static int norm_normalize_types[8] = { /* normalizing ?? (no = 0) */ |
0, |
0, |
1, |
0, |
0, |
1, |
0, |
1 |
}; |
static char *norm_strings[8] = { |
"NORM_TRANSFORM_NO_ROT", |
"NORM_TRANSFORM_NO_ROT | NORM_RESCALE", |
"NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE", |
"NORM_TRANSFORM", |
"NORM_TRANSFORM | NORM_RESCALE", |
"NORM_TRANSFORM | NORM_NORMALIZE", |
"NORM_RESCALE", |
"NORM_NORMALIZE" |
}; |
/* ============================================================= |
* Reference transformations |
*/ |
static void ref_norm_transform_rescale( const GLmatrix *mat, |
GLfloat scale, |
const GLvector4f *in, |
const GLfloat *lengths, |
GLvector4f *dest ) |
{ |
GLuint i; |
const GLfloat *s = in->start; |
const GLfloat *m = mat->inv; |
GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start; |
(void) lengths; |
for ( i = 0 ; i < in->count ; i++ ) { |
GLfloat t[3]; |
TRANSFORM_NORMAL( t, s, m ); |
SCALE_SCALAR_3V( out[i], scale, t ); |
s = (GLfloat *)((char *)s + in->stride); |
} |
} |
static void ref_norm_transform_normalize( const GLmatrix *mat, |
GLfloat scale, |
const GLvector4f *in, |
const GLfloat *lengths, |
GLvector4f *dest ) |
{ |
GLuint i; |
const GLfloat *s = in->start; |
const GLfloat *m = mat->inv; |
GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start; |
for ( i = 0 ; i < in->count ; i++ ) { |
GLfloat t[3]; |
TRANSFORM_NORMAL( t, s, m ); |
if ( !lengths ) { |
GLfloat len = LEN_SQUARED_3FV( t ); |
if ( len > 1e-20 ) { |
/* Hmmm, don't know how we could test the precalculated |
* length case... |
*/ |
scale = 1.0 / sqrt( len ); |
SCALE_SCALAR_3V( out[i], scale, t ); |
} else { |
out[i][0] = out[i][1] = out[i][2] = 0; |
} |
} else { |
scale = lengths[i];; |
SCALE_SCALAR_3V( out[i], scale, t ); |
} |
s = (GLfloat *)((char *)s + in->stride); |
} |
} |
/* ============================================================= |
* 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 ) |
{ |
GLvector4f source[1], dest[1], dest2[1], ref[1], ref2[1]; |
GLmatrix mat[1]; |
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; |
#ifdef RUN_DEBUG_BENCHMARK |
int cycle_i; /* the counter for the benchmarks we run */ |
#endif |
(void) cycles; |
mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 ); |
mat->inv = m = mat->m; |
init_matrix( m ); |
scale = 1.0F + rnd () * norm_scale_types[mtype]; |
for ( i = 0 ; i < 4 ; i++ ) { |
for ( j = 0 ; j < 4 ; j++ ) { |
switch ( norm_templates[mtype][i * 4 + j] ) { |
case NIL: |
m[j * 4 + i] = 0.0; |
break; |
case ONE: |
m[j * 4 + i] = 1.0; |
break; |
case NEG: |
m[j * 4 + i] = -1.0; |
break; |
case VAR: |
break; |
default: |
abort(); |
} |
} |
} |
for ( i = 0 ; i < TEST_COUNT ; i++ ) { |
ASSIGN_3V( d[i], 0.0, 0.0, 0.0 ); |
ASSIGN_3V( s[i], 0.0, 0.0, 0.0 ); |
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] ) ); |
} |
source->data = (GLfloat(*)[4]) s; |
source->start = (GLfloat *) s; |
source->count = TEST_COUNT; |
source->stride = sizeof(s[0]); |
source->flags = 0; |
dest->data = d; |
dest->start = (GLfloat *) d; |
dest->count = TEST_COUNT; |
dest->stride = sizeof(float[4]); |
dest->flags = 0; |
dest2->data = d2; |
dest2->start = (GLfloat *) d2; |
dest2->count = TEST_COUNT; |
dest2->stride = sizeof(float[4]); |
dest2->flags = 0; |
ref->data = r; |
ref->start = (GLfloat *) r; |
ref->count = TEST_COUNT; |
ref->stride = sizeof(float[4]); |
ref->flags = 0; |
ref2->data = r2; |
ref2->start = (GLfloat *) r2; |
ref2->count = TEST_COUNT; |
ref2->stride = sizeof(float[4]); |
ref2->flags = 0; |
if ( norm_normalize_types[mtype] == 0 ) { |
ref_norm_transform_rescale( mat, scale, source, NULL, ref ); |
} else { |
ref_norm_transform_normalize( mat, scale, source, NULL, ref ); |
ref_norm_transform_normalize( mat, scale, source, length, ref2 ); |
} |
if ( mesa_profile ) { |
BEGIN_RACE( *cycles ); |
func( mat, scale, source, NULL, dest ); |
END_RACE( *cycles ); |
func( mat, scale, source, length, dest2 ); |
} else { |
func( mat, scale, source, NULL, dest ); |
func( mat, scale, source, length, dest2 ); |
} |
for ( i = 0 ; i < TEST_COUNT ; i++ ) { |
for ( j = 0 ; j < 3 ; j++ ) { |
if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { |
_mesa_printf(NULL, "-----------------------------\n" ); |
_mesa_printf(NULL, "(i = %i, j = %i)\n", i, j ); |
_mesa_printf(NULL, "%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] ) ); |
_mesa_printf(NULL, "%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] ) ); |
_mesa_printf(NULL, "%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 ) { |
_mesa_printf(NULL, "------------------- precalculated length case ------\n" ); |
_mesa_printf(NULL, "(i = %i, j = %i)\n", i, j ); |
_mesa_printf(NULL, "%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] ) ); |
_mesa_printf(NULL, "%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] ) ); |
_mesa_printf(NULL, "%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; |
} |
} |
} |
} |
ALIGN_FREE( mat->m ); |
return 1; |
} |
void _math_test_all_normal_transform_functions( char *description ) |
{ |
int mtype; |
long benchmark_tab[0xf]; |
static int first_time = 1; |
if ( first_time ) { |
first_time = 0; |
mesa_profile = getenv( "MESA_PROFILE" ); |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
if ( !counter_overhead ) { |
INIT_COUNTER(); |
_mesa_printf(NULL, "counter overhead: %ld cycles\n\n", counter_overhead ); |
} |
_mesa_printf(NULL, "normal transform results after hooking in %s functions:\n", |
description ); |
_mesa_printf(NULL, "\n-------------------------------------------------------\n" ); |
} |
#endif |
for ( mtype = 0 ; mtype < 8 ; mtype++ ) { |
normal_func func = _mesa_normal_tab[norm_types[mtype]]; |
long *cycles = &benchmark_tab[mtype]; |
if ( test_norm_function( func, mtype, cycles ) == 0 ) { |
char buf[100]; |
_mesa_sprintf(NULL, buf, "_mesa_normal_tab[0][%s] failed test (%s)", |
norm_strings[mtype], description ); |
_mesa_problem( NULL, buf ); |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
_mesa_printf(NULL, " %li\t", benchmark_tab[mtype] ); |
_mesa_printf(NULL, " | [%s]\n", norm_strings[mtype] ); |
} |
#endif |
} |
#ifdef RUN_DEBUG_BENCHMARK |
if ( mesa_profile ) { |
_mesa_printf(NULL, "\n" ); |
fflush( stdout ); |
} |
#endif |
} |
#endif /* DEBUG */ |