Recompiler: translate v_cvt_off_f32_i4 #817
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!817
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@mastrr9 on GitHub · 2026-11-24 05:51 UTC · original
mastrr9:feat/recomp-cvt-off-f32-i4→main· +39 −0 · 2 files · 1 commits · openDraft 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.@SlopTart on GitHub · 2026-11-24 06:41 UTC · original
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.
@4usphs on GitHub · 2026-11-24 09:41 UTC · original
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.
@mastrr9 on GitHub · 2026-11-24 14:38 UTC · original
@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.@Toons29 on GitHub · 2026-11-25 03:01 UTC · original
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.@DavidM1911 on GitHub · 2026-11-25 10:48 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@DavidM1911 on GitHub · 2026-11-26 03:00 UTC · original
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
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.