Shaders: fix v_div_fixup_f32 turning 0.0/x and x/Inf into +/-Infinity #349
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/349"
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 fxceless/victory-fork. Originally posted by AscilCH on 2026-11-24T23:49:43Z.
Problem
In
crates/victory-shader/src/emit/lower.rs,v_div_fixup_f32ORedq_nanintomake_infand evaluatedmake_infaftermake_zero.In the console's IEEE f32 division sequence (
v_div_scale_f32->v_rcp_f32->v_fma_f32->v_div_fmas_f32->v_div_fixup_f32):0.0 / x:v_div_scale_f32setsr = qNaNwhenany_zeroholds, soq_nanis true alongsiden_zero.x / ±Inf:v_rcp_f32(±Inf) = 0.0, thenv_fma_f32(-den, 0.0, 1.0) = qNaN, soq_nanis true alongsided_inf.Because
make_infran aftermake_zero, both0.0 / xandx / ±Infreturned±Infinityinstead of±0.0.Fix
q_nanfrommake_inf(n_inf || d_zero) and applyselect(q_nan, signed_inf, signed_q)beforemake_zero(d_inf || n_zero), matching the RDNA2/GFX10V_DIV_FIXUP_F32priority table (n_nan > d_nan > invalid > make_inf > make_zero > q_nan > signed_q).emit::tests::valu_div_f32_sequence_executes_on_gpuwith0.0/1.0,-0.0/1.0,0.0/-2.0,1.0/+Inf,-1.0/+Inf,+Inf/+Inf, and±1e38 / 1e-38across both hardware D3D12 and WARP (plusdxil.dllvalidation).Verification
cargo test -p victory-shader --locked valu_div_f32_sequence_executes_on_gpu: passed (hardware D3D12 + WARP +dxil.dll)cargo xtask policy: 169 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic tests only, no game data.)
Imported from fxceless/victory-fork. Originally posted by cafeoh on 2026-11-25T12:15:56Z.
Tested in the game: this fixes a visible bug.
Setup: RTX 2080 Ti, Windows 10, diagnostics build of fork
f85101bplus other open PRs, warm shader cache.Guess at why: the effect's strength looks like
max(r - r0, 0) / width, so insider0it is0 / x, which came out as infinity.Not tested: a second run, other scenes, other cards.
AI-assisted (Claude Code); the picture was checked by a person.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.