On 11/10/21 2:11 PM, Francisco Casas wrote:
Some dxbc instructions require swizzle types that differ from what is usual for the register type.
e.g. gather4 requires a register with register type VKD3D_SM4_RT_SAMPLER but a swizzle type VKD3D_SM4_SWIZZLE_VEC4 instead of the usual VKD3D_SM4_SWIZZLE_NONE.
You could look at it that way, but I would rather say that "some register types do not use a consistent swizzle type." I.e. there's not really a "usual" case.
This is particularly true upon noticing that gather4 isn't the only "exception". For instance, I believe that single-element writemasks should in general result in SCALAR rather than VEC4 for normal temps.
Along those lines, I'd rather see sm4_swizzle_type() just go away, and the swizzle type explicitly specified everywhere. Introducing helpers like sm4_source_from_node() and sm4_source_from_deref() would make this easier.
As an aside, patch subjects should generally be phrased in the imperative. E.g. in this case I'd say something like "Allow using a custom swizzle type for sm4 source registers", or, if you end up following my suggestion, "Explicitly specify the swizzle type for sm4 source registers".
The new fields of sm4_instruction can be used to handle these exceptions.
Also, they shouldn't change the current behaviour of the rest of the code since they are currently initalized with zeroes everywhere a sm4_instruction is initialized.
I think these paragraphs are obvious enough that they don't need to be in a patch description.