possible values: SATURATE_OFF, SATURATE_ZERO_ONE and SATURATE_PLUS_MINUS_ONE.
{
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;
}
for (fpi=mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) {
- if (fpi->Saturate) {
+ if (fpi->SaturateMode == SATURATE_ZERO_ONE) {
flags = PFS_FLAG_SAT;
}
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 );
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;
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;
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;
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;
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;
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;
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;
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);
_mesa_printf("X");
if (inst->CondUpdate)
_mesa_printf("C");
- if (inst->Saturate)
+ if (inst->SaturateMode == SATURATE_ZERO_ONE)
_mesa_printf("_SAT");
_mesa_printf(" ");
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",
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);
_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) {
/*@}*/
-/*
+/**
* 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
* 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,
* 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.
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];