gpu: read root signature blobs without a host d3d12.dll #83

Manually merged
github merged 1 commit from github-bot/gh-83 into main 2026-11-26 15:00:17 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-26 13:52 UTC · original
Olima34:feat/root-signature-deserializer → main · +465 −10 · 3 files · 1 commits · merged 2026-11-26 14:55 UTC

What this changes

On macOS, d3d12_xs!D3D12CreateRootSignatureDeserializer (root.rs, create_deserializer) forwarded to a host d3d12.dll that does not exist there, so every call logged no host d3d12.dll to deserialize root signatures and returned E_NOTIMPL. Both Series S tester logs (#66, #68) show 29 of these calls at the first world frame, right after the AMD FidelityFX upscaler DLL loads: the upscaler got no root signature description back.

rootser.rs already wrote RTS0 blobs in Rust; it now reads them too, versions 1.0 and 1.1, bare or as the RTS0 part of a DXBC container (victory_shader::dxbc), into an ID3D12RootSignatureDeserializer (IID 34ab647b-3cc8-46ac-841b-c0965645c046: IUnknown, then GetRootSignatureDesc). The object owns the description and the arrays its pointers point into, so they live as long as it does. Layouts follow d3d12.h. Reading is bounds-checked throughout: versions 1 and 2, parameter types 0 to 4, at most 4096 parameters and 2048 static samplers, as the writer allows, and no more descriptor ranges than the blob has room for, so tables pointing at the same bytes cannot make it allocate past the blob's size. A malformed blob gives E_INVALIDARG and a null object; an unknown interface E_NOINTERFACE. On Windows the host DLL is still used: only the warn! and E_NOTIMPL are replaced.

Guess, marked in the code and docs/native-host.md: a 1.1 blob is returned as the 1.0 description with its range and root descriptor flags dropped, which is believed to be what Microsoft's 1.0 deserializer does. The Windows test the_host_reads_our_blobs_as_we_do compares both readers on 1.0 and 1.1 blobs, so the CI settles it.

Tests: v1 and v2 round trips through serialize checking every field and the data behind each pointer (a table of two ranges, constants, a CBV, a static sampler); the same blob in DXBC, DXBC without RTS0, a truncated container; every truncation and 15 corruptions (versions, counts, offsets, type 5, shared ranges past the blob's room); QueryInterface, AddRef and Release; the export itself off Windows.

How it was tested

  • cargo test -p victory-gpu on arm64 with the Metal Shader Converter installed (166 tests)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with --all-features
  • arm64 cargo test --workspace and cargo xtask policy
  • Ran the game: not done, no copy of it here

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Olima34** on GitHub · 2026-11-26 13:52 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/83) `Olima34:feat/root-signature-deserializer` → `main` · +465 −10 · 3 files · 1 commits · merged 2026-11-26 14:55 UTC ## What this changes On macOS, `d3d12_xs!D3D12CreateRootSignatureDeserializer` (`root.rs`, `create_deserializer`) forwarded to a host `d3d12.dll` that does not exist there, so every call logged `no host d3d12.dll to deserialize root signatures` and returned `E_NOTIMPL`. Both Series S tester logs (#66, #68) show 29 of these calls at the first world frame, right after the AMD FidelityFX upscaler DLL loads: the upscaler got no root signature description back. `rootser.rs` already wrote `RTS0` blobs in Rust; it now reads them too, versions 1.0 and 1.1, bare or as the `RTS0` part of a DXBC container (`victory_shader::dxbc`), into an `ID3D12RootSignatureDeserializer` (IID `34ab647b-3cc8-46ac-841b-c0965645c046`: IUnknown, then `GetRootSignatureDesc`). The object owns the description and the arrays its pointers point into, so they live as long as it does. Layouts follow `d3d12.h`. Reading is bounds-checked throughout: versions 1 and 2, parameter types 0 to 4, at most 4096 parameters and 2048 static samplers, as the writer allows, and no more descriptor ranges than the blob has room for, so tables pointing at the same bytes cannot make it allocate past the blob's size. A malformed blob gives `E_INVALIDARG` and a null object; an unknown interface `E_NOINTERFACE`. On Windows the host DLL is still used: only the `warn!` and `E_NOTIMPL` are replaced. Guess, marked in the code and docs/native-host.md: a 1.1 blob is returned as the 1.0 description with its range and root descriptor flags dropped, which is believed to be what Microsoft's 1.0 deserializer does. The Windows test `the_host_reads_our_blobs_as_we_do` compares both readers on 1.0 and 1.1 blobs, so the CI settles it. Tests: v1 and v2 round trips through `serialize` checking every field and the data behind each pointer (a table of two ranges, constants, a CBV, a static sampler); the same blob in DXBC, DXBC without RTS0, a truncated container; every truncation and 15 corruptions (versions, counts, offsets, type 5, shared ranges past the blob's room); QueryInterface, AddRef and Release; the export itself off Windows. ## How it was tested - [x] `cargo test -p victory-gpu` on arm64 with the Metal Shader Converter installed (166 tests) - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`, also with `--all-features` - [x] arm64 `cargo test --workspace` and `cargo xtask policy` - [ ] Ran the game: not done, no copy of it here ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
D3D12CreateRootSignatureDeserializer forwarded to the host's d3d12.dll,
which macOS does not have, so every call failed with E_NOTIMPL (29 at the
first world frame, from the FidelityFX upscaler). rootser now reads RTS0
blobs, versions 1.0 and 1.1, bare or inside a DXBC container, into an
ID3D12RootSignatureDeserializer that owns its description. Malformed
blobs give E_INVALIDARG and no object. A 1.1 blob is returned as the 1.0
description without its flags (a guess; a Windows test compares it with
the host's deserializer).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:45:27 +00:00
github manually merged commit 13b507fec2 into main 2026-11-26 15:00:17 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 14:54 UTC · original · approved these changes

Thanks: the blob reader is bounds-checked, the layouts match d3d12.h, and truncation and corruption are tested. Approved (nit for later: a SAFETY comment on description in rootser.rs).

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 14:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/83#pullrequestreview-6076248929) · **approved these changes** Thanks: the blob reader is bounds-checked, the layouts match d3d12.h, and truncation and corruption are tested. Approved (nit for later: a SAFETY comment on `description` in rootser.rs).
This discussion has been locked. Commenting is limited to contributors.
No description provided.