Recompiler: keep clamped VOP3 pkrtz when patching 32-bit PS exports #3600
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3600"
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 Foniass on 2026-12-01T18:07:58Z.
patch_ps_32bit_exports(from #3200) turns a compressedexp mrtKfed byv_cvt_pkrtz_f16_f32into an uncompressed export of the conversion's raw f32 sources when the render target is 32-bit. It must decline when the VOP3 form has an input or output modifier, but it looked up the clamp bit as"CLMP", while theENC_VOP3field is named"CLAMP". An unknown field name reads as 0, so a clamped conversion was still patched and the clamp was dropped: the 32-bit render target got the unclamped f32 value instead of the value clamped to [0, 1].V_CVT_PKRTZ_F16_F32has no VOP3P form, so only VOP3 is affected.What is in it
crates/xcl/src/gpu/recomp/mod.rs: check"CLAMP"instead of"CLMP"(one line).crates/xcl/src/gpu/dxil/core_tests.rs:ps_32bit_rt_export_declines_patch_for_clamped_vop3_pkrtzexports a VOP3 pkrtz of a large float to a 32-bit MRT. Without CLAMP it is patched; with CLAMP it is left alone, in both the HLSL and the direct DXIL backends.Tested
stable-x86_64-pc-windows-msvc. Suite in debug, smoke in release.cargo test --workspace --no-fail-fast -- --test-threads=4on868e4662: 2905 passed, 0 failed, 51 ignored. These are the same 28 SKIPPED notices as on main:no wave64(wave64 GPU tests ingpu::recomp::lower,lower_dxil,recomp::tests,dxil::kernel)no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form,bind::tests::two_pass_binds_set_the_shared_view_heap)d3d12SDKLayers.dll(the title under the debug layerwith dred false/true,uploads_start_from_each_subresources_state)cannot disable the driver cache (Windows Developer Mode is required)(shaders::tests::pso_measurement_compiles_an_exact_synthetic_record)cargo test -p xcl --lib ps_32bit_rt_export: 3 passed, 0 failed on this branch. On main6bfb5c51with only the new test applied, it gives 2 passed, 1 failed: the new test fails at the clamped HLSL check, and the unclamped control passes. With the HLSL checks removed, it also fails on main at the direct DXIL check, because the raw 0x781d3718 is stored to RT1.Regression run
main:
PR head:
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T19:01:32Z.
merge-check
base:
6bfb5c5153head:
868e466247merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 passed, 0 failed, 51 ignored (base: 2904 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none
review: read the whole diff (2 files, +41 -1). No findings.
"CLMP"->"CLAMP"inpatch_ps_32bit_exports. Every other reader of the VOP3 clamp bit uses"CLAMP"(lower_valu.rs:36,57,535,lower_wide.rs:35), and no other"CLMP"is left insrc.ps_32bit_rt_export_*(3 tests, including the newps_32bit_rt_export_declines_patch_for_clamped_vop3_pkrtz): 3 of 3 runs passed."CLMP"back fails the new test atcore_tests.rs:277. Good.(v8 & 0xFFFF), the packed half bits, to the 32-bit target, as before #3200. A clamped conversion could be patched to exportsaturate(v6)instead.performance: none: one field read per patched export.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T19:26:16Z.
merge-check claim
head:
868e466247Imported from ivall/xcl. Originally posted by throny on 2026-12-01T21:05:41Z.
merge-check
base:
f07e426dadhead:
868e466247(same as the claim)merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 passed, 0 failed, 51 ignored; 25 SKIPPED lines (no wave64 / heap windows / driver-cache test on this adapter). A first run on main
6bfb5c51had the lib test binary end abnormally in a coherent-window restore test (address-space race between parallel tests, unrelated to this diff); the rerun is cleanreview: none after reading the whole diff (64 lines). The VOP3 guard in patch_ps_32bit_exports tested the field "CLMP", which the RDNA2 spec does not have (the field is "CLAMP", rdna2_spec.rs), so a clamped v_cvt_pkrtz_f16_f32 was patched to export raw v6; the one-word fix is right. The new test runs its body on HLSL translate() and direct DXIL (translate_pixel_rt32 + validate), needs no GPU, and asserts both the unclamped (still patched) and clamped (not patched) cases, so it fails without the fix. Scope: one fix plus its test.
performance: no cost by default: a compile-time condition in the translator that declines a patch for clamped VOP3 pkrtz; the emitted shader keeps the real conversion in that case, so a possible GPU cost is one cvt in affected pixel shaders. Reasoned, not measured. Translator source change: testers re-translate shaders.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T22:07:26Z.
Merged at the checked head after a combined trial of #3600, #3493, #3608 and #3607 on
mainf07e426d(RTX 4080 16 GB,cargo test --workspace --no-fail-fast -- --test-threads=4: 2909 passed, 0 failed, 51 ignored, 25 SKIPPED lines). Two merge checks each.AI use: Claude Code (Claude Opus 5.5).