Recompiler: translate v_cvt_off_f32_i4 #811
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/817"
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 mastrr9 on 2026-11-24T05:51:00Z.
Draft pending
scripts/smoke.ps1regression blocks on a retail title (welcome from anyone with a title, or will be added once available).v_cvt_off_f32_i4was previously reported unsupported (VALU), preventing shaders that use it from translating.What is in it
crates/xcl/src/gpu/recomp/emit.rs: translatesv_cvt_off_f32_i4by sign-extendingS0[3:0](ignoring upper bits) and multiplying by0.0625f(-0.5..0.4375, exact), routed throughfresso VOP3clampandomodapply.crates/xcl/src/gpu/recomp/tests.rs: HLSL + DXC compile check (v_cvt_off_f32_i4_sign_extends_the_low_nibble) and cross-GPU wave test (gpu_v_cvt_off_f32_i4) checking all 16 signed nibbles with junk upper bits, plain and with VOP3omod * 2.Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.ecb821f3453c921be8030622ed57f298cc957268):cargo build --workspace && cargo test --workspace -- --test-threads=4gpu::recomp::tests::v_cvt_off_f32_i4_sign_extends_the_low_nibble—okgpu::recomp::tests::gpu_v_cvt_off_f32_i4—ok(executed on RTX 5080, not skipped)gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).Not tested
scripts/smoke.ps1regression runs on a retail title (hence draft), AMD/wave64 hardware, and release build.AI use
emit.rstranslation and initial tests.runner::run_codefor wave32 GPUs, verified the full Windows RTX 5080 MSVC + D3D12 debug-layer workspace suite, and drafted this PR description.Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T06:41:26Z.
2|
3|AMD/wave64 + release-build datapoint - the two axes your row lists as not tested.
4|
5|Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross
x86_64-pc-windows-gnu, release profile,XCL_NETWORK=0, native wave64. Same rig as my Linux rows in #42 / #718.6|
7|Merged state: head
ecb821fonto mainbeaa245, clean merge.8|
9|Full suite,
cargo test --workspace --release --no-fail-fast -- --test-threads=4: 705 passed, 10 failed, 41 ignored (17 suites). The 10 = this rig's 7 stable Wine-lane failures (my #42 row) + the #718 flaky trio firing that run (~2/5 rate, PR-independent). Nothing new fails. Your tests pass on RDNA3:gpu_v_cvt_off_f32_i4ok,v_cvt_off_f32_i4_sign_extends_the_low_nibbleok.10|
11|Not tested: retail titles (none here), Windows, RDNA4.
12|Counts only, no game data.
13|AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-24T09:41:48Z.
Measured on RDNA2 hardware:
v_cvt_off_f32_i4givesS0[3:0](signed) / 16 as translated here, and applies omod and clamp. One condition applies to omod; see below.Method. The Radeon iGPU of a Ryzen 7 9800X3D (
gfx1036, RDNA2), Windows 11 Pro 26200, display driver 32.0.21045.29003, AMD OpenCL3652.0 (PAL,LC). Each instruction runs as inline RDNA2 assembly in an OpenCL C kernel (the #518 / #772 method), one input per work-item, in wave32 and wave64. The inputs are all 16 nibbles, 4 times each, with junk in bits 4..31 (0xABCDEF7n/0x1234568n, as in this PR's test).Result.
v_cvt_off_f32_i4: all 64 match(float)(((int)(S0 << 28)) >> 28) * 0.0625f, with values -0.5 … 0.4375, and wave32 = wave64.clamp: all 64 give the clamped value.mul:2/div:2: all 64 give the modified value when MODE has IEEE = 0 and f32 denormals off (MODE0x000or0x0c0, set withs_setreg_imm32_b32and read back). With IEEE = 1 or f32 denormals on, which is OpenCL's default0x3f0, the hardware ignores omod. It gives the unmodified value (mul:4too). The same happens forv_cvt_f32_i32andv_cvt_f32_ubyte0, so this is the general RDNA2 omod rule, not something of this instruction. So this PR'somod *2expectation is right for the mode console shaders normally run in.0x000,0x0c00x030,0x0f00x200…0x3f0A note outside this PR:
out_modsinemit.rsapplies omod regardless of the program's float mode. That only matters for a console program that runs with IEEE mode or f32 denormals on and still has omod set. I have not checked whether any does.For comparison, an RX 9070 XT (
gfx1201, RDNA4, OpenCL3686.0) gives the same conversion and applies omod even in OpenCL's default mode.Not tested: the console itself (
gfx1036is a desktop RDNA2 APU of the same generation), RDNA1, this PR's D3D12 tests on this GPU, smoke or a title.AI use: Claude Code (Claude Opus 5.5) wrote the OpenCL probes, ran them on my PC and wrote this comment. I have not reviewed the code.
Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-24T14:38:11Z.
@4usphs Thank you for measuring
v_cvt_off_f32_i4directly on RDNA2 (gfx1036) silicon! Really helpful confirmation that the nibble conversion, clamp, andomodbehavior match the console's normal float mode.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:01:59Z.
Regression run of
83116a8aon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T10:48:29Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:00:17Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:41:39Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:11:40Z.
Triage (#1607) – head
2c02b88Main already translates
v_cvt_off_f32_i4. Commitd7df3f9(#2241) emits(float)((int)({a} << 28) >> 28) * 0.0625fin recomp/emit.rs, the same lowering as here, and also lowers it in the direct-DXIL path (dxil/lower_valu.rs). Its test checks values read from RDNA2 hardware.Recommendation: close (superseded by main commit
d7df3f9/ #2241).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:39:39Z.
Closing as superseded: this change is already on
main(d7df3f9). main emit.rs translates v_cvt_off_f32_i4 as sign-extended nibble * 0.0625 and has hardware-value tests; PR is the same expressionTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed