for (i = 0; i < num_srcs; i++) {
if (inst->SrcReg[i].File != PROGRAM_CONSTANT)
return false;
+ if (inst->SrcReg[i].RelAddr)
+ return false;
}
return true;
return (a->File == b->File)
&& (a->Index == b->Index)
&& (a->Swizzle == b->Swizzle)
- && (a->Abs == b->Abs)
&& (a->Negate == b->Negate)
&& (a->RelAddr == 0)
&& (b->RelAddr == 0);
static void
get_value(struct gl_program *prog, struct prog_src_register *r, float *data)
{
+ unsigned pvo = prog->Parameters->ParameterValueOffset[r->Index];
const gl_constant_value *const value =
- prog->Parameters->ParameterValues[r->Index];
+ prog->Parameters->ParameterValues + pvo;
data[0] = value[GET_SWZ(r->Swizzle, 0)].f;
data[1] = value[GET_SWZ(r->Swizzle, 1)].f;
data[2] = value[GET_SWZ(r->Swizzle, 2)].f;
data[3] = value[GET_SWZ(r->Swizzle, 3)].f;
- if (r->Abs) {
- data[0] = fabsf(data[0]);
- data[1] = fabsf(data[1]);
- data[2] = fabsf(data[2]);
- data[3] = fabsf(data[3]);
- }
-
if (r->Negate & 0x01) {
data[0] = -data[0];
}
bool progress = false;
unsigned i;
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *const inst = &prog->Instructions[i];
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *const inst = &prog->arb.Instructions[i];
switch (inst->Opcode) {
case OPCODE_ADD:
get_value(prog, &inst->SrcReg[0], a);
get_value(prog, &inst->SrcReg[1], b);
- /* It seems like a loop could be used here, but we cleverly put
- * DP2A between DP2 and DP3. Subtracting DP2 (or similar) from
- * the opcode results in various failures of the loop control.
- */
result = (a[0] * b[0]) + (a[1] * b[1]);
if (inst->Opcode >= OPCODE_DP3)
}
break;
- case OPCODE_SEQ:
- if (src_regs_are_constant(inst, 2)) {
- float a[4];
- float b[4];
- float result[4];
-
- get_value(prog, &inst->SrcReg[0], a);
- get_value(prog, &inst->SrcReg[1], b);
-
- result[0] = (a[0] == b[0]) ? 1.0f : 0.0f;
- result[1] = (a[1] == b[1]) ? 1.0f : 0.0f;
- result[2] = (a[2] == b[2]) ? 1.0f : 0.0f;
- result[3] = (a[3] == b[3]) ? 1.0f : 0.0f;
-
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_vec4(prog, result);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_float(prog, 1.0f);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- }
- break;
-
case OPCODE_SGE:
if (src_regs_are_constant(inst, 2)) {
float a[4];
}
break;
- case OPCODE_SGT:
- if (src_regs_are_constant(inst, 2)) {
- float a[4];
- float b[4];
- float result[4];
-
- get_value(prog, &inst->SrcReg[0], a);
- get_value(prog, &inst->SrcReg[1], b);
-
- result[0] = (a[0] > b[0]) ? 1.0f : 0.0f;
- result[1] = (a[1] > b[1]) ? 1.0f : 0.0f;
- result[2] = (a[2] > b[2]) ? 1.0f : 0.0f;
- result[3] = (a[3] > b[3]) ? 1.0f : 0.0f;
-
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_vec4(prog, result);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_float(prog, 0.0f);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- }
- break;
-
- case OPCODE_SLE:
- if (src_regs_are_constant(inst, 2)) {
- float a[4];
- float b[4];
- float result[4];
-
- get_value(prog, &inst->SrcReg[0], a);
- get_value(prog, &inst->SrcReg[1], b);
-
- result[0] = (a[0] <= b[0]) ? 1.0f : 0.0f;
- result[1] = (a[1] <= b[1]) ? 1.0f : 0.0f;
- result[2] = (a[2] <= b[2]) ? 1.0f : 0.0f;
- result[3] = (a[3] <= b[3]) ? 1.0f : 0.0f;
-
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_vec4(prog, result);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_float(prog, 1.0f);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- }
- break;
-
case OPCODE_SLT:
if (src_regs_are_constant(inst, 2)) {
float a[4];
}
break;
- case OPCODE_SNE:
- if (src_regs_are_constant(inst, 2)) {
- float a[4];
- float b[4];
- float result[4];
-
- get_value(prog, &inst->SrcReg[0], a);
- get_value(prog, &inst->SrcReg[1], b);
-
- result[0] = (a[0] != b[0]) ? 1.0f : 0.0f;
- result[1] = (a[1] != b[1]) ? 1.0f : 0.0f;
- result[2] = (a[2] != b[2]) ? 1.0f : 0.0f;
- result[3] = (a[3] != b[3]) ? 1.0f : 0.0f;
-
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_vec4(prog, result);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
- inst->Opcode = OPCODE_MOV;
- inst->SrcReg[0] = src_reg_for_float(prog, 0.0f);
-
- inst->SrcReg[1].File = PROGRAM_UNDEFINED;
- inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
-
- progress = true;
- }
- break;
-
default:
break;
}