Skip to content

Runtime: clears match WARP on every format class: tie rounding, and the SNORM/SINT/R8/R16 formats (D3D-45) - #521

Open
NWX10 wants to merge 8 commits into
ItsNotRexed:mainfrom
NWX10:d3d-45-clear-comparison
Open

NWX10 wants to merge 8 commits into
ItsNotRexed:mainfrom
NWX10:d3d-45-clear-comparison

Conversation

@NWX10

@NWX10 NWX10 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

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, like d3d12_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:

  • Rounding at exact ties (29 of the 105 cases that could run). D3D rounds a float clear value to nearest even, so 0.5 on an 8-bit channel is 128. NVIDIA's vkCmdClearColorImage and clear attachments write 127. The same step showed on R10G10B10A2_UNORM (0.5 -> 512), R16G16B16A16_UNORM, the alpha of the sRGB formats and D16_UNORM depth. 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.
  • Formats the layer refused (73 cases, 15 formats). SNORM (6 formats), SINT (5), R8_UINT, R16_UINT, R16_UNORM and R16G16_UNORM gave "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

  • RTX 3060 Ti (Ampere), NVIDIA 621.24, Windows 11 Pro 10.0.26300, MSVC 14.44, Vulkan SDK 1.4.363.1, with WARP as the reference.
  • d3d12_clear_formats_test: 178 cases match WARP, with and without LEONIDA_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); with vulkan_replay.h from 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_test and device_proxy_test: exit 0 with and without validation.
  • Not tested: AMD and Intel GPUs. The tie behaviour is NVIDIA's; rounding in the layer makes the written value independent of the GPU.
  • Overlap: Runtime: preserve explicit RGBA8 typeless RTV formats for clears (D3D-41) #388 (D3D-41) and runtime: ClearUnorderedAccessViewUint/Float on the Vulkan device (D3D-25) #391 (D3D-25) also edit runtime/CMakeLists.txt and runtime/src/vulkan_replay.h near the clear code; they merge with this one apart from adjacent lines, so whichever lands second needs a rebase.

AI-assisted (Claude Code).

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)

🤖 Generated with Claude Code

@VictorJulianiR

Copy link
Copy Markdown
Contributor

Tested 175b0ff on GitHub-hosted Windows Server 2022 using native D3D12 WARP readback as the reference. For R8_UNORM, I compared the full-clear and rectangle-clear values submitted by Leonida's production replay with the actual WARP bytes under three caller rounding modes.

Caller rounding mode Inputs 0.25, 0.125, 0.75 on both paths
Nearest 64, 32, 191
Downward 63, 31, 191
Upward 64, 32, 192

All 18 comparisons matched with MSVC /fp:precise, and all 18 matched with /fp:strict. I checked every pixel in each 5×3 WARP readback, including both sides of the clear rectangle. WARP itself followed the caller's rounding mode for these inputs, which is worth retaining if the conversion changes again.

The Vulkan side used the PR's replay callbacks to capture VkClearColorValue. The native readback used Microsoft's software adapter, vendor 0x1414, device 0x008c. AI-assisted, no physical GPU or game files. Hosted comparison

@kacper-serewis

Copy link
Copy Markdown
Contributor

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).

  • PR head: ctest 19/19; merged: ctest 23/23
  • d3d12_clear_formats_test (both): "178 matched WARP, 0 differ, 0 failed, 0 in formats the layer does not expose, 0 skipped"
  • clear_color_test (merged): 110 replay checks passed

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.

@luisbaker

Copy link
Copy Markdown
Contributor

Ran d3d12_clear_formats_test (from this PR) on the Intel GPU, as requested.

  • GPU: Intel(R) Graphics, driver 32.0.101.6737
  • Result: clears: 168 matched WARP, 10 differ, 0 failed, 0 in formats the layer does not expose, 0 skipped (WARP does not offer the format)

The 10 differences are all sRGB, and they are exactly the .5 boundary rounding you expected — the Intel GPU's linear→sRGB encode is 1 ulp off from WARP:

DIFF SRGB   R8G8B8A8_UNORM_SRGB    case 0 colour byte 2: layer bb, WARP bc
DIFF SRGB   R8G8B8A8_UNORM_SRGB    case 1 colour byte 26: layer bb, WARP bc
DIFF SRGB   R8G8B8A8_UNORM_SRGB    case 2 colour byte 2: layer bb, WARP bc
DIFF SRGB   R8G8B8A8_UNORM_SRGB    case 3 colour byte 0: layer 0c, WARP 0d
DIFF SRGB   R8G8B8A8_UNORM_SRGB    case 4 colour byte 26: layer bb, WARP bc
DIFF SRGB   B8G8R8A8_UNORM_SRGB    case 0 colour byte 0: layer bb, WARP bc
DIFF SRGB   B8G8R8A8_UNORM_SRGB    case 1 colour byte 24: layer bb, WARP bc
DIFF SRGB   B8G8R8A8_UNORM_SRGB    case 2 colour byte 0: layer bb, WARP bc
DIFF SRGB   B8G8R8A8_UNORM_SRGB    case 3 colour byte 0: layer fe, WARP ff
DIFF SRGB   B8G8R8A8_UNORM_SRGB    case 4 colour byte 24: layer bb, WARP bc

So on Intel, leaving the sRGB curve to the GPU does not reproduce WARP byte-for-byte — the same 1-ulp .5-boundary difference that #525 omits sRGB to avoid. Everything else (UNORM, SNORM, FLOAT, UINT, SINT, and every depth/stencil plane) matches WARP. Identical result with LEONIDA_VK_VALIDATION=1 (no validation errors).

@73N1X

73N1X commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent AMD validation of exact PR head 175b0ff04ed7e208431b8643d4ea42e3fb400ca0 on a Radeon RX 5700 XT, Windows driver 32.0.21045.5002, MSVC 19.44, with native D3D12 WARP as the reference. Synthetic fixtures only; Vulkan validation and synchronization validation enabled.

PR head: full runtime build succeeded; CTest 19/19 passed. d3d12_clear_formats_test reported:

clears: 174 matched WARP, 4 differ, 0 failed, 0 in formats the layer does not expose, 0 skipped (WARP does not offer the format)

All four differences are the depth plane of D24_UNORM_S8_UINT (cases 0-3). The device reports D24_UNORM_S8_UINT unavailable, using D32_SFLOAT_S8_UINT. First differing bytes:

  • case 0: byte 2, layer 80, WARP 40
  • case 1: byte 0, layer 00, WARP ff
  • case 2: byte 0, layer 4c, WARP 26
  • case 3: byte 2, layer 00, WARP 80

Baseline control: I built the same comparison fixture against the PR's base 4abd54571b6efa02d97eda4711792fa00b455dc3, adding only the fixture and its CMake target. It reported 101 matches, the exact same four D24 differences, and 73 cases in formats not exposed. Thus these AMD D24 readback differences predate this PR; the 73 newly exposed cases pass here. All color cases, including sRGB, matched WARP on this AMD device. No Vulkan validation errors were reported. The UINT comparison (21 readbacks), COM test and GPU replay suites A-D also passed on the PR head.

Integration note now that #388 has merged: I separately combined this head with #388 head 58019e85ecefde734a4e39b26c72e0792248eff8 in an isolated worktree. Only CMake conflicted; retaining both test targets resolved it. The combined GPU tests passed 13 typeless WARP readbacks plus 12 invalid-view rejections, 21 UINT readbacks, and replay suites A-E including predication. The broad format comparison retained the same 174/4 result.

However, the combined CPU CTest initially fails typeless_rtv_test.cpp:94: it expects unchanged float inputs for UNORM/sRGB, whereas this PR intentionally clamps/quantizes normalized channels before Vulkan. For its existing {1.5f, 2.5f, 256, -1} input, the literal callback expectations should be:

  • explicit RGBA8 UNORM: {1, 1, 1, 0}
  • explicit RGBA8 sRGB: {1.5f, 2.5f, 256, 0} (RGB is still passed to the GPU; alpha is UNORM)
  • UINT remains {1, 2, 255, 0}; the legacy undefined-format pass-through assertion stays unchanged.

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.

@NWX10

NWX10 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

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 d3d12_clear_formats_test. typeless_rtv_test now expects the rounded value from render_target_clear_color instead of the raw float. Re-tested on the RTX 3060 Ti: ctest 24/24. d3d12_clear_formats_test (178), d3d12_typeless_rtv_test (13 readbacks) and d3d12_clear_test (59) all match WARP, with and without LEONIDA_VK_VALIDATION=1.

…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>
@NWX10

NWX10 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased again, onto main c432cdc (after #600), as a7b9ea1. The only conflict was block_format, where both sides added cases; I kept both. Re-tested on the RTX 3060 Ti: ctest 27/27, and d3d12_clear_formats_test (178), d3d12_typeless_rtv_test and d3d12_clear_test (59) all match WARP. The one red check, linux-gpu-tools, is the llvmpipe cs_w32_lane_wrap / cs_wqm_w32 failure that main has too; #555 fixes it.

@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

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.

Test Radeon 880M RTX 5070
d3d12_clear_test (with and without LEONIDA_VK_VALIDATION=1) 59 of 59 cases match WARP 59 of 59 match WARP
d3d12_clear_formats_test 174 match, 4 differ 178 of 178 match
clear_color_test (CPU) 110 checks pass 110 checks pass

Why this matters. On plain main the RTX 5070 fails d3d12_clear_test with format 28 case 0 byte 2: Vulkan 7f, WARP 80. That case is a 0.5 channel of R8G8B8A8_UNORM, and 0.5×255 = 127.5 is an exact tie. NVIDIA's vkCmdClearColorImage writes 127, while WARP and AMD write 128. D3D11.3 §3.2.3.6 defines FLOAT→UNORM as c·(2ⁿ−1)+0.5 truncated, which gives 128, with 0.6 ULP of tolerance. So NVIDIA's 127 is within tolerance but not what an AMD-targeted title gets. This PR fixes it.

The 4 AMD differences are all D24_UNORM_S8_UINT depth cases, for example case 2 depth byte 0: layer 4c, WARP 26. The 880M has no native D24, so the layer substitutes D32S8, and the depth clear value is probably converted for D24 but read back from a D32 image, or the reverse. That looks separate from this PR. I'll post it as a finding: in #374 unless you'd rather take it here.

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).

@tylerstraub

Copy link
Copy Markdown
Contributor

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 175b0ff and its base 4abd545. All four D24 depth cases differed on both, including your case 2 byte 0 (4c versus WARP’s 26). That device also reported the D32S8 fallback. The matching signature on the 880M at a7b9ea1 supports tracking this separately from the color-clear change. The exact point where the depth bytes diverge remains open. If you file the finding, the active tracker is #634. RX 5700 XT baseline and per-case bytes

AI-assisted.

@troythedecoyx

Copy link
Copy Markdown
Contributor

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.

  • d3d12_clear_formats_test: exit 0, 178 matched WARP, 0 differ, 0 failed.
  • d3d12_uint_clear_test: exit 0, 21 readbacks matched WARP on three formats.
  • d3d12_clear_test: exit 0, 59 RTV/DSV readbacks matched WARP. On main c432cdc without this PR it exits 1 at format 28 case 0 byte 2: Vulkan 7f, WARP 80, the exact-tie rounding this PR describes (I hit it while checking Runtime: clear selected slices of 3D color targets (D3D-64) #643, which fails the same way for that reason).
  • ctest 27/27.

AI-assisted.

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested a7b9ea1 on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass

  • Clean RelWithDebInfo Ninja build of runtime/ (Vulkan SDK 1.4.363.0), then ctest --test-dir runtime/build --output-on-failure: 27/27 passed.
  • GPU tests with LEONIDA_VK_VALIDATION=1 and VK_LAYER_KHRONOS_validation: d3d12_clear_formats_test, d3d12_clear_test, d3d12_com_test, d3d12_descriptor_test, d3d12_method_variants_test, d3d12_sampler2_test, d3d12_typeless_rtv_test, d3d12_vulkan_device_test, vk_command_replay_test all exit 0, with 0 validation messages.

d3d12_clear_formats_test and d3d12_clear_test pass. On current main, d3d12_clear_test (from #525) fails on this GPU with format 28 case 0 byte 2: Vulkan 7f, WARP 80, NVIDIA's tie rounding, and every other branch based on current main I tested today fails it the same way. This PR fixes that.

No game files used. AI-assisted run (Claude Code).

NWX10 and others added 2 commits November 23, 2026 01:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NWX10

NWX10 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Updated to c0a92eb: main (aa2988c) merged in, clean.

I couldn't build locally (no C++ toolchain on this machine), so CI will be the first build of this merge.

AI-assisted (Claude Code).

@sds-228

sds-228 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent RTX 3090 verification of c0a92eb (validation on): targeted clears pass — 197 WARP readbacks, 178/178 format cases, 505 replay checks. The device test passes with 16 one-code plain-clear ties accepted; removing that acceptance fails with 16 ours 80, host 7f bytes. Unpatched full CTest: 154 passed, 1 failed, 7 skipped, 1 disabled, 0 validation errors. Sole failure: d3d12_typeless_families, 14 nearest-even tie mismatches on the same-adapter path; it passes on main. Adding a narrow WARP-agrees, one-code acceptance to that test gives 82 clears/0 differ/14 ties accepted and full CTest 155 passed, 0 failed, 7 skipped, 1 disabled. Please include that test update before merge.

AI-assisted (OpenCode)

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested c0a92eb on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1), MSVC RelWithDebInfo build of this head (it already contains main aa2988c), VK_LOADER_LAYERS_DISABLE=~implicit~, no validation layer installed. The Radeon was forced with VK_LOADER_DRIVERS_SELECT=*amd* plus LEONIDA_VK_DEVICE=radeon, and the 5080 with LEONIDA_VK_DEVICE=5080; the device line was confirmed per run. ctest -R "^(d3d12_clear|d3d12_clear_formats|clear_color|d3d12_uav_clear|d3d12_short_uav_clear|replay_clear_gate)$" — pass on both, 6/6 each.

  • d3d12_clear_formats on both: clears: 178 matched WARP, 0 differ, 0 failed, 0 in formats the layer does not expose, 0 skipped.
  • d3d12_clear on both: RTV and DSV clears: 197 full/rectangle readbacks matched WARP, 3D RTVs: 648 RGBA texels match WARP.
  • On current main the RTX 5080 fails d3d12_clear on R8G8B8A8_UNORM/SNORM, B8G8R8A8_UNORM and B8G8R8X8_UNORM (0x7f vs 0x80) while the Radeon passes. With this head both GPUs pass. I did not rerun main myself in this session.
  • d3d12_rgb9e5_rtv: passed on the Radeon, skipped on the 5080.

AI-assisted.

@Hanioe2

Hanioe2 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

TEST-919 comparison on RTX 5070, NVIDIA 610.88, Vulkan 1.4.341, Windows 11 build 26200, MSVC 19.44.35227, SDK 10.0.26100.0, RelWithDebInfo.

Test main aa2988cc #521 c0a92ebc
Default d3d12_clear_test Exit 1, five WARP differences Exit 0, 197 RTV/DSV readbacks and 648 3D RTV texels match WARP
d3d12_clear_formats_test Added by this PR Exit 0, all 178 cases match WARP
d3d12_typeless_families_test (clear cases) Exit 0, 0 of 82 differ from the same-adapter D3D12 host Exit 1, 14 of 82 differ from the same-adapter host

The five baseline default-clear differences are the reported four color formats and depth format 55 (ff vs 00). The PR head already registers the default executable as d3d12_clear with SKIP_RETURN_CODE 77. The restored CTest and d3d12_clear_formats both pass.

For all 14 typeless mismatches the layer bytes match WARP. This independently confirms the same-adapter tie issue reported on the RTX 3090 above.

Synthetic fixtures only. AI-assisted.

@marquezinii

Copy link
Copy Markdown
Contributor

@NWX10, @sds-228's requested test update is up as NWX10#2, a fast-forward of c0a92eb that touches only d3d12_typeless_families_test.cpp. Thanks @sds-228 and @Hanioe2 for catching it. A same-adapter difference is accepted only when the layer matches WARP byte for byte and every normalised component is within one code of the host. On an RTX 5070 that gives 82 clears, 0 differ, 14 ties (the 0.5 clears in the UNORM/SNORM views), 8 draws matching, and full ctest 147/147 with validation.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

TEST-919 check of this PR (head c0a92eb, main aa2988c merged in), run on an RTX 5080 (Linux, driver 580.65.06), runtime cross-built with clang-cl and run under Wine 11 on Xvfb. No code changed, nothing else posted.

1. This PR already registers the test. runtime/CMakeLists.txt on this head has add_test(NAME d3d12_clear COMMAND d3d12_clear_test) with SKIP_RETURN_CODE 77 in place of the "Not in ctest yet" comment that 3fc0b21 left, and it adds d3d12_clear_formats the same way. A separate TEST-919 change that restores those two lines would repeat what this PR does, so I am not opening one. TEST-919 can close when this merges.

2. The default mode could not be run to a result on this setup. Neither d3d12_clear_test (no argument) nor d3d12_clear_formats_test reaches a single clear case: both print WARP reference unavailable: differential test cannot run and exit 1. Wine's vkd3d has no WARP adapter (EnumWarpAdapter fails), so the 0.5 tie cases (0x7f against 0x80) were not compared with WARP. The 5080 result for the clear cases is therefore still open and needs Windows with WARP.

3. A problem for Linux and Wine users once this merges. Both tests exit 1, not 77, when WARP is missing. With SKIP_RETURN_CODE 77 that is a ctest failure, so ctest -R "d3d12|dxgi" under Wine gets two new red tests. Other host-comparison tests already skip under Wine through hostwine::host_is_wine() (runtime/test/host_wine.h). Suggested change: in both tests, where the WARP device cannot be made, return 77 under Wine and keep returning 1 on Windows, where WARP must exist. It needs a test that fakes the missing adapter: run the test with the WARP adapter missing and check the exit code is 77 under Wine and 1 on Windows. I have not written it; happy to send it as a commit on top of this branch if you want.

4. What does run on the 5080 with this head (ctest -R "clear|typeless_rtv|rgb9e5", 10 tests): 5 pass (d3d12_uav_clear, typeless_rtv, clear_color, replay_clear_gate, replay_uav_clear_offset), 3 skip under Wine's host (d3d12_short_uav_clear, d3d12_rgb9e5_rtv, d3d12_typeless_rtv), 2 fail only on the missing WARP above (d3d12_clear, d3d12_clear_formats). clear_color is the CPU-oracle test #521 extends, and it passes on NVIDIA.

AI-assisted. No game files.

@sh1shu1

sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown

Tested c0a92eb on NVIDIA RTX 4070 SUPER (driver 616.92), Windows 11 26200, MSVC 14.44, Vulkan SDK 1.4.363, RelWithDebInfo, LEONIDA_VK_VALIDATION=1: d3d12_clear_test default mode pass, 2 of 2 runs (197 RTV/DSV readbacks and 648 3D-RTV texels match WARP).
Same binary from main aa2988c: exit 1 both runs, the 5 known differences (R8G8B8A8_UNORM, R8G8B8A8_SNORM, B8G8R8A8_UNORM, B8G8R8X8_UNORM 0x7f vs 0x80 / 0x3f vs 0x40; depth format 55 case 1 byte 12 ff vs 00). That is the TEST-919 evidence for re-registering the default mode.
AI-assisted (Claude Code, Claude Fable 5.1).

@erickbobd

Copy link
Copy Markdown
Contributor

Tested c0a92ebc on RTX 5070 Ti / NVIDIA 617.14 / Windows 11 26200 (MSVC 14.51, RelWithDebInfo, full build): the default d3d12_clear_test passes (197 readbacks match WARP), and d3d12_typeless_families shows the same 14 same-adapter ties as on the RTX 3090.

Independent check of the rule in NWX10#2 (@marquezinii): before it was posted I had written the same acceptance separately (layer equals WARP byte for byte, host within one code per 8-bit, 16-bit or 10:10:10:2 component) and ran it here:

  • 82 clears compared ..., 0 differ, 14 ties accepted, 8 draws match; the same with LEONIDA_VK_VALIDATION=1, 0 validation messages.
  • Negative controls, both on the R8G8B8A8_UNORM 0.5 case: one layer byte changed so it no longer equals WARP, exit 1 with MISMATCH; host moved two codes away, exit 1 with MISMATCH.
  • Full ctest with it: 137 passed, 9 skipped, 1 failed of 147. The failure is xbox_present, which aborts on this machine on main too (RivaTuner's hook, RT-269, RT-269: Test that the window presenter retains its Vulkan device #4185).

Code read of NWX10#2: same rule, and it clears the WARP readback when WARP fails to render, which my version didn't. One nit: norm_codes also lists R8G8B8A8_UNORM_SRGB and B8G8R8A8_UNORM_SRGB. A 0.5 sRGB clear isn't an exact tie, and those views matched the host exactly here, so leaving them out would keep the acceptance to the tie cases the comment describes. Not a blocker.

No game files. AI-assisted (Claude Code).

@kingzzim7-create

kingzzim7-create commented Nov 23, 2026 •

Copy link
Copy Markdown

Tested c0a92eb on NVIDIA GeForce RTX 4060 Ti (Ada), driver 621.01, Windows 11 (MSVC 14.52, Visual Studio 2026): pass.

d3d12_clear_test.exe with no arguments: exit 0; RTV and DSV clears: 197 full/rectangle readbacks matched WARP; 3D RTVs: 648 texels match WARP. On main (aa2988c) without this PR the same run exits 1 with the five known differences (R8G8B8A8_UNORM/SNORM, B8G8R8A8_UNORM, B8G8R8X8_UNORM, depth format 55 case 1). #4294 re-registers the test in ctest once this lands (TEST-919).

AI-assisted (Claude).

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

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 Flyander 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.

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);

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.

[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.

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.