Honestly the more I think about my suggestion the more I like it; it seems like what the register set logic was built for. I was envisioning that sm1 bool/int/float would work that way as well, although I guess duplicating the variable there is an option too.
I have been giving it some thought of the idea of having the same variable for both the sampler part and the resource part of a lowered combined sample, and I don't think I like it very much.
There are a couple of problems we may have:
1. Seems that the allocation order of the texture part and the sampler part is not bonded together in the native compiler:
Consider: ```hlsl Texture2D tex0; sampler sam0;
sampler comb;
Texture2D tex1; sampler sam1;
float4 main() : sv_target { return tex2D(comb, float2(0, 0)) + tex0.Sample(sam0, float2(0, 0)) + tex1.Sample(sam1, float2(0, 0)); } ``` we get the following bindings: ``` // sam0 sampler NA NA s0 1 // comb sampler NA NA s1 1 // sam1 sampler NA NA s2 1 // comb texture float4 2d t0 1 // tex0 texture float4 2d t1 1 // tex1 texture float4 2d t2 1 ``` the texture part of comb is allocated before `tex0`, but the sampler part of comb is allocated after `sam0` (respecting declaration order), which shows that the texture parts of lowered combined samplers have to be moved first in the allocation order. I have a continuation patch that handle this in an easy way, just sorting the new created texture variable forward.
If we keep the same variable however, we may need to sort variables between calls to allocate_objects() for different regsets, to ensure this behavior.
2. The `var->objects_usage[]` array is created on hlsl_new_var() from the `type->regsize[]`. So we would either have to allocate memory for it once we discover that `var` is used as a combined sampler or we would have to preemptively set `type->regsize[HLSL_REGSET_TEXTURES]` the same as `type->regsize[HLSL_REGSET_SAMPLERS]` for all samplers in SM4.
3. We are currently assuming that all resources belong to a single regset, so we would have to add additional checks in many places where hlsl_type_get_regset() is called, to know if we are interested in the texture or sampler part.