Graphics Reference
In-Depth Information
mirror once mode, in which the absolute value of the texture coordinates are used and then
clamped in the same way as in the clamp texture addressing mode.
The MipLODBias, MinLOD, and MaxLOD parameters are all used to manipulate the mip-
map level that is used during the sampling process. The min and max parameters specify
the minimum and maximum levels that can be accessed during sampling, and the bias
parameter provides a constant offset to add to the mip-map level selected by the sampling
hardware. In all of these parameters, 0 is the most detailed mip-map level, so adding a posi-
tive bias will select a less detailed mip-map level.
The final member in the sampler state description structure is the ComparisonFunc
parameter. This indicates what type of comparison should be performed on the texture
samples prior to performing the filtering operation. The other value that is used in the
comparison is supplied in the texture object sampling method call. The result is either a 1 if
the comparison passes, or a 0 if it fails. The results of each individual comparison are then
combined according to the chosen filtering method, and returned.
Using Samplers
To use a sampler object, it must first be created as detailed above and then bound to one of
the programmable pipeline stages. Each of the programmable stages can simultaneously
bind up to 16 different sampler objects, and the same sampler state object can be used in
more than one programmable stage at once. After the state objects have been bound to
a pipeline stage, the HLSL program that will run in that stage must declare an appropri-
ate HLSL Sampler-State object, which corresponds to a particular sampler slot. Then the
shader program can pass the SamplerState object to one of the many sampling methods
provided by the various texture resource types. By having to pass the SamplerState object
as an argument in the sample methods, D3D11 allows multiple texture resources within a
shader program to simultaneously use the same sampling object. Due to the large number
of available resources that can be used in a shader program (up to 128), sharing these states
becomes a significant benefit if the same set of options is needed many times. 4
2.3 Resource Manipulations
We have seen throughout this chapter what resource types are available, their typical usage,
how they are constructed, and how to declare them for use in HLSL. We also saw in the
4 In previous versions of Direct3D, the sampler could only be used with a single texture at a time. This limited the
overall number of textures that could be used in a shader program. Without this limitation, Direct3D 11 provides
a significantly larger number of textures (or more specifically resources) that can be accessed in a shader.
Search WWH ::




Custom Search