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

Closed
xndbogdan wants to merge 1 commit from upstream-pr/2866 into main
xndbogdan commented 2026-11-25 22:44:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xndbogdan on 2026-11-25T22:44:22Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5500457551 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866). Originally posted by [xndbogdan](https://github.com/xndbogdan) on 2026-11-25T22:44:22Z. --- 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)
kotekompotek commented 2026-11-25 22:50:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:50:50Z.

Review: COMMENTED


Harmless and useful: counting f16 instructions (with the packed subset split out) is exactly the measurement #2825's native-half path needs to be judged against. Only counted on translated programs so the share is honest. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066068072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#pullrequestreview-6066068072). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T22:50:50Z. **Review:** COMMENTED --- Harmless and useful: counting f16 instructions (with the packed subset split out) is exactly the measurement #2825's native-half path needs to be judged against. Only counted on translated programs so the share is honest. LGTM.
xndbogdan commented 2026-11-25 23:06:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xndbogdan on 2026-11-25T22:53:46Z.


@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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176911572 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7176911572). Originally posted by [xndbogdan](https://github.com/xndbogdan) on 2026-11-25T22:53:46Z. --- @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.
fuzeofficlal commented 2026-11-25 23:44:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:44:17Z.

Review: COMMENTED


Verified head dc792c30 cleanly merged onto origin/main (63bcca43) on Windows 11 x64.

Code Review

  • Scoped cleanly to apps/victory/src/translate.rs (+39 lines) with no changes to victory-shader translation output or emit/lower.rs size.
  • Cross-checked f16_kind(name) ((name.ends_with("_f16") || name.contains("_f16_")).then(|| name.starts_with("v_pk_"))) against all 89 f16 opcodes in crates/victory-shader/src/gfx10/opcodes.rs: Inst::name() returns the base mnemonic without _e32/_e64/_sdwa/_dpp suffixes, so all 89/89 match with 0 false negatives and 0 false positives (v_pk_*_f16 under packed, and scalar/conversion/mix/dot/pack ops such as v_fma_mixlo_f16, v_dot2_f32_f16, v_cvt_pkrtz_f16_f32, v_pack_b32_f16 under f16, matching the test assertions).

Local Verification

  • cargo test --locked -p victory: 15/15 unit tests passed (including translate::tests::f16_instructions_are_counted_and_packed_ones_told_apart), plus census (2/2), census_unreadable (1/1), translate (1/1).
  • cargo clippy --locked -p victory --all-targets -- -D warnings (default and --features diagnostics) & cargo xtask policy (191 files ok): clean.

Looks clean and ready to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066566366 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#pullrequestreview-6066566366). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:44:17Z. **Review:** COMMENTED --- Verified head `dc792c30` cleanly merged onto `origin/main` (`63bcca43`) on Windows 11 x64. ### Code Review - Scoped cleanly to `apps/victory/src/translate.rs` (+39 lines) with no changes to `victory-shader` translation output or `emit/lower.rs` size. - Cross-checked `f16_kind(name)` (`(name.ends_with("_f16") || name.contains("_f16_")).then(|| name.starts_with("v_pk_"))`) against all **89** `f16` opcodes in `crates/victory-shader/src/gfx10/opcodes.rs`: `Inst::name()` returns the base mnemonic without `_e32`/`_e64`/`_sdwa`/`_dpp` suffixes, so all 89/89 match with 0 false negatives and 0 false positives (`v_pk_*_f16` under packed, and scalar/conversion/mix/dot/pack ops such as `v_fma_mixlo_f16`, `v_dot2_f32_f16`, `v_cvt_pkrtz_f16_f32`, `v_pack_b32_f16` under f16, matching the test assertions). ### Local Verification - `cargo test --locked -p victory`: **15/15** unit tests passed (including `translate::tests::f16_instructions_are_counted_and_packed_ones_told_apart`), plus `census` (2/2), `census_unreadable` (1/1), `translate` (1/1). - `cargo clippy --locked -p victory --all-targets -- -D warnings` (default and `--features diagnostics`) & `cargo xtask policy` (`191 files ok`): clean. Looks clean and ready to merge.
cloph-dsp commented 2026-11-26 00:03:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T23:31:58Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177692944 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7177692944). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T23:31:58Z. --- 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).
Marvisak commented 2026-11-26 05:04:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:24:51Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182573133 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7182573133). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T04:24:51Z. --- <!-- 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)_
Dukestar69 commented 2026-11-26 17:52:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:52:42Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64:

  • Counting 16-bit float (_f16) and packed (v_pk_*) IR instructions in translate::Tally is clean and well-tested.
  • cargo test -p victory -- --test-threads=1: 15 unit + 4 integration tests passed, 0 failed (including f16_instructions_are_counted_and_packed_ones_told_apart).
  • cargo clippy -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6078643535 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#pullrequestreview-6078643535). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T17:52:42Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64: - Counting 16-bit float (`_f16`) and packed (`v_pk_*`) IR instructions in `translate::Tally` is clean and well-tested. - `cargo test -p victory -- --test-threads=1`: 15 unit + 4 integration tests passed, 0 failed (including `f16_instructions_are_counted_and_packed_ones_told_apart`). - `cargo clippy -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 17:56:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T17:56:39Z.


NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head dc792c3 (on its base f3578e3).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 864 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: f16_instructions_are_counted_and_packed_ones_told_apart.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7199873537 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2866#issuecomment-7199873537). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T17:56:39Z. --- NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head `dc792c3` (on its base `f3578e3`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **864 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `f16_instructions_are_counted_and_packed_ones_told_apart`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2864
No description provided.