Mesa (gallium-0.1): tgsi: Implement CLAMP opcode.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Aug 27 08:30:20 UTC 2009


Module: Mesa
Branch: gallium-0.1
Commit: eb1ed977fbd1995db35d26fb48f788baaf1b5dfa
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb1ed977fbd1995db35d26fb48f788baaf1b5dfa

Author: Michal Krol <michal at vmware.com>
Date:   Tue Mar 10 10:22:34 2009 +0100

tgsi: Implement CLAMP opcode.

---

 src/gallium/auxiliary/tgsi/tgsi_exec.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 8044222..8f2986e 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -2054,7 +2054,7 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_DOT2ADD:
-      /* TGSI_OPCODE_DP2A */
+   /* TGSI_OPCODE_DP2A */
       FETCH( &r[0], 0, CHAN_X );
       FETCH( &r[1], 1, CHAN_X );
       micro_mul( &r[0], &r[0], &r[1] );
@@ -2090,7 +2090,14 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_CLAMP:
-      assert (0);
+      FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+         FETCH(&r[0], 0, chan_index);
+         FETCH(&r[1], 1, chan_index);
+         micro_max(&r[0], &r[0], &r[1]);
+         FETCH(&r[1], 2, chan_index);
+         micro_min(&r[0], &r[0], &r[1]);
+         STORE(&r[0], 0, chan_index);
+      }
       break;
 
    case TGSI_OPCODE_ROUND:
@@ -2103,7 +2110,7 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_EXPBASE2:
-    /* TGSI_OPCODE_EX2 */
+   /* TGSI_OPCODE_EX2 */
       FETCH(&r[0], 0, CHAN_X);
 
 #if FAST_MATH
@@ -2113,7 +2120,7 @@ exec_instruction(
 #endif
 
       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-	 STORE( &r[0], 0, chan_index );
+         STORE( &r[0], 0, chan_index );
       }
       break;
 
@@ -2127,19 +2134,19 @@ exec_instruction(
       break;
 
    case TGSI_OPCODE_POWER:
-      /* TGSI_OPCODE_POW */
+   /* TGSI_OPCODE_POW */
       FETCH(&r[0], 0, CHAN_X);
       FETCH(&r[1], 1, CHAN_X);
 
       micro_pow( &r[0], &r[0], &r[1] );
 
       FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
-	 STORE( &r[0], 0, chan_index );
+         STORE( &r[0], 0, chan_index );
       }
       break;
 
    case TGSI_OPCODE_CROSSPRODUCT:
-      /* TGSI_OPCODE_XPD */
+   /* TGSI_OPCODE_XPD */
       FETCH(&r[0], 0, CHAN_Y);
       FETCH(&r[1], 1, CHAN_Z);
 




More information about the mesa-commit mailing list