Reputation: 947
In Direct3D10 the Stencil Read/Write mask is a byte (from 0x00 to 0xFF)
In Direct3D9 the Stencil Read/Write mask is a int (from 0x00000000 to 0xFFFFFFFF)
The question is :
How the stencil read/write mask in Direct3D10 relate to the Direct3D9 one?
Direct3D10 | 0x00FFFFFF or Direct3D10 | 0xFFFFFF00 ?
And another question :
Why the Direct3D9 one is a 32 bit integer when the stencil buffer can be max 8 bit? o.O
Thanks.
Upvotes: 1
Views: 1664
Reputation: 14067
Direct3D10 | 0xFFFFFF00
The least significant bits are the relevant ones in D3D9, the docs describe the stencil operations in terms of DWORDs but ultimately the stencil buffer only stores a single byte so it is only the least significant byte of the mask that is important.
The reason D3D9 uses a DWORD is that the value is set through SetRenderState which takes two parameters, a D3DRENDERSTATETYPE enum specifying the state to change and a DWORD value. All render states must therefore use a DWORD value regardless of how they are ultimately used. In some cases this means doing a reinterpret_cast on a floating point number. For the stencil mask it means passing a 32 bit value where only the least significant 8 bits are really needed. D3D10 sets states through typed structures and so avoids this issue.
Upvotes: 3