Does anyone know how to use "packetoffset" with a bool type in DirectX10/11? I am not sure how this should be aligned
cbuffer SomeBuffer : register( b1 )
{
float3 SomeFloat3: packoffset(c0);
float SomeFloat: packoffset(c0.w);
float3 SomeFloat32: packoffset(c1);
float2 SomeFloat2; ??
bool SomeBool1; ??
bool SomeBool2; ??
bool SomeBool3; ??
}
That's actually two questions:
packoffset that results in a variable extending beyond the bounds of a single register?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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With