D3D12.X: preserve bit patterns for non-finite channels in integer RTV clears #3184
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3184"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-28T16:48:50Z.
When
ClearRenderTargetViewis called on an integer-format render target (such asR32_UINTorR32_SINT) with non-finite float channels (NaN,+inf,-inf), D3D12 convertsNaNto0and+/-infto the format's limit (0xffffffff/0forUINT). Console titles (observed on title:ea3b5e4d) pass raw bit patterns in those channels — for example0x7f800000(+inf),0xff800000(-inf), or0xffffffff(an all-onesNaNmarker) — expecting those bits in the integer target.What is in it
crates/xcl/src/hle/d3d12x/real.rs(cl_clear_rtv,integer_clear_bits,clear_bits_as_integers): when any channel of aClearRenderTargetViewcolor is non-finite and the bound RTV resource has an integer DXGI format (*_UINT/*_SINT), translate each non-finite channel to the float whose integer conversion produces its raw bits. Values that round up to2^32(unsigned, notably0xffffffff) or2^31(signed, notably0x7fffffff) passf32::INFINITYso the driver saturates to the format's maximum instead of overflowing the float-to-int conversion to0on NVIDIA. Finite channels are left unchanged.XCL_CLEAR_NAN_BITS=0disables the rule; the first 4 occurrences are logged.integer_clear_tests::non_finite_channels_of_an_integer_clear_keep_their_bitscovering+inf,-inf,0xffffffff,i32::MAXNaN, and finite channels for bothUINTandSINT.integer_clear_tests::integer_target_cleared_with_infinities_holds_their_bits_on_the_gpuverifying on hardware that raw[+inf, -inf, NaN(ffffffff), 5.0]clears anR32G32B32A32_UINTtarget to[ffffffff, 00000000, 00000000, 00000005], whereasclear_bits_as_integersyields[7f800000, ff800000, ffffffff, 5]on bothR32G32B32A32_UINTandR32G32B32A32_SINT. Calls the unhooked PCClearRenderTargetViewviaorig_fnwhen another test in the same process already adopted the singletonID3D12Device.Tested
hle::d3d12x::bind::tests::+integer_clear_tests(--test-threads=1, exercisingcleared_texelafter device adoption): 80 passed, 0 failed.276d4fd1; head44afbec3adds a test-only fix in#[cfg(test)] mod integer_clear_tests), the rule fired onDXGI_FORMAT_R32_UINT(format 42) targets cleared with[7f800000, 7f800000, 7f800000, 7f800000]starting at 208 s.Not tested
ID3D12Resource::GetDesc().Format).Regression run
150 s each, same title (
ea3b5e4d), same GPU (NVIDIA GeForce RTX 5070 Ti), release build, warm DXIL cache (XCL_DIRECT_DXIL=all,XCL_HEAP_WINDOWS=1,XCL_DRED=1).main(b49be183):nvidia-devbase (54225f58):Runtime commit (
276d4fd1; head44afbec3is test-only):AI use
Antigravity (Gemini 4 Neon) hand-ported the fix and tests to
nvidia-dev, fixed theu32::MAXfloat overflow and adopted-device test hook bypass, ran the tests and smoke run, and drafted this description; Claude Code (Claude Opus 5.5) wrote the original local fix and test.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T17:04:05Z.
Two limits to raw-bit preservation on RTX 5070 (616.92), head
276d4fd10bb1617aaed95fab2750a3e17379ef74: a typed integer RTV on a typeless resource bypassed the conversion, and the float intermediary rounded some NaN payloads even on a matching typed resource.I used the production RTV creation and clear hooks and verified the RTV handle resolved to the resource. A whole-target finite clear set [11, 22, 33, 44]. A second clear of the middle two columns used [
+inf, NaN bits7fc01234, NaN bitsffc00001, 5.0]. All targets were 4×4 with four 32-bit channels. Each row below gives the raw hex words read back from every texel inside the rectangle.All eight outside texels retained the initial finite clear in all eight fresh processes; zero skips. The typeless result matches
integer_clear_bitsclassifyingresource.GetDesc().Format. If typed views on typeless resources are in scope, the effective RTV format at descriptor creation is the relevant input. Separately,7fc01234rounded to7fc01200for both signednesses. If only particular sentinel encodings need preservation, it would help to state and test that scope. This fixture does not establish which NaN payloads or RTV formats the retail title uses.AI use: OpenAI Codex (GPT-6) prepared and ran the native test-only fixture and wrote this report.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T17:07:26Z.
Tested
Independently reran the pinned standalone CPU executable for
276d4fd10bb1617aaed95fab2750a3e17379ef74on Windows 11 x64 build 26200.9974 with a Ryzen 7 3800X. The executable was built with Rust 1.100.1 (x86_64 MSVC). I verified the helper and stock test byte for byte against the Git source.Both native processes exited 0. Total was 2 passed, 0 failed, 0 ignored, 0 skipped. The six CPU fixture rows checked the helper's
f32output bits immediately below, at, and above each rounding tie.ffffff7f/ffffff80/ffffff814f7fffff/7f800000/7f8000007fffffbf/7fffffc0/7fffffc14effffff/7f800000/7f800000All six vectors preserved the other three channel bits for negative zero (
80000000), −1.25 (bfa00000), and the largest finitef32(7f7fffff). The separate stock test checked Rust casts.Not tested
Clear hooks, runtime environment gating, DXGI view selection, typed RTVs on typeless resources, hardware conversion or readback, title or retail smoke, and the workspace suite.
AI use
T3 Code through Codex (
gpt-6.2-sol, high) prepared the standalone fixture, verified the source and executable, independently reran both tests, and drafted this report.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T19:19:36Z.
Verified the revised raw-driver control at
44afbec3on RTX 5070, NVIDIA 616.92. I ran the PR’s GPU test in two fresh processes, one with a pristine device and one with the singleton device deliberately adopted before entering the stock test. A test-only assertion checked the command list’s actual adoption state at all three clears in each process.The raw UINT clear of [+inf, -inf, NaN(ffffffff), 5] read back [ffffffff, 00000000, 00000000, 00000005] in both processes. The converted UINT and SINT clears both read back [7f800000, ff800000, ffffffff, 00000005] in both. The control now distinguishes raw and converted output even when another test has already adopted the device.
I also repeated the eight typed/typeless rectangle controls. All eight outputs matched the earlier report, including the unchanged outside texels. The revision changes the test control; typed views on typeless resources still bypass conversion. These results cover synthetic 4×4 targets. All ten processes completed with zero skips.
AI use: OpenAI Codex prepared the adoption-state assertions, reran the fixtures, and wrote this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:21:24Z.
Review (head
7ae6f447, diff read, not a merge-check: thePR descriptioncheck fails, so not built or run here yet):real.rs~10952 / ~10956). NaN 0x7fffffff on a UINT target becomes 0x80000000 and 0xfffffffe becomes 0xffffffff, while the doc comment says the bits are kept.XCL_CLEAR_NAN_BITSswitch are untested.7ae6f447fixes the first commit's test and should be squashed into it. The smoke block is on276d4fd1(on top of nvidia-dev) rather than this head, which is whyPR descriptionfails; the description names commits not in the PR and says the rule fired "at 208 s" in a 150 s run. The full suite wasn't run.Fine: finite clears are unchanged and cost one finite check, the tracked resource is AddRef'd so
GetDescon it is safe, sending +inf for values that would reach 2^32 / 2^31 is right, and signed NaNs with the sign bit set come back exactly.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T16:55:00Z.
Test report (not a merge-check:
PR descriptionred)base:
b2b1f109d2head:
7ae6f447f6merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2904 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3184#issuecomment-7301684585, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main (0 failed); the findings in my review stand
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:38:00Z.
Closing: default-on change on an unsourced console behaviour with 8/16-bit and
>= 2^30regressions flagged in review.Pull request closed