Graphics Reference
In-Depth Information
3.12.2 Output Merger State Configuration
The output merger stage is controlled by a pair of state objects—the depth stencil state and
the blend state. In addition to these, the output merger can also have resources bound to
it, which ultimately represent the final output of the rendering pipeline. In this section, we
will consider how each of these properties is configured, and what restrictions there are for
handling each possible state and resource.
Depth Stencil State
Both the depth test and the stencil test are configured with the same state object, the
ID3DllDepthStencilState. As with all resources in Direct3D 11, this object is created
through the device interface. The depth stencil state is created with the ID3DllDevice:: Create
DepthStencilStateQ method, which takes a pointer to a description structure that contains
the desired state options. Listing 3.25 lists the members of the depth stencil state description.
struct D3D11_DEPTH_STENCIL_DESC {
BOOL DepthEnable;
D3D11_DEPTH_WRITE_MASK DepthWriteMask;
D3D11_C0MPARIS0N_FUNC DepthFunc;
BOOL StencilEnable;
UINT8 StencilReadMask;
UINT8 StencilWriteMask;
D3D11_DEPTH_STENCIL0P_DESC FrontFace;
D3D11_DEPTH_STENCIL0P_DESC BackFace;
}
Listing 3.25. The D3D11_DEPTH_STENCIL_DESC structure and its members.
The first three parameters of the structure configure the depth test functionality, while
the remaining parameters are used to configure the stencil test. Once the depth stencil state
has been created, it is immutable and cannot be changed. If the application requires another
state to be active, a separate state object must be created and bound to the pipeline in the
place of the current state. This is accomplished through the ID3DllDeviceContext::OMSet
DepthStencilStateQ method. As usual, there is a corresponding get method to retrieve
the current state that is bound to the pipeline. The details of what these members do are
discussed in more detail in the "Output Merger Stage Processing" section.
Blend State
The second state object that the output merger supports is the ID3D11BlendState. This
blend state object controls how color values are blended together before being written to
Search WWH ::




Custom Search