Match the primary shader container by database hash during prebuild #3521

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

@⁠steven-seagull27 on GitHub · 2026-11-27 13:01 UTC · original
steven-seagull27:fix/prebuild-primary-shader-identity → main · +192 −19 · 4 files · 1 commits · open

Two DXBC containers can contain the same native program while differing in metadata. The pack already identifies its primary container by an SGD5 shader hash. Prebuild indexed by native program ID alone, so it could successfully warm a pipeline under a different key from the one requested. With multiple workers, the choice could also depend on which container decompressed first.

This change uses both the native program ID and the database hash to select the compute or vertex/mesh container. The pixel shader still uses its own native program ID. Raw inputs and missing database matches use the first matching container in input order. Pipeline creation and the key-reporting diagnostic use the same lookup.

Regression

The CLI test generates two containers, A and B, with identical native instructions and different metadata. It builds a pack with three records referencing database hashes 11 (A), 22 (B), and 33 (unindexed). It checks the exact pipeline keys for A, B, and fallback A with both one and eight workers.

Validation

  • On the parent, the regression fails at one worker because the second record gets A. With this change, it passes with both one and eight workers.
  • I also ran that generated pack through actual D3D12 prebuild on an RTX 5080 and built-in WARP. The parent persisted one distinct title key (A). The fix persisted both A and B. On both devices the identical native programs shared one host pipeline on the cold run, and the warm pass found all three records already present.
  • A separate generated fixture passed 88/88 stage selections. It exercises compute and graphics primary matches, secondary pixel shaders, wrong-stage and wrong-program matches, raw inputs, and databases without a matching record.
  • All 19 CLI tests passed in both default and diagnostics builds. Workspace formatting, strict Clippy, and the repository asset policy passed.
  • Windows CI passed. On the local RTX 5080 the full default workspace run stopped at two descriptor-heap assertions, also reproduced on unmodified main and tracked in #2937. Continuing through all crates also encountered a shader test process crash on both branches. A storage timing test failed once on the candidate and passed on its own.

Related to #2930. The change addresses ambiguous matches among containers present in the input. The eight shader not found records tracked there remain a separate question.

Developed and tested with Codex assistance.

**@⁠steven-seagull27** on GitHub · 2026-11-27 13:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/3521) `steven-seagull27:fix/prebuild-primary-shader-identity` → `main` · +192 −19 · 4 files · 1 commits · open Two DXBC containers can contain the same native program while differing in metadata. The pack already identifies its primary container by an SGD5 shader hash. Prebuild indexed by native program ID alone, so it could successfully warm a pipeline under a different key from the one requested. With multiple workers, the choice could also depend on which container decompressed first. This change uses both the native program ID and the database hash to select the compute or vertex/mesh container. The pixel shader still uses its own native program ID. Raw inputs and missing database matches use the first matching container in input order. Pipeline creation and the key-reporting diagnostic use the same lookup. ### Regression The CLI test generates two containers, A and B, with identical native instructions and different metadata. It builds a pack with three records referencing database hashes 11 (A), 22 (B), and 33 (unindexed). It checks the exact pipeline keys for A, B, and fallback A with both one and eight workers. ### Validation - On the parent, the regression fails at one worker because the second record gets A. With this change, it passes with both one and eight workers. - I also ran that generated pack through actual D3D12 prebuild on an RTX 5080 and built-in WARP. The parent persisted one distinct title key (A). The fix persisted both A and B. On both devices the identical native programs shared one host pipeline on the cold run, and the warm pass found all three records already present. - A separate generated fixture passed 88/88 stage selections. It exercises compute and graphics primary matches, secondary pixel shaders, wrong-stage and wrong-program matches, raw inputs, and databases without a matching record. - All 19 CLI tests passed in both default and diagnostics builds. Workspace formatting, strict Clippy, and the repository asset policy passed. - [Windows CI passed](https://github.com/Marvisak/VIctory/actions/runs/46003478619/job/140520715040). On the local RTX 5080 the full default workspace run stopped at two descriptor-heap assertions, also reproduced on unmodified main and tracked in #2937. Continuing through all crates also encountered a shader test process crash on both branches. A storage timing test failed once on the candidate and passed on its own. Related to #2930. The change addresses ambiguous matches among containers present in the input. The eight `shader not found` records tracked there remain a separate question. Developed and tested with Codex assistance.
Distinct shader containers can start with the same native program ID. Resolve a compute or vertex/mesh primary using its pack hash, native ID and stage role. Keep native-ID fallback in source order for unknown hashes and secondary stages.

Exercise the normal CLI with generated containers and compare each prepared compute key with the key for its intended container at one and eight workers.

AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:01:27 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-27 13:51 UTC · original

Linux/Wine matched A/B of exact head c9e00b2 vs base 63bcca43 — the regression reproduces the parent failure here and passes on the head. RTX 4060 Laptop 8 GiB, NVIDIA 590.48.1, Wine 11.0, vkd3d-proton 3.2.0 diagnostic build 2576c0b4adfae4a+ (relaxed-vtable; not stock certification), DXVK vendor masking disabled. No title run; no game assets used (the fixture's containers and SGD5 database are synthetic).

Parent control 63bcca43 + this PR's test/manifest/lock files only (production prebuild.rs unchanged): 0/1 FAIL at prebuild_identity.rs:119. The persisted keys file shows all three compute records under one identical key 218f1d7dd72b2b405ca4e3fd6ea4db75 (container A): record 1, named by database hash 22→container B, is warmed under A's key. The CLI itself ran on the physical adapter (real D3D12 pipelines), so this is the warm-miss defect end-to-end on hardware, matching your RTX 5080 result. Evidence verify-pr3521-parent-control-63bcca4-20261127T135040Z/.

Head c9e00b2 (clean worktree): 1/1 pass. Both CLI legs (--jobs 1, --jobs 8) created real pipelines and persisted exactly A, B, A(fallback) — the hash+program-ID lookup selects the right container and the fallback keeps input order. Fresh 8.39 s compile, 2.87 s test. Evidence verify-pr3521-prebuild-identity-c9e00b2-20261127T135010Z/.

Why this matters for the title on this machine (context from our guarded runs, not a matched measurement): a demand-capture trial here recorded 44 lighting compute keys prebuilt yet still demanded at runtime, plus 211 CS_RaytracingResolve variants requested-but-unbuilt. If any of those records' containers share native programs with differently-keyed metadata twins, the parent's ID-only prebuild warms the wrong key and the runtime pays the build (or refuses) again. Your fix removes that class; whether it reduces the 211 unbuilt variants is only testable by a guarded title run after merge onto a stack cleared for runtime trials.

Parent control files restored afterwards; both worktrees left clean at their exact refs. Evidence dirs under .compat-runtime/logs/ with per-run resource samples (peak GPU 250 MiB, min available RAM 10.8 GiB, min disk 15.19 GiB). AI-assisted verification, review-only; no direct PR contributions.

**@⁠pickles976** on GitHub · 2026-11-27 13:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/3521#issuecomment-7220032527) Linux/Wine matched A/B of exact head `c9e00b2` vs base `63bcca43` — the regression reproduces the parent failure here and passes on the head. RTX 4060 Laptop 8 GiB, NVIDIA 590.48.1, Wine 11.0, vkd3d-proton 3.2.0 diagnostic build `2576c0b4adfae4a+` (relaxed-vtable; not stock certification), DXVK vendor masking disabled. No title run; no game assets used (the fixture's containers and SGD5 database are synthetic). **Parent control `63bcca43` + this PR's test/manifest/lock files only (production `prebuild.rs` unchanged): 0/1 FAIL at `prebuild_identity.rs:119`.** The persisted keys file shows all three compute records under **one identical key** `218f1d7dd72b2b405ca4e3fd6ea4db75` (container A): record 1, named by database hash 22→container B, is warmed under A's key. The CLI itself ran on the physical adapter (real D3D12 pipelines), so this is the warm-miss defect end-to-end on hardware, matching your RTX 5080 result. Evidence `verify-pr3521-parent-control-63bcca4-20261127T135040Z/`. **Head `c9e00b2` (clean worktree): 1/1 pass.** Both CLI legs (`--jobs 1`, `--jobs 8`) created real pipelines and persisted exactly A, B, A(fallback) — the hash+program-ID lookup selects the right container and the fallback keeps input order. Fresh 8.39 s compile, 2.87 s test. Evidence `verify-pr3521-prebuild-identity-c9e00b2-20261127T135010Z/`. **Why this matters for the title on this machine (context from our guarded runs, not a matched measurement):** a demand-capture trial here recorded 44 lighting compute keys prebuilt yet still demanded at runtime, plus 211 `CS_RaytracingResolve` variants requested-but-unbuilt. If any of those records' containers share native programs with differently-keyed metadata twins, the parent's ID-only prebuild warms the wrong key and the runtime pays the build (or refuses) again. Your fix removes that class; whether it reduces the 211 unbuilt variants is only testable by a guarded title run after merge onto a stack cleared for runtime trials. Parent control files restored afterwards; both worktrees left clean at their exact refs. Evidence dirs under `.compat-runtime/logs/` with per-run resource samples (peak GPU 250 MiB, min available RAM 10.8 GiB, min disk 15.19 GiB). AI-assisted verification, review-only; no direct PR contributions.
Author
Owner

@⁠oddmaniv on GitHub · 2026-11-27 14:50 UTC · original

Independent verification of the PR author's shader-package parser tests at c9e00b21440ea368d6dabc41a1f7ab63e288b79e.

cargo test --locked -p victory-game --lib shaderpack::tests -- --nocapture

Tree Result
Unmodified PR head 3 passed, 0 failed, 0 ignored; native exit 0
Unmodified main 3 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 3 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

**@⁠oddmaniv** on GitHub · 2026-11-27 14:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3521#issuecomment-7221306196) Independent verification of the PR author's shader-package parser tests at `c9e00b21440ea368d6dabc41a1f7ab63e288b79e`. `cargo test --locked -p victory-game --lib shaderpack::tests -- --nocapture` | Tree | Result | | --- | --- | | Unmodified PR head | 3 passed, 0 failed, 0 ignored; native exit 0 | | Unmodified main | 3 passed, 0 failed, 0 ignored; native exit 0 | | PR patch applied to pinned main | 3 passed, 0 failed, 0 ignored; native exit 0 | Main baseline pin: `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits. This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed. AI-assisted verification.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 14:53 UTC · original

I resolved the conflict with #2787 on 63bcca4. Combined branch 0fc3158 retains both PR histories. Full preparation, the warm-key shortcut, and diagnostics select the same database-matched container. Hashes are computed once per indexed container. The worker still publishes results in input order so the fallback stays deterministic.

I used your A/B fixture on app-local WARP 1.0.22 and first warmed only A. I then added B and the unmatched record, which intentionally falls back to A. The control kept the correct full-preparation lookup and used only the native program ID in the shortcut. It reported all three records as warm and left one saved key. The combined branch saved both exact keys, and a repeat found all three records already warm.

The original one-worker/eight-worker regression, all 19 CLI tests, 16 victory-game tests, and the GPU shortcut/full-key equivalence test passed. Strict Clippy for the three affected crates and the asset policy also passed.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 14:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/3521#issuecomment-7221349444) I resolved the conflict with #2787 on `63bcca4`. [Combined branch `0fc3158`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/prebuild-database-identity-and-warm-keys) retains both PR histories. Full preparation, the warm-key shortcut, and diagnostics select the same database-matched container. Hashes are computed once per indexed container. The worker still publishes results in input order so the fallback stays deterministic. I used your A/B fixture on app-local WARP 1.0.22 and first warmed only A. I then added B and the unmatched record, which intentionally falls back to A. The control kept the correct full-preparation lookup and used only the native program ID in the shortcut. It reported all three records as warm and left one saved key. The combined branch saved both exact keys, and a repeat found all three records already warm. The original one-worker/eight-worker regression, all 19 CLI tests, 16 `victory-game` tests, and the GPU shortcut/full-key equivalence test passed. Strict Clippy for the three affected crates and the asset policy also passed.
This pull request can be merged automatically.
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/3521/head:github-bot/gh-3521'
git switch 'github-bot/gh-3521'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3521'
git switch 'github-bot/gh-3521'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3521'
git switch 'github-bot/gh-3521'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3521'
git switch 'main'
git merge --squash 'github-bot/gh-3521'
git switch 'main'
git merge --ff-only 'github-bot/gh-3521'
git switch 'main'
git merge 'github-bot/gh-3521'
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!3521
No description provided.