summaryrefslogtreecommitdiffstats
path: root/src/mesa/math
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-05-07 16:59:58 +0000
committerBrian Paul <[email protected]>2005-05-07 16:59:58 +0000
commit42fa81275c67d7d1ad8d255120af0ffeeb46b963 (patch)
tree1c786fb74f62263d6a1a312178bcef74daeffa5e /src/mesa/math
parente3f684b753c94d8657a1487655b41fdfc0119dba (diff)
x86-64 transform optimizations (Mikko T.)
Diffstat (limited to 'src/mesa/math')
-rw-r--r--src/mesa/math/m_debug_util.h38
-rw-r--r--src/mesa/math/m_debug_xform.c10
-rw-r--r--src/mesa/math/m_xform.c6
3 files changed, 49 insertions, 5 deletions
diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h
index c07cdcf7ba7..765f54dfb5a 100644
--- a/src/mesa/math/m_debug_util.h
+++ b/src/mesa/math/m_debug_util.h
@@ -185,6 +185,44 @@ extern char *mesa_profile;
#endif
+#elif defined(__amd64__)
+
+#define rdtscll(val) do { \
+ unsigned int a,d; \
+ __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); \
+ (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
+} while(0)
+
+/* Copied from i386 PIII version */
+#define INIT_COUNTER() \
+ do { \
+ int cycle_i; \
+ counter_overhead = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \
+ unsigned long cycle_tmp1, cycle_tmp2; \
+ rdtscll(cycle_tmp1); \
+ rdtscll(cycle_tmp2); \
+ if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \
+ counter_overhead = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } \
+ } while (0)
+
+
+#define BEGIN_RACE(x) \
+ x = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \
+ unsigned long cycle_tmp1, cycle_tmp2; \
+ rdtscll(cycle_tmp1); \
+
+#define END_RACE(x) \
+ rdtscll(cycle_tmp2); \
+ if ( x > (cycle_tmp2 - cycle_tmp1) ) { \
+ x = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } \
+ x -= counter_overhead;
+
#elif defined(__sparc__)
#define INIT_COUNTER() \
diff --git a/src/mesa/math/m_debug_xform.c b/src/mesa/math/m_debug_xform.c
index b634527b24d..d8250f246ef 100644
--- a/src/mesa/math/m_debug_xform.c
+++ b/src/mesa/math/m_debug_xform.c
@@ -166,7 +166,7 @@ ALIGN16(static GLfloat, d[TEST_COUNT][4]);
ALIGN16(static GLfloat, r[TEST_COUNT][4]);
static int test_transform_function( transform_func func, int psize,
- int mtype, long *cycles )
+ int mtype, unsigned long *cycles )
{
GLvector4f source[1], dest[1], ref[1];
GLmatrix mat[1];
@@ -187,7 +187,7 @@ static int test_transform_function( transform_func func, int psize,
mat->type = mtypes[mtype];
m = mat->m;
- ASSERT( ((GLuint)m & 15) == 0 );
+ ASSERT( ((long)m & 15) == 0 );
init_matrix( m );
@@ -279,7 +279,7 @@ static int test_transform_function( transform_func func, int psize,
void _math_test_all_transform_functions( char *description )
{
int psize, mtype;
- long benchmark_tab[4][7];
+ unsigned long benchmark_tab[4][7];
static int first_time = 1;
if ( first_time ) {
@@ -291,7 +291,7 @@ void _math_test_all_transform_functions( char *description )
if ( mesa_profile ) {
if ( !counter_overhead ) {
INIT_COUNTER();
- _mesa_printf("counter overhead: %ld cycles\n\n", counter_overhead );
+ _mesa_printf("counter overhead: %lu cycles\n\n", counter_overhead );
}
_mesa_printf("transform results after hooking in %s functions:\n", description );
}
@@ -310,7 +310,7 @@ void _math_test_all_transform_functions( char *description )
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]);
+ unsigned long *cycles = &(benchmark_tab[psize-1][mtype]);
if ( test_transform_function( func, psize, mtype, cycles ) == 0 ) {
char buf[100];
diff --git a/src/mesa/math/m_xform.c b/src/mesa/math/m_xform.c
index 66dc44d9541..5366e34989c 100644
--- a/src/mesa/math/m_xform.c
+++ b/src/mesa/math/m_xform.c
@@ -51,6 +51,10 @@
#include "x86/common_x86_asm.h"
#endif
+#ifdef USE_X86_64_ASM
+#include "x86-64/x86-64.h"
+#endif
+
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
#endif
@@ -212,6 +216,8 @@ _math_init_transformation( void )
_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
}