GET_SWZ(source->Swizzle, 1),
GET_SWZ(source->Swizzle, 2), GET_SWZ(source->Swizzle, 3));
- if (source->NegateBase)
+ if (source->Negate)
src = negate(src,
- GET_BIT(source->NegateBase, 0),
- GET_BIT(source->NegateBase, 1),
- GET_BIT(source->NegateBase, 2),
- GET_BIT(source->NegateBase, 3));
+ GET_BIT(source->Negate, 0),
+ GET_BIT(source->Negate, 1),
+ GET_BIT(source->Negate, 2),
+ GET_BIT(source->Negate, 3));
return src;
}
struct prog_src_register src )
{
GLuint i;
- GLubyte active = src.NegateBase; /* NOTE! */
+ GLubyte active = src.Negate; /* NOTE! */
if (src.RelAddr)
return 0xf;
/* Note this is ok for non-swizzle instructions:
*/
- reg.negate = src->NegateBase ? 1 : 0;
+ reg.negate = src->Negate ? 1 : 0;
return reg;
}
GLuint ones_mask = 0;
GLuint src_mask = 0;
GLubyte src_swz[4];
- GLboolean need_tmp = (src.NegateBase &&
+ GLboolean need_tmp = (src.Negate &&
dst.file != BRW_GENERAL_REGISTER_FILE);
struct brw_reg tmp = dst;
GLuint i;
if (ones_mask)
brw_MOV(p, brw_writemask(tmp, ones_mask), brw_imm_f(1));
- if (src.NegateBase)
- brw_MOV(p, brw_writemask(tmp, src.NegateBase), negate(tmp));
+ if (src.Negate)
+ brw_MOV(p, brw_writemask(tmp, src.Negate), negate(tmp));
if (need_tmp) {
brw_MOV(p, dst, tmp);
reg.Index = idx;
reg.Swizzle = SWIZZLE_NOOP;
reg.RelAddr = 0;
- reg.NegateBase = 0;
+ reg.Negate = NEGATE_NONE;
reg.Abs = 0;
- reg.NegateAbs = 0;
return reg;
}
src_undef(),
src_undef());
/* Avoid letting negation flag of src0 affect our 1 constant. */
- swz->SrcReg[0].NegateBase &= ~NEGATE_X;
+ swz->SrcReg[0].Negate &= ~NEGATE_X;
}
if (dst.WriteMask & WRITEMASK_W) {
/* dst.w = mov src1.w
src_undef(),
src_undef());
/* Avoid letting the negation flag of src0 affect our 1 constant. */
- swz->SrcReg[0].NegateBase = 0;
+ swz->SrcReg[0].Negate = NEGATE_NONE;
}
if (dst.WriteMask & WRITEMASK_YZ) {
src0,
src_undef(),
src_undef());
- out->SrcReg[0].NegateBase = 0;
+ out->SrcReg[0].Negate = NEGATE_NONE;
out->SrcReg[0].Abs = 1;
/* tmp0 = MAX(coord.X, coord.Y) */
case OPCODE_ABS:
out = emit_insn(c, inst);
out->Opcode = OPCODE_MOV;
- out->SrcReg[0].NegateBase = 0;
+ out->SrcReg[0].Negate = NEGATE_NONE;
out->SrcReg[0].Abs = 1;
break;
case OPCODE_SUB:
out = emit_insn(c, inst);
out->Opcode = OPCODE_ADD;
- out->SrcReg[1].NegateBase ^= 0xf;
+ out->SrcReg[1].Negate ^= NEGATE_XYZW;
break;
case OPCODE_SCS:
const_reg = stride(const_reg, 0, 1, 0);
const_reg.subnr = component * 4;
- if (src->NegateBase)
+ if (src->Negate & (1 << component))
const_reg = negate(const_reg);
if (src->Abs)
const_reg = brw_abs(const_reg);
else {
/* other type of source register */
return get_reg(c, src->File, src->Index, component, nr,
- src->NegateBase, src->Abs);
+ src->Negate, src->Abs);
}
}
const GLfloat *param =
c->fp->program.Base.Parameters->ParameterValues[src->Index];
GLfloat value = param[component];
- if (src->NegateBase)
+ if (src->Negate & (1 << channel))
value = -value;
if (src->Abs)
value = FABSF(value);
newref->value->lastuse = newref;
}
- if (src.NegateBase & (1<<i))
+ if (src.Negate & (1 << i))
newref->hw_reg.negate ^= 1;
if (src.Abs) {
t_swizzle(GET_SWZ(src->Swizzle, 2)),
t_swizzle(GET_SWZ(src->Swizzle, 3)),
t_src_class(src->File),
- src->NegateBase) | (src->RelAddr << 4);
+ src->Negate) | (src->RelAddr << 4);
}
static unsigned long t_src_scalar(struct r200_vertex_program *vp, struct prog_src_register *src)
t_swizzle(GET_SWZ(src->Swizzle, 0)),
t_swizzle(GET_SWZ(src->Swizzle, 0)),
t_src_class(src->File),
- src->NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src->RelAddr << 4);
+ src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src->RelAddr << 4);
}
static unsigned long t_opcode(enum prog_opcode opcode)
t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
SWIZZLE_ZERO,
t_src_class(src[0].File),
- src[0].NegateBase) | (src[0].RelAddr << 4);
+ src[0].Negate) | (src[0].RelAddr << 4);
o_inst->src1 = UNUSED_SRC_0;
o_inst->src2 = UNUSED_SRC_0;
}
t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO,
t_src_class(src[0].File),
- src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
o_inst->src1 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
SWIZZLE_ZERO, SWIZZLE_ZERO,
t_swizzle(GET_SWZ(src[1].Swizzle, 0)), SWIZZLE_ZERO,
t_src_class(src[1].File),
- src[1].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
+ src[1].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
o_inst->src2 = UNUSED_SRC_1;
o_inst++;
o_inst->src1 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X,
t_src_class(src[1].File),
- src[1].NegateBase) | (src[1].RelAddr << 4);
+ src[1].Negate) | (src[1].RelAddr << 4);
o_inst->src2 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y,
t_src_class(src[1].File),
- src[1].NegateBase) | (src[1].RelAddr << 4);
+ src[1].Negate) | (src[1].RelAddr << 4);
}
else {
o_inst->src1 = t_src(vp, &src[1]);
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
SWIZZLE_ZERO,
t_src_class(src[0].File),
- src[0].NegateBase) | (src[0].RelAddr << 4);
+ src[0].Negate) | (src[0].RelAddr << 4);
o_inst->src1 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
SWIZZLE_ZERO,
t_src_class(src[1].File),
- src[1].NegateBase) | (src[1].RelAddr << 4);
+ src[1].Negate) | (src[1].RelAddr << 4);
o_inst->src2 = UNUSED_SRC_1;
goto next;
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
VSF_IN_COMPONENT_ONE,
t_src_class(src[0].File),
- src[0].NegateBase) | (src[0].RelAddr << 4);
+ src[0].Negate) | (src[0].RelAddr << 4);
o_inst->src1 = t_src(vp, &src[1]);
o_inst->src2 = UNUSED_SRC_1;
goto next;
t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
t_src_class(src[1].File),
- (!src[1].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
+ (!src[1].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
o_inst->src2 = UNUSED_SRC_1;
goto next;
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
t_src_class(src[0].File),
- (!src[0].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
+ (!src[0].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
o_inst->src2 = UNUSED_SRC_1;
goto next;
VSF_IN_COMPONENT_W,
VSF_IN_CLASS_TMP,
/* Not 100% sure about this */
- (!src[0].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE/*VSF_FLAG_ALL*/);
+ (!src[0].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE/*VSF_FLAG_ALL*/);
o_inst->src2 = UNUSED_SRC_0;
u_temp_i--;
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
t_src_class(src[0].File),
- src[0].NegateBase) | (src[0].RelAddr << 4);
+ src[0].Negate) | (src[0].RelAddr << 4);
o_inst->src1 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
t_src_class(src[1].File),
- src[1].NegateBase) | (src[1].RelAddr << 4);
+ src[1].Negate) | (src[1].RelAddr << 4);
o_inst->src2 = UNUSED_SRC_1;
o_inst++;
t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
t_src_class(src[1].File),
- (!src[1].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
+ (!src[1].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
o_inst->src1 = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
t_src_class(src[0].File),
- src[0].NegateBase) | (src[0].RelAddr << 4);
+ src[0].Negate) | (src[0].RelAddr << 4);
o_inst->src2 = MAKE_VSF_SOURCE(u_temp_i+1,
VSF_IN_COMPONENT_X,
* r < tex <=> -tex+r < 0
* r >= tex <=> not (-tex+r < 0 */
if (comparefunc == GL_LESS || comparefunc == GL_GEQUAL)
- tgt[1].SrcReg[2].NegateBase = tgt[0].SrcReg[2].NegateBase ^ NEGATE_XYZW;
+ tgt[1].SrcReg[2].Negate = tgt[0].SrcReg[2].Negate ^ NEGATE_XYZW;
else
- tgt[1].SrcReg[0].NegateBase = tgt[0].SrcReg[0].NegateBase ^ NEGATE_XYZW;
+ tgt[1].SrcReg[0].Negate = tgt[0].SrcReg[0].Negate ^ NEGATE_XYZW;
tgt[2].Opcode = OPCODE_CMP;
tgt[2].DstReg = orig_inst->DstReg;
GLboolean r300FPIsNativeSwizzle(GLuint opcode, struct prog_src_register reg)
{
if (reg.Abs)
- reg.NegateBase = 0;
+ reg.Negate = NEGATE_NONE;
if (opcode == OPCODE_KIL ||
opcode == OPCODE_TEX ||
opcode == OPCODE_TXP) {
int j;
- if (reg.Abs || reg.NegateBase != (15*reg.NegateAbs))
+ if (reg.Abs || (reg.Negate != NEGATE_XYZW &&
+ reg.Negate != NEGATE_NONE))
return GL_FALSE;
for(j = 0; j < 4; ++j) {
if (GET_SWZ(reg.Swizzle, j) != SWIZZLE_NIL)
relevant |= 1 << j;
- if ((reg.NegateBase & relevant) && (reg.NegateBase & relevant) != relevant)
+ if ((reg.Negate & relevant) && (reg.Negate & relevant) != relevant)
return GL_FALSE;
if (!lookup_native_swizzle(reg.Swizzle))
void r300FPBuildSwizzle(struct nqssadce_state *s, struct prog_dst_register dst, struct prog_src_register src)
{
if (src.Abs)
- src.NegateBase = 0;
+ src.Negate = NEGATE_NONE;
while(dst.WriteMask) {
const struct swizzle_data *best_swizzle = 0;
}
}
- if ((src.NegateBase & best_matchmask) != 0) {
- best_matchmask &= src.NegateBase;
- rgbnegate = !src.NegateAbs;
+ if ((src.Negate & best_matchmask) != 0) {
+ best_matchmask &= src.Negate;
+ rgbnegate = !src.Negate;
} else {
- rgbnegate = src.NegateAbs;
+ rgbnegate = src.Negate;
}
struct prog_instruction *inst;
static unsigned long t_src(struct r300_vertex_program *vp,
struct prog_src_register *src)
{
- /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
+ /* src->Negate uses the NEGATE_ flags from program_instruction.h,
* which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
*/
return PVS_SRC_OPERAND(t_src_index(vp, src),
t_swizzle(GET_SWZ(src->Swizzle, 2)),
t_swizzle(GET_SWZ(src->Swizzle, 3)),
t_src_class(src->File),
- src->NegateBase) | (src->RelAddr << 4);
+ src->Negate) | (src->RelAddr << 4);
}
static unsigned long t_src_scalar(struct r300_vertex_program *vp,
struct prog_src_register *src)
{
- /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
+ /* src->Negate uses the NEGATE_ flags from program_instruction.h,
* which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
*/
return PVS_SRC_OPERAND(t_src_index(vp, src),
t_swizzle(GET_SWZ(src->Swizzle, 0)),
t_swizzle(GET_SWZ(src->Swizzle, 0)),
t_src_class(src->File),
- src->
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src->RelAddr << 4);
}
t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
t_src_class(src[0].File),
(!src[0].
- NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[3] = 0;
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
SWIZZLE_ZERO,
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[2] =
PVS_SRC_OPERAND(t_src_index(vp, &src[1]),
t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
t_swizzle(GET_SWZ(src[1].Swizzle, 2)), SWIZZLE_ZERO,
t_src_class(src[1].File),
- src[1].
- NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+ src[1].Negate ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
(src[1].RelAddr << 4);
inst[3] = __CONST(1, SWIZZLE_ZERO);
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
PVS_SRC_SELECT_FORCE_1,
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[2] = t_src(vp, &src[1]);
inst[3] = __CONST(1, SWIZZLE_ZERO);
PVS_SRC_SELECT_W, PVS_SRC_REG_TEMPORARY,
/* Not 100% sure about this */
(!src[0].
- NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE
+ Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE
/*VSF_FLAG_ALL */ );
inst[3] = __CONST(0, SWIZZLE_ZERO);
(*u_temp_i)--;
t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[2] = __CONST(0, SWIZZLE_ZERO);
inst[3] = __CONST(0, SWIZZLE_ZERO);
PVS_SRC_SELECT_FORCE_0, // Z
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
PVS_SRC_SELECT_FORCE_0, // Z
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[3] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
PVS_SRC_SELECT_FORCE_0, // Z
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
return inst;
t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
t_src_class(src[1].File),
(!src[1].
- NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[1].RelAddr << 4);
inst[3] = 0;
#else
t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
t_src_class(src[1].File),
(!src[1].
- NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[1].RelAddr << 4);
#endif
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // Z
t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // X
t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // Y
t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // W
t_src_class(src[1].File),
- src[1].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[1].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[1].RelAddr << 4);
inst[3] = __CONST(1, SWIZZLE_ZERO);
inst += 4;
t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // W
t_src_class(src[1].File),
(!src[1].
- NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[1].RelAddr << 4);
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // Z
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
(src[0].RelAddr << 4);
inst[3] =
PVS_SRC_OPERAND(*u_temp_i, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y,
* r < tex <=> -tex+r < 0
* r >= tex <=> not (-tex+r < 0 */
if (comparefunc == GL_LESS || comparefunc == GL_GEQUAL)
- tgt[1].SrcReg[2].NegateBase = tgt[0].SrcReg[2].NegateBase ^ NEGATE_XYZW;
+ tgt[1].SrcReg[2].Negate = tgt[0].SrcReg[2].Negate ^ NEGATE_XYZW;
else
- tgt[1].SrcReg[0].NegateBase = tgt[0].SrcReg[0].NegateBase ^ NEGATE_XYZW;
+ tgt[1].SrcReg[0].Negate = tgt[0].SrcReg[0].Negate ^ NEGATE_XYZW;
tgt[2].Opcode = OPCODE_CMP;
tgt[2].DstReg = orig_inst->DstReg;
if (reg.Abs)
return GL_FALSE;
- if (reg.NegateAbs)
- reg.NegateBase ^= 15;
+ if (reg.Negate)
+ reg.Negate ^= NEGATE_XYZW;
if (opcode == OPCODE_KIL) {
if (reg.Swizzle != SWIZZLE_NOOP)
for(i = 0; i < 4; ++i) {
GLuint swz = GET_SWZ(reg.Swizzle, i);
if (swz == SWIZZLE_NIL) {
- reg.NegateBase &= ~(1 << i);
+ reg.Negate &= ~(1 << i);
continue;
}
if (swz >= 4)
}
}
- if (reg.NegateBase)
+ if (reg.Negate)
return GL_FALSE;
return GL_TRUE;
} else if (opcode == OPCODE_DDX || opcode == OPCODE_DDY) {
/* DDX/MDH and DDY/MDV explicitly ignore incoming swizzles;
* if it doesn't fit perfectly into a .xyzw case... */
- if (reg.Swizzle == SWIZZLE_NOOP && !reg.Abs
- && !reg.NegateBase && !reg.NegateAbs)
+ if (reg.Swizzle == SWIZZLE_NOOP && !reg.Abs && !reg.Negate)
return GL_TRUE;
return GL_FALSE;
if (swz != SWIZZLE_NIL && swz != SWIZZLE_ZERO)
relevant |= 1 << i;
}
- if ((reg.NegateBase & relevant) && ((reg.NegateBase & relevant) != relevant))
+ if ((reg.Negate & relevant) && ((reg.Negate & relevant) != relevant))
return GL_FALSE;
return GL_TRUE;
GLuint swz = GET_SWZ(src.Swizzle, i);
if (swz == SWIZZLE_NIL)
continue;
- negatebase[GET_BIT(src.NegateBase, i)] |= 1 << i;
+ negatebase[GET_BIT(src.Negate, i)] |= 1 << i;
}
_mesa_insert_instructions(s->Program, s->IP, (negatebase[0] ? 1 : 0) + (negatebase[1] ? 1 : 0));
struct prog_src_register tmp = srcreg;
int i;
tmp.Swizzle = 0;
- tmp.NegateBase = 0;
+ tmp.Negate = NEGATE_NONE;
for(i = 0; i < 4; ++i) {
GLuint swz = GET_SWZ(swizzle, i);
if (swz < 4) {
tmp.Swizzle |= GET_SWZ(srcreg.Swizzle, swz) << (i*3);
- tmp.NegateBase |= GET_BIT(srcreg.NegateBase, swz) << i;
+ tmp.Negate |= GET_BIT(srcreg.Negate, swz) << i;
} else {
tmp.Swizzle |= swz << (i*3);
}
inst->SrcReg[src].File = PROGRAM_TEMPORARY;
inst->SrcReg[src].Index = dstreg.Index;
inst->SrcReg[src].Swizzle = 0;
- inst->SrcReg[src].NegateBase = 0;
+ inst->SrcReg[src].Negate = NEGATE_NONE;
inst->SrcReg[src].Abs = 0;
- inst->SrcReg[src].NegateAbs = 0;
for(i = 0; i < 4; ++i) {
if (GET_BIT(sourced, i))
inst->SrcReg[src].Swizzle |= i << (3*i);
static void set_negate_base(struct prog_src_register *SrcReg, int coordinate, int negate)
{
- SrcReg->NegateBase &= ~(1 << coordinate);
- SrcReg->NegateBase |= (negate << coordinate);
+ /* XXX note sure about this negation logic here */
+ SrcReg->Negate &= ~(1 << coordinate);
+ SrcReg->Negate |= (negate << coordinate);
}
static struct prog_dst_register dstreg(int file, int index)
{
struct prog_src_register newreg = reg;
newreg.Abs = 1;
- newreg.NegateBase = 0;
- newreg.NegateAbs = 0;
+ newreg.Negate = NEGATE_NONE;
return newreg;
}
static struct prog_src_register negate(struct prog_src_register reg)
{
struct prog_src_register newreg = reg;
- newreg.NegateAbs = !newreg.NegateAbs;
+ newreg.Negate = newreg.Negate ^ NEGATE_XYZW;
return newreg;
}
{
struct prog_src_register src = inst->SrcReg[0];
src.Abs = 1;
- src.NegateBase = 0;
- src.NegateAbs = 0;
+ src.Negate = NEGATE_NONE;
emit1(t->Program, OPCODE_MOV, inst->SaturateMode, inst->DstReg, src);
}
struct prog_instruction* inst)
{
struct prog_src_register src0 = inst->SrcReg[0];
- if (src0.NegateAbs) {
+ if (src0.Negate) {
if (src0.Abs) {
int tempreg = radeonFindFreeTemporary(t);
emit1(t->Program, OPCODE_MOV, 0, dstreg(PROGRAM_TEMPORARY, tempreg), src0);
src0 = srcreg(src0.File, src0.Index);
} else {
- src0.NegateAbs = 0;
- src0.NegateBase ^= NEGATE_XYZW;
+ src0.Negate ^= NEGATE_XYZW;
}
}
set_swizzle(&src0, 3, SWIZZLE_ONE);
B.Swizzle = MAKE_SWIZZLE4(SWIZZLE_ONE, SWIZZLE_ONE,
SWIZZLE_ONE, SWIZZLE_ONE);
- B.NegateBase = NEGATE_XYZW;
+ B.Negate = NEGATE_XYZW;
emit2(t->Program, inst->Opcode, inst->SaturateMode, inst->DstReg,
inst->SrcReg[0], B);
inst->SrcReg[2] = inst->SrcReg[1];
inst->SrcReg[1].File = PROGRAM_BUILTIN;
inst->SrcReg[1].Swizzle = SWIZZLE_1111;
- inst->SrcReg[1].NegateBase = 0;
- inst->SrcReg[1].NegateAbs = 0;
+ inst->SrcReg[1].Negate = NEGATE_NONE;
inst->Opcode = OPCODE_MAD;
break;
case OPCODE_CMP:
srcrgb = GL_TRUE;
else if (swz < 4)
srcalpha = GL_TRUE;
- if (swz != SWIZZLE_NIL && GET_BIT(inst->SrcReg[i].NegateBase, j))
+ if (swz != SWIZZLE_NIL && GET_BIT(inst->SrcReg[i].Negate, j))
negatebase = 1;
}
source = alloc_pair_source(s, pair, inst->SrcReg[i], srcrgb, srcalpha);
pair->RGB.Arg[i].Source = source;
pair->RGB.Arg[i].Swizzle = inst->SrcReg[i].Swizzle & 0x1ff;
pair->RGB.Arg[i].Abs = inst->SrcReg[i].Abs;
- pair->RGB.Arg[i].Negate = (negatebase & ~pair->RGB.Arg[i].Abs) ^ inst->SrcReg[i].NegateAbs;
+ pair->RGB.Arg[i].Negate = (negatebase & ~pair->RGB.Arg[i].Abs) ^ inst->SrcReg[i].Negate;
}
if (pairinst->NeedAlpha) {
GLboolean srcrgb = GL_FALSE;
GLboolean srcalpha = GL_FALSE;
- GLuint negatebase = GET_BIT(inst->SrcReg[i].NegateBase, pairinst->IsTranscendent ? 0 : 3);
+ GLuint negatebase = GET_BIT(inst->SrcReg[i].Negate, pairinst->IsTranscendent ? 0 : 3);
GLuint swz = GET_SWZ(inst->SrcReg[i].Swizzle, pairinst->IsTranscendent ? 0 : 3);
if (swz < 3)
srcrgb = GL_TRUE;
pair->Alpha.Arg[i].Source = source;
pair->Alpha.Arg[i].Swizzle = swz;
pair->Alpha.Arg[i].Abs = inst->SrcReg[i].Abs;
- pair->Alpha.Arg[i].Negate = (negatebase & ~pair->RGB.Arg[i].Abs) ^ inst->SrcReg[i].NegateAbs;
+ pair->Alpha.Arg[i].Negate = (negatebase & ~pair->RGB.Arg[i].Abs) ^ inst->SrcReg[i].Negate;
}
}
src->File = reg.file;
src->Index = reg.idx;
src->Swizzle = reg.swz;
- src->NegateBase = reg.negate ? NEGATE_XYZW : 0;
+ src->Negate = reg.negate ? NEGATE_XYZW : NEGATE_NONE;
src->Abs = 0;
- src->NegateAbs = 0;
src->RelAddr = 0;
/* Check that bitfield sizes aren't exceeded */
ASSERT(src->Index == reg.idx);
reg->File = ureg.file;
reg->Index = ureg.idx;
reg->Swizzle = ureg.swz;
- reg->NegateBase = ureg.negatebase ? 0xf : 0x0;
+ reg->Negate = ureg.negatebase ? NEGATE_XYZW : NEGATE_NONE;
reg->Abs = ureg.abs;
- reg->NegateAbs = ureg.negateabs;
}
static void emit_dst( struct prog_dst_register *dst,
reg->File = file;
reg->Index = index;
reg->Swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], swizzle[2], swizzle[3]);
- reg->NegateBase = negateMask;
+ reg->Negate = negateMask;
reg->RelAddr = isRelOffset;
return 0;
}
reg->File = file;
reg->Index = index;
reg->Swizzle = (swizzle[0] << 0);
- reg->NegateBase = negateMask;
+ reg->Negate = negateMask;
reg->RelAddr = isRelOffset;
return 0;
}
parse_extended_swizzle_mask(inst, swizzle, &negateMask);
fp->SrcReg[0].File = file;
fp->SrcReg[0].Index = index;
- fp->SrcReg[0].NegateBase = negateMask;
+ fp->SrcReg[0].Negate = negateMask;
fp->SrcReg[0].Swizzle = MAKE_SWIZZLE4(swizzle[0],
swizzle[1],
swizzle[2],
parse_extended_swizzle_mask (inst, swizzle, &negateMask);
vp->SrcReg[0].File = file;
vp->SrcReg[0].Index = index;
- vp->SrcReg[0].NegateBase = negateMask;
+ vp->SrcReg[0].Negate = negateMask;
vp->SrcReg[0].Swizzle = MAKE_SWIZZLE4(swizzle[0],
swizzle[1],
swizzle[2],
GLfloat sign = 1.0F;
GLubyte token[100];
GLint idx;
+ GLuint negateBase, negateAbs;
/*
* First, take care of +/- and absolute value stuff.
if (Parse_String(parseState, "|")) {
srcReg->Abs = GL_TRUE;
- srcReg->NegateAbs = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+ negateAbs = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE;
if (Parse_String(parseState, "-"))
- srcReg->NegateBase = NEGATE_XYZW;
+ negateBase = NEGATE_XYZW;
else if (Parse_String(parseState, "+"))
- srcReg->NegateBase = NEGATE_NONE;
+ negateBase = NEGATE_NONE;
else
- srcReg->NegateBase = NEGATE_NONE;
+ negateBase = NEGATE_NONE;
}
else {
srcReg->Abs = GL_FALSE;
- srcReg->NegateAbs = GL_FALSE;
- srcReg->NegateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE;
+ negateAbs = NEGATE_NONE;
+ negateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE;
}
+ srcReg->Negate = srcReg->Abs ? negateAbs : negateBase;
+
/* This should be the real src vector/register name */
if (!Peek_Token(parseState, token))
RETURN_ERROR;
GLfloat sign = 1.0F;
GLboolean needSuffix = GL_TRUE;
GLint idx;
+ GLuint negateBase, negateAbs;
/*
* First, take care of +/- and absolute value stuff.
if (Parse_String(parseState, "|")) {
srcReg->Abs = GL_TRUE;
- srcReg->NegateAbs = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+ negateAbs = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE;
if (Parse_String(parseState, "-"))
- srcReg->NegateBase = NEGATE_XYZW;
+ negateBase = NEGATE_XYZW;
else if (Parse_String(parseState, "+"))
- srcReg->NegateBase = NEGATE_NONE;
+ negateBase = NEGATE_NONE;
else
- srcReg->NegateBase = NEGATE_NONE;
+ negateBase = NEGATE_NONE;
}
else {
srcReg->Abs = GL_FALSE;
- srcReg->NegateAbs = GL_FALSE;
- srcReg->NegateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE;
+ negateAbs = NEGATE_NONE;
+ negateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE;
}
+ srcReg->Negate = srcReg->Abs ? negateAbs : negateBase;
+
if (!Peek_Token(parseState, token))
RETURN_ERROR;
}
inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
- inst->SrcReg[0].NegateBase = NEGATE_NONE;
inst->SrcReg[0].Abs = GL_FALSE;
- inst->SrcReg[0].NegateAbs = GL_FALSE;
+ inst->SrcReg[0].Negate = NEGATE_NONE;
return GL_TRUE;
}
RETURN_ERROR;
if (token[0] == '-') {
(void) Parse_String(parseState, "-");
- srcReg->NegateBase = NEGATE_XYZW;
+ srcReg->Negate = NEGATE_XYZW;
if (!Peek_Token(parseState, token))
RETURN_ERROR;
}
else {
- srcReg->NegateBase = NEGATE_NONE;
+ srcReg->Negate = NEGATE_NONE;
}
/* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
if (!Peek_Token(parseState, token))
RETURN_ERROR;
if (token[0] == '-') {
- srcReg->NegateBase = NEGATE_XYZW;
+ srcReg->Negate = NEGATE_XYZW;
(void) Parse_String(parseState, "-"); /* consume '-' */
if (!Peek_Token(parseState, token))
RETURN_ERROR;
}
else {
- srcReg->NegateBase = NEGATE_NONE;
+ srcReg->Negate = NEGATE_NONE;
}
/* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
RETURN_ERROR;
srcReg->RelAddr = GL_FALSE;
- srcReg->NegateBase = NEGATE_NONE;
+ srcReg->Negate = NEGATE_NONE;
srcReg->Swizzle = SWIZZLE_NOOP;
/* Register can be R<n>, c[n], c[n +/- offset], a named vertex attrib,
result[3] = src[GET_SWZ(source->Swizzle, 3)];
}
- if (source->NegateBase) {
- result[0] = -result[0];
- result[1] = -result[1];
- result[2] = -result[2];
- result[3] = -result[3];
- }
if (source->Abs) {
result[0] = FABSF(result[0]);
result[1] = FABSF(result[1]);
result[2] = FABSF(result[2]);
result[3] = FABSF(result[3]);
}
- if (source->NegateAbs) {
+ if (source->Negate) {
+ ASSERT(source->Negate == NEGATE_XYZW);
result[0] = -result[0];
result[1] = -result[1];
result[2] = -result[2];
result[3] = src[GET_SWZ(source->Swizzle, 3)];
}
- /* Note: no NegateBase, Abs, NegateAbs here */
+ /* Note: no Negate or Abs here */
}
result[2] = deriv[GET_SWZ(source->Swizzle, 2)];
result[3] = deriv[GET_SWZ(source->Swizzle, 3)];
- if (source->NegateBase) {
- result[0] = -result[0];
- result[1] = -result[1];
- result[2] = -result[2];
- result[3] = -result[3];
- }
if (source->Abs) {
result[0] = FABSF(result[0]);
result[1] = FABSF(result[1]);
result[2] = FABSF(result[2]);
result[3] = FABSF(result[3]);
}
- if (source->NegateAbs) {
+ if (source->Negate) {
+ ASSERT(source->Negate == NEGATE_XYZW);
result[0] = -result[0];
result[1] = -result[1];
result[2] = -result[2];
result[0] = src[GET_SWZ(source->Swizzle, 0)];
- if (source->NegateBase) {
- result[0] = -result[0];
- }
if (source->Abs) {
result[0] = FABSF(result[0]);
}
- if (source->NegateAbs) {
+ if (source->Negate) {
result[0] = -result[0];
}
}
ASSERT(swz <= 3);
result[i] = src[swz];
}
- if (source->NegateBase & (1 << i))
+ if (source->Negate & (1 << i))
result[i] = -result[i];
}
store_vector4(inst, machine, result);
GLuint Swizzle:12;
GLuint RelAddr:1;
- /**
- * \name Source register "sign" control.
- *
- * The ARB and NV extensions allow varrying degrees of control over the
- * sign of the source vector components. These values allow enough control
- * for all flavors of the extensions.
- */
- /*@{*/
- /**
- * Per-component negation for the SWZ instruction. For non-SWZ
- * instructions the only possible values are NEGATE_XYZW and NEGATE_NONE.
- *
- * \since
- * ARB_vertex_program, ARB_fragment_program
- */
- GLuint NegateBase:4;
-
- /**
- * Take the component-wise absolute value.
- *
- * \since
- * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2,
- * NV_vertex_program2_option.
- */
+ /** Take the component-wise absolute value */
GLuint Abs:1;
/**
- * Post-absolute value negation (all components).
+ * Post-Abs negation.
+ * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ
+ * instruction which allows per-component negation.
*/
- GLuint NegateAbs:1;
- /*@}*/
+ GLuint Negate:4;
};
* \param extended if true, also allow 0, 1 values
*/
const char *
-_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended)
+_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended)
{
static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */
static char s[20];
GLuint i = 0;
- if (!extended && swizzle == SWIZZLE_NOOP && negateBase == 0)
+ if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0)
return ""; /* no swizzle/negation */
if (!extended)
s[i++] = '.';
- if (negateBase & NEGATE_X)
+ if (negateMask & NEGATE_X)
s[i++] = '-';
s[i++] = swz[GET_SWZ(swizzle, 0)];
s[i++] = ',';
}
- if (negateBase & NEGATE_Y)
+ if (negateMask & NEGATE_Y)
s[i++] = '-';
s[i++] = swz[GET_SWZ(swizzle, 1)];
s[i++] = ',';
}
- if (negateBase & NEGATE_Z)
+ if (negateMask & NEGATE_Z)
s[i++] = '-';
s[i++] = swz[GET_SWZ(swizzle, 2)];
s[i++] = ',';
}
- if (negateBase & NEGATE_W)
+ if (negateMask & NEGATE_W)
s[i++] = '-';
s[i++] = swz[GET_SWZ(swizzle, 3)];
reg_string((gl_register_file) srcReg->File,
srcReg->Index, mode, srcReg->RelAddr, prog),
_mesa_swizzle_string(srcReg->Swizzle,
- srcReg->NegateBase, GL_FALSE),
+ srcReg->Negate, GL_FALSE),
abs);
#if 0
_mesa_fprintf(f, "%s[%d]%s",
file_string((gl_register_file) srcReg->File, mode),
srcReg->Index,
_mesa_swizzle_string(srcReg->Swizzle,
- srcReg->NegateBase, GL_FALSE));
+ srcReg->Negate, GL_FALSE));
#endif
}
mode),
inst->SrcReg[0].Index,
_mesa_swizzle_string(inst->SrcReg[0].Swizzle,
- inst->SrcReg[0].NegateBase, GL_FALSE));
+ inst->SrcReg[0].Negate, GL_FALSE));
}
if (inst->Comment)
_mesa_fprintf(f, " # %s", inst->Comment);
mode),
inst->SrcReg[0].Index,
_mesa_swizzle_string(inst->SrcReg[0].Swizzle,
- inst->SrcReg[0].NegateBase, GL_TRUE));
+ inst->SrcReg[0].Negate, GL_TRUE));
fprint_comment(f, inst);
break;
case OPCODE_TEX:
inst->DstReg.WriteMask = WRITEMASK_X;
inst->SrcReg[0].File = PROGRAM_TEMPORARY;
inst->SrcReg[0].Index = fogFactorTemp;
- inst->SrcReg[0].NegateBase = NEGATE_XYZW;
+ inst->SrcReg[0].Negate = NEGATE_XYZW;
inst->SrcReg[0].Swizzle = SWIZZLE_XXXX;
inst->SaturateMode = SATURATE_ZERO_ONE;
inst++;
n->Children[0]->Store,
NULL,
NULL);
- inst->SrcReg[0].NegateBase = NEGATE_XYZW;
+ inst->SrcReg[0].Negate = NEGATE_XYZW;
return inst;
}
p->Instructions[ic].SrcReg[0].Swizzle = SWIZZLE_XXXX;
p->Instructions[ic].SrcReg[0].Index = 0;
- p->Instructions[ic].SrcReg[0].NegateBase = NEGATE_XYZW;
+ p->Instructions[ic].SrcReg[0].Negate = NEGATE_XYZW;
ic++;
/* END; */
/* swizzle (ext swizzle also depends on negation) */
{
GLuint swz[4];
- GLboolean extended = (inst->SrcReg[i].NegateBase != NEGATE_NONE &&
- inst->SrcReg[i].NegateBase != NEGATE_XYZW);
+ GLboolean extended = (inst->SrcReg[i].Negate != NEGATE_NONE &&
+ inst->SrcReg[i].Negate != NEGATE_XYZW);
for( j = 0; j < 4; j++ ) {
swz[j] = GET_SWZ( inst->SrcReg[i].Swizzle, j );
if (swz[j] > SWIZZLE_W)
}
}
- if( inst->SrcReg[i].NegateBase == NEGATE_XYZW ) {
+ if( inst->SrcReg[i].Negate == NEGATE_XYZW ) {
fullsrc->SrcRegister.Negate = 1;
}
- else if( inst->SrcReg[i].NegateBase != NEGATE_NONE ) {
- if( inst->SrcReg[i].NegateBase & NEGATE_X ) {
+ else if( inst->SrcReg[i].Negate != NEGATE_NONE ) {
+ if( inst->SrcReg[i].Negate & NEGATE_X ) {
fullsrc->SrcRegisterExtSwz.NegateX = 1;
}
- if( inst->SrcReg[i].NegateBase & NEGATE_Y ) {
+ if( inst->SrcReg[i].Negate & NEGATE_Y ) {
fullsrc->SrcRegisterExtSwz.NegateY = 1;
}
- if( inst->SrcReg[i].NegateBase & NEGATE_Z ) {
+ if( inst->SrcReg[i].Negate & NEGATE_Z ) {
fullsrc->SrcRegisterExtSwz.NegateZ = 1;
}
- if( inst->SrcReg[i].NegateBase & NEGATE_W ) {
+ if( inst->SrcReg[i].Negate & NEGATE_W ) {
fullsrc->SrcRegisterExtSwz.NegateW = 1;
}
}
fullsrc->SrcRegisterExtMod.Absolute = 1;
}
- if( inst->SrcReg[i].NegateAbs ) {
- fullsrc->SrcRegisterExtMod.Negate = 1;
- }
-
if( inst->SrcReg[i].RelAddr ) {
fullsrc->SrcRegister.Indirect = 1;