Shaders: allow abs/neg source modifiers on v_cvt_{u16,i16}_f16 #2963
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2963
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2963"
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?
@Dukestar69 on GitHub · 2026-11-26 01:44 UTC · original
Dukestar69:fix/valu16-omod-and-cvt-saturation→main· +92 −3 · 2 files · 1 commits · openSummary
Allow VOP3
abs/negsource modifiers onv_cvt_u16_f16andv_cvt_i16_f16invalu16_op(crates/victory-shader/src/emit/lower.rs).Testing
cvt_16bit_int_from_f16_saturates_and_honors_modifiersincrates/victory-shader/src/emit/valu_tests.rs.cargo test -p victory-shader cvt_16bit_int_from_f16_saturates_and_honors_modifiers: passed on RTX 5090 and WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 02:01 UTC · original
Independent Windows WARP report: head
81cf605968dbbacdfe167d20421c0f262f903848, exact parent63bcca43c6a00a758510398fa43096ce7e4f7df0Setup: Windows 11 Pro 26200, Rust MSVC,
VICTORY_D3D12_WARP=1andVICTORY_WARP=1(sorun_cases' "hardware" pass also goes throughEnumWarpAdapter),VICTORY_DXIL=SDK 10.0.26100.0x64\dxil.dll,-j 4, fresh target dir. No physical adapter was used.Forcing confirmed (local-only probe, not pushed):
Host::new(false)andHost::new(true)both report adapterMicrosoft Basic Render Driver,DXGI_ADAPTER_FLAG_SOFTWAREset,host.warp = true. The SDK validator loaded from that path and validated all five synthetic shaders below (u16, u16|src0|, i16, i16-src0, u16-|src0|).Results
63bcca481cf605cvt_16bit_int_from_f16_saturates_and_honors_modifiers(PR test file applied to parent)modifiers on a 16-bit integer operation is not supported-|123.75|→0, u16-(-123.75)→123, u16|-inf|→0xFFFF, i16|-40000|→0x7FFF, i16-(-inf)→0x7FFF, i16-|40000|→0x8000, i16-|NaN|→0cargo test -p victory-shader --no-fail-fast(lib)On both commits the same 4 tests fail. They are WARP baseline failures, unrelated to this PR:
emit::synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out}. The only difference is the one new test, which passes. Other test targets: 3 passed / 1 ignored on both.Lint/policy at head:
cargo clippy -p victory-shader --all-targets -- -D warningsclean;cargo xtask policy: 191 files ok. Nit:cargo fmt --checkshows 2 new hunks invalu_tests.rs(the alignment of the trailing comments ini16_cases). The parent isn't rustfmt-clean either, so this doesn't block anything.Verdict: on WARP the fix does what it says. The abs/neg relaxation covers only
v_cvt_{u16,i16}_f16, the diff still refuses clamp/omod (I read that, I didn't test it), and no WARP regressions show up compared with the parent.Synthetic shaders only; no game files, dumps or title shaders. AI-assisted: Claude Code (Claude Opus 5.5).
@steven-seagull27 on GitHub · 2026-11-26 02:15 UTC · original
I checked the full binary16 input range on
81cf6059, including source and destination half selection. For each ofv_cvt_u16_f16andv_cvt_i16_f16, I ran all fourabs/negcombinations, both source halves and both destination halves. Each of the 32 shaders consumed all 65,536 bit patterns from a raw SRV and wrote the entire destination register to a UAV.For each row, the other source half contained
input ^ 0xc535so an incorrect source selector would be visible. The initial destination was0xa53cf139. The CPU reference applied absolute value, then negation, then Rust's saturating float-to-integer cast, and compared the unselected destination half as well. This covers signed zero, subnormals, infinities, and every NaN payload/sign combination. I couldn't reproduce a selector, modifier-order, or partial-write regression on either adapter.@Marvisak on GitHub · 2026-11-26 05:43 UTC · original
Automated triage for the maintainers.
Verdict: merge candidate. This is a small change in
crates/victory-shader/src/emit/lower.rs(the 16-bit integer arm of the VALU lowering).v_cvt_u16_f16andv_cvt_i16_f16with VOP3abs/negwere refused before; now they translate.clampandomodare still refused, as before.The change is safe because those two conversions read their source through
half_fsrc, which already appliesabsand thennegper operand. Before this, the shared modifier check refused them anyway.abs/negon a float input is standard GFX10 VOP3 behaviour. Every other 16-bit integer op still refuses source modifiers.The new test
cvt_16bit_int_from_f16_saturates_and_honors_modifierscovers saturation, NaN and the modifier forms. Testers above report it passing on WARP and an RTX 5080, and one checked all 65,536 inputs with every modifier and half combination against a CPU reference: 0 mismatches.CI: not run on this head (no check runs reported). Recommending a look, not approving.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 01:54 UTC · original · reviewed
Reviewed and verified against
main(63bcca43) on Windows 11 (RTX 5090 + WARP +dxil.dll) — clean and ready to merge:crates/victory-shader/src/emit/lower.rs:7107-7129restrictsabs/negrelaxation tov_cvt_u16_f16/v_cvt_i16_f16(still rejectingclamp/omodand modifiers on other 16-bit integer ops);half_fsrc(inst, 0)applieslegacyF16ToF32exact widening and AMD VOP3 modifier order (-(|src0|)), followed by[0, 65535]/[-32768, 32767]clamping,FpToSi, andpred::UNONaN-to-zero.emit/lower.rssize on63bcca43: 520,800 B (+237 B, 3,488 B below the 512 KiB policy limit).Local verification:
cargo test --locked -p victory-shader -- cvt_16bit_int_from_f16 v_cvt_: 5/5 passed (includingcvt_16bit_int_from_f16_saturates_and_honors_modifiersviavalu_tests::run_caseson RTX 5090 + WARP +dxil.dll)cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningscargo xtask policy: 191 files ok@kotekompotek on GitHub · 2026-11-26 02:19 UTC · original · reviewed
Verified: VOP3 abs/neg modifiers are legal on these two conversions because their source is float — the restriction stays in place for the integer-source ops via the float_src carve-out, and half_fsrc applies the modifiers. The vop3_mod encoding is correct (clamp bit 15, abs 8:10, omod 27:28, neg 29:31) and the cases pin saturation (not wrap), NaN→0, and both modifiers.
@Lyrnc on GitHub · 2026-11-26 17:21 UTC · original
Checked
81cf605on RDNA2 hardware: VOP3v_cvt_u16_f16andv_cvt_i16_f16withabs/neg, using the same instruction words on both sides.Hardware: Radeon iGPU (Ryzen 7 9800X3D), gfx1036 / RDNA2, driver 32.0.21042.62. A HIP kernel (assembled by the driver's amd_comgr) runs all four
abs/negcombinations on 192 halves:Each destination is preset, and the other half of the source holds a different value.
Translator: the same words through a local copy of the
build_valu_csharness (a local test, not part of this PR). I ran it onmain63bcca4and on the PR merged onto it, on the RTX 5080 (610.88) and on the same Radeon (picked with a local adapter-name filter inhardware_adapter).With
op_sel0 (see below), 2 opcodes × 4 modifier combinations × 192 inputs give 1,536 results:modifiers on a 16-bit integer operation)So these all match the hardware:
-|x|order, saturation, NaN → 0, and the kept high half. Without modifiers, main and the PR both match all 384 results.op_sel, outside this PR. This is the same on main. On this GPU, VOP3
op_selhas no effect on these two opcodes:op_sel, so those forms differ. For example, with source0x45358000and op_sel[0], the hardware gives 0 (from the low half, -0) and the translator gives 5 (from the high half, 5.207).Compiled code probably never sets
op_selon these. Still, the source/destination half-select cases in the larger check above follow the translator's model, not the hardware.No game data was used.
AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them on the GPUs above; the numbers come from those runs.
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.