Shaders: reuse the DXIL emit plan when collecting shader flags #3791

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

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


Build the DXIL emission plan once and use it for both instruction-usage flags and bitcode writing. The analysis runs after the instructions and branches are final. The remaining work appends entry metadata and its values.

In four generated branch-heavy modules, 17 paired Windows release measurements put analysis plus writing at 0.798x to 0.826x the previous time. The largest fixture emitted the same 185,872 bytes with 1,036 to 543 allocations and 83 to 62 reallocations.

Nine generated full translations also emitted byte-identical DXIL and passed the signed validator. In five alternating pairs pinned to one CPU, the per-module median elapsed-time ratios were 0.943x to 0.991x. The metadata/plan regression, 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:5544407142 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3791). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T20:45:03Z. --- Build the DXIL emission plan once and use it for both instruction-usage flags and bitcode writing. The analysis runs after the instructions and branches are final. The remaining work appends entry metadata and its values. In four generated branch-heavy modules, 17 paired Windows release measurements put analysis plus writing at 0.798x to 0.826x the previous time. The largest fixture emitted the same 185,872 bytes with 1,036 to 543 allocations and 83 to 62 reallocations. Nine generated full translations also emitted byte-identical DXIL and passed the signed validator. In five alternating pairs pinned to one CPU, the per-module median elapsed-time ratios were 0.943x to 0.991x. The metadata/plan regression, 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 20:50:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T20:50:15Z.


Windows CI passed on 3e0fbaa, including both Clippy configurations and the workspace tests. The local Windows A/B check emitted 9 byte-identical complete DXIL modules, all accepted by the signed Microsoft DXIL validator. Their median elapsed times were 0.943–0.991× baseline across five alternating pairs. The four branch-heavy bitcode fixtures emitted identical bytes with median times of 0.798–0.826× baseline. In the largest case (185,872 bytes), the fixture counted 1,036 → 543 allocations and 83 → 62 reallocations.

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:7245576960 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3791#issuecomment-7245576960). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T20:50:15Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46188020087/job/141112212242) passed on 3e0fbaa, including both Clippy configurations and the workspace tests. The local Windows A/B check emitted 9 byte-identical complete DXIL modules, all accepted by the signed Microsoft DXIL validator. Their median elapsed times were 0.943–0.991× baseline across five alternating pairs. The four branch-heavy bitcode fixtures emitted identical bytes with median times of 0.798–0.826× baseline. In the largest case (185,872 bytes), the fixture counted 1,036 → 543 allocations and 83 → 62 reallocations. 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.
cloph-dsp commented 2026-11-28 23:09:00 +00:00 (Migrated from github.com)

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


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

  • PR #3791 at head 3e0fbaa42fa4a6b9ffb12dcf0b9493a81f2cbdd0, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::planned_module_may_append_metadata_before_emission --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 (2 files, +49/-23).
  • 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:7247233320 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3791#issuecomment-7247233320). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T23:09:00Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3791 at head `3e0fbaa42fa4a6b9ffb12dcf0b9493a81f2cbdd0`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::planned_module_may_append_metadata_before_emission --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 (2 files, +49/-23). - 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/3791:upstream-pr/3791'
git switch 'upstream-pr/3791'

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