Make Saturate a 2-bit field again, renamed to SaturateMode with three
authorBrian Paul <brian.paul@tungstengraphics.com>
Sun, 20 Nov 2005 17:52:40 +0000 (17:52 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sun, 20 Nov 2005 17:52:40 +0000 (17:52 +0000)
possible values: SATURATE_OFF, SATURATE_ZERO_ONE and SATURATE_PLUS_MINUS_ONE.

src/mesa/drivers/dri/i915/i915_fragprog.c
src/mesa/drivers/dri/r300/r300_fragprog.c
src/mesa/main/texenvprogram.c
src/mesa/shader/arbprogparse.c
src/mesa/shader/nvfragparse.c
src/mesa/shader/program.c
src/mesa/shader/program_instruction.h
src/mesa/swrast/s_nvfragprog.c

index eed2767..5dd6671 100644 (file)
@@ -177,7 +177,7 @@ static GLuint get_result_flags( const struct prog_instruction *inst )
 {
    GLuint flags = 0;
 
-   if (inst->Saturate) flags |= A0_DEST_SATURATE;
+   if (inst->Saturate == SATURATE_ZERO_ONE) flags |= A0_DEST_SATURATE;
    if (inst->DstReg.WriteMask & WRITEMASK_X) flags |= A0_DEST_CHANNEL_X;
    if (inst->DstReg.WriteMask & WRITEMASK_Y) flags |= A0_DEST_CHANNEL_Y;
    if (inst->DstReg.WriteMask & WRITEMASK_Z) flags |= A0_DEST_CHANNEL_Z;
index abcff64..aef574b 100644 (file)
@@ -757,7 +757,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp)
        }
 
        for (fpi=mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) {
-               if (fpi->Saturate) {
+               if (fpi->SaturateMode == SATURATE_ZERO_ONE) {
                        flags = PFS_FLAG_SAT;
                }
                
index 0d53695..a92db42 100644 (file)
@@ -486,7 +486,7 @@ emit_op(struct texenv_fragment_program *p,
    emit_arg( &inst->SrcReg[1], src1 );
    emit_arg( &inst->SrcReg[2], src2 );
    
-   inst->Saturate = saturate;
+   inst->SaturateMode = saturate ? SATURATE_ZERO_ONE : SATURATE_OFF;
 
    emit_dst( &inst->DstReg, dest, mask );
 
index d847a81..09b1cae 100644 (file)
@@ -2730,31 +2730,31 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_ALU_VECTOR:
          switch (code) {
             case OP_ABS_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_ABS:
                fp->Opcode = OPCODE_ABS;
                break;
 
             case OP_FLR_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_FLR:
                fp->Opcode = OPCODE_FLR;
                break;
 
             case OP_FRC_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_FRC:
                fp->Opcode = OPCODE_FRC;
                break;
 
             case OP_LIT_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_LIT:
                fp->Opcode = OPCODE_LIT;
                break;
 
             case OP_MOV_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_MOV:
                fp->Opcode = OPCODE_MOV;
                break;
@@ -2770,43 +2770,43 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_ALU_SCALAR:
          switch (code) {
             case OP_COS_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_COS:
                fp->Opcode = OPCODE_COS;
                break;
 
             case OP_EX2_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_EX2:
                fp->Opcode = OPCODE_EX2;
                break;
 
             case OP_LG2_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_LG2:
                fp->Opcode = OPCODE_LG2;
                break;
 
             case OP_RCP_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_RCP:
                fp->Opcode = OPCODE_RCP;
                break;
 
             case OP_RSQ_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_RSQ:
                fp->Opcode = OPCODE_RSQ;
                break;
 
             case OP_SIN_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_SIN:
                fp->Opcode = OPCODE_SIN;
                break;
 
             case OP_SCS_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_SCS:
 
                fp->Opcode = OPCODE_SCS;
@@ -2823,7 +2823,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_ALU_BINSC:
          switch (code) {
             case OP_POW_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_POW:
                fp->Opcode = OPCODE_POW;
                break;
@@ -2842,73 +2842,73 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_ALU_BIN:
          switch (code) {
             case OP_ADD_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_ADD:
                fp->Opcode = OPCODE_ADD;
                break;
 
             case OP_DP3_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_DP3:
                fp->Opcode = OPCODE_DP3;
                break;
 
             case OP_DP4_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_DP4:
                fp->Opcode = OPCODE_DP4;
                break;
 
             case OP_DPH_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_DPH:
                fp->Opcode = OPCODE_DPH;
                break;
 
             case OP_DST_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_DST:
                fp->Opcode = OPCODE_DST;
                break;
 
             case OP_MAX_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_MAX:
                fp->Opcode = OPCODE_MAX;
                break;
 
             case OP_MIN_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_MIN:
                fp->Opcode = OPCODE_MIN;
                break;
 
             case OP_MUL_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_MUL:
                fp->Opcode = OPCODE_MUL;
                break;
 
             case OP_SGE_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_SGE:
                fp->Opcode = OPCODE_SGE;
                break;
 
             case OP_SLT_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_SLT:
                fp->Opcode = OPCODE_SLT;
                break;
 
             case OP_SUB_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_SUB:
                fp->Opcode = OPCODE_SUB;
                break;
 
             case OP_XPD_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_XPD:
                fp->Opcode = OPCODE_XPD;
                break;
@@ -2925,19 +2925,19 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_ALU_TRI:
          switch (code) {
             case OP_CMP_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_CMP:
                fp->Opcode = OPCODE_CMP;
                break;
 
             case OP_LRP_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_LRP:
                fp->Opcode = OPCODE_LRP;
                break;
 
             case OP_MAD_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_MAD:
                fp->Opcode = OPCODE_MAD;
                break;
@@ -2955,7 +2955,7 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_ALU_SWZ:
          switch (code) {
             case OP_SWZ_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_SWZ:
                fp->Opcode = OPCODE_SWZ;
                break;
@@ -2985,19 +2985,19 @@ parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
       case OP_TEX_SAMPLE:
          switch (code) {
             case OP_TEX_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_TEX:
                fp->Opcode = OPCODE_TEX;
                break;
 
             case OP_TXP_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_TXP:
                fp->Opcode = OPCODE_TXP;
                break;
 
             case OP_TXB_SAT:
-               fp->Saturate = 1;
+               fp->SaturateMode = SATURATE_ZERO_ONE;
             case OP_TXB:
                fp->Opcode = OPCODE_TXB;
                break;
index 52b3675..e56bf58 100644 (file)
@@ -1327,7 +1327,8 @@ Parse_InstructionSequence(struct parse_state *parseState,
 
          inst->Opcode = instMatch.opcode;
          inst->Precision = instMatch.suffixes & (_R | _H | _X);
-         inst->Saturate = (instMatch.suffixes & (_S)) ? GL_TRUE : GL_FALSE;
+         inst->SaturateMode = (instMatch.suffixes & (_S))
+            ? SATURATE_ZERO_ONE : SATURATE_OFF;
          inst->CondUpdate = (instMatch.suffixes & (_C)) ? GL_TRUE : GL_FALSE;
          inst->StringPos = parseState->curLine - parseState->start;
          assert(inst->StringPos >= 0);
@@ -1745,7 +1746,7 @@ _mesa_print_nv_fragment_program(const struct fragment_program *program)
                _mesa_printf("X");
             if (inst->CondUpdate)
                _mesa_printf("C");
-            if (inst->Saturate)
+            if (inst->SaturateMode == SATURATE_ZERO_ONE)
                _mesa_printf("_SAT");
             _mesa_printf(" ");
 
index 28b982b..38982de 100644 (file)
@@ -1458,7 +1458,7 @@ _mesa_print_instruction(const struct prog_instruction *inst)
       break;
    case OPCODE_SWZ:
       _mesa_printf("SWZ");
-      if (inst->Saturate)
+      if (inst->SaturateMode == SATURATE_ZERO_ONE)
          _mesa_printf("_SAT");
       print_dst_reg(&inst->DstReg);
       _mesa_printf("%s[%d], %s;\n",
@@ -1471,7 +1471,7 @@ _mesa_print_instruction(const struct prog_instruction *inst)
    case OPCODE_TXP:
    case OPCODE_TXB:
       _mesa_printf("%s", _mesa_opcode_string(inst->Opcode));
-      if (inst->Saturate)
+      if (inst->SaturateMode == SATURATE_ZERO_ONE)
          _mesa_printf("_SAT");
       _mesa_printf(" ");
       print_dst_reg(&inst->DstReg);
@@ -1504,7 +1504,7 @@ _mesa_print_instruction(const struct prog_instruction *inst)
          _mesa_printf("%s", _mesa_opcode_string(inst->Opcode));
 
          /* frag prog only */
-         if (inst->Saturate)
+         if (inst->SaturateMode == SATURATE_ZERO_ONE)
             _mesa_printf("_SAT");
 
          if (inst->DstReg.File != PROGRAM_UNDEFINED) {
index a6910bd..20886d9 100644 (file)
@@ -54,7 +54,7 @@
 /*@}*/
 
 
-/*
+/**
  * Instruction precision for GL_NV_fragment_program
  */
 /*@{*/
 
 
 /**
+ * Saturation modes when storing values.
+ */
+/*@{*/
+#define SATURATE_OFF            0
+#define SATURATE_ZERO_ONE       1
+#define SATURATE_PLUS_MINUS_ONE 2
+/*@}*/
+
+
+/**
  * Program instruction opcodes, for both vertex and fragment programs.
  * \note changes to this opcode list must be reflected in t_vb_arbprogram.c
  */
@@ -267,8 +277,8 @@ struct prog_instruction
     * condition code register that is to be updated.
     *
     * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition
-    * code register 0 is available.  In GL_NV_vertex_program3 mode, condition code registers
-    * 0 and 1 are available.
+    * code register 0 is available.  In GL_NV_vertex_program3 mode, condition
+    * code registers 0 and 1 are available.
     *
     * \since
     * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
@@ -280,11 +290,12 @@ struct prog_instruction
     * Saturate each value of the vectored result to the range [0,1] or the
     * range [-1,1].  \c SSAT mode (i.e., saturation to the range [-1,1]) is
     * only available in NV_fragment_program2 mode.
+    * Value is one of the SATURATE_* tokens.
     *
     * \since
     * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3.
     */
-   GLuint Saturate:1;
+   GLuint SaturateMode:2;
    
    /**
     * Per-instruction selectable precision.
index 9e35f4e..7c59a2b 100644 (file)
@@ -390,7 +390,7 @@ store_vector4( const struct prog_instruction *inst,
                const GLfloat value[4] )
 {
    const struct prog_dst_register *dest = &(inst->DstReg);
-   const GLboolean clamp = inst->Saturate;
+   const GLboolean clamp = inst->SaturateMode == SATURATE_ZERO_ONE;
    const GLboolean updateCC = inst->CondUpdate;
    GLfloat *dstReg;
    GLfloat dummyReg[4];