Repository navigation
Conversation
These read f16 sources with the f32 bits of an inline constant, whose low half is 0 (1.0 became 0.0). Use the f16 value, as half_src and packed_src do.
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
|
RDNA2 hardware measurement: the low half is right (the constant is its f16 value), but the high half of an inline float constant is 0 on the hardware, not the f16 value again. So Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) runs each of the nine inline float constants (0.5, -0.5, 1, -1, 2, -2, 4, -4, 1/(2π)) as src1, with v4 = f32 3.0 and v5 = f16 2.0 in both halves. RDNA2 desktop silicon, not the console's. No game data.
The same holds for all nine constants. 1/(2π) is So an inline float constant used as a 16-bit operand is For this PR: AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run. |
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
What
v_fma_mix_f32,v_fma_mixlo_f16,v_fma_mixhi_f16(for sources with op_sel_hi set) andv_pack_b32_f16read their f16 sources throughoperand. For an inline float constant (codes 240..=248: 0.5, -0.5, 1, -1, 2, -2, 4, -4, 1/(2 pi)) that gives the f32 bits, e.g. 0x3F800000 for 1.0, whose low 16 bits are 0, so the shader saw 0.0 instead of 1.0.half_srcandpacked_srcalready used f16 values for these.This adds
f16_operand(the f16 bits in both halves, so op_sel works for either half) and uses it on those paths. The constant table now lives in oneinline_f16thathalf_srcandpacked_srcshare (no behavior change there). op_sel, neg and abs handling is untouched: they act on the value after it is read, and were right.Why
Mixed-precision FMAs and packs with an inline constant such as
v_fma_mix_f32 v0, v1, 1.0, v2 op_sel_hi:[1,1,1]computed with a 0.0 operand.Tested
Linux x86_64 only, in the worktree:
cargo test -j4 -p victory-shader: 52 passed, 0 failedcargo clippy -j4 -p victory-shader --tests: no new warnings (one existing dead-code warning forconstant_colorinemit/mod.rs)rustfmt --edition 2024 --check crates/victory-shader/src/emit/lower.rs: cleaninline_float_constants_mean_the_same_in_f16: withinline_f16temporarily returning the low half ofresource::inline(the old value) it fails (left 0, right 0x3C00); with the fix it passes.Not verified: lowering a whole shader (there is no unit-test harness for
Lower, so the test covers the constant helper, not the call sites), the Windows runtime, and any GPU.