From 18e5f1cee4cadc6306ebc2e2ba047172ff42556a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 18:33:46 -0700 Subject: tgsi: implement saturation Fix recent performance regression. --- progs/fp/add-sat.txt | 6 +++++ src/gallium/auxiliary/tgsi/tgsi_sse2.c | 43 ++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 progs/fp/add-sat.txt diff --git a/progs/fp/add-sat.txt b/progs/fp/add-sat.txt new file mode 100644 index 0000000000..2253efb085 --- /dev/null +++ b/progs/fp/add-sat.txt @@ -0,0 +1,6 @@ +!!ARBfp1.0 +TEMP R0; +MOV R0, fragment.color; +ADD_SAT R0, R0, R0; +MUL result.color, {0.5}.x, R0; +END diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 3cdf8b9f35..53e3f746ee 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1360,6 +1360,32 @@ emit_store( const struct tgsi_full_instruction *inst, unsigned chan_index ) { + switch( inst->Instruction.Saturate ) { + case TGSI_SAT_NONE: + break; + + case TGSI_SAT_ZERO_ONE: + sse_maxps( + func, + make_xmm( xmm ), + get_temp( + TGSI_EXEC_TEMP_00000000_I, + TGSI_EXEC_TEMP_00000000_C ) ); + + sse_minps( + func, + make_xmm( xmm ), + get_temp( + TGSI_EXEC_TEMP_ONE_I, + TGSI_EXEC_TEMP_ONE_C ) ); + break; + + case TGSI_SAT_MINUS_PLUS_ONE: + assert( 0 ); + break; + } + + switch( reg->DstRegister.File ) { case TGSI_FILE_OUTPUT: emit_output( @@ -1388,19 +1414,6 @@ emit_store( default: assert( 0 ); } - - switch( inst->Instruction.Saturate ) { - case TGSI_SAT_NONE: - break; - - case TGSI_SAT_ZERO_ONE: - /* assert( 0 ); */ - break; - - case TGSI_SAT_MINUS_PLUS_ONE: - assert( 0 ); - break; - } } #define STORE( FUNC, INST, XMM, INDEX, CHAN )\ @@ -1747,10 +1760,6 @@ emit_instruction( if (indirect_temp_reference(inst)) return FALSE; - /* we don't handle saturation/clamping yet */ - if (inst->Instruction.Saturate != TGSI_SAT_NONE) - return FALSE; - /* need to use extra temps to fix SOA dependencies : */ if (tgsi_check_soa_dependencies(inst)) return FALSE; -- cgit v1.2.3