Repository navigation
Runtime: clears match WARP on every format class: tie rounding, and the SNORM/SINT/R8/R16 formats (D3D-45) - #521
Conversation
|
Tested
All 18 comparisons matched with MSVC The Vulkan side used the PR's replay callbacks to capture |
|
Tested 175b0ff on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200: pass, also merged onto current main (91b36cf, clean merge).
For comparison, #525's d3d12_clear_test fails on this GPU at the RGBA8_UNORM 0.5 tie (NVIDIA 0x7f, WARP 0x80), which this PR's tie rounding covers. |
|
Ran
The 10 differences are all sRGB, and they are exactly the So on Intel, leaving the sRGB curve to the GPU does not reproduce WARP byte-for-byte — the same 1-ulp |
|
Independent AMD validation of exact PR head PR head: full runtime build succeeded; CTest 19/19 passed. All four differences are the depth plane of
Baseline control: I built the same comparison fixture against the PR's base Integration note now that #388 has merged: I separately combined this head with #388 head However, the combined CPU CTest initially fails
Changing only those test expectations in the isolated combination gives CTest 24/24. That adjustment is local validation only, not pushed to either branch. Please include it when updating #521 onto the main containing #388. This is an integration-test expectation change, not evidence of a typeless GPU regression. The D24 fallback remains a separate inherited issue; I would not describe this AMD run as a full 178/178 pass. |
175b0ff to
f53f7de
Compare
|
Rebased after #525 merged: the branch is now one commit on main, f53f7de. It keeps only what #525 doesn't cover: round-half-to-even for UNORM/SNORM, the remaining format classes, sRGB alpha, D16, and the 178-case |
…D-45) Rebased onto main after ItsNotRexed#525, which added SNORM/SINT render targets for four formats. This keeps ItsNotRexed#525's formats and adds what it leaves out: - Normalised clears round to nearest even like D3D, so 0.5 on an 8-bit channel is 128 (NVIDIA's clears write 127). The layer hands Vulkan the exact fraction; NaN is 0 and out-of-range values clamp. Covers UNORM, SNORM (scale 127 or 32767, -1.0 is -127), the alpha of the sRGB formats, R10G10B10A2_UNORM and D16_UNORM depth. - More formats: R8/R8G8/R16/R16G16/R16G16B16A16 SNORM, R8/R16 SINT, R8/R16 UINT, R16_UNORM and R16G16_UNORM, with their copy sizes; SINT and UINT of every width clamp to the component range and truncate toward zero. - d3d12_clear_formats_test: 178 cases against WARP over UNORM, SNORM, sRGB, FLOAT, UINT, SINT and the four depth formats. typeless_rtv_test now expects the rounded UNORM value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f53f7de to
a7b9ea1
Compare
|
Rebased again, onto main c432cdc (after #600), as a7b9ea1. The only conflict was |
|
I tested a7b9ea1 on an AMD Radeon 880M (AMD driver 26.11.2) and an NVIDIA RTX 5070 Laptop (617.42), Windows 11, MSVC 17.14: pass, with one finding for D24S8 on AMD.
Why this matters. On plain The 4 AMD differences are all D24_UNORM_S8_UINT depth cases, for example A note on ties. The spec rounds ties up, while this PR rounds half to even. They agree on every value 8-bit and 10-bit UNORM can produce, because 0.5 is the only tie there. AI-assisted (Claude Code). |
|
Replying to @AlxcBTW. There’s a baseline control for the D24 finding. On the RX 5700 XT, @73N1X ran the same comparison fixture on both AI-assisted. |
|
Tested a7b9ea1 merged onto main c432cdc on NVIDIA GeForce RTX 4060 Ti (Ada), driver 32.0.16.2124 (NVIDIA 621.24), Windows 11 Home 26300, MSVC 2022 / Ninja, Vulkan SDK 1.4.363: pass, and it fixes an existing failure on this card.
AI-assisted. |
|
Tested a7b9ea1 on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass
No game files used. AI-assisted run (Claude Code). |
|
Tested c0a92eb on NVIDIA GeForce RTX 4060 Ti (Ada), driver 621.01, Windows 11 (MSVC 14.52, Visual Studio 2026): pass.
AI-assisted (Claude). |
Kam471
left a comment
There was a problem hiding this comment.
Verified c0a92ebc on Windows 11, RTX 5070 Ti (NVIDIA 621.24), matching the case #521 exists to fix:
d3d12_clear_test.exe(default mode) -> exit 0: RTV and DSV clears: 197 full/rectangle readbacks matched WARP, and 648 RGBA 3D-RTV texels match WARP/expected slices. This is the test that failed on main with the five 0x7f/0x80 and depth-55 differences.d3d12_clear_formats_test.exe-> exit 0: 178 matched WARP, 0 differ, 0 failed, covering UNORM/SNORM/SRGB/FLOAT/UINT/SINT and the depth/stencil planes; 0 formats unexposed and 0 skipped by WARP.ctest -R 'd3d12_clear'-> 2/2 passed (0.32 s / 0.29 s).
This also unblocks #4294's ctest registration. No blocking issue.
Flyander
left a comment
There was a problem hiding this comment.
Review of the current clear-rounding implementation.
| // changes the mode would round differently. floor() does not depend on it, and x + 0.5 is exact here (x is at most | ||
| // a float times 65535, well inside a double's 53 bits). | ||
| inline double round_half_even(double x) { | ||
| const double r = std::floor(x + 0.5); |
There was a problem hiding this comment.
[P2] Avoid the mode-sensitive addition for tiny positive values
x can be much smaller than one double ULP at 0.5 (for example, float denorm_min multiplied by 255). Under FE_UPWARD, x + 0.5 rounds to the next double above 0.5, so floor returns 1 and the clear becomes 1/255 instead of 0. This contradicts the comment that the sum is exact and breaks the intended rounding-mode independence for near-zero inputs. Please handle this range without adding the tiny value to 0.5, and include a near-zero case in the rounding-mode coverage.
There was a problem hiding this comment.
Thanks for catching the assumption about x + 0.5. I ran the three clear helpers verbatim from c0a92ebc with native MSVC /fp:strict and all four fesetround modes.
For float denorm_min() scaled by 255, FE_UPWARD moves the sum to nextafter(0.5, 1.0). That is still below 1, so floor returns 0. R8 UNORM with the positive input and R8 SNORM with both signs returned zero in all four modes.
I also checked 598,284 scaled inputs per mode at the half-integer thresholds and neighboring float values across the supported scales 3, 127, 255, 1023, 32767 and 65535. All selected the expected integer. A near-zero regression case would cover the distinction: the addition can round while staying in the same interval for floor.
AI-assisted.
|
Tested c0a92eb (merged onto main 64b45d0) on RTX 3060 (Ampere, subgroup 32..32), driver 617.14, Windows 11: Ran: ctest, ctest with LEONIDA_VK_VALIDATION=1, the unregistered *_test.exe, and run_gpu_tests.py native and with LEONIDA_W64_EMULATE=1, each compared with main 64b45d0 on the same machine.
My reading, not checked beyond this output: the test counts a clear as a failure when the layer differs from the host adapter's own D3D12 result ( Nothing else new: no other ctest or GPU-test failure compared with main. AI-assisted: the build and test run were done with Claude Code on my machine; the numbers above are its unedited output. |
|
Independent A/B on a GTX 1650 Mobile (Turing), NVIDIA 621.24, Windows 11. Built
All 8 typeless draws match the native adapter in both builds; no typeless view formats were skipped. WARP differs from native D3D12 in 14/82 typeless clears in both builds. Example: This reproduces the RTX 3060 report on Turing: the test fails because it checks the native-adapter result, even when the layer now matches WARP in those cases. AI-assisted build and test run; synthetic fixtures only. |
|
Tested c0a92eb merged onto main ec34b54 on an RTX 4060 Ti (Ada), driver 621.01, Windows 11 build 26300, VS 2026 / MSVC 14.52.37025: the same result as the RTX 3060 and GTX 1650 reports above.
|
|
Tested c0a92eb on Intel UHD 770 (driver 32.0.101.7088), Windows 11, MSVC 19.44, Vulkan SDK 1.4.357.0: fail in d3d12_clear_formats_test, all on the two sRGB colour formats. d3d12_clear_formats_test exits 1 with and without LEONIDA_VK_VALIDATION=1: "clears: 168 matched WARP, 10 differ, 0 failed, 0 in formats the layer does not expose, 0 skipped". Every difference is one step off WARP in an sRGB colour byte:
With validation on, clear_color_test (505 replay checks passed), d3d12_com_test, d3d12_vulkan_device_test, d3d12_descriptor_test, device_proxy_test and d3d12_typeless_rtv_test pass. ctest -R over the clear, COM, device, descriptor and replay tests: 92% tests passed, 1 tests failed out of 13 (d3d12_clear_formats). The PR body also names d3d12_uint_clear_test, which is not a target at this head. AI-assisted. |
|
@kingzzim7-create Thanks for the Ada comparison. The test-only update is open at NWX10/Leonida#2, head That update checks that the layer matches WARP byte for byte and the same-adapter normalized components are within one code. The Ada rerun you offered can use AI-assisted. |
|
@Hanioe2 re-ran with efde95c (NWX10#2) merged onto main 3faac55, RTX 4060 Ti (Ada), driver 621.01, Windows 11, MSVC 14.52: all pass.
|
|
Tested
The five on main on the RTX 3070: The last one is the D16 in more detail. A separate probe (not in the repository) clears 7934 depth values into
Not checked: AI-assisted. |
#525 (D3D-45) renamed the test and widened it, but this paragraph kept the old name and its "seven input sets on all three formats". It now names the test, its eleven integer input sets on the UINT/SINT formats, and that ctest runs only its --rgb9e5 mode until #521 lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tsNotRexed#521), three close-parity copies now match WARP, the source-size checks start from 300x200 again after ResizeTarget, one test_attribute_trace in xmem_test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Flyander, thanks for the review. I checked the near-zero case. You were right that the comment overstated it: |
Claimed in #374 as: D3D-45
What and why
D3D-45 asks for the clears to be compared with the host runtime across the format classes. This adds
d3d12_clear_formats_test(run explicitly, liked3d12_uint_clear_test, which it extends) and fixes what it found. It clears, copies the result into a readback buffer through D3D12 and compares the bytes with WARP's: 178 cases over UNORM, SNORM, SRGB, FLOAT, UINT and SINT render targets and the four depth formats (depth and stencil planes), each with a full clear and a rectangle clear.On main (4abd545) the test found two things, one commit each:
vkCmdClearColorImageand clear attachments write 127. The same step showed onR10G10B10A2_UNORM(0.5 -> 512),R16G16B16A16_UNORM, the alpha of the sRGB formats andD16_UNORMdepth. The layer now rounds the value itself and hands Vulkan the exact fraction, so no GPU can round it differently (NaN is 0, values outside 0..1 clamp, as in D3D). The sRGB colour channels stay with the GPU's curve.SNORM(6 formats),SINT(5),R8_UINT,R16_UINT,R16_UNORMandR16G16_UNORMgave "texture format not supported yet". They are mapped now, with their copy sizes, and clear like D3D: SINT clamps to the component range and truncates toward zero, SNORM rounds to nearest even on a scale of 127 or 32767 with -1.0 as -127.The conversions were measured against WARP, not taken from the documentation.
Tested
d3d12_clear_formats_test: 178 cases match WARP, with and withoutLEONIDA_VK_VALIDATION=1, no validation errors. Before the commits: 29 differ and 73 are not exposed (the test lists such formats as "not exposed" instead of failing, so it stays usable on a layer that lacks a format).ctest: 19/19.clear_color_test(CPU only) now also checks the rounded UNORM/SNORM values and the SINT and small UINT conversions (110 checks); withvulkan_replay.hfrom main its new checks fail (normalised clear: format 37 ... got 0.5, expected 0.501960814).d3d12_com_test,d3d12_vulkan_device_test,d3d12_descriptor_test,d3d12_uint_clear_test,vk_command_replay_testanddevice_proxy_test: exit 0 with and without validation.runtime/CMakeLists.txtandruntime/src/vulkan_replay.hnear the clear code; they merge with this one apart from adjacent lines, so whichever lands second needs a rebase.AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code