Shaders: stop scanning for integer-width usage once resolved #3792

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3792 into main
andrewpozdnakov7-jpg commented 2026-11-28 21:03:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T21:03:09Z.


Resolve the interned i64 type before scanning live DXIL instructions. If the module has no such type, operand inspection is unnecessary. Once a live i64 result or operand is found, continue scanning only for the other usage flags.

Four generated branch-heavy modules emitted identical bitcode. Across 17 alternating Windows release pairs, analysis plus writing took 0.887x to 0.953x baseline, with the same allocation and reallocation counts. Nine generated full translations emitted identical DXIL and passed the signed Microsoft validator. In two five-pair CPU-pinned runs, the larger conversion fixtures were 0.893x to 0.944x baseline. Medians for the other fixtures varied from 0.902x to 1.024x across both runs.

The focused test exercises no interned i64, a dead i64 operand, and a live i64 operand with a narrow result. The bitcode tests, both strict shader Clippy configurations and the asset policy passed.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5544548073 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3792). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T21:03:09Z. --- Resolve the interned `i64` type before scanning live DXIL instructions. If the module has no such type, operand inspection is unnecessary. Once a live `i64` result or operand is found, continue scanning only for the other usage flags. Four generated branch-heavy modules emitted identical bitcode. Across 17 alternating Windows release pairs, analysis plus writing took 0.887x to 0.953x baseline, with the same allocation and reallocation counts. Nine generated full translations emitted identical DXIL and passed the signed Microsoft validator. In two five-pair CPU-pinned runs, the larger conversion fixtures were 0.893x to 0.944x baseline. Medians for the other fixtures varied from 0.902x to 1.024x across both runs. The focused test exercises no interned `i64`, a dead `i64` operand, and a live `i64` operand with a narrow result. The bitcode tests, both strict shader Clippy configurations and the asset policy passed. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 21:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T21:06:10Z.


Windows CI passed on 945e5cb, including both Clippy configurations and the workspace tests. The focused regression covers no interned i64, an unused i64 operand, and an i64 operand whose live instruction returns i32. Nine generated full translations were byte-identical and passed the signed DXIL validator. Both paired CPU runs saw lower median times in the 128- and 512-conversion fixtures, while the other timings varied.

The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245773352 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3792#issuecomment-7245773352). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T21:06:10Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46189568151/job/141117036035) passed on 945e5cb, including both Clippy configurations and the workspace tests. The focused regression covers no interned i64, an unused i64 operand, and an i64 operand whose live instruction returns i32. Nine generated full translations were byte-identical and passed the signed DXIL validator. Both paired CPU runs saw lower median times in the 128- and 512-conversion fixtures, while the other timings varied. The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 21:18:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T21:18:16Z.


#3791 and #3792 both change the DXIL usage scan. I resolved the overlap in 85e0bea, with 3e0fbaa and 945e5cb as its parents. The shared plan feeds flag collection and the writer, and the i64 regression now exercises that same entry point.

On Windows with Rust 1.98.1, the combined branch passed all 14 bitcode unit tests, with one benchmark ignored. I ran nine generated full translations against main 63bcca4 in five alternating release pairs pinned to one logical CPU. All 45 paired comparisons were byte-identical, and every container passed Microsoft DXIL validation, version 1.9.2609.5.

Each of the nine fixtures used nine fewer allocations. For the 143,188-byte conversion fixture, reallocations went from 1,731 to 1,722. Median paired time ratios ranged from 0.950 to 1.037, with seven fixtures below 1.000. Default and all-features Clippy and the asset policy check passed.

Integration branch. Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the work into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245920075 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3792#issuecomment-7245920075). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T21:18:16Z. --- #3791 and #3792 both change the DXIL usage scan. I resolved the overlap in [`85e0bea`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/85e0beaf6e911a45f2232020cd3885fae3338a4b), with `3e0fbaa` and `945e5cb` as its parents. The shared plan feeds flag collection and the writer, and the i64 regression now exercises that same entry point. On Windows with Rust 1.98.1, the combined branch passed all 14 bitcode unit tests, with one benchmark ignored. I ran nine generated full translations against main `63bcca4` in five alternating release pairs pinned to one logical CPU. All 45 paired comparisons were byte-identical, and every container passed Microsoft DXIL validation, version 1.9.2609.5. Each of the nine fixtures used nine fewer allocations. For the 143,188-byte conversion fixture, reallocations went from 1,731 to 1,722. Median paired time ratios ranged from 0.950 to 1.037, with seven fixtures below 1.000. Default and all-features Clippy and the asset policy check passed. [Integration branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/3791-3792-dxil-plan). Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the work into another commit. AI-assisted with OpenAI Codex.
cloph-dsp commented 2026-11-28 23:08:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T23:08:59Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3792 at head 945e5cb03c55e6ae588518f4a83e6cc597156d18, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::uses_int64_from_a_live_operand_with_a_narrow_result --exact --test-threads=1 --quiet → 1 passed, 0 failed, 305 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check HEAD^ HEAD clean (1 file, +24/-3).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only shader bitcode test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7247233074 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3792#issuecomment-7247233074). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T23:08:59Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3792 at head `945e5cb03c55e6ae588518f4a83e6cc597156d18`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::uses_int64_from_a_live_operand_with_a_narrow_result --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 305 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check HEAD^ HEAD` clean (1 file, +24/-3). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only shader bitcode test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3792:upstream-pr/3792'
git switch 'upstream-pr/3792'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3792'
git switch 'upstream-pr/3792'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3792'
git switch 'upstream-pr/3792'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3792'
git switch 'main'
git merge --squash 'upstream-pr/3792'
git switch 'main'
git merge --ff-only 'upstream-pr/3792'
git switch 'main'
git merge 'upstream-pr/3792'
git push origin 'main'
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!3792
No description provided.