Skip to content

Shaders: one helper applies abs and neg to a float source - #2

Open
Moon0755 wants to merge 1 commit into
ci/a13-stack-basefrom
fix/float-mods
Open

Moon0755 wants to merge 1 commit into
ci/a13-stack-basefrom
fix/float-mods

Conversation

@Moon0755

@Moon0755 Moon0755 commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Parked here until its base exists upstream. Not proposed for merging before Marvisak#3158 and Marvisak#3192 are in; then it gets rebased on the new main and opened there.

What

One helper, float_mods(abs, neg, f), replaces the block that applied abs and then neg to a float source, which was written out in six places in emit/lower.rs: fsrc, the f32 accumulator of v_fmac_f32 / v_mac_f32 / v_mac_legacy_f32, the three sources of v_fma_mix* (where the bit passed as abs is the measured neg_hi), half_fsrc, the f16 accumulator, and packed16 (neg only).

No behaviour change is intended: each replaced block has the same two steps as the helper, abs as the unary op, neg as -0.0 - x. The bitwise paths stay on the bits: v_cubesc_f32 / v_cubetc_f32 from Marvisak#3127 and v_cndmask_b32.

The helper was suggested in review on Marvisak#3192.

Why now

lower.rs is 520,563 bytes on main (63bcca4) and the policy cap is 524,288. Marvisak#3127 adds 3,167, Marvisak#3158 adds 284, Marvisak#3192 adds 336: together 524,350, 62 bytes over. Whichever of the three goes in last would fail repository_passes_policy. With this commit the file is 523,817 bytes, 471 under the cap.

Base

ci/a13-stack-base is main with the heads of the three pull requests merged (de77244, cf8f543, 9874157). The merges conflict only in semantics_tests.rs, where each side appended whole tests; both sides are kept. This pull request is the one commit on top: lower.rs only, +16 −35, no test file touched.

Evidence

  • Base without the helper: run 45858824771 is red on repository_passes_policy alone (lower.rs: 524350 bytes exceeds the 524288-byte limit); 310 victory-shader tests pass.
  • With the helper: run 45859910176 is green; 310 tests pass, repository_passes_policy ... ok.
  • This pull request's own check ran the whole workspace: run 45863083327 is green (victory-shader 310, victory-gpu 231, policy 6 of 6).
  • Locally, full victory-shader on WARP: 306 pass, 4 fail, the same four that fail on unmodified 63bcca4 on this machine (three no pipeline for a wave of 32, one gather test). 21 tests matching fmac cube mixed_precision packed sixteen_bit modifiers pass on an AMD integrated Radeon and on an NVIDIA RTX 2060.
  • Four of the six sites used a block index saved earlier in the arm, and the helper uses the current block. A local run with an assertion at each of those sites that the two are equal went through the whole WARP suite without firing.

Not checked

  • The full suite on a hardware adapter (only the 21 tests above).
  • The first two fork runs cover victory-shader and xtask only; the whole workspace ran once, in this pull request's own check.
  • Whether the number of emitted DXIL instructions is unchanged; the helper emits the same two operations under the same conditions, but this was not counted.
  • rustfmt reports older lines of lower.rs that this commit does not touch.

Synthetic tests only; no game files.

— Devin & Fable

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.

1 participant