Default Texture Mapping

The use of default texture mapping reduces copying and memory usage while sharing image data between the GPU and the CPU. However, it should only be used in specific situations. The standard swizzle layout avoids copying or swizzling data in multiple layouts.

Overview

Mapping default textures should not be the first choice for developers. Developers should code in a discrete-GPU friendly way first (that is, do not have any CPU access for the majority of textures and upload with CopySubresourceRegion1). But, for certain cases, the CPU and GPU may interact so frequently on the same data, that mapping default textures becomes helpful to save power, or to speed up a particular design on particular adapters or architectures. Applications should detect these cases and optimize out the unnecessary copies.

In D3D11.3, textures created with D3D11_TEXTURE_LAYOUT_UNDEFINED (one member of the D3D11_TEXTURE_LAYOUT enum) and no CPU access are the most efficient for frequent GPU rendering and sampling. When performance testing, those textures should be compared against D3D11_TEXTURE_LAYOUT_UNDEFINED with CPU access, and D3D11_TEXTURE_LAYOUT_64K_STANDARD_SWIZZLE with CPU access, and D3D11_TEXTURE_LAYOUT_ROW_MAJOR for cross-adapter support.

Using D3D11_TEXTURE_LAYOUT_UNDEFINED with CPU access enables the methods WriteToSubresource, ReadFromSubresource, Map (precluding application access to pointer), and Unmap; but can sacrifice efficiency of GPU access. Using D3D11_TEXTURE_LAYOUT_64K_STANDARD_SWIZZLE with CPU access enables WriteToSubresource, ReadFromSubresource, Map (which returns a valid pointer to application), and Unmap. It can also sacrifice efficiency of GPU access more than D3D11_TEXTURE_LAYOUT_UNDEFINED with CPU access.

In general, applications should create the majority of textures as GPU-only-accessible, and with D3D11_TEXTURE_LAYOUT_UNDEFINED.

Previous to the mapping default textures feature, there was only one standardized layout for multi-dimensional data: "linear", also known as "row-major". Applications should avoid USAGE_STAGING and USAGE_DYNAMIC textures when map default is available. The USAGE_STAGING and USAGE_DYNAMIC textures use the linear layout.

D3D11.3 (and D3D12) introduce a standard multi-dimensional data layout. This is done to enable multiple processing units to operate on the same data without copying the data or swizzling the data between multiple layouts. A standardized layout enables efficiency gains through network effects and allows algorithms to make short-cuts assuming a particular pattern.

Note though that this standard swizzle is a hardware feature, and may not be supported by all GPUs.

D3D11.3 APIs

Unlike D3D12, D3D11.3 does not supports texture mapping by default, so you need to query D3D11_FEATURE_DATA_D3D11_OPTIONS2. Standard swizzle will also need to be queried for with a call to ID3D11Device::CheckFeatureSupport and checking the StandardSwizzle64KBSupported field of D3D11_FEATURE_DATA_D3D11_OPTIONS2.

The following APIs reference texture mapping:

Enums

Structures

Methods

Direct3D 11.3 Features