Graphics Reference
In-Depth Information
any location within the resource. This provides a completely new class of resource access,
since it allows the resource to be used in a much more flexible manner. However, it is im-
portant to note that this type of view is not available for all programmable shader stages.
These resource views can only be used with the pixel shader and compute shader stages.
Resource View Creation
The process of creating a resource view is somewhat similar to the process that we have
seen for creating a resource. The ID3D11 Device is also responsible for creating resource
views, and it provides one creation method for each type. All creation methods follow the
same pattern, with three different parameters provided by the application. As an example,
Listing 2.5 shows the creation of a shader resource view.
ID3DllShaderResourceView* CreateShaderResourceView( ID3D11Resource* pResource.,
D3D11_SHADER_RES0URCE_VIEW_DESC* pDesc )
{
ID3DllShaderResourceView* pView = 0;
HRESULT hr = m_pDevice->CreateShaderResourceView( pResource,
pDesc, SpView );
return( pView );
}
Listing 2.5. An example technique for creating a shader resource view.
The first parameter for all of these creation methods is a pointer to the resource that
the resource view will represent. The second parameter is a pointer to a description struc-
ture, with all of the available options for that particular type of resource view. The third and
final parameter is a pointer to a pointer to the corresponding resource view type, which is
where the newly created resource view will be stored if the creation call succeeds. The sec-
ond parameter is the most interesting with respect to configuring a resource view in the way
we want it to behave. Each of the four resource view types uses a unique description struc-
ture, exposing each of their various unique properties. We will take a closer look at each
of these structures to gain an understanding of what options are available to the developer.
Render target view options. We begin by looking closer into the available options for
creating a render target view. Figure 2.3 shows the structure that must be filled in and
passed to the creation method, ID3DllDevice::CreateRenderTargetView().
As seen in Figure 2.3, this structure uses several normal member variables, followed
by a union of possible structures. This allows all different resource types to use the same
description structure, while still providing unique properties for each one. The format pa-
rameter specifies the data format that the resource will be cast to when it is read. In some
Search WWH ::




Custom Search