}
static unsigned
-vector_to_scalar_source(unsigned u, bool is_int, bool is_full)
+vector_to_scalar_source(unsigned u, bool is_int, bool is_full,
+ unsigned masked_component)
{
midgard_vector_alu_src v;
memcpy(&v, &u, sizeof(v));
/* TODO: Integers */
- unsigned component = v.swizzle & 3;
+ unsigned component = (v.swizzle >> (2*masked_component)) & 3;
bool upper = false; /* TODO */
midgard_scalar_alu_src s = { 0 };
bool is_full = v.reg_mode == midgard_reg_mode_32;
bool is_inline_constant = ins->ssa_args.inline_constant;
+ unsigned comp = component_from_mask(ins->mask);
+
/* The output component is from the mask */
midgard_scalar_alu s = {
.op = v.op,
- .src1 = vector_to_scalar_source(v.src1, is_int, is_full),
- .src2 = !is_inline_constant ? vector_to_scalar_source(v.src2, is_int, is_full) : 0,
+ .src1 = vector_to_scalar_source(v.src1, is_int, is_full, comp),
+ .src2 = !is_inline_constant ? vector_to_scalar_source(v.src2, is_int, is_full, comp) : 0,
.unknown = 0,
.outmod = v.outmod,
.output_full = is_full,
- .output_component = component_from_mask(ins->mask),
+ .output_component = comp
};
/* Full components are physically spaced out */