D3D12_TEXTURE_LAYOUT enumeration (d3d12.h)

Specifies texture layout options.

Syntax

typedef enum D3D12_TEXTURE_LAYOUT {
  D3D12_TEXTURE_LAYOUT_UNKNOWN = 0,
  D3D12_TEXTURE_LAYOUT_ROW_MAJOR = 1,
  D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE = 2,
  D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = 3
} ;

Constants

 
D3D12_TEXTURE_LAYOUT_UNKNOWN
Value: 0
Indicates that the layout is unknown, and is likely adapter-dependent.
During creation, the driver chooses the most efficient layout based on other resource properties, especially resource size and flags.
Prefer this choice unless certain functionality is required from another texture layout.

Zero-copy texture upload optimizations exist for UMA architectures; see ID3D12Resource::WriteToSubresource.
D3D12_TEXTURE_LAYOUT_ROW_MAJOR
Value: 1
Indicates that data for the texture is stored in row-major order (sometimes called "pitch-linear order").

This texture layout locates consecutive texels of a row contiguously in memory, before the texels of the next row.
Similarly, consecutive texels of a particular depth or array slice are contiguous in memory before the texels of the next depth or array slice.
Padding may exist between rows and between depth or array slices to align collections of data.
A stride is the distance in memory between rows, depth, or array slices; and it includes any padding.

This texture layout enables sharing of the texture data between multiple adapters, when other layouts aren't available.

Many restrictions apply, because this layout is generally not efficient for extensive usage:


  • The locality of nearby texels is not rotationally invariant.

  • Only the following texture properties are supported:


  • The texture must be created on a heap with D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER.


Buffers are created with D3D12_TEXTURE_LAYOUT_ROW_MAJOR, because row-major texture data can be located in them without creating a texture object.
This is commonly used for uploading or reading back texture data, especially for discrete/NUMA adapters.
However, D3D12_TEXTURE_LAYOUT_ROW_MAJOR can also be used when marshaling texture data between GPUs or adapters.
For examples of usage with ID3D12GraphicsCommandList::CopyTextureRegion, see some of the following topics:

D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE
Value: 2
Indicates that the layout within 64KB tiles and tail mip packing is up to the driver.
No standard swizzle pattern.

This texture layout is arranged into contiguous 64KB regions, also known as tiles, containing near equilateral amount of consecutive number of texels along each dimension.
Tiles are arranged in row-major order.
While there is no padding between tiles, there are typically unused texels within the last tile in each dimension.
The layout of texels within the tile is undefined.
Each subresource immediately follows where the previous subresource end, and the subresource order follows the same sequence as subresource ordinals.
However, tail mip packing is adapter-specific.
For more details, see tiled resource tier and ID3D12Device::GetResourceTiling.

This texture layout enables partially resident or sparse texture scenarios when used together with virtual memory page mapping functionality.
This texture layout must be used together with ID3D12Device::CreateReservedResource to enable the usage of ID3D12CommandQueue::UpdateTileMappings.

Some restrictions apply to textures with this layout:

D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE
Value: 3
Indicates that a default texture uses the standardized swizzle pattern.

This texture layout is arranged the same way that D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE is, except that the layout of texels within the tile is defined. Tail mip packing is adapter-specific.

This texture layout enables optimizations when marshaling data between multiple adapters or between the CPU and GPU.
The amount of copying can be reduced when multiple components understand the texture memory layout.
This layout is generally more efficient for extensive usage than row-major layout, due to the rotationally invariant locality of neighboring texels.
This layout can typically only be used with adapters that support standard swizzle, but exceptions exist for cross-adapter shared heaps.

The restrictions for this layout are that the following aren't supported:

Remarks

This enum is used by the D3D12_RESOURCE_DESC structure.

This enumeration controls the swizzle pattern of default textures and enable map support on default textures. Callers must query D3D12_FEATURE_DATA_D3D12_OPTIONS to ensure that each option is supported.

The standard swizzle formats applies within each page-sized chunk, and pages are laid out in linear order with respect to one another. A 16-bit interleave pattern defines the conversion from pre-swizzled intra-page location to the post-swizzled location.

Standard swizzle patterns

To demonstrate, consider the 2D 32bpp swizzle format above. This is represented by the following interleave masks, where bits on the left are most-significant:

UINT xBytesMask = 1010 1010 1000 1111
UINT yMask =      0101 0101 0111 0000

To compute the swizzled address, the following code could be used (where the _pdep_u32 intrinsic instruction is supported):

UINT swizzledOffset = resourceBaseOffset +
                      _pdep_u32(xOffset, xBytesMask) +
                      _pdep_u32(yOffset, yBytesMask);

Requirements

Requirement Value
Header d3d12.h

See also

CD3DX12_RESOURCE_DESC

Core Enumerations

UMA Optimizations: CPU Accessible Textures and Standard Swizzle