struct rc_instruction * inst,
struct rc_src_register * src)
{
- unsigned int * new_mask = (unsigned int *)userdata;
- src->Swizzle = rc_adjust_channels(src->Swizzle, *new_mask);
+ unsigned int * conversion_swizzle = (unsigned int *)userdata;
+ src->Swizzle = rc_adjust_channels(src->Swizzle, *conversion_swizzle);
}
/**
struct rc_instruction * inst,
unsigned int conversion_swizzle)
{
- unsigned int new_mask;
struct rc_sub_instruction * sub = &inst->U.I;
const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
sub->DstReg.WriteMask =
return;
}
- new_mask = sub->DstReg.WriteMask;
- rc_for_all_reads_src(inst, normal_rewrite_writemask_cb, &new_mask);
+ rc_for_all_reads_src(inst, normal_rewrite_writemask_cb,
+ &conversion_swizzle);
}
/**
}
return conversion_swizzle;
}
+
+/**
+ * @return 1 if the register contains an immediate value, 0 otherwise.
+ */
+unsigned int rc_src_reg_is_immediate(
+ struct radeon_compiler * c,
+ unsigned int file,
+ unsigned int index)
+{
+ return file == RC_FILE_CONSTANT &&
+ c->Program.Constants.Constants[index].Type == RC_CONSTANT_IMMEDIATE;
+}
+
+/**
+ * @return The immediate value in the specified register.
+ */
+float rc_get_constant_value(
+ struct radeon_compiler * c,
+ unsigned int index,
+ unsigned int swizzle,
+ unsigned int negate,
+ unsigned int chan)
+{
+ float base = 1.0f;
+ int swz = GET_SWZ(swizzle, chan);
+ if(swz >= 4 || index >= c->Program.Constants.Count ){
+ rc_error(c, "get_constant_value: Can't find a value.\n");
+ return 0.0f;
+ }
+ if(GET_BIT(negate, chan)){
+ base = -1.0f;
+ }
+ return base *
+ c->Program.Constants.Constants[index].u.Immediate[swz];
+}
+
+/**
+ * This function returns the component value (RC_SWIZZLE_*) of the first used
+ * channel in the swizzle. This is only useful for scalar instructions that are
+ * known to use only one channel of the swizzle.
+ */
+unsigned int rc_get_scalar_src_swz(unsigned int swizzle)
+{
+ unsigned int swz, chan;
+ for (chan = 0; chan < 4; chan++) {
+ swz = GET_SWZ(swizzle, chan);
+ if (swz != RC_SWIZZLE_UNUSED) {
+ break;
+ }
+ }
+ assert(swz != RC_SWIZZLE_UNUSED);
+ return swz;
+}