const int nr = 1;
int component = GET_SWZ(src->Swizzle, index);
return get_reg(c, src->File, src->Index, component, nr,
- src->NegateBase, src->Abs);
+ src->NegateBase, src->Abs);
}
+
+/**
+ * Same as \sa get_src_reg() but if the register is a literal, emit
+ * a brw_reg encoding the literal.
+ * Note that a brw instruction only allows one src operand to be a literal.
+ * For instructions with more than one operand, only the second can be a literal.
+ */
+static struct brw_reg get_src_reg_imm(struct brw_wm_compile *c,
+ struct prog_src_register *src, int index)
+{
+ if (src->File == PROGRAM_CONSTANT) {
+ /* a literal */
+ const int component = GET_SWZ(src->Swizzle, index);
+ const GLfloat *param =
+ c->fp->program.Base.Parameters->ParameterValues[src->Index];
+ return brw_imm_f(param[component]);
+ }
+ else {
+ return get_src_reg(c, src, index);
+ }
+}
+
+
/**
* Subroutines are minimal support for resusable instruction sequences.
* They are implemented as simply as possible to minimise overhead: there
if (mask & (1<<i)) {
struct brw_reg src, dst;
dst = get_dst_reg(c, inst, i);
- src = get_src_reg(c, &inst->SrcReg[0], i);
+ src = get_src_reg_imm(c, &inst->SrcReg[0], i);
brw_MOV(p, dst, src);
}
}
struct brw_reg src0, src1, dst;
dst = get_dst_reg(c, inst, i);
src0 = negate(get_src_reg(c, &inst->SrcReg[0], i2));
- src1 = get_src_reg(c, &inst->SrcReg[1], i1);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i1);
brw_MUL(p, brw_null_reg(), src0, src1);
src0 = get_src_reg(c, &inst->SrcReg[0], i1);
- src1 = get_src_reg(c, &inst->SrcReg[1], i2);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i2);
brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
brw_MAC(p, dst, src0, src1);
brw_set_saturate(p, 0);
struct brw_compile *p = &c->func;
for (i = 0; i < 3; i++) {
src0[i] = get_src_reg(c, &inst->SrcReg[0], i);
- src1[i] = get_src_reg(c, &inst->SrcReg[1], i);
+ src1[i] = get_src_reg_imm(c, &inst->SrcReg[1], i);
}
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
struct brw_compile *p = &c->func;
for (i = 0; i < 4; i++) {
src0[i] = get_src_reg(c, &inst->SrcReg[0], i);
- src1[i] = get_src_reg(c, &inst->SrcReg[1], i);
+ src1[i] = get_src_reg_imm(c, &inst->SrcReg[1], i);
}
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
struct brw_compile *p = &c->func;
for (i = 0; i < 4; i++) {
src0[i] = get_src_reg(c, &inst->SrcReg[0], i);
- src1[i] = get_src_reg(c, &inst->SrcReg[1], i);
+ src1[i] = get_src_reg_imm(c, &inst->SrcReg[1], i);
}
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
brw_ADD(p, dst, src0, src1);
}
}
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
brw_ADD(p, dst, src0, negate(src1));
}
}
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
brw_MUL(p, dst, src0, src1);
}
}
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
+ src0 = get_src_reg_imm(c, &inst->SrcReg[0], i);
brw_FRC(p, dst, src0);
}
}
for (i = 0 ; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
+ src0 = get_src_reg_imm(c, &inst->SrcReg[0], i);
brw_RNDD(p, dst, src0);
}
}
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
brw_MOV(p, dst, src0);
brw_set_saturate(p, 0);
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->SrcReg[0], i);
+ src0 = get_src_reg_imm(c, &inst->SrcReg[0], i);
src1 = get_src_reg(c, &inst->SrcReg[1], i);
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
brw_MOV(p, dst, src0);
struct brw_compile *p = &c->func;
struct brw_reg dst, src0, src1;
dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- src0 = get_src_reg(c, &inst->SrcReg[0], 0);
- src1 = get_src_reg(c, &inst->SrcReg[1], 0);
+ src0 = get_src_reg_imm(c, &inst->SrcReg[0], 0);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], 0);
brw_MOV(p, brw_message_reg(2), src0);
brw_MOV(p, brw_message_reg(3), src1);
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
if (src1.nr == dst.nr) {
tmp1 = alloc_tmp(c);
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
- src2 = get_src_reg(c, &inst->SrcReg[2], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
+ src2 = get_src_reg_imm(c, &inst->SrcReg[2], i);
brw_MUL(p, dst, src0, src1);
brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, &inst->SrcReg[0], i);
- src1 = get_src_reg(c, &inst->SrcReg[1], i);
+ src1 = get_src_reg_imm(c, &inst->SrcReg[1], i);
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), cond, src0, src1);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);