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

Merged
Olima34 merged 1 commit from upstream-pr/83 into main 2026-11-26 14:55:24 +00:00
Olima34 commented 2026-11-26 13:52:04 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T13:52:04Z.


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)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6628112324 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/83). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-26T13:52:04Z. --- ## 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)
LakshanSivakumar commented 2026-11-26 14:54:43 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T14:54:43Z.

Review: APPROVED


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).

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6076248929 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/83#pullrequestreview-6076248929). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T14:54:43Z. **Review:** APPROVED --- 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).
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
LakshanSivakumar/Native-Victory-macOS!83
No description provided.