GPU: deserialize console pipeline states #3586

Open
github-bot wants to merge 2 commits from github-bot/gh-3586 into main AGit
Owner

@⁠kotekompotek on GitHub · 2026-11-27 19:15 UTC · original
kotekompotek:gpu/offline-pipeline-deserialize → main · +1095 −1 · 5 files · 2 commits · open

Device slots 56/57/66/67 — the console offline-pipeline (de)serialization entry points — are now wired and implemented. GTA VI uses both deserializers with IID_ID3D12PipelineState during boot: graphics through a 0x108-byte description (root signature, two fixed-function state blobs, seven stage blocks) and compute through a 0x48-byte description (root signature plus kind 0/1/6/7 payloads). Previously the slots were absent, so every serialized pipeline lookup failed — leaving the title's pipeline tables incomplete.

What is in it

  • vtable wiring at the exact measured offsets: serializers 56 (0x1c0) / 66 (0x210) return E_ACCESSDENIED (serialization is an offline content-build operation), deserializers 57 (0x1c8) / 67 (0x218) implemented.
  • Strict ABI validation with compile-time layout assertions: zero-size pairs are absent even when the pointer is non-null, null data with non-zero size is malformed, inputs capped at 16 MiB, accepted bytes copied before use, output nulled before validation, correct E_POINTER/E_NOINTERFACE/E_INVALIDARG behavior.
  • Real compute deserialization: the four kind payloads are deterministically reconstructed into an FSPX container wrapped as a minimal DXBC/ACCC part and passed through the existing shader()/lazy-translation/hand-out path — identical descriptions share the shader-container cache, and the synthetic compute shader translates successfully through the real emit path.
  • Graphics baseline: strict parsing of the 0x108-byte description (state blob B required, measured state blob A shape enforced, stage blocks independently optional), validated copies retained in the pipeline object for later fixed-function/native-program work. Returns a normal reference-counted lazy pipeline object: binding is safe, draws go through the existing no-host-pipeline drop path rather than crashing.
  • tracing::debug! logs pair sizes and short BLAKE3 hashes for real-game evidence.
  • Deliberately out of scope (follow-ups): fixed-function state decode, graphics native-program translation, digest-based container resolution.

Tested

  • Windows 10 Pro 19045, i5-8300H, GTX 1050 (driver 32.0.15.8228), Rust 1.98.1 MSVC, debug.
  • 11 new focused tests: exact vtable offsets, COM validation matrix, pair validation, FSPX/DXBC reconstruction, successful real translation of the synthetic compute shader, end-to-end non-null compute pipeline creation, shader-container sharing, AddRef/Release lifetime, graphics lazy-pipeline retention, binding without panic.
  • cargo test --locked -p victory-gpu --lib: 236 passed / 6 failed / 1 ignored — the 6 failures are the documented environmental baseline on this machine (bit-identical set on unmodified main: no SM 6.6, GTX 1050 driver, frame-timing flake); +11 vs baseline are the new tests.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings clean.
  • cargo test --locked -p xtask: 6 passed — repository policy green.

Not tested
Real-game boot behavior (run planned as a follow-up — will be reported in comments); fixed-function state correctness (not decoded yet); graphics shader translation (future work).

AI use: design informed by static analysis of the title's call sites; implementation and verification AI-assisted (Devin / SWE-2.1).

**@⁠kotekompotek** on GitHub · 2026-11-27 19:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/3586) `kotekompotek:gpu/offline-pipeline-deserialize` → `main` · +1095 −1 · 5 files · 2 commits · open Device slots 56/57/66/67 — the console offline-pipeline (de)serialization entry points — are now wired and implemented. GTA VI uses both deserializers with `IID_ID3D12PipelineState` during boot: graphics through a 0x108-byte description (root signature, two fixed-function state blobs, seven stage blocks) and compute through a 0x48-byte description (root signature plus kind 0/1/6/7 payloads). Previously the slots were absent, so every serialized pipeline lookup failed — leaving the title's pipeline tables incomplete. **What is in it** - vtable wiring at the exact measured offsets: serializers 56 (`0x1c0`) / 66 (`0x210`) return `E_ACCESSDENIED` (serialization is an offline content-build operation), deserializers 57 (`0x1c8`) / 67 (`0x218`) implemented. - Strict ABI validation with compile-time layout assertions: zero-size pairs are absent even when the pointer is non-null, null data with non-zero size is malformed, inputs capped at 16 MiB, accepted bytes copied before use, output nulled before validation, correct `E_POINTER`/`E_NOINTERFACE`/`E_INVALIDARG` behavior. - **Real compute deserialization**: the four kind payloads are deterministically reconstructed into an FSPX container wrapped as a minimal DXBC/ACCC part and passed through the existing `shader()`/lazy-translation/hand-out path — identical descriptions share the shader-container cache, and the synthetic compute shader translates successfully through the real emit path. - **Graphics baseline**: strict parsing of the 0x108-byte description (state blob B required, measured state blob A shape enforced, stage blocks independently optional), validated copies retained in the pipeline object for later fixed-function/native-program work. Returns a normal reference-counted lazy pipeline object: binding is safe, draws go through the existing no-host-pipeline drop path rather than crashing. - `tracing::debug!` logs pair sizes and short BLAKE3 hashes for real-game evidence. - Deliberately out of scope (follow-ups): fixed-function state decode, graphics native-program translation, digest-based container resolution. **Tested** - Windows 10 Pro 19045, i5-8300H, GTX 1050 (driver 32.0.15.8228), Rust 1.98.1 MSVC, debug. - 11 new focused tests: exact vtable offsets, COM validation matrix, pair validation, FSPX/DXBC reconstruction, successful real translation of the synthetic compute shader, end-to-end non-null compute pipeline creation, shader-container sharing, AddRef/Release lifetime, graphics lazy-pipeline retention, binding without panic. - `cargo test --locked -p victory-gpu --lib`: 236 passed / 6 failed / 1 ignored — the 6 failures are the documented environmental baseline on this machine (bit-identical set on unmodified main: no SM 6.6, GTX 1050 driver, frame-timing flake); +11 vs baseline are the new tests. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` clean. - `cargo test --locked -p xtask`: 6 passed — repository policy green. **Not tested** Real-game boot behavior (run planned as a follow-up — will be reported in comments); fixed-function state correctness (not decoded yet); graphics shader translation (future work). AI use: design informed by static analysis of the title's call sites; implementation and verification AI-assisted (Devin / SWE-2.1).
Wire device slots 56/57/66/67. The serializers answer E_ACCESSDENIED. Compute descriptions are checked, rebuilt as FSPX in an ACCC container, and enter the ordinary shader and pipeline path. Graphics descriptions keep validated copies of their serialized blobs in lazy pipeline objects whose draws fall through the existing no-host-pipeline drop path.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:18:09 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-27 19:35 UTC · original

Real-title boot test of head 7b85a1a3 (GTA VI game_scarlett_master.exe, GTX 1050, debug build with diagnostics, VICTORY_LOG=info,victory_gpu::pipeline::deserialize=debug):

The deserializers are heavily exercised immediately — 2,695 successful operations: 1,026 compute (kind0=28B/kind1=20B always; 178 unique kind6 shader hashes, 256B–26KB programs) and 1,669 graphics (state_a 380–480B in the measured families; state_b 80–224B; stage combinations overwhelmingly 0+1, mesh stage 2 in 25 cases). Input shapes match the reverse-engineered formats. Compute/deserialize input tuples are all unique; no malformed-input rejections are visible — though see the instrumentation caveat below.

Boot proceeds identically to before (frame 1024 at ~48 s, all draws dropped on this SM-6.2-capped machine as expected), and the original crash is unchanged: 0xc0000005 reading [null+0x68] at image+0xb5a5f8 at ~59 s, same two thread stack shapes as baseline. So returning valid lazy pipeline objects for accepted descriptions is not by itself sufficient to populate the null effect-variant entries — the hypothesis is cleanly falsified in its simple form, which narrows the search considerably.

New observational leads from this run:

  1. The last successful deserialize is at +17.7 s but the crash is at +59.5 s — a 42 s gap in which either no deserialize calls happen or calls are rejected. Only successes are currently logged — E_INVALIDARG/E_NOINTERFACE rejections are invisible; this is the biggest observational gap.
  2. One unimplemented device method fires once right in the deserialize-init period: slot 0x1b8 (index 55) with pointer arguments — per the console vtable map this is the derived-PSO creation entry point, a plausible source of the missing effect-variant entries (variant pipelines are typically derived from base pipelines).
  3. Mesh-stage (2) pipelines exist in the wild: 19 with stages 0+2, 6 stage-2-only.

Instrumentation follow-ups in progress locally: failure-path logging and investigation of slot 55. This PR remains the correct foundation regardless — the 2,695 successful deserializations are real work the runtime previously couldn't do at all.

**@⁠kotekompotek** on GitHub · 2026-11-27 19:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3586#issuecomment-7226678433) **Real-title boot test of head `7b85a1a3`** (GTA VI `game_scarlett_master.exe`, GTX 1050, debug build with diagnostics, `VICTORY_LOG=info,victory_gpu::pipeline::deserialize=debug`): The deserializers are heavily exercised immediately — **2,695 successful operations**: 1,026 compute (kind0=28B/kind1=20B always; 178 unique kind6 shader hashes, 256B–26KB programs) and 1,669 graphics (state_a 380–480B in the measured families; state_b 80–224B; stage combinations overwhelmingly 0+1, mesh stage 2 in 25 cases). Input shapes match the reverse-engineered formats. Compute/deserialize input tuples are all unique; no malformed-input rejections are visible — though see the instrumentation caveat below. Boot proceeds identically to before (frame 1024 at ~48 s, all draws dropped on this SM-6.2-capped machine as expected), and the original crash is **unchanged**: `0xc0000005` reading `[null+0x68]` at image+0xb5a5f8 at ~59 s, same two thread stack shapes as baseline. So returning valid lazy pipeline objects for accepted descriptions is not by itself sufficient to populate the null effect-variant entries — the hypothesis is cleanly falsified in its simple form, which narrows the search considerably. New observational leads from this run: 1. The last successful deserialize is at +17.7 s but the crash is at +59.5 s — a 42 s gap in which either no deserialize calls happen or calls are rejected. **Only successes are currently logged** — `E_INVALIDARG`/`E_NOINTERFACE` rejections are invisible; this is the biggest observational gap. 2. One unimplemented device method fires once right in the deserialize-init period: **slot `0x1b8` (index 55)** with pointer arguments — per the console vtable map this is the derived-PSO creation entry point, a plausible source of the missing effect-variant entries (variant pipelines are typically derived from base pipelines). 3. Mesh-stage (2) pipelines exist in the wild: 19 with stages 0+2, 6 stage-2-only. Instrumentation follow-ups in progress locally: failure-path logging and investigation of slot 55. This PR remains the correct foundation regardless — the 2,695 successful deserializations are real work the runtime previously couldn't do at all.
Author
Owner

@⁠upipibi on GitHub · 2026-11-27 23:33 UTC · original

A risk with the graphics half, read from the code at 1960fa5 and not run (I don't run the title):

  • Main today. Slots 57/67 come from missing_table (device.rs:394), so a deserialize returns E_NOTIMPL, and main reaches the world with its pipelines. xcl does the same: its deserialize_pso_x returns E_NOTIMPL with the note "the title creates the pipeline from its desc" (xcl hle/d3d12x/device_x.rs:581-592), and it renders the world too.
  • With this PR. deserialize::graphics returns S_OK with a pipeline that has no shaders and no host graphics state (hand_out(Vec::new(), None, Some(offline), …), deserialize.rs:631-638). Its draws take the no-host-pipeline drop path, as the description says.

If the title builds a pipeline from its description only when the deserialize fails, the 1,669 graphics deserializations in your boot run would turn pipelines that render on main into dropped draws. That would only show on an SM 6.6 card: the GTX 1050 run drops every draw either way. The same scene on an SM 6.6 host, with and without this PR, would settle it from the frame line's dropped N without a host pipeline count and the draws per frame. The compute half builds a real shader from the payloads, so this is about graphics only.

Until the fixed-function state is decoded, graphics could keep returning E_NOTIMPL and still log the shapes, so the graphics description path stays as it is on main.

AI-assisted (Claude Code, Claude Opus 5.5 read this head, main and xcl's stub).

**@⁠upipibi** on GitHub · 2026-11-27 23:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3586#issuecomment-7230232033) A risk with the graphics half, read from the code at `1960fa5` and not run (I don't run the title): - **Main today.** Slots 57/67 come from `missing_table` (`device.rs:394`), so a deserialize returns `E_NOTIMPL`, and main reaches the world with its pipelines. xcl does the same: its `deserialize_pso_x` returns `E_NOTIMPL` with the note "the title creates the pipeline from its desc" (xcl `hle/d3d12x/device_x.rs:581-592`), and it renders the world too. - **With this PR.** `deserialize::graphics` returns `S_OK` with a pipeline that has no shaders and no host graphics state (`hand_out(Vec::new(), None, Some(offline), …)`, `deserialize.rs:631-638`). Its draws take the no-host-pipeline drop path, as the description says. If the title builds a pipeline from its description only when the deserialize fails, the 1,669 graphics deserializations in your boot run would turn pipelines that render on main into dropped draws. That would only show on an SM 6.6 card: the GTX 1050 run drops every draw either way. The same scene on an SM 6.6 host, with and without this PR, would settle it from the frame line's `dropped N without a host pipeline` count and the draws per frame. The compute half builds a real shader from the payloads, so this is about graphics only. Until the fixed-function state is decoded, graphics could keep returning `E_NOTIMPL` and still log the shapes, so the graphics description path stays as it is on main. AI-assisted (Claude Code, Claude Opus 5.5 read this head, main and xcl's stub).
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/3586/head:github-bot/gh-3586'
git switch 'github-bot/gh-3586'

Merge

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