Graphics Reference
In-Depth Information
number of mip-map levels and array slices are specified in the MipLevels and ArraySize
elements, respectively. The texture format also operates in the same manner as for the 1D
texture and must be set to a member of the DXGI_FORMAT enumeration. The SampleDesc
parameter is a structure that describes the multi-sampling features that will be included
with the 2D texture. It contains two members: Count and Quality. The Count parameter
specifies the number of subsamples to include in the texture, while the Quality parameter
indicates the pattern and algorithm used to resolve the subsamples into a single pixel value.
The quality level is a vendor-specific metric, and it may or may not support more than
one quality level. Since support for various quality levels is left up to the GPU manufac-
turer, the application must query what the available quality level is for a particular texture
format and sample count. This is performed with the ID3DllDevice: :CheckMultisample
QualityLevels() method. An example usage of this method is shown in Listing 2.29.
UINT NumQuality;
HRESULT hr = m_pDevice->CheckMultisampleQualityLevels(
DXGI_F0RMAT_R8G8B8A8_UNORM, 4 , & NumQuality );
Listing 2.29. A demonstration of how to check the available quality level of a texture format and multi-
sample count.
In this example, we can see that the desired format is DXGI_F0RMAT_R8G8B8A8_
UNORM and the desired number of samples is 4. The available quality level is returned in
the NumQuality variable. If the result is 0, that particular format and sample count are not
supported. If the value is 1 or greater, any quality level can be used, up to the returned value
in the 2D texture description structure described above. It is important to note that if n is
returned, that the value of n-1 should be used in the sample description structure!
The Usage, BindFlags, and CPUAccess parameters are selected according to the op-
tions specified in the beginning of this chapter and define where and how the texture re-
source can be used.
Finally, we have MiscFlags. The flags that correspond to 2D textures are listed below:
D3D11_RESOURCE_MISC_GENERATE_MIPS
D3D11_RES0URCE_MISC_RES0URCE CLAMP
D3D11_RESOURCE_MISC_TEXTURECUBE
The first two flags have the same behavior as seen in the 1D texture case. The mips
generation flag allows for automatically filling in the mip-map levels of a texture if its
top level has been written to as a render target, while the resource clamp flag provides
a mechanism to manually control which mip-map levels must reside in video memory.
Search WWH ::




Custom Search