Shaders: support clamp output modifier on v_cvt_pkrtz_f16_f32 #1339
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!1339
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1339"
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?
@AscilCH on GitHub · 2026-11-24 17:33 UTC · original
AscilCH:fix/v-cvt-pkrtz-f16-f32-clamp→main· +109 −2 · 2 files · 1 commits · openBug
In
crates/victory-shader/src/emit/lower.rs,v_cvt_pkrtz_f16_f32(VOP2 0x2f/VOP3 0x12f) finished withint(self, r)→write_i(), which rejects the VOP3clampoutput modifier withUnsupported { what: "integer output modifiers" }.On RDNA2 (GFX10.3),
v_cvt_pkrtz_f16_f32supportsclamp, saturating both convertedf16lanes to[0.0, 1.0](withNaN → +0.0) while preserving round-toward-zero semantics for values in(0.0, 1.0).Reproduction (Before Fix)
Lowering a synthetic RDNA2 compute shader with
v_cvt_pkrtz_f16_f32_e64 ... clamp:Fix
v.omodexplicitly, saturate bothf32operands viadx.op.unary.f32(Saturate)whenv.clampis set before callingf16_toward_zero(), and write the packedu32directly viaself.write(inst, Reg::V(reg), r, guard).dxil.dlltestemit::valu_tests::v_cvt_pkrtz_f16_f32_supports_clamp_and_rtzcovering unclamped RTZ/overflow/infinity/subnormal values, clamped[0.0, 1.0]/NaN/infinity/sub-ULP values, and VOP3abs/neginput modifiers.Verification
Tested on Windows 11, NVIDIA RTX 3050 6GB Laptop GPU, WARP, and Windows SDK
dxil.dll:rustfmt --edition 2024 --checkonvalu_tests.rs: cleancargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p victory-shader --locked -- v_cvt_pkrtz_f16_f32_supports_clamp_and_rtz --nocapture --test-threads=1: passed (hardware + WARP +dxil.dll)VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1:121 passed, 0 failed, 1 ignoredIn crates/victory-shader/src/emit/lower.rs, v_cvt_pkrtz_f16_f32 finished with int(self, r), which calls write_i() and rejects VOP3 clamp with Err("integer output modifiers"). On RDNA2 (GFX10.3), v_cvt_pkrtz_f16_f32 (VOP2 0x2f / VOP3 0x12f) supports the clamp output modifier, saturating both converted f16 results to [0.0, 1.0] (with NaN -> +0.0) while preserving round-toward-zero semantics on values in (0.0, 1.0). Fix: - Reject unsupported v.omod, saturate both f32 inputs via dx.op.unary.f32(Saturate) when v.clamp is set before f16_toward_zero(), and write the packed result directly via self.write(). - Add hardware + WARP + dxil.dll test emit::valu_tests::v_cvt_pkrtz_f16_f32_supports_clamp_and_rtz covering unclamped RTZ/overflow/inf/subnormal cases, clamped range/NaN/inf/sub-ULP cases, and abs/neg input modifiers.@marquezinii on GitHub · 2026-11-24 18:33 UTC · original
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
b686bcc.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 121 passed, 0 failed, 1 ignored.v_cvt_pkrtz_f16_f32_supports_clamp_and_rtzpasses on the hardware adapter and WARP.Clamping in f32 before the round-toward-zero conversion gives the same result as clamping after it: 0 and 1 are exact in f16, and DXIL
Saturatemaps NaN to +0, which matches your table.@Marvisak on GitHub · 2026-11-25 01:23 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@sinan-cmyk on GitHub · 2026-11-25 01:48 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
b686bccontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.