Skip to content

Runtime: reserved resources follow AMD's standard/packed mip split (D3D-65) - #868

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
AC-Storm-YT:runtime/amd-mip-split
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
AC-Storm-YT:runtime/amd-mip-split

Conversation

@AC-Storm-YT

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-65 (#374)

What and why

D3D12 leaves where the packed mip tail starts to the driver, and #654 made the test accept any host's split. The layer reported NVIDIA's split, which is what #295 could measure. The console is RDNA2, so it now reports AMD's, as @traeb0n recommended on #634.

AMD's rule, identical on an RX 9070 XT (RDNA4, 32.0.31041.1004) and a Ryzen 7 9800X3D iGPU (RDNA2, 32.0.21045.5002): a mip stays standard while it is wider than half the tile or taller than the tile; depth does not count.

Following @traeb0n's review points, I measured 30 edge cases on top of compare_tiling's 17 layouts: mips exactly at or just past half a tile, thin and tall textures, and non-square 2D and volume tiles. The rule first proposed on #374 ("every axis ≤ half the tile's largest side") fitted the 17 but missed four tall or deep cases (64×128, 1×4096, 8×8×64, 16×16×17). The rule above fits all 47.

  • runtime/src/resource_tiling.h: the new split.
  • runtime/test/resource_tiling_test.cpp: the five changed layouts expect AMD's values, plus a table of all 47 AMD layouts checking standard and packed mips, the packed start and NumTilesForPackedMips. Packed tiles match AMD in 45. For the two deep volumes that pack from mip 0, AMD reserves 2 tiles and the layer's tight count gives 1 (the packed size stays the driver's choice).
  • docs/d3d12_vulkan.md §4.2: the rule and the measurement.

Tested

Windows 11, VS 2026, Vulkan SDK 1.4.363.1, on main 4a36bb1:

  • resource_tiling_test: pass (47 AMD layouts).
  • d3d12_vulkan_device_test with LEONIDA_VK_VALIDATION=1 and LEONIDA_HOST_ADAPTER = RX 9070 XT / 9800X3D iGPU / WARP: 0 split differences on both AMD hosts, and the WARP split is only logged. The test exits 1 later, at options_mismatches (OPTIONS19 SupportedSampleCountsWithNoOutputs, ours 0xf, host 0x1d). That's the D3D-86 regression on main on every AMD GPU, which Runtime: OPTIONS19 no-output sample counts are 1/4/8/16 (no 2x) — fixes the red d3d12_vulkan_device_test on AMD #855 fixes; this PR doesn't touch it.
  • ctest: 31/32, with the same single failure.

@traeb0n: you offered to review and test on the RTX 5070. That would be great.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A: no translator change; the runtime rule is in docs/d3d12_vulkan.md §4.2 with its measurement.)

AI-assisted (Claude Code).

…3D-65)

D3D12 leaves where the packed tail starts to the driver (ItsNotRexed#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 ItsNotRexed#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 ItsNotRexed#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).
@kapitche

Copy link
Copy Markdown
Contributor

Tested 0bad3d7 on Windows 11, NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1714), MSVC 14.51: pass

So on NVIDIA every case that differs at all has more standard mips than the host reports. That's expected for AMD's rule. An AMD host would be the real confirmation; I don't have one.

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 0bad3d7 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • resource_tiling_test (changed here): exit=0 validation=0 | resource tiling: buffer, 2D, array, block-compressed and volume layouts match
  • 32 test programs in the build pass with 0 validation errors
  • d3d12_clear_test fails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as on main 4a36bb1 here, so not from this PR; #521 addresses it

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@AC-Storm-YT

Copy link
Copy Markdown
Contributor Author

Thanks @kapitche and @quackottu for testing on NVIDIA. For the AMD side, the description has the run against both AMD hosts with LEONIDA_HOST_ADAPTER: RX 9070 XT (RDNA4) and the Ryzen 7 9800X3D iGPU (RDNA2) both give 0 split differences, and resource_tiling_test checks all 47 AMD-measured layouts directly.

@traeb0n

traeb0n commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 0bad3d7 on an NVIDIA GeForce RTX 5070, driver 621.01, Windows 11, MSVC 14.44 (VS 2022 Build Tools), Vulkan SDK 1.4.363: pass

  • Clean RelWithDebInfo Ninja build. ctest -E loader: 28/28 including resource_tiling. loader_test is excluded because it hangs on this PC; that's unrelated and also happens on main.
  • d3d12_vulkan_device_test with LEONIDA_VK_VALIDATION=1: pass, 0 validation errors. Against this NVIDIA host it logs the six layouts where the split differs: cases 2, 8, 9, 11, 12, 14, with ours 4, 4, 3, 1, 6, 4 and host 2, 3, 2, 0, 0, 3. Ours are exactly the RDNA2/RDNA4 values from your Coordinating who works on what (2) (moved to #634) #374 table, and the host's are the old NVIDIA split. So the change does what it says on both sides.

Review, as D3D-20's author:

  • The rule and the packed_mips == 0 guard look right. Once a mip packs, everything after it stays packed, and a standard mip narrower than a tile still takes one tile on that axis, which keeps the tile numbering consistent.
  • I checked the other users of the split. GetResourceTiling is the only consumer of the numbers. CreateReservedResource calls resource_tiling only to check that the format has a tile shape, and backs the resource with a full committed allocation, so the split can't change any allocation size. Nothing else in the layer needs to follow.
  • Optional nit: for the two deep volumes that pack from mip 0, AMD reports 2 packed tiles and the layer's tight count gives 1. Any value is consistent while resources are fully backed, so this is fine as is. If you want the layer to match the console's answer exactly, those two could use AMD's count. That would matter only once real sparse binding lands.
  • Thanks for testing the edge cases. The corrected rule (depth doesn't count, a tall mip stays standard) is the kind of thing 17 layouts couldn't show.

Looks good to me. AI-assisted (Claude Code).

@AC-Storm-YT

Copy link
Copy Markdown
Contributor Author

Thanks @traeb0n for the review and the RTX 5070 run.

On the nit: I'd keep the tight count here, since everything tested so far is 0bad3d7, and do it as a follow-up if it's wanted. One pattern from the data: the only two volumes where AMD reserves 2 packed tiles are the ones deeper than one tile (8×8×64 R8 on a 64×32×32 tile, 16×16×17 RGBA8 on a 32×32×16 tile); every fully packed volume within one tile's depth gets 1. That looks like one packed tile per tile-depth slice, but two points aren't enough. I can measure more deep volumes on both AMD GPUs and send it once sparse binding makes it matter, or sooner if you'd like it.

@ItsNotRexed
ItsNotRexed merged commit e730377 into ItsNotRexed:main Nov 22, 2026
10 checks passed
AC-Storm-YT added a commit to AC-Storm-YT/Leonida that referenced this pull request Nov 22, 2026
…ad (review of ItsNotRexed#2728)

8x8x64 R8, 16x16x16 RGBA8, 16x16x17 RGBA8 and 8x8x8 RGBA32F were in the
table twice with the same expectations. The deep-volume set is 32 new
layouts, 79 distinct in all; the header comment and docs/d3d12_vulkan.md
section 4.2 now say so.

AI-assisted (Claude Code).
AC-Storm-YT added a commit to AC-Storm-YT/Leonida that referenced this pull request Nov 22, 2026
…he AMD rule (review of ItsNotRexed#2728)

The test file header still called the packed-tile count this layer's own
tight rule; it now says the split and the packed count follow AMD's PC
runtime, with AMD's values in the AmdCase table. resource_tiling.h names
the 47 layouts of ItsNotRexed#868 for the split and those 47 plus 32 deeper volumes
for the packed count.

AI-assisted (Claude Code).
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
…llow-up)

The layer gave the packed tail its tight linear size in whole tiles. AMD's PC
runtime gives it one tile per tile-depth slice it spans: ceil(depth of the
first packed mip / tile depth), so 1 for every 2D layout and a step at each
tile depth for volumes (8x8x32 R8: 1 tile, 8x8x33: 2, 8x8x256: 8), even where
the bytes would fit in fewer (16x16x128 RGBA8: 8 tiles for 3 tiles of data).

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: the rule fits all 83 layouts, the
47 from #868 (where it explains the two deep volumes AMD gave 2 tiles) and 36
new volumes whose tail is deeper than a tile, including tails that start after
standard mips. It matters once sparse textures (D3D-285) reach mip tails.

- src/resource_tiling.h: packed tiles = max(1, tight size, tail depth slices).
- resource_tiling_test: the two deep volumes expect 2, plus the 36 new volumes
  with AMD's values.
- docs/d3d12_vulkan.md 4.2: the rule and the measurement.

AI-assisted (Claude Code).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants