Graphics Reference
In-Depth Information
The Width parameter alone specifies the size of the texture, because this is a one-
dimensional texture. It represents the number of texture elements that will be included in
the texture. The desired number of mip-map levels is specified in the MipLevels member.
The most important consideration for the number of mip-maps is that a value of 1 provides
just the top level mip-map, while a value of 0 will create a complete mip-map chain all the
way down to a single element. Any value greater than 1 will specify the number of mip-
map levels, until the single element mip-map level is reached. The ArraySize member of
this method indicates how many texture elements to create in the array. Each texture slice
in the array will contain the number of mip-maps specified in the MipLevels member. The
format of the texture is logically specified in the Format member. This must specify one of
the DXGI_FORMAT types, which provide a large variety of different precisions, component
counts, and data types. The next three members of this structure define the usage charac-
teristics, as described at the beginning of this chapter. However, the MiscFlags member
allows for some customized resource behavior for special uses. The available flags that are
usable with a TexturelD resource are listed below.
D3D11 RESOURCE_MISC_GENERATE MIPS
D3D11_RESOURCE_MISC_RESOURCE_CLAMP
The generate mips flag allows the Direct3D runtime to populate the available mip-
map levels with data based on the current values within the top level. To use this function-
ality, the resource must be used as a render target (and thus created with the D3D11_BIND_
RENDER_TARGET bind flag) to fill the top mip-map level, and then the lower mip-map levels
can be filled with a call to the ID3DllDeviceContext::GenerateMips() method. This
method takes a shader resource view of the texture resource and will fill in the mip-map
levels indicated in the view. Of course, to be able to use the resource in a shader stage, it
must also be created with the shader resource bind flag (D3D11_BIND_SHADER_RES0URCE).
The resource clamp flag is used to indicate that a texture resource will use the mini-
mum LOD functionality. This is a way for the application to use the device context to set
the maximum detail level of a texture that will be used. The specification of the maxi-
mum detail level is performed with the ID3DllDeviceContext: :SetResourceMinLOD()
method, which takes a pointer to the resource and a float parameter that can have a value
between 0 and 1. This functionality allows the GPU to page out unused portions of a re-
source so that more memory can be devoted to resources that are more likely to be used.
This setting could be used to implement a resource level of detail that varies as a function
of the distance from the camera, where the top mip-map levels will not be used when an
object is very far from the camera.
Resource view requirements. A 1D texture resource can use all four types of resource
views and cannot be bound to the pipeline without a resource view. The usage semantics
Search WWH ::




Custom Search