tgsi: implement saturation
authorKeith Whitwell <keithw@vmware.com>
Sun, 13 Sep 2009 01:33:46 +0000 (18:33 -0700)
committerKeith Whitwell <keithw@vmware.com>
Sun, 13 Sep 2009 01:33:46 +0000 (18:33 -0700)
Fix recent performance regression.

progs/fp/add-sat.txt [new file with mode: 0644]
src/gallium/auxiliary/tgsi/tgsi_sse2.c

diff --git a/progs/fp/add-sat.txt b/progs/fp/add-sat.txt
new file mode 100644 (file)
index 0000000..2253efb
--- /dev/null
@@ -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
index 3cdf8b9..53e3f74 100644 (file)
@@ -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;