I've read the article on GPU Pro about states caching in Just Cause 2. They use some kind of bit packing mechanism to have a transparent multiplatform interface to manage states. The idea is to create every state block beforehand and cache it (you know dx10/dx11 validation has been shifted at creation time). However state blocks, like the rasterizer state, group a lot of states and I've found very difficult to pack them all in a 64bit integer bitmask.
Here is the union/struct layout to outline you guys the basic idea:
struct RasterizerState
{
Real32 DepthBiasClamp; //Real32 is typedef float Real32;
Real32 SlopeScaleDepthBias;
union
{
U64 index; //index used to lookup the cache
struct
{
S64 DepthBias : 32;
S64 FillMode : 2;
S64 CullMode : 2;
S64 FrontCounterClockwise : 1; //vertex winding order (CW/CCW)
S64 DepthClipEnable : 1;
S64 ScissorEnable : 1;
S64 MultisampleEnable : 1;
S64 AntialiasedLineEnable : 1;
};
};
};
I can't have DepthBiasClamp and SlopeScaleDepthBias to fit in the bit fields. I thought to split them but we loose the advantage of a unique state block and the index must be unique. Any Idea to have everything in ? Or alternate solutions ? the important thing is that "index" is unique. If I chose to not to put them in the
bit field, the value of "index" is not garantied to be unique.
thanks all in advance!













