[Mesa-dev] gallium: remove TGSI_SAT_MINUS_PLUS_ONE

Submitted by Marek Olšák on May 17, 2015, 2:49 p.m.

Details

Message ID 1431874162-3750-1-git-send-email-maraeo@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák May 17, 2015, 2:49 p.m.
From: Marek Olšák <marek.olsak@amd.com>

It's a remnant of some old NV extension. Unused.

I also have a patch that removes predicates if anyone is interested.
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c    | 16 +------
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c    | 21 +--------
 src/gallium/auxiliary/nir/tgsi_to_nir.c            |  1 -
 src/gallium/auxiliary/tgsi/tgsi_build.c            |  4 +-
 src/gallium/auxiliary/tgsi/tgsi_dump.c             | 11 +----
 src/gallium/auxiliary/tgsi/tgsi_exec.c             | 51 +++-------------------
 src/gallium/auxiliary/tgsi/tgsi_lowering.c         |  3 +-
 src/gallium/auxiliary/tgsi/tgsi_text.c             | 12 ++---
 src/gallium/drivers/freedreno/a2xx/fd2_compiler.c  | 22 ++--------
 src/gallium/drivers/freedreno/ir3/ir3_compiler.c   |  8 +---
 src/gallium/drivers/i915/i915_fpc_optimize.c       |  4 +-
 src/gallium/drivers/i915/i915_fpc_translate.c      |  2 +-
 src/gallium/drivers/ilo/shader/toy_tgsi.c          |  3 --
 .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  | 13 +-----
 src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c   |  2 +-
 src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c   |  4 +-
 src/gallium/drivers/r300/r300_tgsi_to_rc.c         |  8 +---
 .../drivers/radeon/radeon_setup_tgsi_llvm.c        | 40 ++++++++---------
 src/gallium/include/pipe/p_shader_tokens.h         |  4 +-
 19 files changed, 46 insertions(+), 183 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 738d5e9..610283d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -232,23 +232,9 @@  lp_emit_store_aos(
    /*
     * Saturate the value
     */
-
-   switch (inst->Instruction.Saturate) {
-   case TGSI_SAT_NONE:
-      break;
-
-   case TGSI_SAT_ZERO_ONE:
+   if (inst->Instruction.Saturate) {
       value = lp_build_max(&bld->bld_base.base, value, bld->bld_base.base.zero);
       value = lp_build_min(&bld->bld_base.base, value, bld->bld_base.base.one);
-      break;
-
-   case TGSI_SAT_MINUS_PLUS_ONE:
-      value = lp_build_max(&bld->bld_base.base, value, lp_build_const_vec(bld->bld_base.base.gallivm, bld->bld_base.base.type, -1.0));
-      value = lp_build_min(&bld->bld_base.base, value, bld->bld_base.base.one);
-      break;
-
-   default:
-      assert(0);
    }
 
    /*
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 448c99d..092bd18 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1670,30 +1670,11 @@  emit_store_chan(
     *
     * It is always assumed to be float.
     */
-   switch( inst->Instruction.Saturate ) {
-   case TGSI_SAT_NONE:
-      break;
-
-   case TGSI_SAT_ZERO_ONE:
+   if (inst->Instruction.Saturate) {
       assert(dtype == TGSI_TYPE_FLOAT ||
              dtype == TGSI_TYPE_UNTYPED);
       value = LLVMBuildBitCast(builder, value, float_bld->vec_type, "");
       value = lp_build_clamp_zero_one_nanzero(float_bld, value);
-      break;
-
-   case TGSI_SAT_MINUS_PLUS_ONE:
-      assert(dtype == TGSI_TYPE_FLOAT ||
-             dtype == TGSI_TYPE_UNTYPED);
-      value = LLVMBuildBitCast(builder, value, float_bld->vec_type, "");
-      /* This will give -1.0 for NaN which is probably not what we want. */
-      value = lp_build_max_ext(float_bld, value,
-                               lp_build_const_vec(gallivm, float_bld->type, -1.0),
-                               GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN);
-      value = lp_build_min(float_bld, value, float_bld->one);
-      break;
-
-   default:
-      assert(0);
    }
 
    if (reg->Register.Indirect) {
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 59aaf67..50ce3dc 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -1625,7 +1625,6 @@  ttn_emit_instruction(struct ttn_compile *c)
    }
 
    if (tgsi_inst->Instruction.Saturate) {
-      assert(tgsi_inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
       assert(!dest.dest.is_ssa);
       ttn_move_dest(b, dest, nir_fsat(b, ttn_src_for_dest(b, &dest)));
    }
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 39a4296..fdb7feb 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -610,7 +610,7 @@  tgsi_default_instruction( void )
    instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
    instruction.NrTokens = 0;
    instruction.Opcode = TGSI_OPCODE_MOV;
-   instruction.Saturate = TGSI_SAT_NONE;
+   instruction.Saturate = 0;
    instruction.Predicate = 0;
    instruction.NumDstRegs = 1;
    instruction.NumSrcRegs = 1;
@@ -632,7 +632,7 @@  tgsi_build_instruction(unsigned opcode,
    struct tgsi_instruction instruction;
 
    assert (opcode <= TGSI_OPCODE_LAST);
-   assert (saturate <= TGSI_SAT_MINUS_PLUS_ONE);
+   assert (saturate <= 1);
    assert (num_dst_regs <= 3);
    assert (num_src_regs <= 15);
 
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 27d4108..c584c2b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -539,17 +539,8 @@  iter_instruction(
 
    TXT( info->mnemonic );
 
-   switch (inst->Instruction.Saturate) {
-   case TGSI_SAT_NONE:
-      break;
-   case TGSI_SAT_ZERO_ONE:
+   if (inst->Instruction.Saturate) {
       TXT( "_SAT" );
-      break;
-   case TGSI_SAT_MINUS_PLUS_ONE:
-      TXT( "_SATNV" );
-      break;
-   default:
-      assert( 0 );
    }
 
    for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index d9e4050..6a558f9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -1765,14 +1765,12 @@  store_dest(struct tgsi_exec_machine *mach,
    if (!dst)
       return;
 
-   switch (inst->Instruction.Saturate) {
-   case TGSI_SAT_NONE:
+   if (!inst->Instruction.Saturate) {
       for (i = 0; i < TGSI_QUAD_SIZE; i++)
          if (execmask & (1 << i))
             dst->i[i] = chan->i[i];
-      break;
-
-   case TGSI_SAT_ZERO_ONE:
+   }
+   else {
       for (i = 0; i < TGSI_QUAD_SIZE; i++)
          if (execmask & (1 << i)) {
             if (chan->f[i] < 0.0f)
@@ -1782,22 +1780,6 @@  store_dest(struct tgsi_exec_machine *mach,
             else
                dst->i[i] = chan->i[i];
          }
-      break;
-
-   case TGSI_SAT_MINUS_PLUS_ONE:
-      for (i = 0; i < TGSI_QUAD_SIZE; i++)
-         if (execmask & (1 << i)) {
-            if (chan->f[i] < -1.0f)
-               dst->f[i] = -1.0f;
-            else if (chan->f[i] > 1.0f)
-               dst->f[i] = 1.0f;
-            else
-               dst->i[i] = chan->i[i];
-         }
-      break;
-
-   default:
-      assert( 0 );
    }
 }
 
@@ -3315,16 +3297,14 @@  store_double_channel(struct tgsi_exec_machine *mach,
    union tgsi_double_channel temp;
    const uint execmask = mach->ExecMask;
 
-   switch (inst->Instruction.Saturate) {
-   case TGSI_SAT_NONE:
+   if (!inst->Instruction.Saturate) {
       for (i = 0; i < TGSI_QUAD_SIZE; i++)
          if (execmask & (1 << i)) {
             dst[0].u[i] = chan->u[i][0];
             dst[1].u[i] = chan->u[i][1];
          }
-      break;
-
-   case TGSI_SAT_ZERO_ONE:
+   }
+   else {
       for (i = 0; i < TGSI_QUAD_SIZE; i++)
          if (execmask & (1 << i)) {
             if (chan->d[i] < 0.0)
@@ -3337,25 +3317,6 @@  store_double_channel(struct tgsi_exec_machine *mach,
             dst[0].u[i] = temp.u[i][0];
             dst[1].u[i] = temp.u[i][1];
          }
-      break;
-
-   case TGSI_SAT_MINUS_PLUS_ONE:
-      for (i = 0; i < TGSI_QUAD_SIZE; i++)
-         if (execmask & (1 << i)) {
-            if (chan->d[i] < -1.0)
-               temp.d[i] = -1.0;
-            else if (chan->d[i] > 1.0)
-               temp.d[i] = 1.0;
-            else
-               temp.d[i] = chan->d[i];
-
-            dst[0].u[i] = temp.u[i][0];
-            dst[1].u[i] = temp.u[i][1];
-         }
-      break;
-
-   default:
-      assert( 0 );
    }
 
    store_dest_double(mach, &dst[0], reg, inst, chan_0, TGSI_EXEC_DATA_UINT);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_lowering.c b/src/gallium/auxiliary/tgsi/tgsi_lowering.c
index 4954c11..a3b90bd 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_lowering.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_lowering.c
@@ -1133,8 +1133,7 @@  transform_samp(struct tgsi_transform_context *tctx,
 
    /* MOV_SAT tmpA.<mask>, tmpA */
    if (mask) {
-      create_mov(tctx, &ctx->tmp[A].dst, &ctx->tmp[A].src, mask,
-                 TGSI_SAT_ZERO_ONE);
+      create_mov(tctx, &ctx->tmp[A].dst, &ctx->tmp[A].src, mask, 1);
    }
 
    /* modify the texture samp instruction to take fixed up coord: */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index b6b3585..a9734db 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -903,7 +903,7 @@  match_inst(const char **pcur,
    /* simple case: the whole string matches the instruction name */
    if (str_match_nocase_whole(&cur, info->mnemonic)) {
       *pcur = cur;
-      *saturate = TGSI_SAT_NONE;
+      *saturate = 0;
       return TRUE;
    }
 
@@ -911,13 +911,7 @@  match_inst(const char **pcur,
       /* the instruction has a suffix, figure it out */
       if (str_match_nocase_whole(&cur, "_SAT")) {
          *pcur = cur;
-         *saturate = TGSI_SAT_ZERO_ONE;
-         return TRUE;
-      }
-
-      if (str_match_nocase_whole(&cur, "_SATNV")) {
-         *pcur = cur;
-         *saturate = TGSI_SAT_MINUS_PLUS_ONE;
+         *saturate = 1;
          return TRUE;
       }
    }
@@ -931,7 +925,7 @@  parse_instruction(
    boolean has_label )
 {
    uint i;
-   uint saturate = TGSI_SAT_NONE;
+   uint saturate = 0;
    const struct tgsi_opcode_info *info;
    struct tgsi_full_instruction inst;
    const char *cur;
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
index e4acc7e..b48fb46 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
@@ -414,32 +414,16 @@  add_src_reg(struct fd2_compile_context *ctx, struct ir2_instruction *alu,
 static void
 add_vector_clamp(struct tgsi_full_instruction *inst, struct ir2_instruction *alu)
 {
-	switch (inst->Instruction.Saturate) {
-	case TGSI_SAT_NONE:
-		break;
-	case TGSI_SAT_ZERO_ONE:
+	if (inst->Instruction.Saturate) {
 		alu->alu.vector_clamp = true;
-		break;
-	case TGSI_SAT_MINUS_PLUS_ONE:
-		DBG("unsupported saturate");
-		assert(0);
-		break;
 	}
 }
 
 static void
 add_scalar_clamp(struct tgsi_full_instruction *inst, struct ir2_instruction *alu)
 {
-	switch (inst->Instruction.Saturate) {
-	case TGSI_SAT_NONE:
-		break;
-	case TGSI_SAT_ZERO_ONE:
+	if (inst->Instruction.Saturate) {
 		alu->alu.scalar_clamp = true;
-		break;
-	case TGSI_SAT_MINUS_PLUS_ONE:
-		DBG("unsupported saturate");
-		assert(0);
-		break;
 	}
 }
 
@@ -758,7 +742,7 @@  translate_tex(struct fd2_compile_context *ctx,
 	struct tgsi_src_register tmp_src;
 	const struct tgsi_src_register *coord;
 	bool using_temp = (inst->Dst[0].Register.File == TGSI_FILE_OUTPUT) ||
-			(inst->Instruction.Saturate != TGSI_SAT_NONE);
+			inst->Instruction.Saturate;
 	int idx;
 
 	if (using_temp || (opc == TGSI_OPCODE_TXP))
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
index 43f4c95..ad03400 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
@@ -3487,15 +3487,9 @@  compile_instructions(struct ir3_compile_context *ctx)
 						tgsi_get_opcode_name(opc));
 			}
 
-			switch (inst->Instruction.Saturate) {
-			case TGSI_SAT_ZERO_ONE:
+			if (inst->Instruction.Saturate) {
 				create_clamp_imm(ctx, &inst->Dst[0].Register,
 						fui(0.0), fui(1.0));
-				break;
-			case TGSI_SAT_MINUS_PLUS_ONE:
-				create_clamp_imm(ctx, &inst->Dst[0].Register,
-						fui(-1.0), fui(1.0));
-				break;
 			}
 
 			instr_finish(ctx);
diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c b/src/gallium/drivers/i915/i915_fpc_optimize.c
index e0134a7..83bb649 100644
--- a/src/gallium/drivers/i915/i915_fpc_optimize.c
+++ b/src/gallium/drivers/i915/i915_fpc_optimize.c
@@ -552,7 +552,7 @@  static boolean i915_fpc_useless_mov(union tgsi_full_token *tgsi_current)
    if ( current.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
         current.FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV &&
         op_has_dst(current.FullInstruction.Instruction.Opcode) &&
-        current.FullInstruction.Instruction.Saturate == TGSI_SAT_NONE &&
+        !current.FullInstruction.Instruction.Saturate &&
         current.FullInstruction.Src[0].Register.Absolute == 0 &&
         current.FullInstruction.Src[0].Register.Negate == 0 &&
         is_unswizzled(&current.FullInstruction.Src[0], current.FullInstruction.Dst[0].Register.WriteMask) &&
@@ -582,7 +582,7 @@  static void i915_fpc_optimize_useless_mov_after_inst(struct i915_optimize_contex
         next->Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
         next->FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV &&
         op_has_dst(current->FullInstruction.Instruction.Opcode) &&
-        next->FullInstruction.Instruction.Saturate == TGSI_SAT_NONE &&
+        !next->FullInstruction.Instruction.Saturate &&
         next->FullInstruction.Src[0].Register.Absolute == 0 &&
         next->FullInstruction.Src[0].Register.Negate == 0 &&
         unused_from(ctx, &current->FullInstruction.Dst[0], index) &&
diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c
index b74f823..38a3388 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -329,7 +329,7 @@  get_result_flags(const struct i915_full_instruction *inst)
       = inst->Dst[0].Register.WriteMask;
    uint flags = 0x0;
 
-   if (inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE)
+   if (inst->Instruction.Saturate)
       flags |= A0_DEST_SATURATE;
 
    if (writeMask & TGSI_WRITEMASK_X)
diff --git a/src/gallium/drivers/ilo/shader/toy_tgsi.c b/src/gallium/drivers/ilo/shader/toy_tgsi.c
index 65e47bf..d38585f 100644
--- a/src/gallium/drivers/ilo/shader/toy_tgsi.c
+++ b/src/gallium/drivers/ilo/shader/toy_tgsi.c
@@ -2036,9 +2036,6 @@  parse_instruction(struct toy_tgsi *tgsi,
       if (!dst_is_scratch[i])
          continue;
 
-      if (tgsi_inst->Instruction.Saturate == TGSI_SAT_MINUS_PLUS_ONE)
-         tc_fail(tgsi->tc, "TGSI_SAT_MINUS_PLUS_ONE unhandled");
-
       tgsi->tc->templ.saturate = tgsi_inst->Instruction.Saturate;
 
       /* emit indirect store */
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 6f7f397..2dcadee 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -1604,19 +1604,8 @@  Converter::storeDst(int d, int c, Value *val)
 {
    const tgsi::Instruction::DstRegister dst = tgsi.getDst(d);
 
-   switch (tgsi.getSaturate()) {
-   case TGSI_SAT_NONE:
-      break;
-   case TGSI_SAT_ZERO_ONE:
+   if (tgsi.getSaturate()) {
       mkOp1(OP_SAT, dstTy, val, val);
-      break;
-   case TGSI_SAT_MINUS_PLUS_ONE:
-      mkOp2(OP_MAX, dstTy, val, val, mkImm(-1.0f));
-      mkOp2(OP_MIN, dstTy, val, val, mkImm(+1.0f));
-      break;
-   default:
-      assert(!"invalid saturation mode");
-      break;
    }
 
    Value *ptr = NULL;
diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
index 9889c4e..9ef1696 100644
--- a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
+++ b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
@@ -531,7 +531,7 @@  nvfx_fragprog_parse_instruction(struct nvfx_fpc *fpc,
 
    dst  = tgsi_dst(fpc, &finst->Dst[0]);
    mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
-   sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
+   sat  = finst->Instruction.Saturate;
 
    switch (finst->Instruction.Opcode) {
    case TGSI_OPCODE_ABS:
diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c
index 29d506b..c8960db 100644
--- a/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c
+++ b/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c
@@ -539,7 +539,7 @@  nvfx_vertprog_parse_instruction(struct nvfx_vpc *vpc,
 
    final_dst = dst  = tgsi_dst(vpc, &finst->Dst[0]);
    mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
-   if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE) {
+   if(finst->Instruction.Saturate) {
       assert(finst->Instruction.Opcode != TGSI_OPCODE_ARL);
       if (vpc->is_nv4x)
          sat = TRUE;
@@ -796,7 +796,7 @@  nvfx_vertprog_parse_instruction(struct nvfx_vpc *vpc,
       return FALSE;
    }
 
-   if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE && !vpc->is_nv4x) {
+   if(finst->Instruction.Saturate && !vpc->is_nv4x) {
       if (!vpc->r_0_1.type)
          vpc->r_0_1 = constant(vpc, -1, 0, 1, 0, 0);
       nvfx_vp_emit(vpc, arith(0, VEC, MAX, dst, mask, nvfx_src(dst), swz(nvfx_src(vpc->r_0_1), X, X, X, X), none));
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index 69afb4c..23ed2cf 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -133,13 +133,7 @@  static unsigned translate_opcode(unsigned opcode)
 
 static unsigned translate_saturate(unsigned saturate)
 {
-    switch(saturate) {
-        default:
-            fprintf(stderr, "Unknown saturate mode: %i\n", saturate);
-            /* fall-through */
-        case TGSI_SAT_NONE: return RC_SATURATE_NONE;
-        case TGSI_SAT_ZERO_ONE: return RC_SATURATE_ZERO_ONE;
-    }
+    return saturate ? RC_SATURATE_ZERO_ONE : RC_SATURATE_NONE;
 }
 
 static unsigned translate_register_file(unsigned file)
diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 20e506b..8638537 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -314,6 +314,21 @@  static void emit_declaration(
 	}
 }
 
+static LLVMValueRef radeon_llvm_saturate(struct lp_build_tgsi_context *bld_base,
+                                         LLVMValueRef value)
+{
+	struct lp_build_emit_data clamp_emit_data;
+
+	memset(&clamp_emit_data, 0, sizeof(clamp_emit_data));
+	clamp_emit_data.arg_count = 3;
+	clamp_emit_data.args[0] = value;
+	clamp_emit_data.args[2] = bld_base->base.one;
+	clamp_emit_data.args[1] = bld_base->base.zero;
+
+	return lp_build_emit_llvm(bld_base, TGSI_OPCODE_CLAMP,
+				  &clamp_emit_data);
+}
+
 static void
 emit_store(
 	struct lp_build_tgsi_context * bld_base,
@@ -324,7 +339,6 @@  emit_store(
 	struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base);
 	struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
 	struct gallivm_state *gallivm = bld->bld_base.base.gallivm;
-	struct lp_build_context base = bld->bld_base.base;
 	const struct tgsi_full_dst_register *reg = &inst->Dst[0];
 	LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
 	LLVMValueRef temp_ptr;
@@ -350,28 +364,8 @@  emit_store(
 	TGSI_FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
 		LLVMValueRef value = dst[chan_index];
 
-		if (inst->Instruction.Saturate != TGSI_SAT_NONE) {
-			struct lp_build_emit_data clamp_emit_data;
-
-			memset(&clamp_emit_data, 0, sizeof(clamp_emit_data));
-			clamp_emit_data.arg_count = 3;
-			clamp_emit_data.args[0] = value;
-			clamp_emit_data.args[2] = base.one;
-
-			switch(inst->Instruction.Saturate) {
-			case TGSI_SAT_ZERO_ONE:
-				clamp_emit_data.args[1] = base.zero;
-				break;
-			case TGSI_SAT_MINUS_PLUS_ONE:
-				clamp_emit_data.args[1] = LLVMConstReal(
-						base.elem_type, -1.0f);
-				break;
-			default:
-				assert(0);
-			}
-			value = lp_build_emit_llvm(bld_base, TGSI_OPCODE_CLAMP,
-						&clamp_emit_data);
-		}
+		if (inst->Instruction.Saturate)
+			value = radeon_llvm_saturate(bld_base, value);
 
 		if (reg->Register.File == TGSI_FILE_ADDRESS) {
 			temp_ptr = bld->addr[reg->Register.Index][chan_index];
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index ff1f7d6..24cab94 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -561,13 +561,13 @@  struct tgsi_instruction
    unsigned Type       : 4;  /* TGSI_TOKEN_TYPE_INSTRUCTION */
    unsigned NrTokens   : 8;  /* UINT */
    unsigned Opcode     : 8;  /* TGSI_OPCODE_ */
-   unsigned Saturate   : 2;  /* TGSI_SAT_ */
+   unsigned Saturate   : 1;  /* BOOL */
    unsigned NumDstRegs : 2;  /* UINT */
    unsigned NumSrcRegs : 4;  /* UINT */
    unsigned Predicate  : 1;  /* BOOL */
    unsigned Label      : 1;
    unsigned Texture    : 1;
-   unsigned Padding    : 1;
+   unsigned Padding    : 2;
 };
 
 /*

Comments

On 05/17/2015 04:49 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak@amd.com>
>
> It's a remnant of some old NV extension. Unused.
>
> I also have a patch that removes predicates if anyone is interested.
> ---
>   src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c    | 16 +------
>   src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c    | 21 +--------
>   src/gallium/auxiliary/nir/tgsi_to_nir.c            |  1 -
>   src/gallium/auxiliary/tgsi/tgsi_build.c            |  4 +-
>   src/gallium/auxiliary/tgsi/tgsi_dump.c             | 11 +----
>   src/gallium/auxiliary/tgsi/tgsi_exec.c             | 51 +++-------------------
>   src/gallium/auxiliary/tgsi/tgsi_lowering.c         |  3 +-
>   src/gallium/auxiliary/tgsi/tgsi_text.c             | 12 ++---
>   src/gallium/drivers/freedreno/a2xx/fd2_compiler.c  | 22 ++--------
>   src/gallium/drivers/freedreno/ir3/ir3_compiler.c   |  8 +---
>   src/gallium/drivers/i915/i915_fpc_optimize.c       |  4 +-
>   src/gallium/drivers/i915/i915_fpc_translate.c      |  2 +-
>   src/gallium/drivers/ilo/shader/toy_tgsi.c          |  3 --
>   .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  | 13 +-----
>   src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c   |  2 +-
>   src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c   |  4 +-
>   src/gallium/drivers/r300/r300_tgsi_to_rc.c         |  8 +---
>   .../drivers/radeon/radeon_setup_tgsi_llvm.c        | 40 ++++++++---------
>   src/gallium/include/pipe/p_shader_tokens.h         |  4 +-
>   19 files changed, 46 insertions(+), 183 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
> index 738d5e9..610283d 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
> @@ -232,23 +232,9 @@ lp_emit_store_aos(
>      /*
>       * Saturate the value
>       */
> -
> -   switch (inst->Instruction.Saturate) {
> -   case TGSI_SAT_NONE:
> -      break;
> -
> -   case TGSI_SAT_ZERO_ONE:
> +   if (inst->Instruction.Saturate) {
>         value = lp_build_max(&bld->bld_base.base, value, bld->bld_base.base.zero);
>         value = lp_build_min(&bld->bld_base.base, value, bld->bld_base.base.one);
> -      break;
> -
> -   case TGSI_SAT_MINUS_PLUS_ONE:
> -      value = lp_build_max(&bld->bld_base.base, value, lp_build_const_vec(bld->bld_base.base.gallivm, bld->bld_base.base.type, -1.0));
> -      value = lp_build_min(&bld->bld_base.base, value, bld->bld_base.base.one);
> -      break;
> -
> -   default:
> -      assert(0);
>      }
>
>      /*
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> index 448c99d..092bd18 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> @@ -1670,30 +1670,11 @@ emit_store_chan(
>       *
>       * It is always assumed to be float.
>       */
> -   switch( inst->Instruction.Saturate ) {
> -   case TGSI_SAT_NONE:
> -      break;
> -
> -   case TGSI_SAT_ZERO_ONE:
> +   if (inst->Instruction.Saturate) {
>         assert(dtype == TGSI_TYPE_FLOAT ||
>                dtype == TGSI_TYPE_UNTYPED);
>         value = LLVMBuildBitCast(builder, value, float_bld->vec_type, "");
>         value = lp_build_clamp_zero_one_nanzero(float_bld, value);
> -      break;
> -
> -   case TGSI_SAT_MINUS_PLUS_ONE:
> -      assert(dtype == TGSI_TYPE_FLOAT ||
> -             dtype == TGSI_TYPE_UNTYPED);
> -      value = LLVMBuildBitCast(builder, value, float_bld->vec_type, "");
> -      /* This will give -1.0 for NaN which is probably not what we want. */
> -      value = lp_build_max_ext(float_bld, value,
> -                               lp_build_const_vec(gallivm, float_bld->type, -1.0),
> -                               GALLIVM_NAN_RETURN_OTHER_SECOND_NONNAN);
> -      value = lp_build_min(float_bld, value, float_bld->one);
> -      break;
> -
> -   default:
> -      assert(0);
>      }
>
>      if (reg->Register.Indirect) {
> diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
> index 59aaf67..50ce3dc 100644
> --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
> +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
> @@ -1625,7 +1625,6 @@ ttn_emit_instruction(struct ttn_compile *c)
>      }
>
>      if (tgsi_inst->Instruction.Saturate) {
> -      assert(tgsi_inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
>         assert(!dest.dest.is_ssa);
>         ttn_move_dest(b, dest, nir_fsat(b, ttn_src_for_dest(b, &dest)));
>      }
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
> index 39a4296..fdb7feb 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_build.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
> @@ -610,7 +610,7 @@ tgsi_default_instruction( void )
>      instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
>      instruction.NrTokens = 0;
>      instruction.Opcode = TGSI_OPCODE_MOV;
> -   instruction.Saturate = TGSI_SAT_NONE;
> +   instruction.Saturate = 0;
>      instruction.Predicate = 0;
>      instruction.NumDstRegs = 1;
>      instruction.NumSrcRegs = 1;
> @@ -632,7 +632,7 @@ tgsi_build_instruction(unsigned opcode,
>      struct tgsi_instruction instruction;
>
>      assert (opcode <= TGSI_OPCODE_LAST);
> -   assert (saturate <= TGSI_SAT_MINUS_PLUS_ONE);
> +   assert (saturate <= 1);
>      assert (num_dst_regs <= 3);
>      assert (num_src_regs <= 15);
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
> index 27d4108..c584c2b 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
> @@ -539,17 +539,8 @@ iter_instruction(
>
>      TXT( info->mnemonic );
>
> -   switch (inst->Instruction.Saturate) {
> -   case TGSI_SAT_NONE:
> -      break;
> -   case TGSI_SAT_ZERO_ONE:
> +   if (inst->Instruction.Saturate) {
>         TXT( "_SAT" );
> -      break;
> -   case TGSI_SAT_MINUS_PLUS_ONE:
> -      TXT( "_SATNV" );
> -      break;
> -   default:
> -      assert( 0 );
>      }
>
>      for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> index d9e4050..6a558f9 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> @@ -1765,14 +1765,12 @@ store_dest(struct tgsi_exec_machine *mach,
>      if (!dst)
>         return;
>
> -   switch (inst->Instruction.Saturate) {
> -   case TGSI_SAT_NONE:
> +   if (!inst->Instruction.Saturate) {
>         for (i = 0; i < TGSI_QUAD_SIZE; i++)
>            if (execmask & (1 << i))
>               dst->i[i] = chan->i[i];
> -      break;
> -
> -   case TGSI_SAT_ZERO_ONE:
> +   }
> +   else {
>         for (i = 0; i < TGSI_QUAD_SIZE; i++)
>            if (execmask & (1 << i)) {
>               if (chan->f[i] < 0.0f)
> @@ -1782,22 +1780,6 @@ store_dest(struct tgsi_exec_machine *mach,
>               else
>                  dst->i[i] = chan->i[i];
>            }
> -      break;
> -
> -   case TGSI_SAT_MINUS_PLUS_ONE:
> -      for (i = 0; i < TGSI_QUAD_SIZE; i++)
> -         if (execmask & (1 << i)) {
> -            if (chan->f[i] < -1.0f)
> -               dst->f[i] = -1.0f;
> -            else if (chan->f[i] > 1.0f)
> -               dst->f[i] = 1.0f;
> -            else
> -               dst->i[i] = chan->i[i];
> -         }
> -      break;
> -
> -   default:
> -      assert( 0 );
>      }
>   }
>
> @@ -3315,16 +3297,14 @@ store_double_channel(struct tgsi_exec_machine *mach,
>      union tgsi_double_channel temp;
>      const uint execmask = mach->ExecMask;
>
> -   switch (inst->Instruction.Saturate) {
> -   case TGSI_SAT_NONE:
> +   if (!inst->Instruction.Saturate) {
>         for (i = 0; i < TGSI_QUAD_SIZE; i++)
>            if (execmask & (1 << i)) {
>               dst[0].u[i] = chan->u[i][0];
>               dst[1].u[i] = chan->u[i][1];
>            }
> -      break;
> -
> -   case TGSI_SAT_ZERO_ONE:
> +   }
> +   else {
>         for (i = 0; i < TGSI_QUAD_SIZE; i++)
>            if (execmask & (1 << i)) {
>               if (chan->d[i] < 0.0)
> @@ -3337,25 +3317,6 @@ store_double_channel(struct tgsi_exec_machine *mach,
>               dst[0].u[i] = temp.u[i][0];
>               dst[1].u[i] = temp.u[i][1];
>            }
> -      break;
> -
> -   case TGSI_SAT_MINUS_PLUS_ONE:
> -      for (i = 0; i < TGSI_QUAD_SIZE; i++)
> -         if (execmask & (1 << i)) {
> -            if (chan->d[i] < -1.0)
> -               temp.d[i] = -1.0;
> -            else if (chan->d[i] > 1.0)
> -               temp.d[i] = 1.0;
> -            else
> -               temp.d[i] = chan->d[i];
> -
> -            dst[0].u[i] = temp.u[i][0];
> -            dst[1].u[i] = temp.u[i][1];
> -         }
> -      break;
> -
> -   default:
> -      assert( 0 );
>      }
>
>      store_dest_double(mach, &dst[0], reg, inst, chan_0, TGSI_EXEC_DATA_UINT);
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_lowering.c b/src/gallium/auxiliary/tgsi/tgsi_lowering.c
> index 4954c11..a3b90bd 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_lowering.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_lowering.c
> @@ -1133,8 +1133,7 @@ transform_samp(struct tgsi_transform_context *tctx,
>
>      /* MOV_SAT tmpA.<mask>, tmpA */
>      if (mask) {
> -      create_mov(tctx, &ctx->tmp[A].dst, &ctx->tmp[A].src, mask,
> -                 TGSI_SAT_ZERO_ONE);
> +      create_mov(tctx, &ctx->tmp[A].dst, &ctx->tmp[A].src, mask, 1);
>      }
>
>      /* modify the texture samp instruction to take fixed up coord: */
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
> index b6b3585..a9734db 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_text.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
> @@ -903,7 +903,7 @@ match_inst(const char **pcur,
>      /* simple case: the whole string matches the instruction name */
>      if (str_match_nocase_whole(&cur, info->mnemonic)) {
>         *pcur = cur;
> -      *saturate = TGSI_SAT_NONE;
> +      *saturate = 0;
>         return TRUE;
>      }
>
> @@ -911,13 +911,7 @@ match_inst(const char **pcur,
>         /* the instruction has a suffix, figure it out */
>         if (str_match_nocase_whole(&cur, "_SAT")) {
>            *pcur = cur;
> -         *saturate = TGSI_SAT_ZERO_ONE;
> -         return TRUE;
> -      }
> -
> -      if (str_match_nocase_whole(&cur, "_SATNV")) {
> -         *pcur = cur;
> -         *saturate = TGSI_SAT_MINUS_PLUS_ONE;
> +         *saturate = 1;
>            return TRUE;
>         }
>      }
> @@ -931,7 +925,7 @@ parse_instruction(
>      boolean has_label )
>   {
>      uint i;
> -   uint saturate = TGSI_SAT_NONE;
> +   uint saturate = 0;
>      const struct tgsi_opcode_info *info;
>      struct tgsi_full_instruction inst;
>      const char *cur;
> diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
> index e4acc7e..b48fb46 100644
> --- a/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
> +++ b/src/gallium/drivers/freedreno/a2xx/fd2_compiler.c
> @@ -414,32 +414,16 @@ add_src_reg(struct fd2_compile_context *ctx, struct ir2_instruction *alu,
>   static void
>   add_vector_clamp(struct tgsi_full_instruction *inst, struct ir2_instruction *alu)
>   {
> -	switch (inst->Instruction.Saturate) {
> -	case TGSI_SAT_NONE:
> -		break;
> -	case TGSI_SAT_ZERO_ONE:
> +	if (inst->Instruction.Saturate) {
>   		alu->alu.vector_clamp = true;
> -		break;
> -	case TGSI_SAT_MINUS_PLUS_ONE:
> -		DBG("unsupported saturate");
> -		assert(0);
> -		break;
>   	}
>   }
>
>   static void
>   add_scalar_clamp(struct tgsi_full_instruction *inst, struct ir2_instruction *alu)
>   {
> -	switch (inst->Instruction.Saturate) {
> -	case TGSI_SAT_NONE:
> -		break;
> -	case TGSI_SAT_ZERO_ONE:
> +	if (inst->Instruction.Saturate) {
>   		alu->alu.scalar_clamp = true;
> -		break;
> -	case TGSI_SAT_MINUS_PLUS_ONE:
> -		DBG("unsupported saturate");
> -		assert(0);
> -		break;
>   	}
>   }
>
> @@ -758,7 +742,7 @@ translate_tex(struct fd2_compile_context *ctx,
>   	struct tgsi_src_register tmp_src;
>   	const struct tgsi_src_register *coord;
>   	bool using_temp = (inst->Dst[0].Register.File == TGSI_FILE_OUTPUT) ||
> -			(inst->Instruction.Saturate != TGSI_SAT_NONE);
> +			inst->Instruction.Saturate;
>   	int idx;
>
>   	if (using_temp || (opc == TGSI_OPCODE_TXP))
> diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
> index 43f4c95..ad03400 100644
> --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
> +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
> @@ -3487,15 +3487,9 @@ compile_instructions(struct ir3_compile_context *ctx)
>   						tgsi_get_opcode_name(opc));
>   			}
>
> -			switch (inst->Instruction.Saturate) {
> -			case TGSI_SAT_ZERO_ONE:
> +			if (inst->Instruction.Saturate) {
>   				create_clamp_imm(ctx, &inst->Dst[0].Register,
>   						fui(0.0), fui(1.0));
> -				break;
> -			case TGSI_SAT_MINUS_PLUS_ONE:
> -				create_clamp_imm(ctx, &inst->Dst[0].Register,
> -						fui(-1.0), fui(1.0));
> -				break;
>   			}
>
>   			instr_finish(ctx);
> diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c b/src/gallium/drivers/i915/i915_fpc_optimize.c
> index e0134a7..83bb649 100644
> --- a/src/gallium/drivers/i915/i915_fpc_optimize.c
> +++ b/src/gallium/drivers/i915/i915_fpc_optimize.c
> @@ -552,7 +552,7 @@ static boolean i915_fpc_useless_mov(union tgsi_full_token *tgsi_current)
>      if ( current.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
>           current.FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV &&
>           op_has_dst(current.FullInstruction.Instruction.Opcode) &&
> -        current.FullInstruction.Instruction.Saturate == TGSI_SAT_NONE &&
> +        !current.FullInstruction.Instruction.Saturate &&
>           current.FullInstruction.Src[0].Register.Absolute == 0 &&
>           current.FullInstruction.Src[0].Register.Negate == 0 &&
>           is_unswizzled(&current.FullInstruction.Src[0], current.FullInstruction.Dst[0].Register.WriteMask) &&
> @@ -582,7 +582,7 @@ static void i915_fpc_optimize_useless_mov_after_inst(struct i915_optimize_contex
>           next->Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION  &&
>           next->FullInstruction.Instruction.Opcode == TGSI_OPCODE_MOV &&
>           op_has_dst(current->FullInstruction.Instruction.Opcode) &&
> -        next->FullInstruction.Instruction.Saturate == TGSI_SAT_NONE &&
> +        !next->FullInstruction.Instruction.Saturate &&
>           next->FullInstruction.Src[0].Register.Absolute == 0 &&
>           next->FullInstruction.Src[0].Register.Negate == 0 &&
>           unused_from(ctx, &current->FullInstruction.Dst[0], index) &&
> diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c
> index b74f823..38a3388 100644
> --- a/src/gallium/drivers/i915/i915_fpc_translate.c
> +++ b/src/gallium/drivers/i915/i915_fpc_translate.c
> @@ -329,7 +329,7 @@ get_result_flags(const struct i915_full_instruction *inst)
>         = inst->Dst[0].Register.WriteMask;
>      uint flags = 0x0;
>
> -   if (inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE)
> +   if (inst->Instruction.Saturate)
>         flags |= A0_DEST_SATURATE;
>
>      if (writeMask & TGSI_WRITEMASK_X)
> diff --git a/src/gallium/drivers/ilo/shader/toy_tgsi.c b/src/gallium/drivers/ilo/shader/toy_tgsi.c
> index 65e47bf..d38585f 100644
> --- a/src/gallium/drivers/ilo/shader/toy_tgsi.c
> +++ b/src/gallium/drivers/ilo/shader/toy_tgsi.c
> @@ -2036,9 +2036,6 @@ parse_instruction(struct toy_tgsi *tgsi,
>         if (!dst_is_scratch[i])
>            continue;
>
> -      if (tgsi_inst->Instruction.Saturate == TGSI_SAT_MINUS_PLUS_ONE)
> -         tc_fail(tgsi->tc, "TGSI_SAT_MINUS_PLUS_ONE unhandled");
> -
>         tgsi->tc->templ.saturate = tgsi_inst->Instruction.Saturate;
>
>         /* emit indirect store */
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> index 6f7f397..2dcadee 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> @@ -1604,19 +1604,8 @@ Converter::storeDst(int d, int c, Value *val)
>   {
>      const tgsi::Instruction::DstRegister dst = tgsi.getDst(d);
>
> -   switch (tgsi.getSaturate()) {
> -   case TGSI_SAT_NONE:
> -      break;
> -   case TGSI_SAT_ZERO_ONE:
> +   if (tgsi.getSaturate()) {
>         mkOp1(OP_SAT, dstTy, val, val);
> -      break;
> -   case TGSI_SAT_MINUS_PLUS_ONE:
> -      mkOp2(OP_MAX, dstTy, val, val, mkImm(-1.0f));
> -      mkOp2(OP_MIN, dstTy, val, val, mkImm(+1.0f));
> -      break;
> -   default:
> -      assert(!"invalid saturation mode");
> -      break;
>      }
>
>      Value *ptr = NULL;
> diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
> index 9889c4e..9ef1696 100644
> --- a/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
> +++ b/src/gallium/drivers/nouveau/nv30/nvfx_fragprog.c
> @@ -531,7 +531,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_fpc *fpc,
>
>      dst  = tgsi_dst(fpc, &finst->Dst[0]);
>      mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
> -   sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
> +   sat  = finst->Instruction.Saturate;
>
>      switch (finst->Instruction.Opcode) {
>      case TGSI_OPCODE_ABS:
> diff --git a/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c b/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c
> index 29d506b..c8960db 100644
> --- a/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c
> +++ b/src/gallium/drivers/nouveau/nv30/nvfx_vertprog.c
> @@ -539,7 +539,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_vpc *vpc,
>
>      final_dst = dst  = tgsi_dst(vpc, &finst->Dst[0]);
>      mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
> -   if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE) {
> +   if(finst->Instruction.Saturate) {
>         assert(finst->Instruction.Opcode != TGSI_OPCODE_ARL);
>         if (vpc->is_nv4x)
>            sat = TRUE;
> @@ -796,7 +796,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_vpc *vpc,
>         return FALSE;
>      }
>
> -   if(finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE && !vpc->is_nv4x) {
> +   if(finst->Instruction.Saturate && !vpc->is_nv4x) {
>         if (!vpc->r_0_1.type)
>            vpc->r_0_1 = constant(vpc, -1, 0, 1, 0, 0);
>         nvfx_vp_emit(vpc, arith(0, VEC, MAX, dst, mask, nvfx_src(dst), swz(nvfx_src(vpc->r_0_1), X, X, X, X), none));
> diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
> index 69afb4c..23ed2cf 100644
> --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
> +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
> @@ -133,13 +133,7 @@ static unsigned translate_opcode(unsigned opcode)
>
>   static unsigned translate_saturate(unsigned saturate)
>   {
> -    switch(saturate) {
> -        default:
> -            fprintf(stderr, "Unknown saturate mode: %i\n", saturate);
> -            /* fall-through */
> -        case TGSI_SAT_NONE: return RC_SATURATE_NONE;
> -        case TGSI_SAT_ZERO_ONE: return RC_SATURATE_ZERO_ONE;
> -    }
> +    return saturate ? RC_SATURATE_ZERO_ONE : RC_SATURATE_NONE;
>   }
>
>   static unsigned translate_register_file(unsigned file)
> diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> index 20e506b..8638537 100644
> --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> @@ -314,6 +314,21 @@ static void emit_declaration(
>   	}
>   }
>
> +static LLVMValueRef radeon_llvm_saturate(struct lp_build_tgsi_context *bld_base,
> +                                         LLVMValueRef value)
> +{
> +	struct lp_build_emit_data clamp_emit_data;
> +
> +	memset(&clamp_emit_data, 0, sizeof(clamp_emit_data));
> +	clamp_emit_data.arg_count = 3;
> +	clamp_emit_data.args[0] = value;
> +	clamp_emit_data.args[2] = bld_base->base.one;
> +	clamp_emit_data.args[1] = bld_base->base.zero;
> +
> +	return lp_build_emit_llvm(bld_base, TGSI_OPCODE_CLAMP,
> +				  &clamp_emit_data);
> +}
> +
>   static void
>   emit_store(
>   	struct lp_build_tgsi_context * bld_base,
> @@ -324,7 +339,6 @@ emit_store(
>   	struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base);
>   	struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base);
>   	struct gallivm_state *gallivm = bld->bld_base.base.gallivm;
> -	struct lp_build_context base = bld->bld_base.base;
>   	const struct tgsi_full_dst_register *reg = &inst->Dst[0];
>   	LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder;
>   	LLVMValueRef temp_ptr;
> @@ -350,28 +364,8 @@ emit_store(
>   	TGSI_FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) {
>   		LLVMValueRef value = dst[chan_index];
>
> -		if (inst->Instruction.Saturate != TGSI_SAT_NONE) {
> -			struct lp_build_emit_data clamp_emit_data;
> -
> -			memset(&clamp_emit_data, 0, sizeof(clamp_emit_data));
> -			clamp_emit_data.arg_count = 3;
> -			clamp_emit_data.args[0] = value;
> -			clamp_emit_data.args[2] = base.one;
> -
> -			switch(inst->Instruction.Saturate) {
> -			case TGSI_SAT_ZERO_ONE:
> -				clamp_emit_data.args[1] = base.zero;
> -				break;
> -			case TGSI_SAT_MINUS_PLUS_ONE:
> -				clamp_emit_data.args[1] = LLVMConstReal(
> -						base.elem_type, -1.0f);
> -				break;
> -			default:
> -				assert(0);
> -			}
> -			value = lp_build_emit_llvm(bld_base, TGSI_OPCODE_CLAMP,
> -						&clamp_emit_data);
> -		}
> +		if (inst->Instruction.Saturate)
> +			value = radeon_llvm_saturate(bld_base, value);
>
>   		if (reg->Register.File == TGSI_FILE_ADDRESS) {
>   			temp_ptr = bld->addr[reg->Register.Index][chan_index];
> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
> index ff1f7d6..24cab94 100644
> --- a/src/gallium/include/pipe/p_shader_tokens.h
> +++ b/src/gallium/include/pipe/p_shader_tokens.h
> @@ -561,13 +561,13 @@ struct tgsi_instruction
>      unsigned Type       : 4;  /* TGSI_TOKEN_TYPE_INSTRUCTION */
>      unsigned NrTokens   : 8;  /* UINT */
>      unsigned Opcode     : 8;  /* TGSI_OPCODE_ */
> -   unsigned Saturate   : 2;  /* TGSI_SAT_ */
> +   unsigned Saturate   : 1;  /* BOOL */
>      unsigned NumDstRegs : 2;  /* UINT */
>      unsigned NumSrcRegs : 4;  /* UINT */
>      unsigned Predicate  : 1;  /* BOOL */
>      unsigned Label      : 1;
>      unsigned Texture    : 1;
> -   unsigned Padding    : 1;
> +   unsigned Padding    : 2;
>   };
>
>   /*
>

I don't think we used it anywhere internally neither.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>