Repository navigation
d3d12: clear values convert as D3D12/WARP do, found by a new differential clear fuzzer (d3d12_clear_fuzz_test) - #5425
Exopus-0x65f7ad0 wants to merge 3 commits into
Conversation
|
Independent Windows verification of head Machine: Windows 11 Pro build 26300, NVIDIA GeForce RTX 4070 Ti, driver 610.88; VS 2022 MSVC 14.44.35230, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, Ninja. No game files. With
Coverage and comparator limits: verbose output excluded Comparator concern confirmed with a synthetic CPU probe against these actual functions: |
Hiiva
left a comment
There was a problem hiding this comment.
Independent Windows Radeon review of f13305d55d57ff8e693b2081ff88060332514dd0, using native WARP as the reference. Windows 11 build 26200, AMD Radeon(TM) Graphics / 32.0.21043.5001, MSVC 19.44.35228, SDK 10.0.26100.0, Vulkan SDK 1.4.363.0. Synthetic inputs only.
The normalization change removes 25 differences in the same 1,000 generated cases, with no newly differing seeds. The new default test still fails on this Radeon setup because it reaches a separate, pre-existing packed-format UAV clear gap.
| Run | Main production 3faac557 |
This head |
|---|---|---|
| Default seeds 1-40, core + synchronization validation | 6 differences | 5 differences |
| Default seeds 1-1000 | 108 differences | 83 differences |
--all seeds 1-40, core + synchronization validation |
Not run | Same 5 differences |
Both 1,000-seed runs execute all 1,000 seeds with no reference refusals. The 25 corrected cases are D16_UNORM (20), R8_TYPELESS (1), R16G16B16A16_TYPELESS (1) and R32G32B32A32_TYPELESS (3). The head's focused CPU tests also pass: 478 clear_color checks and 93 typeless_rtv scenarios. The main control uses the same new fuzzer and build configuration, with only the three production headers changed by this PR restored to 3faac557.
Remaining packed-UAV coverage gap
All 83 shared failures are B5G6R5_UNORM (37), B5G5R5A1_UNORM (22) or B4G4R4A4_UNORM (24). Each logs ExecuteCommandLists failed: unsupported; nothing was submitted. Although the fuzzer's summary says zero layer refusals, these submissions are rejected and leave the initialized texture bytes in place; they are not additional rounding mismatches.
The capability query admits these views on this machine. CheckFeatureSupport derives typed-UAV support from the Vulkan storage features, while the relevant packed formats are absent from uav_clear::layouts. For example, B5G6R5 maps to VK_FORMAT_R5G6B5_UNORM_PACK16, encode returns false, and vulkan_replay.h:2547-2549 returns unsupported before emission. The layout table and relevant feature-reporting block are identical on main and this head.
Reproduced with LEONIDA_VK_DEVICE=AMD Radeon(TM) Graphics, LEONIDA_VK_VALIDATION=1, and:
d3d12_clear_fuzz_test.exe --seeds 40 --verbose
d3d12_clear_fuzz_test.exe --reduce 14 --verbose
d3d12_clear_fuzz_test.exe --reduce 15 --verbose
Seed 14 reduces to one whole-view ClearUnorderedAccessViewUint on B5G6R5, mip 1, values 0xa62e, 0xfffffffd, 0x4b, 0xdd. Main and head give the same rejection and 351 differing bytes; WARP writes the expected packed value 0x77ab. Seed 15 reduces to one whole-view float clear with (-166, 1, 2.5, 1), again rejected by the layer while WARP writes 0x07ff.
The validated runs and reductions have zero VUID or synchronization-error entries. The larger 1,000-seed pair was run without validation. These counts use this PR's comparator, including its NaN/sRGB tolerances; SirKingg's comparator-provenance finding still applies. No MSAA, game, exhaustive-conformance or clean-default-test claim. No production changes are included in this review. AI-assisted: yes.
Kam471
left a comment
There was a problem hiding this comment.
Head: f13305d55d57ff8e693b2081ff88060332514dd0
Windows 11, RTX 5070 Ti (621.24), vcvars64 + Ninja + Vulkan 1.4.363, RelWithDebInfo:
- Configure/build:
cmake -S runtime -B runtime\build ... && cmake --build runtime\build --target d3d12_clear_fuzz_test d3d12_clear_fuzz_test(default 40 seeds) -> 40 seeds run, 0 differ, 0 refusedd3d12_clear_fuzz_test --seeds 200-> 200 run, 0 differ, 0 refused- Baseline: main
3faac557+ the same fuzzer source -> 40 run, 7 differ (seeds 5, 16, 21, 27, 31, 33, 40), matching the PR's claim. clear_color_test-> 478 checks pass;typeless_rtv_test-> 93 scenarios pass;d3d12_typeless_families_test-> 8 draws, 0 differ;tests/test_ctest_registration.py-> 4/4 OKd3d12_clear_fuzz_test --all(40 seeds) -> 5 differ, all the documented--allcases (4 NVIDIA stencil plane>0, 1 UINT pattern); exit 1 is expected for--all.git diff --check main...HEAD-> clean
Verdict: LGTM.
|
Tested f13305d on two GPUs: AMD Radeon Graphics (Ryzen 9000 iGPU, RDNA2, subgroup 32..64), AMD driver 25.10.30.02, and NVIDIA GeForce RTX 5080, driver 616.64. Windows 11 Pro 26200, MSVC 14.44.35207, Vulkan SDK 1.4.363.0. Merged onto
No game files. AI-assisted (Claude Code). |
|
Tested f13305d on NVIDIA GeForce GTX 1660 (Turing, 32-wide), driver 32.0.16.1742, Windows 10 19045, MSVC 2022, Vulkan SDK 1.4.363.0: pass.
No game files. AI-assisted. |
|
Tested f13305d on NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.14, Windows 11 (build 26300), MSVC 14.44, RelWithDebInfo: pass. |
|
Tested f13305d on NVIDIA GeForce RTX 4080, driver 617.42: d3d12_clear_fuzz_test exits 0 with "clear fuzz (layer against WARP): 40 seeds run, 0 differ, 0 refused by the layer". clear_color_test prints "478 full/rectangle integer and float replay checks passed", typeless_rtv_test prints "93 format, snapshot, whole/rectangle and rejection scenarios passed", and d3d12_typeless_families_test prints "82 clears compared with NVIDIA GeForce RTX 4080, 0 differ" and "8 draws compared with NVIDIA GeForce RTX 4080, 0 differ". d3d12_vulkan_device_test exits 0 with no summary line. The run on main that gives 7 differences was not repeated, and --all and --seeds 1000 were not run. AI-assisted. |
|
Tested f13305d on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: concern (the clear conversions pass; the new fuzzer test fails on this GPU for a format the layer already refused)
AI-assisted (Claude Code). |
…river rounds Clears handed the application's float to vkCmdClear*/loadOp and let the driver convert it. NVIDIA's (621.14) rounds differently from D3D12, WARP and AMD (the Xbox's own hardware): - UNORM/SNORM: 0.5 * 255 = 127.5 gives 0x7f, not the even 0x80; 4-, 5- and 6-bit channels go through 8 bits first (B5G6R5 green 0.3739 is 23, not 24); - sRGB: 0.5 / 255 encodes to 7, not 6; - D16: depth 0.5 clears to 0x7fff, not 0x8000; - a denormal R32_FLOAT colour or D32 depth is kept, where D3D12 flushes it to a zero of its sign. The layer now computes D3D12's code itself (a float multiply, round to nearest, ties to even, as depth24_quantize already does for D24) and hands the driver the nearest float to code / max, which any rounding turns back into that code. ClearUnorderedAccessViewFloat's model (uav_clear::encode) rounded ties away from zero in double; it now matches WARP too. Three tests encoded the driver's rounding: clear_color and typeless_rtv expected UNORM floats to pass through; d3d12_typeless_families and d3d12_vulkan_device compared exactly with the host D3D12 on the same adapter. On NVIDIA they now accept the WARP value where the host and WARP disagree (0.6 ULP, D3D11.3 3.2.3.6). clear_color checks the measured cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e compared Each program fills one texture (19 families: typeless colour families viewed through their typed formats, packed 16-bit, R11G11B10, D16/D24S8/D32/D32S8 and their typeless forms; mips and arrays) with known bytes, then runs random ClearRenderTargetView, ClearDepthStencilView and ClearUnorderedAccessViewUint/Float through views of a mip and an array range, with 0-3 rects, and compares every byte of every plane of every subresource with WARP. --hardware compares with the GPU's D3D12, --reduce SEED shrinks a differing program, --seeds/--start choose them. The default leaves out two known differences (--all puts them back): the UINT patterns uav_clear.h documents as inexact, and on NVIDIA stencil clears with rects past mip 0 (the driver writes a stencil attachment view of mip > 0 into mip 0). A NaN from a float clear compares equal whatever its payload, and an sRGB colour may be one code off (D3D's tolerance). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 1. This PR should also fix 2. A D24S8 clear of mip 1, layer 1 changes the stencil byte of mip 0, layer 0 on Intel. It looks like the stencil-aspect cousin of #5489, on a different driver. AI-assisted (Claude Code). |
…product Two problems the clear fuzzer found after the rebase on main 561b65a: - AMD's Vulkan driver can store to R5G6B5, A1R5G5B5 and A4R4G4B4, so the layer reports typed UAV stores for B5G6R5, B5G5R5A1 and B4G4R4A4 there, but uav_clear.h had no layout for them: a ClearUnorderedAccessView* on one made ExecuteCommandLists refuse the whole list, its other work included (found by @Jadiac5 on an RX 9070 XT). The three layouts are added. - quantize_unorm/quantize_snorm (ItsNotRexed#589) multiplied in double. D3D multiplies in float: a D16 depth of 0.681063533 is 44633.5 in float, a tie that WARP writes as the even 44634, but 44633.4999... in double, which rounds to 44633 (on main, 70 of 2,000 fuzzer seeds, all D16 and 16-bit UNORM). The exact double product is now rounded to the nearest float first (nearest_float, ties to even, by nextafter so the thread's FP rounding mode doesn't matter), then to the code. uav_clear::encode does the same. The sRGB colour channels stay on the GPU's curve, as main decided (ItsNotRexed#589); this branch no longer quantises them. clear_color_test checks the packed layouts and the D16 tie under all four rounding modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f13305d to
45e81b2
Compare
|
@Jadiac5 thank you. The diagnosis was right, and the bug is real beyond the test: with no layout, one UAV clear on those formats made
RTX 5060 Ti / 621.14:
I can't run AMD here. Could you re-run the fuzzer on the 9070 XT? AI-assisted (Claude Code). |
|
Independent Windows check of 45e81b28 on 561b65a8. Windows 11 x64, RTX 3080 Ti / 621.35, MSVC 19.44.35230, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, RelWithDebInfo. All five stock CTests passed. The 40 default A logging-only fixture run confirmed packed RTV coverage for B5G6R5 and B5G5R5A1. The format intersection exposed no packed UAV path on this setup, so the new packed UAV encodings were covered by the CPU checks. Synthetic inputs only. AI-assisted. |
Hiiva
left a comment
There was a problem hiding this comment.
Follow-up Radeon verification of 45e81b282132788c5a9de4524df89678479e5926 on main 561b65a8. Windows 11 x64 build 26200, MSVC 19.44, Vulkan SDK 1.4.363.0, AMD Radeon(TM) Graphics driver 32.0.21043.5001, native WARP reference.
- Rebuilt your unchanged
d3d12_clear_fuzz_testand ran 1,000 seeds on Radeon: zero differences, zero refused cases. - An independent exact-byte probe replays all 83 packed-format seeds from my earlier review: all 241,598 readback bytes now match WARP. Its separate 42 deterministic whole/rectangle programs match all 13,440 literal bytes on both WARP and replay, including Uint high-bit masking, clamp/NaN/infinities, and alpha at/above 0.5. These comparisons bypass the fuzzer's tolerance comparator.
- CPU
clear_color_test: 535 checks pass;typeless_rtv_test: 100 pass. The stock UAV clear fixture plus the additional packed mip/array/rectangle coverage also passes. - All GPU runs used Khronos validation and synchronization validation, with no VUID or synchronization-hazard messages.
The test tree is the restacked #5616 child, whose only delta from your exact head is 39 test lines and four documentation lines. Production source and your fuzzer source are byte-identical to your head. I removed the child's duplicate layout rows now that this PR supplies them; #5616 retains the additional boundary and GPU regression coverage. This confirms the previously reported packed-format failures are resolved on this Radeon device. No game files. AI-assisted: yes.
|
Tested 45e81b2 on
New:
The 22 seeds are exactly the ones where
Overall the PR brings the layer much closer to AMD (101 to 22). For those tie cases, though, WARP and the Xbox's own GPU vendor disagree, and the PR picks WARP. It may be worth a line in the |
Hiiva
left a comment
There was a problem hiding this comment.
Additional reference-policy evidence for exact head 45e81b282132788c5a9de4524df89678479e5926, compared with unchanged main 561b65a8.
WARP's normalized color clears change with the submission thread's FP rounding mode on this machine. Native AMD D3D12, main, and this head remain mode independent for the measured inputs. The parent changes one 16-bit tie to match default-mode WARP; that tie differs from this AMD driver's result.
| Identical 42 phase cases | Main | This head |
|---|---|---|
| Cases differing from WARP | 24 | 16 |
| Cases differing from native AMD D3D12 | 0 | 14 |
These are differing-case counts, with zero setup errors, skipped formats, or FP-state errors. Both native backends return byte-identical results between the main/head runs.
The six fixed programs use one whole-view ClearRenderTargetView or ClearUnorderedAccessViewFloat on an 8x8 texture:
R8G8B8A8_UNORM: input words3f000000, 3e800000, 3effffff, 3f000001.R16G16B16A16_UNORM:3f000000, 3f2e5a2e, 3effffff, 3f000001.R8G8B8A8_SNORM:bf000000, 3f000000, be800000, 3e800000.
Each runs with default rounding, three recording-only mode changes, and three submission-only mode changes. Recording-only changes leave all results unchanged. For example, both APIs give these literal RGBA8 UNORM bytes for the first vector:
| Submission mode | WARP | Native AMD | Main / this head |
|---|---|---|---|
| Nearest | 80 40 7f 80 |
80 40 7f 80 |
80 40 7f 80 |
| Upward | 80 40 80 80 |
80 40 7f 80 |
80 40 7f 80 |
| Downward / toward zero | 7f 3f 7f 7f |
80 40 7f 80 |
80 40 7f 80 |
The only main-to-head output change is the UNORM16 component with input 0x3f2e5a2e (0.6810635328292847). Its exact product with 65535 is 44633.49862396717; the nearest float product is 44633.5. Main and native AMD return 44633 in every phase. This head returns 44634 in every phase. WARP returns 44634 under nearest/upward submission and 44633 under downward/toward-zero submission. This accounts for all 14 newly differing AMD comparisons. No internal AMD conversion algorithm is inferred from its output.
The probe retains the stock fixture's resource setup, barriers, initialization, and readback. Visible adaptations only scope FP modes around the clear-recording call and ExecuteCommandLists. It compares every defined byte directly, without the fuzzer's tolerance comparator. Default WARP bytes have literal checks, and all 28,672 native readback bytes match across the two production builds.
Native AMD selection uses the Vulkan device's valid LUID, 2726010000000000, and verifies that ID3D12Device::GetAdapterLuid() matches exactly. Device: AMD Radeon(TM) Graphics, PCI 1002:164e, driver 32.0.21043.5001. MSVC 19.44.35228, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, native D3D12 runtime 10.0.26100.8521. Each API call retains the requested rounding mode. The harness restores its saved full environment; final rounding mode and MXCSR equal their initial values. Khronos core and synchronization validation report zero VUID or synchronization-hazard messages.
This is bounded evidence about the reference policy, with no new implementation-defect claim. The head library comes from the test-only #5616 child; production and stock fixture source are byte-identical to this exact head. The main control uses a clean 561b65a8 library and the identical probe. No production or game files were changed. AI-assisted.
|
@Hiiva thank you, that measurement changes the picture for 16-bit ties. At |
|
Tested 45e81b2 on NVIDIA RTX 4070 SUPER (driver 616.92), Windows 11 26200, MSVC 14.44, Vulkan SDK 1.4.363, RelWithDebInfo: pass, no regression against main 561b65a.
|
|
Independent Intel run of exact head
No claim that this PR introduced these differences; no baseline tested. Synthetic inputs only, no game files. AI-assisted (Codex). |
|
Follow-up baseline control for my Intel result above: same Windows 11 / RaptorLake-S Mobile iGPU / driver 32.0.101.7085 and Against WARP, 1,000 default seeds: control 43 differ, PR head 18 differ. Comparing seed numbers: 25 control differences disappear and none are new in the PR run. The remaining 18 include 21 and 997. This is a controlled comparison of the three changed production files, not a diagnosis of the remaining differences; the fuzzer comparator’s documented tolerances apply. Synthetic inputs only; no game files. AI-assisted (Codex). |
|
Tested head NVIDIA GeForce RTX 5060 Laptop GPU, 621.24: pass. Intel UHD Graphics (Raptor Lake mobile, Xe-LP), 101.7088: 7/9.
I've opened #9353 for that (D3D-993). It picks the sRGB code on the CPU and hands the driver the linear value a quarter of a code above the code's start, so a rounding and a truncating encoder agree; 251/251 on both GPUs here. It changes AI-assisted (Claude Code). |
Claimed in the coordination issue: #5256 (comment)
What and why
A seeded differential fuzzer for the shaderless clears, built on the same harness as #5272 (WARP is the reference,
--hardware,--reduce SEED). It found that the layer hands the application's clear float to the Vulkan driver and lets the driver convert it. NVIDIA's driver converts differently from D3D12, WARP and AMD, and AMD is the Xbox's own hardware. This PR has two commits: the fix, then the fuzzer.1.
d3d12: clear values convert as D3D12 does (WARP). Each case below was reduced by the fuzzer to one clear (RTX 5060 Ti, 621.14):main>>2)ClearUnorderedAccessViewFloatR8_UNORM 0.5/255lroundin double)The layer now computes D3D12's code itself: a float multiply, then round to nearest, ties to even.
depth24_quantizealready does this for D24, with the same reasoning in its comment. The layer then hands the driver the nearest float tocode / max, which any rounding rule turns back into that code. This coversrender_target_clear_color(UNORM, SNORM, 4/5/6-bit packed, sRGB colour and linear alpha, float denormals), a newdepth_clear_value(D16, denormals) anduav_clear::encode.Four existing tests encoded the driver's rounding, and I adapted them:
clear_colorandtypeless_rtvexpected UNORM floats to reach the driver unchanged. They now expect the code's float, andclear_coloradds the measured cases above.d3d12_typeless_familiescompares with the host D3D12 on the same adapter. Its log already said "WARP differs from the host in 14". On this branch the layer gives WARP's bytes in all 14, and NVIDIA's host gives 0x7f where WARP gives 0x80. Where the host and WARP disagree it now accepts either.d3d12_vulkan_device's placed-clear check applied its 0.6 ULP tolerance (D3D11.3 3.2.3.6 and 3.2.3.8) only against another adapter. The layer no longer copies its own driver's rounding, so the tolerance now applies on the same adapter too. Its comment already names the tie: "WARP and AMD give the upper code, NVIDIA's D3D12 driver and its Vulkan driver the lower".2.
d3d12_clear_fuzz_test(ctestd3d12_clear_fuzz, 40 seeds by default):ClearRenderTargetView,ClearDepthStencilViewandClearUnorderedAccessViewUint/Floatcalls, through views of one mip and an array range, with 0-3 rects.--verboselists them.The default run leaves out two known differences, and
--allputs them back:ClearUnorderedAccessViewUintpatterns thatuav_clear.halready documents as inexact (SNORM 0x80.., float NaN bits);vkCmdClearAttachmentsandloadOp = CLEARalike, with no validation message.Results (RTX 5060 Ti / 621.14, Windows 11 26300, MSVC 14.51, Vulkan SDK 1.4.363.0)
main3faac557(fuzzer only)LEONIDA_VK_VALIDATION=1Before the fixes and the comparator rules, 91 of the first 300 seeds differed. Full
LEONIDA_VK_VALIDATION=1 ctest -j4with-DLEONIDA_LLVM_MC: 168/168 pass.Not covered
d3d12_clear_fuzz_test --seeds 1000(and--all) there would be welcome.No game files. AI-assisted (Claude Code, Claude Opus 5.5).