Direct DXIL: reject directed f32 rounding on ENC_VINTRP interpolation #2804
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2814"
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 safesearch77 on 2026-11-26T14:07:47Z.
Reject 32-bit
ENC_VINTRPencodings ofV_INTERP_P1_F32andV_INTERP_P2_F32when a shader directsMODE[1:0]single-precision rounding in the Direct DXIL backend, matching the existing 64-bitENC_VOP3path.lower_round::f32_round_unsupported(crates/xcl/src/gpu/dxil/lower_round.rs:481-483) lists"v_interp_p1_f32" | "v_interp_p2_f32"so pixel shaders that direct f32 rounding fail Direct DXIL translation ("directed f32 rounding of this instruction") rather than silently emitting nearest-even rasteriser interpolation. Previously, that check lived at the top ofLw::valu(lower_valu.rs:336), which is only reached byENC_VOP*/VOP*encodings (lower.rs:975); standard 32-bitENC_VINTRPencodings dispatched directly fromLw::inst(lower.rs:972) toLw::interp_gfxand bypassed the guard.Part of #1269
What is in it
crates/xcl/src/gpu/dxil/lower.rs,crates/xcl/src/gpu/dxil/lower_valu.rs: hoist theself.f32_rm && super::lower_round::f32_round_unsupported(&name)check intoLw::instright before encoding dispatch and remove the redundant check fromLw::valu(+3 / -3).crates/xcl/src/gpu/dxil/round_tests.rs:direct_f32_round_mode_vintrp_p1_p2_rejected, checkingS_ROUND_MODE(1,2,3),S_SETREG_IMM32_B32(0x0801), andS_SETREG_B32(0x0801) againstV_INTERP_P1_F32andV_INTERP_P2_F32in bothENC_VINTRPandENC_VOP3acrosswave64: falseandwave64: true, plus positive controls (S_ROUND_MODE 0,S_ROUND_MODE 0xCf16/f64 RTZ with default f32 RNE, andV_INTERP_MOV_F32under directedS_ROUND_MODE 1).Tested
@retrope13(#2814 (comment)) — Windows 11 26H2 (26300.9818), NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver32.0.16.2140, wave32), Intel Core i5-14500HX, 24 GB RAM,rustc 1.100.0(stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0DXC1.9.2602.17,XCL_ADAPTER=NVIDIA:cargo build --workspace --locked+cargo test --workspace --locked --no-fail-fast -- --test-threads=4(debug):1436 passed, 0 failed, 47 ignoredon15e88d74(vs1435 passed, 0 failed, 47 ignoredonb49be183).cargo test --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture(debug &--release):9 passed, 0 failed, 0 ignored, 0 skipped(all 5 GPU rounding tests +direct_f32_round_mode_vintrp_p1_p2_rejected).@ettehn(#2814 (comment)) — Windows 1126200, Ryzen 9 8945HX, NVIDIA GeForce RTX 5070 Ti Laptop (12 GB, driver621.24),rustc 1.97.1MSVC debug, DXC1.8.2502.11,XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64: reproduced RED failure onb49be183(expected error for ("S_ROUND_MODE", "V_INTERP_P1_F32", "ENC_VINTRP", false)) and9 passed, 0 failed, 0 ignored, 0 skippedon15e88d74.x86_64host cross-check (x86_64-pc-windows-gnu,cargo check --offline --workspace --tests:0errors) and nativerustc --edition 2021 --testRED (8/9) → GREEN (9/9) harness overgpu::dxil::round_tests.Regression run
60 s
scripts/smoke.ps1pair (XCL_NETWORK=0, release builds) reported by@Anon64(#2814 (comment)) on NVIDIA GeForce RTX 3060 12 GB (driver581.80), Intel Core i9-14900KF, Windows 1126200:main:
this PR:
Not tested
wave64hardware, the47#[ignore]/SKIPPEDtests on wave32 NVIDIA adapters, and whether the retail title reaches directed-roundingENC_VINTRPpixel shaders underXCL_DIRECT_DXIL=allduring the 60 s smoke window (PR authored on a Linux CPU host; Windows GPU suite and retail smoke runs provided by@retrope13,@ettehn, and@Anon64).AI use
Lw::insthoist, wrotedirect_f32_round_mode_vintrp_p1_p2_rejectedand the Linux hostrustc --testRED-to-GREEN harness, and updated this description (bug isolated during upstream triage with Claude Opus 5.5). Windows test and smoke verifications reported by@retrope13(Antigravity / Gemini 4 Neon),@ettehn(OpenAI Codex), and@Anon64(Claude Code / Claude Opus 5.5).Imported from ivall/xcl. Originally posted by ettehn on 2026-11-26T14:23:06Z.
Native Windows A/B on
15e88d74df3ae653a6cda85fa0538acbe2554731(clean) vsb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7(the new regression test copied over, no production edits). Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop (12 GB, driver 621.24), Rust 1.97.1 MSVC debug, DXC/DXIL 1.8.2502.11.XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64.expected error for ("S_ROUND_MODE", "V_INTERP_P1_F32", "ENC_VINTRP", false). This arm ran only the new test.cargo test --locked --offline -p xcl --lib -j 2 -- gpu::dxil::round_tests:: --test-threads=1 --nocaptureon PR head: 9 passed, 0 failed, 0 ignored, with no reported skips. The new pixel translation rejection and positive controls passed. All five existing GPU arithmetic tests in the module ran on the laptop, including the dynamic/denormal cases.The new pixel cases check translation; the GPU runs cover existing arithmetic cases. Full workspace testing and a retail title were outside this run.
OpenAI Codex assisted with the Windows verification.
Imported from ivall/xcl. Originally posted by retrope13 on 2026-11-26T14:24:00Z.
Independent Windows/MSVC + NVIDIA GPU (RTX 4060 Laptop 8 GB, DXC
1.9.2602.17) verification and diff review of#2814(15e88d74) againstmain(b49be183): full debug workspace suite + releaseround_testsgreen, 0 failures. No title was run.Tested
32.0.16.2140, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build26300.9818),rustc 1.100.0(stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0DXC1.9.2602.17,XCL_ADAPTER=NVIDIA.gpu::dxil::round_tests:cargo test --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture): 9 passed, 0 failed, 0 ignored, 0 skipped (0.49 s; all 5 GPU rounding tests +direct_f32_round_mode_vintrp_p1_p2_rejectedran and passed).cargo test --release --locked -p xcl --lib -- gpu::dxil::round_tests --test-threads=4 --nocapture): 9 passed, 0 failed, 0 ignored, 0 skipped (0.65 s).cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4:main(b49be183): 1435 passed, 0 failed, 47 ignored#2814(15e88d74): 1436 passed, 0 failed, 47 ignored (+1 new test, 0 failures)Diff Check (
b49be183..15e88d74)lw.f32_rmis computed upfront over the whole program (kernel.rs:266), so hoistingself.f32_rm && lower_round::f32_round_unsupported(&name)intoLw::inst(lower.rs:965) closes theENC_VINTRP→interp_gfxbypass regardless of block lowering order.f32_round_unsupportedonly matchesv_fma_mix_f32,v_dot2_f32_f16,v_dot2c_f32_f16,v_interp_p1_f32, andv_interp_p2_f32, so hoisting out ofLw::valuintroduces no false positives on non-VALU encodings while keepingV_INTERP_MOV_F32andMODE[1:0] == 0controls unaffected.Not Tested
scripts/smoke.ps1runs, AMD / Intel GPUs, native wave64 hardware, and the 47#[ignore]/SKIPPEDtests.AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, checked the diff, and drafted this report.
Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-26T14:44:19Z.
Regression run of
15e88d7on a newer retail title: no device removal, no crash, frames and commit within the limits.Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main
b49be18(this PR's base) and of this PR's exact head,scripts/smoke.ps1 -Game <title>for 60 s withXCL_NETWORK=0and A pressed every 4 s from 20 s. Main ran before and after a batch of 11 PRs and peaked at 23,855 and 23,844 MB, so the baseline held steady over the batch.main:
this PR:
100 % of main's frames, 103 % of its peak commit. One run each.
Not tested: the suite on this head; whether the title reaches the code this PR changes in its first 60 s; AMD.
AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by safesearch77 on 2026-11-26T15:40:02Z.
Huge thanks to
@ettehn,@retrope13, and@Anon64for the native Windows GPU test runs, source diff audit, and 60 sscripts/smoke.ps1regression pair on15e88d74! Added the suite andxcl-smokeresults to the PR description and marking Ready for Review.AI use: Antigravity (Gemini 4 Carbon)
Imported from ivall/xcl. Originally posted by rgroenewoudt on 2026-11-26T16:39:32Z.
Tested on AMD Radeon RX 9070 (RDNA4) at this PR's head
15e88d7: the new test and the GPU rounding tests pass; no new failures.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4: 1434 passed, 2 failed, 47 ignored. The 2 failures arefuzz_validate_and_gpu_1(seed 722) and_3(seed 1599), the AMD ones from #2115, not touched here.direct_f32_round_mode_vintrp_p1_p2_rejectedpasses, as do the GPU tests inround_tests(gpu_direct_f32_round_modes_static,gpu_direct_f32_round_modes_dynamic_and_denormals,gpu_frexp_exp_f32_denorm_with_directed_rounding, …)heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Not tested
AI use
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:24:54Z.
merge-check claim
head:
15e88d74dfImported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T15:29:21Z.
merge-check
base:
9dfbe3ea66head:
15e88d74dfmerge: clean, alone and together with #1763 (
0f257d19, test files only undertests/compile_bench/): both heads merged onto the base in one tree (052f736e) without conflictsbuild: cargo build --workspace -> ok on the combined tree (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 on the combined tree of this head and #1763's head on the base (one suite run for the two PRs, not one per PR) -> 2895 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing:
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it).gpu::dxil::round_tests::direct_f32_round_mode_vintrp_p1_p2_rejectedran and passed. Withlower.rsandlower_valu.rsput back to the base, it fails atround_tests.rs:558("expected error for S_ROUND_MODE, V_INTERP_P1_F32, ENC_VINTRP"); files restored after.review: whole diff read (+101/-3). The check
f32_rm && f32_round_unsupported(name)moves fromLw::valuto the top ofLw::inst(lower.rs:965), before the encoding match, soENC_VINTRP, whichlower.rs:1086sends straight tointerp_gfxwithout passing throughvalu, is now covered too. What is rejected: only the five names inf32_round_unsupported(lower_round.rs:480-481: v_fma_mix_f32, v_dot2_f32_f16, v_dot2c_f32_f16, v_interp_p1_f32, v_interp_p2_f32), and only whenf32_round_writes(lower_round.rs:461-473) finds a write of MODE[1:0] anywhere in the program:s_round_modewith low bits set,s_setreg_imm32_b32with a nonzero round field, or anys_setreg_b32that covers the round bits (whatever value it writes, so that one is conservative). What happens to a rejected shader: the direct translation returns an error and the shader takes the HLSL path, logged as[SHADER] direct DXIL fallback stage=... reason=... - HLSL path(recomp/pso.rs:1280-1283); no draw is skipped. The direct-DXIL cache key includes a hash of the translator sources (recomp/pso.rs:330,:371), so cached translations from the base are not reused by this build.performance:
scripts/smoke.ps1, 60 s of a retail title, release, two runs of the merge against today's base run (1659 frames, 17322 MB peak commit, after one warm-up). The first merge run was cold for direct DXIL, since the cache key includes the translator sources: 1697 frames, 16857 MB. The second: 1701 frames, 18164 MB. Both ended on the 60 s limit, exit 0x0, no device removal, no crash; 60753 pipelines made, as on the base. Nodirect DXIL fallbackline names the directed f32 rounding reason in either run, so no shader of the title in these menus takes the HLSL path because of this rejection. The second run logs 20 fallback lines with other reasons (wave64 VS / PS in 32-lane waves reading lanes 32 to 63, and wave64 graphics v_writelane spill). Both reasons also appear in the base runs of today (2 such lines in a base smoke log), and 13 of the 20 come in the last two seconds of the run, so I read the count as how far the run got, not as this PR; the lines carry no shader ids.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite and tests, reviewed the diff against the merged source and wrote this)
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:29:39Z.
merge-check
base:
9dfbe3ea66head:
15e88d74dfmerge: clean (trial merge 4da541f552dcb00f0e7ffa220cd02681ccffe960; git diff --check clean; +101/-3 in crates/xcl/src/gpu/dxil/lower.rs, lower_valu.rs, round_tests.rs)
build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (fails identically on base
9dfbe3ea, same "2D D16 resinfo clobbered v2/v3" assertion). All 11 round_tests pass, including the new direct_f32_round_mode_vintrp_p1_p2_rejected and the five existing GPU rounding tests on this card.review: read the whole diff. The bug is real and verified on main: lower.rs:1083 dispatches "ENC_VINTRP" straight to interp_gfx, so V_INTERP_P1/P2_F32 in the 32-bit pixel encoding never reached the f32_rm check that lived in Lw::valu — a pixel shader under directed f32 rounding lowered those with the default rounding mode instead of falling back to the HLSL path. The fix moves the check into Lw::inst before the encoding match, covering every encoding; it is safe because f32_rm is computed upfront over the whole program (kernel.rs:408), so block lowering order cannot matter, and f32_round_unsupported matches only five names (v_fma_mix_f32, v_dot2_f32_f16, v_dot2c_f32_f16, v_interp_p1_f32, v_interp_p2_f32), so no new rejections of other encodings. The new test covers 5 mode setters x 4 interp variants (P1/P2 x ENC_VINTRP/ENC_VOP3) x wave32/wave64 expecting the rejection, with controls that MODE[1:0]==0, 0xC (f16/f64-only), and V_INTERP_MOV_F32 still translate to well-formed DXIL; ettehn reproduced the failure on main with the test copied over (fail->pass). No unsafe, no new dependencies.
performance: none; a name lookup that valu already did, now once per instruction for all of them — negligible.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:00:34Z.
Triage (#1607) – head
15e88d7No open or merged PR makes the same change. Moving the
f32_round_unsupportedcheck fromLw::valutoLw::instmakes it coverENC_VINTRP(which dispatches tointerp_gfxand bypassed it);valuhas no other caller, so VOP encodings keep the check.No problems found in the diff; the test covers VINTRP and VOP3 forms under three mode setters plus default-mode and
v_interp_mov_f32controls.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.