Graphics Reference
In-Depth Information
Multiple Resource Views of the Same Resource
It is possible to simultaneously use multiple resource views of the same resource. For
example, to bind a resource to the pipeline with a render target view, three things must
happen. First, the resource must have been created with appropriate bind flags for being
used as a render target. Second, the render target view must be created for referencing the
desired resource. Third, the view must then be bound to the pipeline. More specifically, it
must be bound to the output merger stage, since that is the only place that render target
views can be bound to.
However, if you want to use that same resource as an input to a pixel shader on a
subsequent rendering pass, you do not need to copy the contents of the render target to
another memory resource. Instead, you would ensure that the resource was created with
the appropriate bind flags for use as a shader resource, create a shader resource view for
the resource, and then use that view to bind the resource to the pixel shader stage, where it
is then used by a shader program. This concept of multiple connections is shown in a block
diagram in Figure 2.44. This brings us back to our earlier comment about resources—they
are just blocks of memory that are used as input or output to the pipeline, or for both. The
use of the resources is determined by how they are created, and how and where they are
connected to the pipeline.
It is also possible to use multiple resource views of a single resource at the same
time. In general, when a resource is being used for read access, any number of resource
views can be used. For example, if we wanted to write a shader program that used one
shader resource view for each mip-map level of a 2D texture resource, we could just create
separate resource views and bind them individually to the pipeline, as if they were separate
resources.
There are different restrictions when trying to use multiple resource views simultane-
ously when they have read or write access privileges. If a resource view is used for writing,
any other resource view that references the same subresource cannot be bound to the pipe-
line. This is due to the possibility that the subresource contents may change while another
portion of the pipeline is reading them, resulting in unpredictable behavior. In general, if
you try to bind a resource view that reads from a resource that is also bound with a writ-
able resource view, a warning and/or an error will be reported in the debug output window.
2.2.3 Sampler State Objects
The final objects that we will consider in this section are sampler state objects. A sam-
pler state object is used to specify all of the parameters that are used when a shader program
samples a texture resource. The process of sampling a texture involves looking up several
pixels of texture resource and combining them with a mechanism selected by the devel-
oper, to reduce several types of common artifacts, as well as to increase the performance of
Search WWH ::




Custom Search