On Tue Jan 24 20:13:57 2023 +0000, Francisco Casas wrote:
Sorry, I made an inaccuracy in my explanation: In later patches, the promotion of each object component to a separated variable will only be done at the beginning of `hlsl_sm4_write()` for SM5 so. before that, the variables are still tied together. I probably got confused because my memory is bad and I was promoting components much sooner in previous versions of this patch series, but that didn't work (because component usage must be tracked at the variable level for the correct allocation of registers). So the correct answer would be: HLSL_REGSET_NUM is just expected to be retrieved as a fallback for structs, because the callers either only work with derefs to simple types (after struct copies have been lowered), or perform a recursive search through a variable's type and check for
(hlsl_type_get_regset(ctx, type) <= HLSL_REGSET_LAST_OBJECT)
base cases. Maybe I should include an `HLSL_REGSET_UNDETERMINED` enum value for structs?
It feels awkward to have a helper that doesn't always do a well-defined thing and relies on its callers never to care about the poorly-defined case.
I'd suggest a specific solution, but I've forgotten by now why we do ever need an hlsl_ir_var to be allocated to multiple register sets at the same time?