I am afraid that `copy_propagation_compute_replacement()` will still require to receive an **input swizzle** argument though (which I think adds to the awkwardness). I will see if I can use the current output argument `unsigned int *swizzle` for both the input and output swizzles.
Yep, that sounds right. I don't have a strong preference at the moment between using an in/out argument or using two separate arguments.
Oh, I remember why I made `copy_propagation_compute_load_constant_replacement()` receive the whole instruction as an argument. It is that the swizzle alone doesn't convey number of components requested, and that also isn't in the load itself, but rather in the swizzle instruction. I should add it as an additional argument then.
Yes, a separate component count makes sense to me.
Actually, this doesn't make much sense:
static bool copy_propagation_transform_swizzle(...) { ... if (swizzle->val->type != HLSL_IR_LOAD) return false; return copy_propagation_transform_load(ctx, hlsl_ir_load(swizzle->val), state, swizzle->swizzle); }
because calling `copy_propagation_transform_load` would be replacing the swizzle's load, and not the swizzle itself. So I'm going to skip that part of the advice and see where I get to.
Eh, right, you'd need to pull out the hlsl_replace_node() part. But the general idea should still be similar; we want most of that code to be shared.