I wrote patches to address the following design change suggestions:
* Extending the lifetime of deref->data_type to the whole lifetime of the deref. * Removing hlsl_type_get_regset(), and either handle multiple regsets for each data type or using the new hlsl_deref_get_regset().
I added most of these patches on my local branch [master6f](https://gitlab.winehq.org/fcasas/vkd3d/-/commits/master6f), to be sent **after** this MR gets approved.
---
Regarding using the same variable for both the sampler and the resource resulting from lowering a combined sample, I spend a good amount of time making this approach work and rebasing the other patches on top. Everything is in this alternative branch [master6g](https://gitlab.winehq.org/fcasas/vkd3d/-/commits/master6g) for comparison.
Many difficulties arise with this approach (as can be seen in [the most relevant patch](https://gitlab.winehq.org/fcasas/vkd3d/-/commit/28af38f7106c30e3f632310ebe54...)); in particular that the sampler data type doesn't store information required by the separated texture, such as the sampler_dim and the format type, so these have to be added in additional fields within the sampler variable. Also, in many places (specially in tpf.c) new conditional branches have to be added depending of whether the sampler variable has to be handled as a sampler or a resource. So my opinion is to discard this.
---
Some lessons to improve this MR were learn in the process:
* I added an additional check to ensure that sampler arrays cannot be divided if their components are used with different sampling dimensions, with the associated test. * I also changed hlsl_new_synthetic_var_named(), adding the dummy_scope parameter, so we can pass false and put the new synthetic in the globals scope. This because I realized that hlsl_get_var() doesn't search for synthetic variables if they are not in the globals scope. * When creating an array type, the sampler_dim is passed from the "basic type" to this array type, so that it can be queried easily without having to get the type of the component 0. * Removed the deref->regset_offset field, since it can be obtained using hlsl_type_get_regset(deref->data_type). Don't worry, this call is replaced with hlsl_get_type_from_deref() in the follow up patches!