program: Shrink and rename SaturateMode field to Saturate.

It was 2 bits to accommodate SATURATE_PLUS_MINUS_ONE (removed by commit
09b566e1). A similar change was made to TGSI recently in commit
e1c4e8aa.

Reducing the size from 2 bits to 1 reduces the size of the bit fields
from 17 bits to 16, which is a much nicer number.

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Matt Turner
2015-06-01 16:22:55 -07:00
parent 56b2b3d385
commit ef3f89e53e
12 changed files with 20 additions and 32 deletions

View File

@@ -220,7 +220,7 @@ get_result_flags(const struct prog_instruction *inst)
{
GLuint flags = 0;
if (inst->SaturateMode == SATURATE_ZERO_ONE)
if (inst->Saturate)
flags |= A0_DEST_SATURATE;
if (inst->DstReg.WriteMask & WRITEMASK_X)
flags |= A0_DEST_CHANNEL_X;

View File

@@ -2720,7 +2720,7 @@ get_mesa_program(struct gl_context *ctx,
mesa_inst->Opcode = inst->op;
mesa_inst->CondUpdate = inst->cond_update;
if (inst->saturate)
mesa_inst->SaturateMode = SATURATE_ZERO_ONE;
mesa_inst->Saturate = GL_TRUE;
mesa_inst->DstReg.File = inst->dst.file;
mesa_inst->DstReg.Index = inst->dst.index;
mesa_inst->DstReg.CondMask = inst->dst.cond_mask;

View File

@@ -397,7 +397,7 @@ store_vector4(const struct prog_instruction *inst,
struct gl_program_machine *machine, const GLfloat value[4])
{
const struct prog_dst_register *dstReg = &(inst->DstReg);
const GLboolean clamp = inst->SaturateMode == SATURATE_ZERO_ONE;
const GLboolean clamp = inst->Saturate;
GLuint writeMask = dstReg->WriteMask;
GLfloat clampedValue[4];
GLfloat *dst = get_dst_register_pointer(dstReg, machine);

View File

@@ -55,7 +55,7 @@ _mesa_init_instructions(struct prog_instruction *inst, GLuint count)
inst[i].DstReg.CondMask = COND_TR;
inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP;
inst[i].SaturateMode = SATURATE_OFF;
inst[i].Saturate = GL_FALSE;
inst[i].Precision = FLOAT32;
}
}

View File

@@ -117,15 +117,6 @@
/*@}*/
/**
* Saturation modes when storing values.
*/
/*@{*/
#define SATURATE_OFF 0
#define SATURATE_ZERO_ONE 1
/*@}*/
/**
* Per-component negation masks
*/
@@ -327,15 +318,12 @@ struct prog_instruction
GLuint CondDst:1;
/**
* 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.
* Saturate each value of the vectored result to the range [0,1].
*
* \since
* NV_fragment_program_option, NV_vertex_program3.
*/
GLuint SaturateMode:2;
GLuint Saturate:1;
/**
* Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12.

View File

@@ -478,7 +478,7 @@ can_upward_mov_be_modifed(const struct prog_instruction *mov)
return
can_downward_mov_be_modifed(mov) &&
mov->DstReg.File == PROGRAM_TEMPORARY &&
mov->SaturateMode == SATURATE_OFF;
!mov->Saturate;
}
@@ -653,7 +653,7 @@ _mesa_merge_mov_into_inst(struct prog_instruction *inst,
if (mask != (inst->DstReg.WriteMask & mask))
return GL_FALSE;
inst->SaturateMode |= mov->SaturateMode;
inst->Saturate |= mov->Saturate;
/* Depending on the instruction, we may need to recompute the swizzles.
* Also, some other instructions (like TEX) are not linear. We will only

View File

@@ -600,7 +600,7 @@ _mesa_fprint_alu_instruction(FILE *f,
fprintf(f, ".C");
/* frag prog only */
if (inst->SaturateMode == SATURATE_ZERO_ONE)
if (inst->Saturate)
fprintf(f, "_SAT");
fprintf(f, " ");
@@ -658,7 +658,7 @@ _mesa_fprint_instruction_opt(FILE *f,
switch (inst->Opcode) {
case OPCODE_SWZ:
fprintf(f, "SWZ");
if (inst->SaturateMode == SATURATE_ZERO_ONE)
if (inst->Saturate)
fprintf(f, "_SAT");
fprintf(f, " ");
fprint_dst_reg(f, &inst->DstReg, mode, prog);
@@ -675,7 +675,7 @@ _mesa_fprint_instruction_opt(FILE *f,
case OPCODE_TXB:
case OPCODE_TXD:
fprintf(f, "%s", _mesa_opcode_string(inst->Opcode));
if (inst->SaturateMode == SATURATE_ZERO_ONE)
if (inst->Saturate)
fprintf(f, "_SAT");
fprintf(f, " ");
fprint_dst_reg(f, &inst->DstReg, mode, prog);

View File

@@ -900,8 +900,8 @@ ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst)
break;
}
if (prog_inst->SaturateMode) {
assert(prog_inst->SaturateMode == SATURATE_ZERO_ONE);
if (prog_inst->Saturate) {
assert(prog_inst->Saturate);
assert(!dest.dest.is_ssa);
ptn_move_dest(b, dest, nir_fsat(b, ptn_src_for_dest(c, &dest)));
}

View File

@@ -2308,7 +2308,7 @@ asm_instruction_copy_ctor(const struct prog_instruction *base,
inst->Base.Opcode = base->Opcode;
inst->Base.CondUpdate = base->CondUpdate;
inst->Base.CondDst = base->CondDst;
inst->Base.SaturateMode = base->SaturateMode;
inst->Base.Saturate = base->Saturate;
inst->Base.Precision = base->Precision;
asm_instruction_set_operands(inst, dst, src0, src1, src2);

View File

@@ -40,7 +40,7 @@ _mesa_parse_instruction_suffix(const struct asm_parser_state *state,
{
inst->CondUpdate = 0;
inst->CondDst = 0;
inst->SaturateMode = SATURATE_OFF;
inst->Saturate = GL_FALSE;
inst->Precision = FLOAT32;
@@ -82,7 +82,7 @@ _mesa_parse_instruction_suffix(const struct asm_parser_state *state,
*/
if (state->mode == ARB_fragment) {
if (strcmp(suffix, "_SAT") == 0) {
inst->SaturateMode = SATURATE_ZERO_ONE;
inst->Saturate = GL_TRUE;
suffix += 4;
}
}

View File

@@ -305,7 +305,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
/* change the instruction to write to colorTemp w/ clamping */
inst->DstReg.File = PROGRAM_TEMPORARY;
inst->DstReg.Index = colorTemp;
inst->SaturateMode = saturate;
inst->Saturate = saturate;
/* don't break (may be several writes to result.color) */
}
inst++;
@@ -331,7 +331,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
inst->SrcReg[2].File = PROGRAM_STATE_VAR;
inst->SrcReg[2].Index = fogPRefOpt;
inst->SrcReg[2].Swizzle = SWIZZLE_YYYY;
inst->SaturateMode = SATURATE_ZERO_ONE;
inst->Saturate = GL_TRUE;
inst++;
}
else {
@@ -374,7 +374,7 @@ _mesa_append_fog_code(struct gl_context *ctx,
inst->SrcReg[0].Index = fogFactorTemp;
inst->SrcReg[0].Negate = NEGATE_XYZW;
inst->SrcReg[0].Swizzle = SWIZZLE_XXXX;
inst->SaturateMode = SATURATE_ZERO_ONE;
inst->Saturate = GL_TRUE;
inst++;
}
/* LRP result.color.xyz, fogFactorTemp.xxxx, colorTemp, fogColorRef; */

View File

@@ -665,7 +665,7 @@ compile_instruction(
if (num_dst)
dst[0] = translate_dst( t,
&inst->DstReg,
inst->SaturateMode,
inst->Saturate,
clamp_dst_color_output);
for (i = 0; i < num_src; i++)