Graphics Reference
In-Depth Information
Buffers method. Once again, this can be useful for reinstating an existing setting after an
interim operation is performed.
Shader Resource Views
For the vertex shader program to be able to access the various types of read-only resources
that are available to it, the resources must be bound to the vertex shader stage with a
shader resource view. Both buffer resources and texture resources are bound to the pipeline
in exactly the same manner, using the ID3D11DeviceContext: :VSSetShaderResources
method. As with constant buffers, one or more shader resource views can be set simultane-
ously with the same method call. Listing 3.10 demonstrates how this method is used.
ID3DllShaderResourceView*
ShaderResourceViews [D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ];
// Fill the array with the desired resource views...
pContext->VSSetShaderResources( start, count , ShaderResourceViews );
Listing 3.10. Binding an array of shader resource views to the vertex shader stage.
The array of shader resource views operates in much the same fashion as described
for the constant buffers. Once a shader resource view has been set in one of the slots, it will
remain bound in this location until it is replaced by either another shader resource view or a
NULL pointer. The technique of clearing out all unused shader resource views with NULL
in between pipeline executions takes on more importance when applied to resources. If a
resource that is dynamically generated by the GPU is used as a shader resource in another
rendering pass, it is first written to by the pipeline in the first pass, and then read in the
shader program in the second pass. Writing to the resource is done with either a render
target view or an unordered access view, while reading is performed with a shader resource
view. If a resource is bound for reading with a shader resource view and is mistakenly left
bound to the vertex shader stage, any attempt to bind the resource for writing will generate
an error, since a resource cannot be simultaneously read and written by multiple views.
This situation is depicted in Figure 3.15. The simplest way to ensure that this does not hap-
pen is to clear all unneeded shader resource views from the vertex shader stage each time
the pipeline is configured for a new rendering effect.
Samplers
The final configuration that the application can supply to the vertex shader stage is sam-
pler objects. Samplers provide the ability to perform various types of filtering on textures
Search WWH ::




Custom Search