Technically true, but I feel like this could be clearer. Perhaps something like "must be properly aligned"?
"proper_offset" is not a very clear name for a variable. "aligned_offset" strikes me as clearer.
Okay, I also changed the error message to: ``` "Reservation with swizzle in packoffset() breaks register boundaries." ```
Also, should this check be here? Note that calculate_buffer_offset() is called only for variables that are used. We don't have tests for this.
Hmm, I am pretty sure that, at least now, `calculate_buffer_offset()` is called on all variables within constant buffers, not only used variables.
It is worth noting that native also allocates unused variables within buffers. The only exception is when the whole buffer is not used at all, in which case it is not written (so, in the end it doesn't matter whether we allocate or not).
On SM4, native throws an error on invalid offsets even if the variable (or even the whole buffer) is not used, so this behavior is correct. In SM1, native ignores packoffset and so these checks.
The tests are indeed missing though, I added these two:
```hlsl [pixel shader fail] // Elements must respect register boundaries. cbuffer buffer { float4 c : packoffset(c0.z); }
float4 main() : sv_target { return c; }
[pixel shader fail] // Invalid offset on unused buffer. cbuffer buffer { float3 a : packoffset(c0.z); }
float4 main() : sv_target { return 0; } ```