Skip to content

d3d12: GetCopyableFootprints refuses what the PC runtime refuses (found by a host/WARP differential fuzzer) - #5218

Open
Exopus-0x65f7ad0 wants to merge 4 commits into
ItsNotRexed:mainfrom
Exopus-0x65f7ad0:d3d12/footprint-refusals
Open

Exopus-0x65f7ad0 wants to merge 4 commits into
ItsNotRexed:mainfrom
Exopus-0x65f7ad0:d3d12/footprint-refusals

Conversation

@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: a new D3D item, GetCopyableFootprints answering descriptions the PC runtime refuses (claim).

Depends on: none. #2498 (unaligned BaseOffset) touches the same method but not the same lines; the fuzzer only uses 512-aligned bases so it doesn't overlap with that PR.

What and why

d3d12_footprint_fuzz_test (new, in ctest) asks the layer, the host adapter and WARP about seeded random descriptions:

  • every DXGI format 1–132, buffers, 1D/2D/3D, arrays and mip chains;
  • the depth-stencil flag;
  • subresource ranges that run past the end, and aligned base offsets.

GetCopyableFootprints is the runtime's arithmetic and validation, so wherever the two hosts agree the layer must give the same answer. On main 3faac557 it answers about 930 of every 20,000 descriptions that both hosts refuse. An application probing a description with GetCopyableFootprints would get a layout for a resource it can never create.

These are the rules, derived over the whole population, not a sample. I dumped all 49,739 descriptions with the three answers. The RTX 5060 Ti and WARP disagree on 2 of them, and neither host ever accepts a description that breaks one of these rules:

Refused by the PC runtime Cases Host accepts main accepts
ALLOW_DEPTH_STENCIL on a buffer 1,472 0 66
ALLOW_DEPTH_STENCIL on a format outside the R32G8X24, R32, R24G8, R16 families 3,943 0 687
Width/height past 16384 (1D, 2D), any axis past 2048 (3D) 2,048 0 281
Block-compressed 1D texture 2,042 0 660
3D in the R32G8X24 or R24G8 families, D32_FLOAT, D16_UNORM (per format, 83–117 each) 0 37–58 per format

I also checked rules that turned out wrong, and they stay unchecked:

  • the host does accept some mip counts past the full chain, which the existing comment already said;
  • it accepts BC 2D/3D textures whose size isn't a multiple of 4;
  • it accepts R32_TYPELESS/R16_TYPELESS-family volumes.

The changes:

  1. footprint_refused() holds those five checks, and GetCopyableFootprints calls it next to xr_bias_compatible and rgb96_refused. The old comment saying extent limits "differ between adapters" is updated: on these two hosts they don't.
  2. The depth-stencil view formats (R32_FLOAT_X8X24_TYPELESS, X32_TYPELESS_G8X24_UINT, R24_UNORM_X8_TYPELESS, X24_TYPELESS_G8_UINT) lay out as their typeless family, with two planes, as on both hosts. The layer used to refuse them.

How the test judges: the layer answering where the host refuses, or answering differently, fails the run. The layer refusing where the host answers is a gap: it is counted, printed with --gaps, and doesn't fail. The remaining gaps are video and palette formats (AYUV, Y416, R8G8_B8G8, P8…).

A host quirk, not copied: the PC runtime computes a volume subresource's size in 32 bits. For 805×777×750 RGBA32, the next mip lands at 7,608,384,000 − 2^32 = 3,313,416,704 on both hosts, while the layer keeps the true offset. The test skips subresources of 4 GiB or more, and the docs record it. DXGI_FORMAT_420_OPAQUE is skipped because the host runtime fast-fails on some 3D descriptions of it.

Tested

Windows 11 (26300), RTX 5060 Ti / 621.14, MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363.0, RelWithDebInfo.

seeds 1–5 (~99,500 descriptions)
main 3faac557 939 / 917 wrong (seeds 1, 2)
this PR, refusals only 0 wrong, ~250 gaps per seed
this PR 0 wrong, ~50 gaps per seed

The full LEONIDA_VK_VALIDATION=1 ctest -j4 on the head gives 168/168 pass, 0 VUIDs. That includes d3d12_vulkan_device, whose compare_footprints still matches the PC runtime, and the new d3d12_footprint_fuzz (about 25 s).

Found with the same differential approach as #5180 (fences). AI-assisted (Claude Code). Synthetic descriptions only, no game files.

🤖 Generated with Claude Code

Exopus-0x65f7ad0 and others added 2 commits November 23, 2026 10:25
…refuses, found by a footprint fuzzer

d3d12_footprint_fuzz_test asks the layer, the host adapter and WARP about seeded random descriptions and compares
where the two hosts agree. On main, about 930 of 20,000 descriptions per seed got footprints the host refuses. Over
49,739 descriptions (RTX 5060 Ti 621.14 and WARP agree on all but two), neither host ever accepts:
- ALLOW_DEPTH_STENCIL on a buffer, or on a format outside the R32G8X24, R32, R24G8 and R16 families;
- an extent past 16384 (1D, 2D) or 2048 (3D);
- a block-compressed 1D texture;
- a 3D texture in the R32G8X24 or R24G8 families, D32_FLOAT or D16_UNORM.
footprint_refused() checks those. The fuzzer runs in ctest: the layer answering where the host refuses, or answering
differently, fails it; the layer refusing where the host answers is printed as a gap. Volume subresources of 4 GiB or
more are skipped: the PC runtime wraps their offsets at 32 bits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heir typeless family

R32_FLOAT_X8X24_TYPELESS and X32_TYPELESS_G8X24_UINT lay out as R32G8X24_TYPELESS, R24_UNORM_X8_TYPELESS and
X24_TYPELESS_G8_UINT as R24G8_TYPELESS (two planes), as on the host adapter and WARP; the layer refused them.
d3d12_footprint_fuzz_test's gaps go from about 250 to about 50 per 20,000 descriptions (the rest are video and
palette formats), with none wrong. --gaps now also prints the host's answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kam471 Kam471 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.

Built and ran d3d12_footprint_fuzz_test at 21254166c on Windows 11, RTX 5070 Ti: exit 0 — footprint fuzz (NVIDIA GeForce RTX 5070 Ti and WARP): 19906 descriptions, 0 wrong, 51 gaps (the layer refuses), 0 where the two hosts disagree, 1 where the host wraps a 4 GiB subresource; git diff --check clean.

The differential fuzzer drives GetCopyableFootprints over 19,906 descriptions and compares the layer with the host and WARP; none of the 19,906 answers is wrong, the 51 refusals are the layer's documented gaps, and the two hosts never disagree. The change lays out depth-stencil view formats as their typeless family, which is what the host does, and the one 4 GiB wrap is the host's own behavior. No blocking issue.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

At 2125416, the last valid unsigned seed produces a false pass. AI-assisted review on Windows 11.

Run d3d12_footprint_fuzz_test.exe --start 4294967295 --seeds 1 --cases 20000. The program reports 0 descriptions and exits with code 0. Expected: run the 20,000 draws for seed 4294967295. The unsigned sum in seed < start + seeds wraps to zero before the first iteration. Count iterations from zero and derive the seed from the iteration index.

For comparison, seed 1 ran on both the RTX 4090 and the AMD Radeon iGPU as the Vulkan device. The native D3D12 references were the RTX 4090 and WARP in both runs. Each run reported 19,906 descriptions, 0 wrong answers, 51 gaps, and 1 skipped host size wrap. The same test built against merge base 3faac55 reported 939 wrong answers on the RTX 4090 and exited with code 1.

@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor Author

Relation to #4533 (query sweep): that PR's grid found no footprint value difference and counts a layer refusal as a gap. The same is true here, since every footprint the layer answers matches. What this PR adds is the opposite direction, which a grid of engine-style descriptions rarely reaches: the layer answering descriptions both hosts refuse (depth flag on colour formats and buffers, extents past the limits, BC 1D, 3D depth families). The two touch different methods (allocation() there, GetCopyableFootprints here), so they don't conflict. AI-assisted.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2125416 on NVIDIA GeForce RTX 4080, driver 617.42: d3d12_footprint_fuzz_test with its default arguments exits 0 and prints "footprint fuzz (NVIDIA GeForce RTX 4080 and WARP): 19906 descriptions, 0 wrong, 51 gaps (the layer refuses), 0 where the two hosts disagree, 1 where the host wraps a 4 GiB subresource". d3d12_vulkan_device_test also exits 0, and it prints no check summary on a pass. The five-seed comparison from the description was not run, only the default seed, and the build is clang-cl rather than MSVC.

AI-assisted.

@im-a-cat

Copy link
Copy Markdown

Verified on Windows 11, MSVC v17.14 (BuildTools), Vulkan SDK 1.4.363.0, NVIDIA GeForce RTX 4060 Ti (16 GB) with WARP host reference:

  • Build: Clean MSVC compile and link for both d3d12_footprint_fuzz_test.exe and d3d12_vulkan_device_test.exe.
  • Default seed:
    footprint fuzz (NVIDIA GeForce RTX 4060 Ti and WARP): 19906 descriptions, 0 wrong, 51 gaps (the layer refuses), 0 where the two hosts disagree, 1 where the host wraps a 4 GiB subresource (exit code 0).
  • 5-seed stress run (--seeds 5 --cases 20000):
    footprint fuzz (NVIDIA GeForce RTX 4060 Ti and WARP): 99503 descriptions, 0 wrong, 247 gaps (the layer refuses), 2 where the two hosts disagree, 3 where the host wraps a 4 GiB subresource (exit code 0).
  • Existing suite: d3d12_vulkan_device_test.exe passes end-to-end; all clears, uploads, copies, resolves, queries, and GetCopyableFootprints / GetResourceTiling error paths matched the PC host runtime.

Also confirmed @shdann's edge case with --start 4294967295 --seeds 1 --cases 20000: seed < start + seeds wraps UINT_MAX + 1 to 0, reporting 0 descriptions and exiting 0.
A straightforward fix in runtime/test/d3d12_footprint_fuzz_test.cpp:

    for (unsigned i = 0; i < seeds; ++i) {
        const unsigned seed = start + i;
        std::mt19937_64 rng(seed);

Overall looks solid and ready to land once the loop bound is adjusted.

AI-assisted.

…5 --seeds 1 runs instead of wrapping to none

Found by @shdann on ItsNotRexed#5218: start + seeds wrapped to 0 and the loop never ran, a false pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exopus-0x65f7ad0 added a commit to Exopus-0x65f7ad0/Leonida that referenced this pull request Nov 23, 2026
… cannot wrap the seed range to none

The same wrap @shdann found in d3d12_footprint_fuzz_test (ItsNotRexed#5218).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor Author

@shdann thanks, confirmed and fixed in aea6f35a: runs are counted from zero and the seed is start + index. --start 4294967295 --seeds 1 now runs its 19,881 descriptions (0 wrong, 35 gaps) on the RTX 5060 Ti, and the default run is unchanged (19,906, 0 wrong, 51 gaps). #5180's fence fuzzer had the same loop and got the same fix (4bb567a2): --start 4294967295 --seeds 2 runs seeds 4294967295 and 0. AI-assisted.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested aea6f35 on NVIDIA GeForce RTX 4080, driver 617.42: d3d12_footprint_fuzz_test with its default arguments exits 0 and prints "footprint fuzz (NVIDIA GeForce RTX 4080 and WARP): 19906 descriptions, 0 wrong, 51 gaps (the layer refuses), 0 where the two hosts disagree, 1 where the host wraps a 4 GiB subresource". d3d12_vulkan_device_test exits 0 and prints no pass summary. Only these two targets and only the default seed were run, so the full ctest count and the multi-seed comparison from the description were not reproduced.

AI-assisted.

…ead of running 0 seeds

A count option (--seeds, --start, --ops, --cases, --reduce, --queues) now needs decimal digits
that fit in 32 bits. A missing value, the next option, "-1" or "12x" exits 2 with a usage
message. Before, "--seeds --verbose" read as 0 seeds and exited 0 without testing anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor Author

Same argument-parsing hole as @shdann found in #5272: --seeds --verbose read as 0 seeds and exited 0. Fixed in bc2b6c11: a missing, negative, non-numeric or >32-bit count exits 2. Checked on the RTX 5060 Ti / 621.14: those four cases exit 2; --seeds 2 gives 39,801 descriptions, 0 wrong, 98 gaps, 0 host disagreements. AI-assisted (Claude Code).

@kormocicsaba

Copy link
Copy Markdown

Tested bc2b6c11 (up to date with main 3faac557) on Windows 11 Pro 26300, VS 2026 (MSVC) + Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, no game files: pass

Vulkan device driver d3d12_footprint_fuzz_test, seeds 1–5 --start 4294967295 --seeds 2 d3d12_vulkan_device_test
NVIDIA GeForce RTX 4070 621.01 99,503 descriptions, 0 wrong, 247 gaps 39,774, 0 wrong, 64 gaps pass
AMD Radeon iGPU (VK_LOADER_DRIVERS_SELECT=*amd*) 24.10.34 same counts same counts pass
  • The host references are the RTX 4070 and WARP in both rows. The test always picks the first hardware D3D12 adapter, so only the Vulkan device changes.
  • Every run was repeated with LEONIDA_VK_VALIDATION=1: same counts, 0 VUIDs.
  • The seeds 1–5 counts match im-a-cat's run on 21254166: 2 where the hosts disagree, 3 host wraps.
  • The --start 4294967295 --seeds 2 run used seeds 4294967295 and 0, so the loop fix from aea6f35a works.

Argument handling from bc2b6c11: each of these exits 2 with "needs a decimal count":

  • --seeds --verbose, --seeds -1, --seeds abc, --seeds 4294967296, --seeds 99999999999999999999999
  • --seeds +5, --seeds " 5", a bare --seeds or --start at the end, --cases 12x, --start 4294967296

--seeds 1 --cases 100 and --start 4294967295 --seeds 1 --cases 100 still run 100 descriptions and exit 0. A small leftover, not blocking: an explicit --seeds 0 or --cases 0 is still accepted, runs 0 descriptions and exits 0.

Negative control: I put main's runtime/shims/d3d12_vulkan_device.cpp back, kept the new test and rebuilt it. Seed 1 then gave 939 wrong, 248 gaps, exit 1, matching the description; seeds 1–5 gave 4,538 wrong, exit 1. With the PR's file restored, it gave 0 wrong and 51 gaps again.

Not re-run on this head: the full ctest, because bc2b6c11 changes only the test's argument parsing. On aea6f35a, with the same runtime source, the full ctest -j4 on the RTX 4070 passed 169/169 with 10 not run. That is main's baseline plus d3d12_footprint_fuzz. With LEONIDA_VK_VALIDATION=1 it gave 169 passed, 0 VUIDs and one d3d12_queue_wait timeout. That timeout isn't related to this PR: with main's runtime, the test exe hangs in 5 of 10 runs here, with or without validation.

AI-assisted (Claude Code).

@caltr98

caltr98 commented Nov 23, 2026

Copy link
Copy Markdown

Tested bc2b6c1 on NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.14, Windows 11 (build 26300), MSVC 14.44, RelWithDebInfo: pass. d3d12_footprint_fuzz passes (2.3 s). AI-assisted.

1 similar comment
@caltr98

caltr98 commented Nov 23, 2026

Copy link
Copy Markdown

Tested bc2b6c1 on NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.14, Windows 11 (build 26300), MSVC 14.44, RelWithDebInfo: pass. d3d12_footprint_fuzz passes (2.3 s). AI-assisted.

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested bc2b6c1 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass

  • Built d3d12_footprint_fuzz_test and d3d12_vulkan_device_test at the head (RelWithDebInfo, Ninja, MSVC 19.44). The host reference here is the AMD driver; the earlier checks on this PR were on NVIDIA.
  • d3d12_footprint_fuzz_test.exe default run (14 s): "19906 descriptions, 0 wrong, 28 gaps (the layer refuses), 0 where the two hosts disagree, 1 where the host wraps a 4 GiB subresource", exit 0. --seeds 5: 99503 descriptions, 0 wrong, 144 gaps, 0 host disagreements, exit 0.
  • --start 4294967295 --seeds 1: 19881 descriptions, exit 0. --start 4294967295 --seeds 2: 39774 descriptions, exit 0. The wrap-around case from review is fixed.
  • Bad arguments exit 2 with "--seeds needs a decimal count": --seeds alone, --seeds --verbose, --seeds -1, --seeds abc, --seeds 4294967296.
  • ctest -R "footprint|d3d12_vulkan_device" -j1: both pass (7.3 s and 1.1 s).
  • Negative control: main 3faac55 plus only the new test file and its CMake lines: "19906 descriptions, 939 wrong, 225 gaps, 3 where the two hosts disagree", exit 1. The same 939 wrong as the description's RTX 5060 Ti figure, so the rules hold on the AMD host too and the fix removes all of them here.
  • Read the diff (d3d12_vulkan_device.cpp footprint_refused, and the depth-stencil view-format mapping): the DXGI ranges (R32 41..43 plus D32_FLOAT, R16 53..59, R24G8 44..47, R32G8X24 19..26) match the enum values, and the 3D, 1D BC and extent rules match the table in the description. No bug found.
  • Not done: the two hosts disagree on 3 descriptions on main and on 0 here, so there is nothing to compare for those 3. Only 512-aligned bases are fuzzed (the unaligned BaseOffset case is d3d12: GetCopyableFootprints aligns from BaseOffset #2498).

AI-assisted (Claude Code).

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested bc2b6c11 merged onto main 561b65a8 (merges cleanly) on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363: pass.

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.

9 participants