summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-20 17:52:40 +0000
committerBrian Paul <[email protected]>2005-11-20 17:52:40 +0000
commite31ac052236ea615b4995f9ec301d8af4b864531 (patch)
tree5f0229e4a01b25078b710cbc4d288c0c37fc83c3 /src/mesa/shader
parent22db53577603afef8fdf62c324ff5977de76b9d8 (diff)
Make Saturate a 2-bit field again, renamed to SaturateMode with three
possible values: SATURATE_OFF, SATURATE_ZERO_ONE and SATURATE_PLUS_MINUS_ONE.
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbprogparse.c64
-rw-r--r--src/mesa/shader/nvfragparse.c5
-rw-r--r--src/mesa/shader/program.c6
-rw-r--r--src/mesa/shader/program_instruction.h19
4 files changed, 53 insertions, 41 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index d847a81a59b..09b1caeaaeb 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -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;
diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c
index 52b36758324..e56bf589fbb 100644
--- a/src/mesa/shader/nvfragparse.c
+++ b/src/mesa/shader/nvfragparse.c
@@ -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(" ");
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 28b982b6ea7..38982de9936 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -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) {
diff --git a/src/mesa/shader/program_instruction.h b/src/mesa/shader/program_instruction.h
index a6910bd2f8b..20886d9f021 100644
--- a/src/mesa/shader/program_instruction.h
+++ b/src/mesa/shader/program_instruction.h
@@ -54,7 +54,7 @@
/*@}*/
-/*
+/**
* Instruction precision for GL_NV_fragment_program
*/
/*@{*/
@@ -65,6 +65,16 @@
/**
+ * 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.