Shaders: decode f16 inline float constants in whole-wave v_add_f16 simulation #2493
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!2493
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2493/head"
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?
@reeledMarek on GitHub · 2026-11-25 14:48 UTC · original
reeledMarek:fix/shader-wave-f16-inline-constants→main· +47 −0 · 1 files · 1 commits · merged 2026-11-25 21:57 UTCProblem
In
crates/victory-shader/src/emit/wave.rs,simulate()decoded allOperand::Const(c)operands throughcrate::resource::inline(c)(f32 bit patterns) even when simulatingv_add_f16.On GFX10,
v_add_f16encodes inline float constants (240..=248:0.5,-0.5,1.0,-1.0,2.0,-2.0,4.0,-4.0,1/(2*pi)) as 16-bit f16 bit patterns in the low half (0x3800,0xB800,0x3C00, ...), not f32. Because the f32 bit patterns for240..=247(e.g.0x3F80_0000for1.0) have zero in their low 15 bits,Op::AddH.identity(k)(k & 0x7FFF == 0) erroneously returnedtrueand silently dropped non-zerov_add_f16constant additions as additive identities (+ 0.0).Fix
Operand::Const(240..=248)as GFX10 f16 bit patterns when simulatingv_add_f16(matchingLower::f16_operand).emit::wave::tests::v_add_f16_inline_float_constants_are_not_zero_identityverifying0(code 128) still reduces toShape::Halfwhile all inline float constants240..=248invalidate the reduction.Verification
cargo test -p victory-shader --locked(145 passed, 0 failed)cargo test -p xtask --locked(repository_passes_policypassed)cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings(0 warnings)@cloph-dsp on GitHub · 2026-11-25 15:41 UTC · original
Independent local validation (Windows, Rust 1.100.0/MSVC, head
6cd2489, no game data):cargo test --locked -p victory-shader --lib-> 248 passed, 0 failed, 3 ignored, exit 0;git diff --checkclean. CPU-only regression run; the synthetic f16 inline-constant scenario was not replayed. AI-assisted (Hy4 flash). GPU/driver: N/A for CPU tests.@Marvisak on GitHub · 2026-11-25 15:53 UTC · original
Automated triage for the maintainers. Recommended for a look (not an approval).
In
crates/victory-shader/src/emit/wave.rs,simulate()fed inline float constants 240..=247 tohalf(Op::AddH, ...)as f32 bit patterns, whose low 15 bits are zero, soOp::identitytreated e.g.v_add_f16 v1, 1.0, v1as+0and the reduction match could fire wrongly. The PR decodes them as f16 forv_add_f16, using the same table asLower::f16_operandinemit/lower.rs, and adds a regression test that checks 0 still reduces while 240..=248 do not. CI (check) is passing.Generated by Claude Code