Shaders: a formatted load converts only the fields its DST_SEL reads #33

Manually merged
github merged 1 commit from gh-pr/33/head into gh-pr/33/base 2026-11-27 03:14:45 +00:00
Owner

@⁠Sr-0w on GitHub · 2026-11-25 13:55 UTC · original
Sr-0w:shaders/format-load-swizzle → main · +47 −22 · 5 files · 1 commits · merged 2026-11-25 14:02 UTC

Until now, FmtLoad converted all four fields of an element, and fmt_swizzle picked among them afterwards. Every component's conversion (int-to-float, two divides, f16 widening and the format selects) therefore stayed live, even when the program reads only x.

FmtLoad now takes V# dword3. Each result component converts only the one field its selector names, so unread components fold away. Results are unchanged bit for bit. fmt_swizzle and fmt_select are gone, and probe_FmtLoad gets the extra argument.

A retail game's 122k-dword compute program has 3,281 format loads. Its DXIL backend output shrinks as follows:

before after
instructions 1,256,697 735,530 (−41%)
fdiv 26,260 6,574
DXIL size 7.4 MB 4.9 MB

The driver compile scales with that size. That program is the one that stays a stand-in for the longest.

Tests: the new cs_buffer_rule_format_select case loads an 8_8_8_8_UINT element through DST_SEL z,y,x,1 and w,0. It fails when the selectors are ignored. The full suite is green.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-25 13:55 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/33) `Sr-0w:shaders/format-load-swizzle` → `main` · +47 −22 · 5 files · 1 commits · merged 2026-11-25 14:02 UTC Until now, `FmtLoad` converted all four fields of an element, and `fmt_swizzle` picked among them afterwards. Every component's conversion (int-to-float, two divides, f16 widening and the format selects) therefore stayed live, even when the program reads only `x`. `FmtLoad` now takes V# dword3. Each result component converts only the one field its selector names, so unread components fold away. Results are unchanged bit for bit. `fmt_swizzle` and `fmt_select` are gone, and `probe_FmtLoad` gets the extra argument. A retail game's 122k-dword compute program has 3,281 format loads. Its DXIL backend output shrinks as follows: | | before | after | |---|---|---| | instructions | 1,256,697 | 735,530 (−41%) | | `fdiv` | 26,260 | 6,574 | | DXIL size | 7.4 MB | 4.9 MB | The driver compile scales with that size. That program is the one that stays a stand-in for the longest. Tests: the new `cs_buffer_rule_format_select` case loads an 8_8_8_8_UINT element through DST_SEL z,y,x,1 and w,0. It fails when the selectors are ignored. The full suite is green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
FmtLoad converted all four fields of the element and fmt_swizzle chose
among them after, so every component's conversion (int-to-float, two
divides, f16 widening and the format selects) stayed live even where
the program reads only x. FmtLoad now takes V# dword3 and each result
component converts the one field its selector names: the unread
components fold away. The results are unchanged bit for bit.

In a retail game's 122k-dword compute program with 3,281 format loads,
the DXIL backend output goes from 1,256,697 to 735,530 instructions
(-41%), 26,260 to 6,574 divides, 7.4 to 4.9 MB.

Tests: cs_buffer_rule_format_select loads an 8_8_8_8_UINT element
through DST_SEL z,y,x,1 and w,0; it fails when the selectors are
ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:14:43 +00:00
github manually merged commit c719e9e0dd into gh-pr/33/base 2026-11-27 03:14:45 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-25 14:02 UTC · original

41% fewer instructions on the biggest compute program with identical results is a great win, especially since that's the one stuck as a stand-in longest. merged, thanks!

**@⁠ThatRecompDev** on GitHub · 2026-11-25 14:02 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/33#issuecomment-7164658520) 41% fewer instructions on the biggest compute program with identical results is a great win, especially since that's the one stuck as a stand-in longest. merged, thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.