Repository navigation
Conversation
ee5726d to
4919f2e
Compare
|
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
Not tested: Windows MSVC build, the title itself. AI-assisted. |
|
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200 Environment: Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 5060 Ti (driver 621.24,
The PR's D16 buffer tests pass on this hardware:
The 5 failures are the same pre-existing NVIDIA 1,000,000-view heap cap ( Triage note: this branch is based on |
|
Automated triage for the maintainers. Verdict: merge candidate (unchanged). The new commit It merges cleanly with CI: passing ( Generated by Claude Code |
Offline measurement on a retail dumpResult: no count change against I merged head 4919f2e onto No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
RDNA2 saturates a 32-bit UINT channel of a d16 format load to 0xFFFF and a SINT one to -32768..32767; d16_channels kept the low 16 bits (70000 loaded as 0x1170). Measured on gfx1031 (xcl-dev/xcl#1488, XCL-BT-020) and gfx1036 (boykopovar/AnyPS5#22750). 8- and 16-bit formats never leave that range, so they are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A d16 format load of a UNORM / SNORM channel went through legacyF32ToF16 of the decoded f32: two roundings, the second toward zero. RDNA2 rounds code / (2^w - 1) once to nearest even, so about half of the codes came back a unit low (16_UNORM 0x0801: 0x2800 for 0x2801; 57 of 128 sampled 16-bit codes on hardware and WARP). The value's binary expansion repeats the w-bit code, so its first 32 bits decide the rounding and a tie cannot happen (checked against exact rounding for every code at w = 2..16). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4919f2e to
d09a715
Compare
|
I tested the double-rounding question on Windows 11 with a Radeon RX 9060 XT 16 GB. I ran the same synthetic
Both revisions also returned the expected values for the endpoint controls, 0 and 65535. This confirms two inputs where the intermediate f32 rounding in #2843 changes the final FP16 result by one ULP. The single-rounding path in #1940 matched the exact reference for both. This probe covered |
|
Code review and RTX 5090 + WARP + DXIL verification at head
Math and hardware tests look solid — just needs extracting out of |
…he size limit Merged onto main, lower.rs was 524,906 bytes, over the 524,288 bytes cargo xtask policy allows. norm_f16, which this branch adds, moves unchanged with its doc comment into lower/d16.rs, a child module like lower/bvh.rs; d16_channels stays in lower.rs and calls it as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@fuzeofficlal thanks. On that merge, RTX 3070 (driver 616.56) and WARP: On scope: you're right that it covers buffer format loads only ( AI-assisted (Claude Code, Claude Opus 5.5). |
|
The single-rounding result can be kept without requiring The new DXIL feature regression failed on git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1940-d16-i32
git cherry-pick f41d919dd9ace93f669464b911eaa34caac69a02
cargo test --locked -p victory-shader --lib d16 |
|
@steven-seagull27 thanks, pushed as AI-assisted (Claude Code, Claude Opus 5.5). |
Stacked on #1927: the second, third and fourth commits (
Shaders: d16 format loads of UNORM / SNORM data round once to nearest, and95dc5d2, which moves this PR'snorm_f16unchanged into the new child moduleemit/lower/d16.rsto keeplower.rsunder the 512 KiB policy limit, and steven-seagull27'sf41d919, which drops the 64-bit divide) belong to this PR. Both of the first two changed16_channels. Scope: D16 buffer format loads (tbuffer_load_format_d16*/buffer_load_format_d16*) only.A d16 buffer format load of a UNORM / SNORM channel went through
legacyF32ToF16of the decoded f32. That's two roundings, and the second rounds toward zero. RDNA2 roundscode / (2^w − 1)once, to nearest even (gfx1031 for buffer format loads, xcl-dev/xcl#1488 XCL-BT-020; gfx1036 for D16 image reads, boykopovar/AnyPS5#22750). So about half of all codes came back one unit in the last place low: 16_UNORM0x0801gave0x2800, where RDNA2 gives0x2801.What is in it
emit/lower/d16.rs(a child module ofemit/lower.rs):norm_f16, used byd16_channels(inlower.rs) for UNORM / SNORM channels of 2 to 16 bits. The width comes frombuffer_format, so it's a constant.round(|f| · (2^w − 1)).code / (2^w − 1)has a binary expansion that repeats thew-bit code, so its first 32 bits decide the rounding, and a tie can't happen. They are built in 32 bits:code · ⌊(2^32 − 1) / (2^w − 1)⌋places every whole copy, and whenwdoesn't divide 32 the top32 mod wbits of the code fill the low bits. No 64-bit arithmetic, so the shader no longer needs Int64ShaderOps. This is steven-seagull27's patch (f41d919, Shaders: d16 buffer format loads of UNORM / SNORM data round once to nearest #1940 (comment)), which replaced the 64-bitudivthe first version used; it also addsd16_normalized_format_loads_do_not_require_int64, which checks that SFI0 bit 0x8000 is clear for all 20 UNORM / SNORM buffer formats.|v| / (2^(w−1) − 1)with the sign put back.legacyF32ToF16, whose toward-zero rounding matches RDNA2's packing of 32-bit float texels.emit/valu_tests.rs:tbuffer_d16_loads_of_16_bit_norms_round_oncechecks 64 16_UNORM and 64 16_SNORM codes against exact single rounding. Only the low half is compared.Overlap: #2843 (opened 22:02Z) changes the same
d16_channelspath andvalu_tests.rs. For USCALED / SSCALED / UNORM / SNORM it converts the decoded f32 withnarrow16_bits(f, false)(round to nearest even) instead oflegacyF32ToF16; this PR instead roundscode / (2^w − 1)once, from the integer code, for UNORM / SNORM only. So #2843 still rounds twice (to f32, then to f16), and also covers the scaled formats, which this PR leaves alone. Measured over all 65536 codes per format ata0a2e52(RTX 3070, driver 616.56, and WARP, same bits on both): it differs from single rounding on exactly 2 16_UNORM codes (0xFFAFgives0x3BFE, want0x3BFD;0xFFEFgives0x3C00, want0x3BFF) and 2 16_SNORM codes (0x7FF7gives0x3C00, want0x3BFF;0x8009gives0xBC00, want0xBBFF), each 1 ulp larger in magnitude: there the decoded f32 lands exactly on an f16 midpoint. This PR'stbuffer_d16_loads_of_16_bit_norms_round_once, copied onto #2843 unchanged, fails on those codes on both backends. For comparison,main(842b0cb) truncates and differs on 31740 16_UNORM and 30716 16_SNORM codes. #2843's own test checks only thatlegacyF32ToF16is gone. dooprazol confirmed the two 16_UNORM codes on a Radeon RX 9060 XT and WARP, with this PR exact on both: #1940 (comment) The two conflict inlower.rs(git merge-treeof both heads).Related: #2030 rounds D16 image reads of UNORM / SNORM textures the same way (
code / (2^w − 1)rounded once to nearest even). This PR covers the buffer format-load path (d16_channels) and doesn't touch the image path; the two change different functions, so their own changes don't conflict.Tested
f41d919merged withmain63bcca4(clean):cargo xtask policypasses,cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean,cargo test -p victory-shader --lib d16 -- --nocapture: 7 passed, 0 failed, on both the RTX 3070 (616.56) and WARP (no skip lines). Atf41d919alone: policy and clippy pass, d16 7 passed, 0 failed.lower.rsis unchanged by it (521,518 bytes after the merge). The 32-bit sum equals the old(code << 32) / (2^w − 1)for every code below2^w − 1atw= 1…16 (131,054 checks, CPU). steven-seagull27 reports 962,048 / 962,048 exact field values on an RTX 5080 and on WARP.95dc5d2merged withmain63bcca4(clean):lower.rs521,518 bytes (limit 524,288; it was 524,906 before the move),cargo xtask policypasses,cargo clippy -p victory-shader --all-targets --locked -- -D warningsclean,cargo test -p victory-shader --lib d16: 6 passed, 0 failed on the RTX 3070 (616.56) and on WARP. Headroom after the merge is 2,770 bytes: another PR that growslower.rs(e.g. Shaders/Lower: dense Value tables, FxHash maps, lazy get() mask checks, O(1) valu16 reject, and zero-alloc buffer/mask helpers #2942) can use it up.norm_f16against exact rational rounding: every code atw= 2…16, UNORM and SNORM, with the decoded value off by up to ±2 ULP (524,272 checks). No mismatches.4919f2e(base940d32f):mainfails on both backends with 57 of the 128 codes one ULP low. This branch passes.cargo test -p victory-shader --locked: 245 passed, 3 failed, 3 ignored. The 3 are Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744's NVIDIA failures onmain.cargo xtask policyandcargo clippy -p victory-shader --all-targets --locked -- -D warnings: pass.main67e8ae1(headd09a715). The conflict withda82e44was two functions added at the same place inlower.rs(itsnorm_quotient/exact_normfor f32 loads, and this PR'snorm_f16); both are kept. RTX 3070, debug:cargo test -p victory-shader --lib d16: 6 passed, 0 failed.main67e8ae1plus Shaders: d16 format loads saturate 32-bit integer channels #1927's commit, with only this test added (no fix): fails 3 of 3 on the RTX 3070 and on WARP, first at 16_UNORM0x0801(0x2800, want0x2801). Soda82e44doesn't cover the d16 path; this PR is still needed.cargo test -p victory-shader --lockedwithheap_direct_texture_reads_mark_their_heap_indexskipped: 268 passed, 3 failed (the same Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744 failures). That test crashes the test process onmain67e8ae1on this card too (Shader tests: heap_direct_texture_reads_mark_their_heap_index kills the test process on a real GPU (RTX 5070, main 67e8ae1) #2571; a fix is proposed in Shader tests: an empty root-constant list is set as the one constant it declares (#2571) #2596, open, which passes that test 3 of 3 on this card).cargo xtask policyandcargo clippy -p victory-shader --all-targets --locked -- -D warnings: pass.Not tested: a title. D16 image reads are not in scope here; #2030 covers them with the same single-rounding rule.
AI-assisted (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code