Skip to content

Shaders: lower v_div_fixup_f16 (port of upstream VIctory #379) - #1040

Open
Moon0755 wants to merge 1 commit into
fxceless:mainfrom
Moon0755:fix/v-div-fixup-f16
Open

Moon0755 wants to merge 1 commit into
fxceless:mainfrom
Moon0755:fix/v-div-fixup-f16

Conversation

@Moon0755

Copy link
Copy Markdown

Port of upstream Marvisak/VIctory#379 (originally authored by @LouisRiverstone).

Summary

Adds DXIL lowering for the RDNA2 16-bit division fixup instruction v_div_fixup_f16.

Previously, Lower::valu16 did not handle v_div_fixup_f16, rejecting shaders that use half-precision division fixup sequences.

Changes

  • crates/victory-shader/src/emit/lower.rs:
    • Added "v_div_fixup_f16" to FLOAT3 in Lower::valu16 and dispatched it to Lower::div_fixup(a, b, acc) in Lower::valu16_op (so half_fsrc / float_result apply source/destination op_sel, abs/neg, omod, clamp, and half preservation automatically).
    • Implemented Lower::div_fixup following the RDNA2 (gfx1036) ISA special-case precedence order on exact f32 representations: numerator NaN, denominator NaN, 0/0 or inf/inf -> qNaN, x/0 or inf/x -> signed infinity, 0/x or x/inf -> signed zero, quotient overflow / NaN -> signed infinity, otherwise copysign(|q|, num ^ den).
  • crates/victory-shader/src/emit/valu_tests.rs: added div_fixup_f16_reference and D3D12 WARP regression test v_div_fixup_f16_follows_the_isa_special_cases exercising 400 combinations of quotients, denominators, and numerators (including ±0, subnormals, ±inf, qNaN, sNaN, and verifying the upper 16 bits of the destination VGPR remain unchanged).

Verification

Verified on windows-latest via GitHub Actions (run 45660058837):

  • cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings — passed
  • cargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings — passed
  • cargo test -p victory-shader -p xtask --locked -- --nocapture — 216 passed; 0 failed; 3 ignored (including v_div_fixup_f16_follows_the_isa_special_cases executed on D3D12 WARP, plus xtask 4 passed, repository_passes_policy passed)

— Neon

@HAL9000RELOADED

Copy link
Copy Markdown

A hardware run of this PR's new test: v_div_fixup_f16_follows_the_isa_special_cases passes on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with #402's Agility SDK runtime. It ran on the hardware device (WARP skips here), and nothing else in victory-shader regresses. The setup, and the same run for eight related ports, are in one table on #1030: #1030 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants