upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/resource_tiling.h
diff options
context:
space:
mode:
authorStørm <52797150+AC-Storm-YT@users.noreply.github.com>2026-11-21 21:03:11 -0500
committerStørm <52797150+AC-Storm-YT@users.noreply.github.com>2026-11-21 22:57:55 -0500
commit0bad3d7aed3e8a5d7a820582f5c70f2d2c1a322f (patch)
tree4a4b44bbecc23a7612d49b0fb1d7b6e91f0a948a /runtime/src/resource_tiling.h
parent4a36bb19979b611f525d027f92e0fefad1626546 (diff)
Runtime: reserved resources follow AMD's standard/packed mip split (D3D-65)
D3D12 leaves where the packed tail starts to the driver (#654 made the test accept any host's split). The layer used NVIDIA's: packed from the first mip smaller than a tile on any axis. The console is RDNA2, so it now follows AMD's PC runtime, as @traeb0n (D3D-20) recommended on #634. AMD's rule, measured on an RX 9070 XT (RDNA4, 32.0.31041.1004) and a Ryzen 7 9800X3D iGPU (RDNA2, 32.0.21045.5002), identical on both: a mip stays standard while it is wider than half the tile or taller than the tile; depth does not count. It fits all 47 measured layouts: compare_tiling's 17 and 30 edge cases (a mip exactly at or just past half a tile, thin and tall textures, non-square 2D and volume tiles). The rule first proposed on #374 ("every axis at most half the tile's largest side") fitted the 17 but missed four tall or deep ones. - src/resource_tiling.h: the new split; a standard mip smaller than a tile takes one tile on that axis. - resource_tiling_test: the five layouts that change expect the AMD values, plus a table of all 47 AMD layouts checking standard and packed mips, the packed start and NumTilesForPackedMips (AMD's in 45; for the two deep volumes that pack from mip 0, AMD reserves 2 tiles and the layer's tight count gives 1). - docs/d3d12_vulkan.md 4.2: the rule and the measurement. AI-assisted (Claude Code).
Diffstat (limited to 'runtime/src/resource_tiling.h')
-rw-r--r--runtime/src/resource_tiling.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/src/resource_tiling.h b/runtime/src/resource_tiling.h
index 08d8360a1..3a472d872 100644
--- a/runtime/src/resource_tiling.h
+++ b/runtime/src/resource_tiling.h
@@ -9,8 +9,11 @@
9// 9//
10// What a driver chooses (D3D11.3 functional spec 5.9.2.8.5: a mip with any dimension below the tile "may or may not 10// What a driver chooses (D3D11.3 functional spec 5.9.2.8.5: a mip with any dimension below the tile "may or may not
11// be packed, depending on the IHV"): where the packed tail starts, and how many tiles the packed mips take. Here 11// be packed, depending on the IHV"): where the packed tail starts, and how many tiles the packed mips take. Here
12// the tail starts at the first mip smaller than a tile on any axis, as on an NVIDIA GPU; a Radeon 880M keeps one or 12// a mip stays standard while it is wider than half the tile or taller than the tile (depth does not count), as
13// two more mips standard and WARP packs nothing, and the test accepts all of them. The packed size is their tight 13// AMD's PC runtime does on RDNA2 and RDNA4 (D3D-65; the console is AMD): 47 measured layouts, see
14// resource_tiling_test. A standard mip may be smaller than a tile and then takes one tile on that axis. An NVIDIA
15// GPU packs from the first mip smaller than a tile on any axis and WARP packs nothing; the test accepts all of
16// them. The packed size is their tight
14// linear size rounded up to whole tiles (at least one); NVIDIA sometimes reports one more. Applications read the 17// linear size rounded up to whole tiles (at least one); NVIDIA sometimes reports one more. Applications read the
15// numbers rather than assume them, and this layer backs every reserved resource fully, so any split is consistent. 18// numbers rather than assume them, and this layer backs every reserved resource fully, so any split is consistent.
16 19
@@ -93,14 +96,13 @@ inline bool resource_tiling(const TilingDesc& desc, ResourceTiling& out) {
93 const std::uint32_t layers = volume ? 1 : desc.depth_or_layers; 96 const std::uint32_t layers = volume ? 1 : desc.depth_or_layers;
94 const std::uint32_t depth = volume ? desc.depth_or_layers : 1; 97 const std::uint32_t depth = volume ? desc.depth_or_layers : 1;
95 98
96 // One array slice: standard mips while every axis holds a whole tile, then the packed tail. 99 // One array slice: standard mips while wider than half a tile or taller than a tile, then the packed tail.
97 std::vector<SubresourceTiling> slice(desc.mips); 100 std::vector<SubresourceTiling> slice(desc.mips);
98 std::uint64_t standard_tiles = 0, packed_bytes = 0; 101 std::uint64_t standard_tiles = 0, packed_bytes = 0;
99 for (std::uint32_t mip = 0; mip < desc.mips; ++mip) { 102 for (std::uint32_t mip = 0; mip < desc.mips; ++mip) {
100 const std::uint64_t w = std::max<std::uint64_t>(1, desc.width >> mip); 103 const std::uint64_t w = std::max<std::uint64_t>(1, desc.width >> mip);
101 const std::uint32_t h = std::max(1u, desc.height >> mip), d = std::max(1u, depth >> mip); 104 const std::uint32_t h = std::max(1u, desc.height >> mip), d = std::max(1u, depth >> mip);
102 const bool standard = out.packed_mips == 0 && w >= out.shape.width && h >= out.shape.height && 105 const bool standard = out.packed_mips == 0 && (w > out.shape.width / 2 || h > out.shape.height);
103 d >= out.shape.depth;
104 if (standard) { 106 if (standard) {
105 const std::uint64_t tw = up(w, out.shape.width), th = up(h, out.shape.height), td = up(d, out.shape.depth); 107 const std::uint64_t tw = up(w, out.shape.width), th = up(h, out.shape.height), td = up(d, out.shape.depth);
106 slice[mip] = {std::uint32_t(tw), std::uint32_t(th), std::uint32_t(td), std::uint32_t(standard_tiles)}; 108 slice[mip] = {std::uint32_t(tw), std::uint32_t(th), std::uint32_t(td), std::uint32_t(standard_tiles)};