summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/tgsi/tgsi_sse2.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-08-22 15:16:43 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-08-22 15:16:43 -0600
commit1c2ff4d9e65563c071747a9c3bd907bd24706da0 (patch)
treedc80f03cf5f137bb604f2faeb35926f85fba3f2e /src/gallium/auxiliary/tgsi/tgsi_sse2.c
parent07bebb839d8f5e35209c446133743892084a672c (diff)
gallium: use new util_fast_exp2(), _log2(), pow() functions
New code surrounded with #if FAST_MATH to allow comparing against original code if we need to debug.
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_sse2.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 485e5a0e6f..e390607023 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -27,6 +27,7 @@
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi_exec.h"
@@ -42,6 +43,8 @@
*/
#define HIGH_PRECISION 1
+#define FAST_MATH 1
+
#define FOR_EACH_CHANNEL( CHAN )\
for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
@@ -623,10 +626,17 @@ ex24f(
{
const unsigned X = 0;
+#if FAST_MATH
+ store[X + 0] = util_fast_exp2( store[X + 0] );
+ store[X + 1] = util_fast_exp2( store[X + 1] );
+ store[X + 2] = util_fast_exp2( store[X + 2] );
+ store[X + 3] = util_fast_exp2( store[X + 3] );
+#else
store[X + 0] = powf( 2.0f, store[X + 0] );
store[X + 1] = powf( 2.0f, store[X + 1] );
store[X + 2] = powf( 2.0f, store[X + 2] );
store[X + 3] = powf( 2.0f, store[X + 3] );
+#endif
}
static void
@@ -762,10 +772,17 @@ pow4f(
{
const unsigned X = 0;
+#if FAST_MATH
+ store[X + 0] = util_fast_pow( store[X + 0], store[X + 4] );
+ store[X + 1] = util_fast_pow( store[X + 1], store[X + 5] );
+ store[X + 2] = util_fast_pow( store[X + 2], store[X + 6] );
+ store[X + 3] = util_fast_pow( store[X + 3], store[X + 7] );
+#else
store[X + 0] = powf( store[X + 0], store[X + 4] );
store[X + 1] = powf( store[X + 1], store[X + 5] );
store[X + 2] = powf( store[X + 2], store[X + 6] );
store[X + 3] = powf( store[X + 3], store[X + 7] );
+#endif
}
static void
@@ -2235,6 +2252,8 @@ tgsi_emit_sse2(
unsigned ok = 1;
uint num_immediates = 0;
+ util_init_math();
+
func->csr = func->store;
tgsi_parse_init( &parse, tokens );