From 1347439a87a26f261ab07c914ea4e69965703ee2 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 13:54:28 +0100 Subject: [PATCH] tgsi: Implement OPCODE_SSG/SGN. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 18 +++++++++++++++++- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 7114119..65a0f39 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -840,6 +840,17 @@ micro_rnd( } static void +micro_sgn( + union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src ) +{ + dst->f[0] = src->f[0] < 0.0f ? -1.0f : src->f[0] > 0.0f ? 1.0f : 0.0f; + dst->f[1] = src->f[1] < 0.0f ? -1.0f : src->f[1] > 0.0f ? 1.0f : 0.0f; + dst->f[2] = src->f[2] < 0.0f ? -1.0f : src->f[2] > 0.0f ? 1.0f : 0.0f; + dst->f[3] = src->f[3] < 0.0f ? -1.0f : src->f[3] > 0.0f ? 1.0f : 0.0f; +} + +static void micro_shl( union tgsi_exec_channel *dst, const union tgsi_exec_channel *src0, @@ -2423,7 +2434,12 @@ exec_instruction( break; case TGSI_OPCODE_SSG: - assert (0); + /* TGSI_OPCODE_SGN */ + FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( &r[0], 0, chan_index ); + micro_sgn( &r[0], &r[0] ); + STORE( &r[0], 0, chan_index ); + } break; case TGSI_OPCODE_CMP: diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 29442b4..499d865 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -902,6 +902,29 @@ emit_setsign( } static void PIPE_CDECL +sgn4f( + float *store ) +{ + store[0] = store[0] < 0.0f ? -1.0f : store[0] > 0.0f ? 1.0f : 0.0f; + store[1] = store[1] < 0.0f ? -1.0f : store[1] > 0.0f ? 1.0f : 0.0f; + store[2] = store[2] < 0.0f ? -1.0f : store[2] > 0.0f ? 1.0f : 0.0f; + store[3] = store[3] < 0.0f ? -1.0f : store[3] > 0.0f ? 1.0f : 0.0f; +} + +static void +emit_sgn( + struct x86_function *func, + unsigned xmm_save, + unsigned xmm_dst ) +{ + emit_func_call_dst( + func, + xmm_save, + xmm_dst, + sgn4f ); +} + +static void PIPE_CDECL sin4f( float *store ) { @@ -1904,7 +1927,12 @@ emit_instruction( break; case TGSI_OPCODE_SSG: - return 0; + /* TGSI_OPCODE_SGN */ + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( func, *inst, 0, 0, chan_index ); + emit_sgn( func, 0, 0 ); + STORE( func, *inst, 0, 0, chan_index ); + } break; case TGSI_OPCODE_CMP: -- 2.7.4