That's actually two questions:
- What happens if you use a
packoffset
that results in a variable extending beyond the bounds of a single register?
- How do you use
packoffset
with bool
values?
The answer to the first question is: The HLSL compiler will do some validation on the packoffset
values. So the following will not compile, because Var2
can't fit in to c0
, and the compiler will not automatically "wrap" it into c1
:
cbuffer SomeBuffer : register( b1 )
{
float3 Var1 : packoffset(c0);
float2 Var2 : packoffset(c0.w); // will not compile
}
The answer to the second question is: bool
values take the same space as a float
, so you can pack them like this:
cbuffer SomeBuffer : register( b1 )
{
bool SomeBool1 : packoffset(c0);
bool SomeBool2 : packoffset(c0.y);
float SomeFloat1 : packoffset(c0.z);
bool SomeBool3 : packoffset(c0.w);
}