Skip to content

Commit 5a22d68

Browse files
authored
Merge pull request #999 from fdwr/patch-6
D3D12_TEXTURE_LAYOUT - fix weird extra line breaks
2 parents d7110e0 + cd4b9e9 commit 5a22d68

File tree

1 file changed

+46
-103
lines changed

1 file changed

+46
-103
lines changed

sdk-api-src/content/d3d12/ne-d3d12-d3d12_texture_layout.md

Lines changed: 46 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ api_name:
4747

4848
# D3D12_TEXTURE_LAYOUT enumeration
4949

50-
5150
## -description
5251

5352
Specifies texture layout options.
@@ -57,184 +56,128 @@ Specifies texture layout options.
5756
### -field D3D12_TEXTURE_LAYOUT_UNKNOWN
5857

5958
Indicates that the layout is unknown, and is likely adapter-dependent.
60-
During creation, the driver chooses the most efficient layout based on other resource properties, especially resource size and flags.
61-
Prefer this choice unless certain functionality is required from another texture layout.
62-
59+
During creation, the driver chooses the most efficient layout based on other resource properties, especially resource size and flags.
60+
Prefer this choice unless certain functionality is required from another texture layout.
6361

6462
Zero-copy texture upload optimizations exist for UMA architectures; see <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12resource-writetosubresource">ID3D12Resource::WriteToSubresource</a>.
6563

6664
### -field D3D12_TEXTURE_LAYOUT_ROW_MAJOR
6765

6866
Indicates that data for the texture is stored in row-major order (sometimes called "pitch-linear order").
69-
7067

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

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

8075
Many restrictions apply, because this layout is generally not efficient for extensive usage:
81-
8276

8377
<ul>
84-
<li>The locality of nearby texels is not rotationally invariant.
85-
</li>
78+
<li>The locality of nearby texels is not rotationally invariant.</li>
8679
<li>Only the following texture properties are supported:
87-
<ul>
88-
<li>
89-
<a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE_2D.
90-
</li>
91-
<li>A single mip level.
92-
</li>
93-
<li>A single array slice.
94-
</li>
95-
<li>64KB alignment.
96-
</li>
97-
<li>Non-MSAA.
98-
</li>
99-
<li>No <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags">D3D12_RESOURCE_FLAG</a>_ALLOW_DEPTH_STENCIL.
100-
</li>
101-
<li>The format cannot be a YUV format.
102-
</li>
80+
<ul>
81+
<li><a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE_2D.</li>
82+
<li>A single mip level.</li>
83+
<li>A single array slice.</li>
84+
<li>64KB alignment.</li>
85+
<li>Non-MSAA.</li>
86+
<li>No <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags">D3D12_RESOURCE_FLAG</a>_ALLOW_DEPTH_STENCIL.</li>
87+
<li>The format cannot be a YUV format.</li>
10388
</ul>
10489
</li>
105-
<li>The texture must be created on a heap with <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_flags">D3D12_HEAP_FLAG</a>_SHARED_CROSS_ADAPTER.
106-
</li>
90+
<li>The texture must be created on a heap with <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_flags">D3D12_HEAP_FLAG</a>_SHARED_CROSS_ADAPTER.</li>
10791
</ul>
10892
Buffers are created with <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_texture_layout">D3D12_TEXTURE_LAYOUT</a>_ROW_MAJOR, because row-major texture data can be located in them without creating a texture object.
109-
This is commonly used for uploading or reading back texture data, especially for discrete/NUMA adapters.
110-
However, <b>D3D12_TEXTURE_LAYOUT</b>_ROW_MAJOR can also be used when marshaling texture data between GPUs or adapters.
111-
For examples of usage with <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copytextureregion">ID3D12GraphicsCommandList::CopyTextureRegion</a>, see some of the following topics:
112-
93+
This is commonly used for uploading or reading back texture data, especially for discrete/NUMA adapters.
94+
However, <b>D3D12_TEXTURE_LAYOUT</b>_ROW_MAJOR can also be used when marshaling texture data between GPUs or adapters.
95+
For examples of usage with <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copytextureregion">ID3D12GraphicsCommandList::CopyTextureRegion</a>, see some of the following topics:
11396

11497
<ul>
115-
<li>
116-
<a href="/windows/win32/direct3d12/default-texture-mapping">Default Texture Mapping and Standard Swizzle</a>
117-
</li>
118-
<li>
119-
<a href="/windows/win32/direct3d12/predication">Predication</a>
120-
</li>
121-
<li>
122-
<a href="/windows/win32/direct3d12/user-mode-heap-synchronization">Multi-engine synchronization</a>
123-
</li>
124-
<li>
125-
<a href="/windows/win32/direct3d12/upload-and-readback-of-texture-data">Uploading Texture Data</a>
126-
</li>
98+
<li><a href="/windows/win32/direct3d12/default-texture-mapping">Default Texture Mapping and Standard Swizzle</a></li>
99+
<li><a href="/windows/win32/direct3d12/predication">Predication</a></li>
100+
<li><a href="/windows/win32/direct3d12/user-mode-heap-synchronization">Multi-engine synchronization</a></li>
101+
<li><a href="/windows/win32/direct3d12/upload-and-readback-of-texture-data">Uploading Texture Data</a></li>
127102
</ul>
128103

129104
### -field D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE
130105

131106
Indicates that the layout within 64KB tiles and tail mip packing is up to the driver.
132-
No standard swizzle pattern.
133-
107+
No standard swizzle pattern.
134108

135109
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.
136-
Tiles are arranged in row-major order.
137-
While there is no padding between tiles, there are typically unused texels within the last tile in each dimension.
138-
The layout of texels within the tile is undefined.
139-
Each subresource immediately follows where the previous subresource end, and the subresource order follows the same sequence as subresource ordinals.
140-
However, tail mip packing is adapter-specific.
141-
For more details, see tiled resource tier and <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12device-getresourcetiling">ID3D12Device::GetResourceTiling</a>.
142-
110+
Tiles are arranged in row-major order.
111+
While there is no padding between tiles, there are typically unused texels within the last tile in each dimension.
112+
The layout of texels within the tile is undefined.
113+
Each subresource immediately follows where the previous subresource end, and the subresource order follows the same sequence as subresource ordinals.
114+
However, tail mip packing is adapter-specific.
115+
For more details, see tiled resource tier and <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12device-getresourcetiling">ID3D12Device::GetResourceTiling</a>.
143116

144117
This texture layout enables partially resident or sparse texture scenarios when used together with virtual memory page mapping functionality.
145-
This texture layout must be used together with <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12device-createreservedresource">ID3D12Device::CreateReservedResource</a> to enable the usage of <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12commandqueue-updatetilemappings">ID3D12CommandQueue::UpdateTileMappings</a>.
146-
118+
This texture layout must be used together with <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12device-createreservedresource">ID3D12Device::CreateReservedResource</a> to enable the usage of <a href="/windows/win32/api/d3d12/nf-d3d12-id3d12commandqueue-updatetilemappings">ID3D12CommandQueue::UpdateTileMappings</a>.
147119

148120
Some restrictions apply to textures with this layout:
149-
150121

151122
<ul>
152-
<li>The adapter must support <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_tiled_resources_tier">D3D12_TILED_RESOURCES_TIER</a> 1 or greater.
153-
</li>
154-
<li>64KB alignment must be used.
155-
</li>
156-
<li>
157-
<a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE1D is not supported, nor are all formats.
158-
</li>
159-
<li>The tiled resource tier indicates whether textures with <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE3D is supported.
160-
</li>
123+
<li>The adapter must support <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_tiled_resources_tier">D3D12_TILED_RESOURCES_TIER</a> 1 or greater.</li>
124+
<li>64KB alignment must be used.</li>
125+
<li><a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE1D is not supported, nor are all formats.</li>
126+
<li>The tiled resource tier indicates whether textures with <a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE3D is supported.</li>
161127
</ul>
162128

163129
### -field D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE
164130

165131
Indicates that a default texture uses the standardized swizzle pattern.
166-
167132

168-
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.
169-
Tail mip packing is adapter-specific.
170-
133+
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.
171134

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

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

180-
181142
<ul>
182-
<li>
183-
<a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE1D
184-
</li>
185-
<li>Multi-sample anti-aliasing (MSAA)
186-
</li>
187-
<li>
188-
<a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags">D3D12_RESOURCE_FLAG</a>_ALLOW_DEPTH_STENCIL
189-
</li>
190-
<li>Formats within the <a href="/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format">DXGI_FORMAT</a>_R32G32B32_TYPELESS group
191-
</li>
143+
<li><a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_dimension">D3D12_RESOURCE_DIMENSION</a>_TEXTURE1D</li>
144+
<li>Multi-sample anti-aliasing (MSAA)</li>
145+
<li><a href="/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags">D3D12_RESOURCE_FLAG</a>_ALLOW_DEPTH_STENCIL</li>
146+
<li>Formats within the <a href="/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format">DXGI_FORMAT</a>_R32G32B32_TYPELESS group</li>
192147
</ul>
193148

194149
## -remarks
195150

196151
This enum is used by the <a href="/windows/win32/api/d3d12/ns-d3d12-d3d12_resource_desc">D3D12_RESOURCE_DESC</a> structure.
197-
198152

199153
This enumeration controls the swizzle pattern of default textures and enable map support on default textures.
200-
Callers must query <a href="/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options">D3D12_FEATURE_DATA_D3D12_OPTIONS</a> to ensure that each option is supported.
201-
154+
Callers must query <a href="/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options">D3D12_FEATURE_DATA_D3D12_OPTIONS</a> to ensure that each option is supported.
202155

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

207159
<img alt="Standard swizzle patterns" src="./images/d3d12_standardswizzle.png"/>
208-
To demonstrate, consider the 2D 32bpp swizzle format above.
209-
This is represented by the following interleave masks, where bits on the left are most-significant:
210-
211160

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

213164
``` syntax
214165
UINT xBytesMask = 1010 1010 1000 1111
215166
UINT yMask = 0101 0101 0111 0000
216167
```
217168

218169
To compute the swizzled address, the following code could be used (where the <b>_pdep_u32</b> intrinsic instruction is supported):
219-
220-
221170

222171
``` syntax
223172
UINT swizzledOffset = resourceBaseOffset +
224173
_pdep_u32(xOffset, xBytesMask) +
225174
_pdep_u32(yOffset, yBytesMask);
226175
```
227176

228-
229177
## -see-also
230178

231179
<a href="/windows/win32/direct3d12/cd3dx12-resource-desc">CD3DX12_RESOURCE_DESC</a>
232180

233-
234-
235181
<a href="/windows/win32/direct3d12/direct3d-12-enumerations">Core Enumerations</a>
236182

237-
238-
239183
<a href="/windows/win32/direct3d12/default-texture-mapping">UMA Optimizations: CPU Accessible Textures and Standard Swizzle</a>
240-

0 commit comments

Comments
 (0)