diff options
author | Brian Paul <[email protected]> | 2005-11-20 17:52:40 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-11-20 17:52:40 +0000 |
commit | e31ac052236ea615b4995f9ec301d8af4b864531 (patch) | |
tree | 5f0229e4a01b25078b710cbc4d288c0c37fc83c3 /src/mesa | |
parent | 22db53577603afef8fdf62c324ff5977de76b9d8 (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')
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_fragprog.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_fragprog.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texenvprogram.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 64 | ||||
-rw-r--r-- | src/mesa/shader/nvfragparse.c | 5 | ||||
-rw-r--r-- | src/mesa/shader/program.c | 6 | ||||
-rw-r--r-- | src/mesa/shader/program_instruction.h | 19 | ||||
-rw-r--r-- | src/mesa/swrast/s_nvfragprog.c | 2 |
8 files changed, 57 insertions, 45 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c index eed27677f95..5dd6671a9e3 100644 --- a/src/mesa/drivers/dri/i915/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c @@ -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; diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c index abcff64235f..aef574b8698 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog.c @@ -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; } diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 0d536951c94..a92db42bfd0 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -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 ); 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. diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 9e35f4e4253..7c59a2bb594 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -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]; |