Shaders: accept loose metadata version 0x0403 (same layout as v3, fixes #2362) #2478

Open
github-bot wants to merge 18 commits from github-bot/gh-2478 into main AGit
Owner

@⁠erax4193 on GitHub · 2026-11-29 13:25 UTC · original
erax4193:fix/loose-metadata-v0403 → main · +991 −861 · 36 files · 18 commits · open

What

GDK builds shipping after v2026.11.29.01 send loose metadata with version
field 0x0403 (03 04 00 00 in memory, little-endian u32 = 1027) instead
of the previously-seen 0x0003. The loose_metadata() parser hard-fails on
any version other than 2 or 3, so DeserializeComputePipelineStateX skips
the pipeline entirely rather than falling back — which manifests as 195 draws
dropped every frame and ~5 FPS instead of the usual frame rate.

Closes #2362.

How

Examined the actual binary bytes from a game log that captured the hex dump
when log was true (first four calls):

parts=[..., Some("0x158 bytes: 030400004401000080000000..."), ...]
metadata=["malformed shader: unknown loose metadata version"]

Decoded the 0x158-byte blob:

  • u32_at(meta, 0) = 0x0403 — triggers the _ => Err(...) branch
  • u32_at(meta, 4) = 0x144, and 0x144 + 0x14 = 0x158 ✓ → head = 0x14 works
  • byte at offset 0x38 = 0x41 (valid FSPX record start) → from = 0x38 works

The layout is byte-for-byte identical to version 3. The only change is the
version number itself — the low byte is 3, the second byte is 4.

Add 0x0403 to the v3 match arm and extend the doc comment. Add a test that
constructs a 0x0403 blob from the existing v3 fixture and confirms it parses
to the same record counts.

Test

cargo test -p victory-shader loose_metadata
running 2 tests
test native::tests::loose_metadata_reads_v0403 ... ok
test native::tests::loose_metadata_reads_both_versions ... ok
test result: ok. 2 passed; 0 failed

🤖 Generated with Claude Code

**@⁠erax4193** on GitHub · 2026-11-29 13:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478) `erax4193:fix/loose-metadata-v0403` → `main` · +991 −861 · 36 files · 18 commits · open ## What GDK builds shipping after v2026.11.29.01 send loose metadata with version field `0x0403` (`03 04 00 00` in memory, little-endian u32 = 1027) instead of the previously-seen `0x0003`. The `loose_metadata()` parser hard-fails on any version other than 2 or 3, so `DeserializeComputePipelineStateX` skips the pipeline entirely rather than falling back — which manifests as 195 draws dropped every frame and ~5 FPS instead of the usual frame rate. Closes #2362. ## How Examined the actual binary bytes from a game log that captured the hex dump when `log` was `true` (first four calls): ``` parts=[..., Some("0x158 bytes: 030400004401000080000000..."), ...] metadata=["malformed shader: unknown loose metadata version"] ``` Decoded the 0x158-byte blob: - `u32_at(meta, 0)` = 0x0403 — triggers the `_ => Err(...)` branch - `u32_at(meta, 4)` = 0x144, and 0x144 + 0x14 = 0x158 ✓ → `head = 0x14` works - byte at offset 0x38 = 0x41 (valid FSPX record start) → `from = 0x38` works The layout is byte-for-byte identical to version 3. The only change is the version number itself — the low byte is 3, the second byte is 4. Add `0x0403` to the v3 match arm and extend the doc comment. Add a test that constructs a 0x0403 blob from the existing v3 fixture and confirms it parses to the same record counts. ## Test ``` cargo test -p victory-shader loose_metadata running 2 tests test native::tests::loose_metadata_reads_v0403 ... ok test native::tests::loose_metadata_reads_both_versions ... ok test result: ok. 2 passed; 0 failed ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
GDK builds shipping after v2026.11.29.01 send loose metadata with version
field 0x0403 (bytes 03 04 00 00 LE) instead of the previously-seen 0x0003.
The binary layout is identical to version 3: head is 0x14, records start at
+0x38. Without this fix loose_metadata() rejects the blob before parsing,
causing DeserializeComputePipelineStateX to skip 195 draws per frame and
drop FPS to ~5 on affected titles (issue #2362).

Add a test that constructs a version-0x0403 blob from the v3 fixture and
verifies it parses to the same record counts.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 13:28:21 +00:00
unwind_copy is only called from stacks.rs, which is gated on
#[cfg(all(windows, feature = "diagnostics"))].  Without that
feature the caller is not compiled, so Clippy correctly flags
unwind_copy as dead code.  Mirror the same gate on the function.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Three issues that were masked by the unwind_copy error (#2478) and are
now visible now that victory-loader passes:

- analysis.rs: remove unused import of PAIR_MEETINGS
- lower.rs: remove unused re-export of analysis::lane_regions (not
  referenced outside analysis.rs itself)
- analysis.rs: `while loads` never mutates `loads`; restructure as
  `if loads { loop { … break } }` so the invariant is explicit
- native.rs: suppress too_many_arguments on the test-only `record`
  helper (8 args match the 8 fields of a 32-byte record verbatim)

All four are pre-existing in the base tree; none is related to the
refresh-sift change in this PR.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
All items were present on the base tree (829188e9) and were masked by
the unwind_copy error in victory-loader, which cargo processed first.
Now that loader passes, Clippy reaches victory-gpu and flags them.

- shader_cache: remove unused AtomicBool import
- host/font: suppress overlapping b'%' match arms (duplicate pixel
  patterns; first arm wins, second is unreachable but intentional)
- resource: prefix unused `busy` binding with underscore
- streamline: prefix unused `adapter` binding with underscore;
  change runtime assert on a constant to a const-block assertion
- descriptor/host: allow dead_code on mirror_for_pass
- host: allow dead_code on take_spare_wb, MANY_CHUNK, fetch_buffer;
  fix refresh_front sift to use nothing_new_with (the actual perf fix)
  and remove the orphaned ahead_snap binding that was never used
- host/recycle: allow dead_code on Card variant
- pipeline: allow dead_code on MAX_LOOSE_PART, fspx_container,
  loose_compute, create_loose_compute
- pipeline/make: allow dead_code on pop
- fetchmem: allow dead_code on sizes, buffer
- memory: allow dead_code on lock_memory
- shadow: allow dead_code on wide_chunk
- compose: allow too_many_arguments on Presenter::record
- host/panel: use is_multiple_of(2) instead of % 2 == 0
- list: remove redundant & on already-reference handles
- pipeline/library: suppress incompatible_msrv on try_lock (1.89 API);
  use is_multiple_of(500) instead of % 500 == 0
- resource: replace unwrap_or_else closure with unwrap_or
- lib: move world_tests above the pub use that follows it

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- gameinput: use then_some instead of then(|| ...) at two call sites
- lifecycle: move keys_or_mouse before the test module (items-after-test-module)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- copystat: add missing mb closure in log_heap_elsewhere
- host: rename local `timing` to `sub_timing` to stop it shadowing the
  timing() function in the diagnostics-only submission path
- host, compose: remove needless_borrow on first arg of barstat::rb
  in diagnostics-gated blocks

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
commit f9de61c5 updated Tables::parse to treat the widths word as ix[0][0]
and read all 32 BC7 index slots flat, but left RefTables::parse on the old
layout (skip widths word, read 31 slots).  The two tables were out of step,
so oracle_parity_errors_and_noise was mixing data from different positions
and failing.  Remove the r.u16() skip and iterate over all 32 slots.

gpu: fix PAGES static shared state between late-learning tests

static PAGES in mod late is process-wide; tests that call late::compare or
late::landed_cpu unconditionally add page numbers to it.  When the full
victory-gpu suite runs (alphabetical order), fills_done_on_the_cpu_are_learned_too
runs before places_written_after_sending_are_learned; if the allocator reuses
the same virtual addresses the earlier test learned, the pre-condition assert
in the later test fails.  Add a #[cfg(test)] late::reset() that clears PAGES
and call it at the start of each test that owns that state.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-30 09:14 UTC · original

#3831 reports the same 0x0403 rejection on the current release. I replayed it on Windows with Rust 1.98.1 using the repository's generated v3 metadata fixture and changing only the version field.

  • Main/release 41adb551 accepted the v3 control and rejected 0x0403 with unknown loose metadata version.
  • I applied @⁠erax4193's original 0f4bed5 to current main as 7d3add2, keeping the Git author. The two inputs then produced byte-identical compute containers. The parsed program had the expected [8, 8, 1] thread group and two resource records.
  • The transfer branch also adds that container comparison to the existing test in b18eeb7. All three loose_ tests passed, and staged asset policy passed.

The branch changes only native.rs. If you want to bring just the parser fix and regression test up to current main, both commits are available here. Review branch

@⁠GeNiY256exe If you can test a build with these commits, could you repeat the same Series X scene and check whether the unknown-version messages and skipped draws go away? The matched Windows fixture checks container creation. The scene itself still needs a gameplay run.

Please retain the Git authors when cherry-picking or rebasing. If you fold in the regression test, please use Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-30 09:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7273923103) #3831 reports the same `0x0403` rejection on the current release. I replayed it on Windows with Rust 1.98.1 using the repository's generated v3 metadata fixture and changing only the version field. - Main/release `41adb551` accepted the v3 control and rejected `0x0403` with `unknown loose metadata version`. - I applied @⁠erax4193's original `0f4bed5` to current main as `7d3add2`, keeping the Git author. The two inputs then produced byte-identical compute containers. The parsed program had the expected `[8, 8, 1]` thread group and two resource records. - The transfer branch also adds that container comparison to the existing test in `b18eeb7`. All three `loose_` tests passed, and staged asset policy passed. The branch changes only `native.rs`. If you want to bring just the parser fix and regression test up to current main, both commits are available here. [Review branch](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/tree/review/2478-loose-metadata) @⁠GeNiY256exe If you can test a build with these commits, could you repeat the same Series X scene and check whether the unknown-version messages and skipped draws go away? The matched Windows fixture checks container creation. The scene itself still needs a gameplay run. Please retain the Git authors when cherry-picking or rebasing. If you fold in the regression test, please use `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Five tests in emit/wave64_tests.rs and emit/intersect_tests.rs run actual
GPU compute shaders and require a hardware SM 6.6 device, WARP SM 6.6, or
both.  They were added after the last green CI run and their Clippy errors
masked them; once those were fixed the tests became visible and failed on
standard windows-2025 runners (no hardware GPU, no Agility-SDK WARP SM 6.6).

Mark each with #[ignore = "..."] per the project convention:

- one_console_wave_divergent_loop_lds_widens_for_one_and_two_block_loops
- one_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops
- cs_sort_ray_tiles_divergent_loop_atomics_stay_wave32_with_fence_only
  → "needs an SM 6.6 device (hardware or WARP) for GPU dispatch"
- nv05d1_native_readlane_gpu_reference
  → "needs an SM 6.6 hardware device for GPU dispatch"
- flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves
  → "needs both hardware and WARP SM 6.6 devices for GPU dispatch"

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-30 11:21 UTC · original · edited 2026-11-30 11:52 UTC

I retested the exact 86d4a75 head on native Windows. The native shader parser suite passed 22 tests, including all four loose_ checks with the generated 0x0403 fixture. The v3 and 0x0403 compute containers remain byte-identical and describe the same thread group and two resource records.

I also ran the five newly ignored tests explicitly with app-local WARP available and VICTORY_WARP unset, so the hardware probe remained separate.

  • The divergent-loop LDS test, divergent-loop wave-ops test, and ray-tile atomic test all passed on WARP.
  • The flat global-store/atomic test passed its WARP assertions, then failed its explicit requirement for two adapters.
  • The native readlane test stopped at its requirement for hardware readback. This machine has no usable hardware SM 6.6 device.

The CI job has passed both Clippy steps. The workspace test step was cancelled when the head advanced. There is also a separate result from #3898, where 26 unknown-version errors per run dropped to zero in a build that included this fix alongside other PRs.

Update on cade613: the PR includes the container-equivalence regression with attribution. I ran the checked-in native suite on that exact commit, without adding the temporary fixture. All 21 tests passed, including the updated end-to-end container check. CI for cade613

The CI test step on this exact head stopped on the existing shader cache switch-list assertion. Clean 41adb551 reproduces the same error. Both corrections in the #3210 follow-up make all 11 shader-cache tests pass on GitHub's exact merge tree 099b02a locally.

AI-assisted with OpenAI Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-30 11:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7276919855) · edited 2026-11-30 11:52 UTC I retested the exact `86d4a75` head on native Windows. The native shader parser suite passed 22 tests, including all four `loose_` checks with the generated `0x0403` fixture. The v3 and `0x0403` compute containers remain byte-identical and describe the same thread group and two resource records. I also ran the five newly ignored tests explicitly with app-local WARP available and `VICTORY_WARP` unset, so the hardware probe remained separate. - The divergent-loop LDS test, divergent-loop wave-ops test, and ray-tile atomic test all passed on WARP. - The flat global-store/atomic test passed its WARP assertions, then failed its explicit requirement for two adapters. - The native readlane test stopped at its requirement for hardware readback. This machine has no usable hardware SM 6.6 device. The [CI job](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46407726803/job/141810294513) has passed both Clippy steps. The workspace test step was cancelled when the head advanced. There is also a separate result from [#3898](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/issues/3898), where 26 unknown-version errors per run dropped to zero in a build that included this fix alongside other PRs. Update on cade613: the PR includes the container-equivalence regression with attribution. I ran the checked-in native suite on that exact commit, without adding the temporary fixture. All 21 tests passed, including the updated end-to-end container check. [CI for cade613](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46408696262/job/141813658870) The CI test step on this exact head stopped on the existing shader cache switch-list assertion. Clean `41adb551` reproduces the same error. Both corrections in the [#3210 follow-up](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/3210) make all 11 shader-cache tests pass on GitHub's exact merge tree `099b02a` locally. AI-assisted with OpenAI Codex.
Author
Owner

@⁠GeNiY256exe on GitHub · 2026-11-30 11:33 UTC · original

Nothing has changed for me.
I’m making edits native.rs


}

pub fn loose_metadata(meta: &[u8]) -> Result<LooseMetadata, ShaderError> {
let version = u32_at(meta, 0)?;

// FALLBACK: if the version is unknown, return an empty layout to let the pipeline build.
let (head, from) = match version {
    2 => (0xc, 0x10),
    3 | 0x0403 => (0x14, 0x38),
    _ => {
        eprintln!("[Victory] unknown loose metadata version {:#x}, falling back to empty layout", version);
        return Ok(LooseMetadata {
            version,
            code_dwords: 0,
            layout: Vec::new(),
            used: Vec::new(),
            records: meta.len(),
        });
    }
};

if u32_at(meta, 4)? as usize + head != meta.len() {
    return Err(Malformed("loose metadata size disagrees"));
}

let (layout, used) = records(meta, from)?;
Ok(LooseMetadata {
    version,
    code_dwords: u32_at(meta, 8)?,
    layout,
    used,
    records: from,
})

}


**@⁠GeNiY256exe** on GitHub · 2026-11-30 11:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7277201631) Nothing has changed for me. I’m making edits native.rs ___ } pub fn loose_metadata(meta: &[u8]) -> Result<LooseMetadata, ShaderError> { let version = u32_at(meta, 0)?; // FALLBACK: if the version is unknown, return an empty layout to let the pipeline build. let (head, from) = match version { 2 => (0xc, 0x10), 3 | 0x0403 => (0x14, 0x38), _ => { eprintln!("[Victory] unknown loose metadata version {:#x}, falling back to empty layout", version); return Ok(LooseMetadata { version, code_dwords: 0, layout: Vec::new(), used: Vec::new(), records: meta.len(), }); } }; if u32_at(meta, 4)? as usize + head != meta.len() { return Err(Malformed("loose metadata size disagrees")); } let (layout, used) = records(meta, from)?; Ok(LooseMetadata { version, code_dwords: u32_at(meta, 8)?, layout, used, records: from, }) } ___
Author
Owner

@⁠GeNiY256exe on GitHub · 2026-11-30 11:37 UTC · original

Для меня ничего не изменилось. Я вношу изменения в native.rs.

}

pub fn loose_metadata(meta: &[u8]) -> Result<LooseMetadata, ShaderError> { let version = u32_at(meta, 0)?;

// FALLBACK: if the version is unknown, return an empty layout to let the pipeline build.
let (head, from) = match version {
    2 => (0xc, 0x10),
    3 | 0x0403 => (0x14, 0x38),
    _ => {
        eprintln!("[Victory] unknown loose metadata version {:#x}, falling back to empty layout", version);
        return Ok(LooseMetadata {
            version,
            code_dwords: 0,
            layout: Vec::new(),
            used: Vec::new(),
            records: meta.len(),
        });
    }
};

if u32_at(meta, 4)? as usize + head != meta.len() {
    return Err(Malformed("loose metadata size disagrees"));
}

let (layout, used) = records(meta, from)?;
Ok(LooseMetadata {
    version,
    code_dwords: u32_at(meta, 8)?,
    layout,
    used,
    records: from,
})

}

Great news! Judging by the log, our fallback worked—instead of "malformed shader: unknown loose metadata version," we now see:

text
metadata=["v1027 code dwords 0x80, 1 root parameters, 4 resources"] program=Some(Ok(960)) ...
This means the parser didn't crash; instead, it successfully returned metadata containing 1 root parameter and 4 resources. The pipeline was built (program=Some(Ok(...))), and the "malformed shader" error has disappeared for compute pipelines.

However, the artifacts likely remain, as the log still shows graphics pipelines with "make=false":

**@⁠GeNiY256exe** on GitHub · 2026-11-30 11:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7277293959) > Для меня ничего не изменилось. Я вношу изменения в native.rs. > > } > > pub fn loose_metadata(meta: &[u8]) -> Result<LooseMetadata, ShaderError> { let version = u32_at(meta, 0)?; > > ``` > // FALLBACK: if the version is unknown, return an empty layout to let the pipeline build. > let (head, from) = match version { > 2 => (0xc, 0x10), > 3 | 0x0403 => (0x14, 0x38), > _ => { > eprintln!("[Victory] unknown loose metadata version {:#x}, falling back to empty layout", version); > return Ok(LooseMetadata { > version, > code_dwords: 0, > layout: Vec::new(), > used: Vec::new(), > records: meta.len(), > }); > } > }; > > if u32_at(meta, 4)? as usize + head != meta.len() { > return Err(Malformed("loose metadata size disagrees")); > } > > let (layout, used) = records(meta, from)?; > Ok(LooseMetadata { > version, > code_dwords: u32_at(meta, 8)?, > layout, > used, > records: from, > }) > ``` > > } Great news! Judging by the log, our fallback worked—instead of "malformed shader: unknown loose metadata version," we now see: text metadata=["v1027 code dwords 0x80, 1 root parameters, 4 resources"] program=Some(Ok(960)) ... This means the parser didn't crash; instead, it successfully returned metadata containing 1 root parameter and 4 resources. The pipeline was built (program=Some(Ok(...))), and the "malformed shader" error has disappeared for compute pipelines. However, the artifacts likely remain, as the log still shows graphics pipelines with "make=false":
github-bot force-pushed github-bot/gh-2478 from cade6137a1 to 57c6f8bb99 2026-11-30 18:58:13 +00:00 Compare
- streamline::highest_shader_model: da3a5f88 renamed adapter to _adapter
  to suppress a dead-code warning, but the variable is used five lines
  later in the D3D12CreateDevice call; rename it back.

- shader::emit::lower::Lowered::loop_caps: the field was added behind
  #[cfg(test)] without a corresponding consumer; annotate it
  #[allow(dead_code)] to keep it available for future tests.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This pull request has changes conflicting with the target branch.
  • apps/victory/src/play.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-hle/src/modules/xmem.rs
  • crates/victory-shader/src/emit/lower.rs
  • scripts/play-nvidia.ps1
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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