summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/tgsi/tgsi_sse2.c
diff options
context:
space:
mode:
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 );