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

Open
erax4193 wants to merge 18 commits from upstream-pr/2478 into main
erax4193 commented 2026-11-29 13:25:53 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by erax4193 on 2026-11-29T13:25:53Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5551152952 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478). Originally posted by [erax4193](https://github.com/erax4193) on 2026-11-29T13:25:53Z. --- ## 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)
andrewpozdnakov7-jpg commented 2026-11-30 09:14:06 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-11-30T09:14:06Z.


#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]>.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7273923103 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7273923103). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-30T09:14:06Z. --- #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]>`.
andrewpozdnakov7-jpg commented 2026-11-30 11:21:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-11-30T11:21:49Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7276919855 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7276919855). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-30T11:21:49Z. --- 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://github.com/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://github.com/trustno1-coder/VIctory-NVIDIA/pull/3210#issuecomment-7277628476) make all 11 shader-cache tests pass on GitHub's exact merge tree `099b02a` locally. AI-assisted with OpenAI Codex.
GeNiY256exe commented 2026-11-30 11:33:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by GeNiY256exe on 2026-11-30T11:33:43Z.


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,
})

}


<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7277201631 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7277201631). Originally posted by [GeNiY256exe](https://github.com/GeNiY256exe) on 2026-11-30T11:33:43Z. --- 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 commented 2026-11-30 11:37:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by GeNiY256exe on 2026-11-30T11:37:41Z.


Для меня ничего не изменилось. Я вношу изменения в 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":

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7277293959 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2478#issuecomment-7277293959). Originally posted by [GeNiY256exe](https://github.com/GeNiY256exe) on 2026-11-30T11:37:41Z. --- > Для меня ничего не изменилось. Я вношу изменения в 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":
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/2478:upstream-pr/2478'
git switch 'upstream-pr/2478'

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