Translate: count the instructions on 16-bit floats (for #2384, #2825) #2866

Open
github-bot wants to merge 1 commit from github-bot/gh-2866 into main AGit
Owner

@⁠xndbogdan on GitHub · 2026-11-25 22:44 UTC · original
xndbogdan:translate/f16-count → main · +39 −0 · 1 files · 1 commits · open

For #2384 and #2825.

Why

#2806 and #2825 measured what the translator's software f16 rounding costs against native 16-bit math, on NVIDIA, AMD and WARP. How much that saves in the game depends on one number nobody has posted: what share of the title's shader code is 16-bit float math. Anyone with the game's files can now read it in one run.

What

victory translate prints one more line after the program count:

f16          N of M instructions on 16-bit floats (P%), K packed (v_pk_*); counted in the code, not as run
  • An instruction counts when its name has an _f16 operand or result (f16_kind): arithmetic, compares and conversions. v_pk_* ones are also counted as packed.
  • Only translated programs are counted, the same ones as the IR instructions total, so the percentage is of that total.
  • Each instruction is counted once where it appears in the code, not by how often it runs or how hot its shader is. It is a first estimate of the share, not of GPU time.

Tests

  • f16_instructions_are_counted_and_packed_ones_told_apart: f16_kind on packed, scalar, compare and conversion _f16 names, and on names that are not f16 (v_fma_f32, v_pk_add_u16, s_mov_b32, empty).
  • cargo test --locked -p victory --bin victory translate: 2 passed.
  • cargo clippy --locked -p victory --all-targets -- -D warnings: clean. cargo fmt --check: clean. cargo xtask policy: 190 files ok.
  • victory translate on an empty folder prints the new line with zeros.

Not done

  • No game data here, so there is no count from the title's shaders. If you have shaders.rpf, the f16 line from victory translate <game dir>\shaders.rpf would answer #2825's open question.
  • The counting loop is not tested on a real program, only f16_kind is.

🤖 Generated with Claude Code

**@⁠xndbogdan** on GitHub · 2026-11-25 22:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2866) `xndbogdan:translate/f16-count` → `main` · +39 −0 · 1 files · 1 commits · open For #2384 and #2825. ## Why #2806 and #2825 measured what the translator's software f16 rounding costs against native 16-bit math, on NVIDIA, AMD and WARP. How much that saves in the game depends on one number nobody has posted: what share of the title's shader code is 16-bit float math. Anyone with the game's files can now read it in one run. ## What `victory translate` prints one more line after the program count: ``` f16 N of M instructions on 16-bit floats (P%), K packed (v_pk_*); counted in the code, not as run ``` - An instruction counts when its name has an `_f16` operand or result (`f16_kind`): arithmetic, compares and conversions. `v_pk_*` ones are also counted as packed. - Only translated programs are counted, the same ones as the `IR instructions` total, so the percentage is of that total. - Each instruction is counted once where it appears in the code, not by how often it runs or how hot its shader is. It is a first estimate of the share, not of GPU time. ## Tests - `f16_instructions_are_counted_and_packed_ones_told_apart`: `f16_kind` on packed, scalar, compare and conversion `_f16` names, and on names that are not f16 (`v_fma_f32`, `v_pk_add_u16`, `s_mov_b32`, empty). - `cargo test --locked -p victory --bin victory translate`: 2 passed. - `cargo clippy --locked -p victory --all-targets -- -D warnings`: clean. `cargo fmt --check`: clean. `cargo xtask policy`: 190 files ok. - `victory translate` on an empty folder prints the new line with zeros. ## Not done - **No game data here**, so there is no count from the title's shaders. If you have `shaders.rpf`, the `f16` line from `victory translate <game dir>\shaders.rpf` would answer #2825's open question. - The counting loop is not tested on a real program, only `f16_kind` is. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`victory translate` prints how many of the translated programs'
instructions work on 16-bit floats and how many of those are packed, so
the game's share of f16 math can be read in one run (#2384, #2825). The
count is of instructions in the code, not as run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:17 +00:00
Author
Owner

@⁠xndbogdan on GitHub · 2026-11-25 22:53 UTC · original

@⁠Proudnoob4 you've run victory translate --warm on the world shaders (on #2825), so you may be the person who can answer the question this PR is for. If you have a moment: with this commit applied (dc792c3, one file, apps/victory/src/translate.rs), victory translate prints an f16 line with the share of the translated instructions that work on 16-bit floats. That line, ideally over the whole shaders.rpf, would say how much of the game's shader code #2825's native path can speed up. Thanks either way, and thanks for the in-game RTX 4080 run.

**@⁠xndbogdan** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7176911572) @⁠Proudnoob4 you've run `victory translate --warm` on the world shaders (on #2825), so you may be the person who can answer the question this PR is for. If you have a moment: with this commit applied (`dc792c3`, one file, `apps/victory/src/translate.rs`), `victory translate` prints an `f16` line with the share of the translated instructions that work on 16-bit floats. That line, ideally over the whole `shaders.rpf`, would say how much of the game's shader code #2825's native path can speed up. Thanks either way, and thanks for the in-game RTX 4080 run.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 23:31 UTC · original

Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.

  • git diff --check against merge-base f3578e3 is clean; 1 file, +39/-0.
  • Negative control: translate::tests::f16_instructions_are_counted_and_packed_ones_told_apart is absent from the base commit.
  • cargo test --locked -p victory --bin victory -- translate::tests::f16_instructions_are_counted_and_packed_ones_told_apart --exact --quiet -> 1 passed (14 filtered out).
  • Full cargo test --locked -p victory --bin victory --quiet -> 15 passed, 0 failed.

AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-25 23:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7177692944) Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup. - `git diff --check` against merge-base f3578e3 is clean; 1 file, +39/-0. - Negative control: `translate::tests::f16_instructions_are_counted_and_packed_ones_told_apart` is absent from the base commit. - `cargo test --locked -p victory --bin victory -- translate::tests::f16_instructions_are_counted_and_packed_ones_told_apart --exact --quiet` -> 1 passed (14 filtered out). - Full `cargo test --locked -p victory --bin victory --quiet` -> 15 passed, 0 failed. AI-assisted (Hy4 flash).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:24 UTC · original

Automated triage for the maintainers.

Merge candidate. This adds an f16 line to victory translate: the share of translated IR instructions that work on 16-bit floats and how many are packed (v_pk_*), answering the open question in #2825 without putting title data in the repo. f16_kind catches arithmetic, compares and conversions in both directions and leaves out v_pk_*_u16 and f32 ops; the count runs over the same programs as the IR instructions total. Mixed-precision ops such as v_fma_mix_f32 are not counted, which is fine for a first estimate.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7182573133) <!-- victory-triage v1 head=dc792c30df9e74978b2d0174d08766dc2ab850d3 verdict=merge-candidate at=2026-11-26T04:24:45Z --> Automated triage for the maintainers. **Merge candidate.** This adds an `f16` line to `victory translate`: the share of translated IR instructions that work on 16-bit floats and how many are packed (`v_pk_*`), answering the open question in #2825 without putting title data in the repo. `f16_kind` catches arithmetic, compares and conversions in both directions and leaves out `v_pk_*_u16` and f32 ops; the count runs over the same programs as the `IR instructions` total. Mixed-precision ops such as `v_fma_mix_f32` are not counted, which is fine for a first estimate. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2866/head:github-bot/gh-2866'
git switch 'github-bot/gh-2866'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2866'
git switch 'github-bot/gh-2866'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2866'
git switch 'github-bot/gh-2866'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2866'
git switch 'main'
git merge --squash 'github-bot/gh-2866'
git switch 'main'
git merge --ff-only 'github-bot/gh-2866'
git switch 'main'
git merge 'github-bot/gh-2866'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2866
No description provided.