d3d12_xs: capture a pipeline stream that carries a VIEW_INSTANCING subobject #2399

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

@⁠ERROR890 on GitHub · 2026-11-26 19:30 UTC · original
ERROR890:fix/pso-stream-view-instancing → main · +39 −1 · 2 files · 2 commits · open

Claimed in the coordination issue as: PSO-STREAM-VIEW-INSTANCING
(#1608)

Depends on: none.

Fixes: none.

What and why

The parser that decides creation models D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING
(shims/d3d12_vulkan_device.cpp): it refuses a non-zero ViewInstanceCount and accepts the subobject with a count of
0. The capture walker that keeps a stream for derivation (layout_of in shims/d3d12_xs_pso_stream.cpp) did not model
it, so that same stream created a PSO and was never captured. The PSO carried no PsoStreamRecord, and every
CreateDerivedPipelineState on it failed with E_FAIL ("base PSO has no kept stream") - a silent loss of the derived
states the title asks for, with nothing in the trace to say why.

The two walkers should agree: a stream the parser accepts has to be capturable. This models the subobject's size and
alignment in the capture walker. Only the ViewInstanceCount == 0 shape reaches it (a non-zero count is refused before
a PSO is created), so the payload's pViewInstanceLocations is never read; the walk needs the entry's size and
alignment to step over it, nothing more, and that is what the comment on the case says.

Testing

Built pso_stream_test with MSVC 19.44 (Windows SDK 10.0.26100) on Windows 11 26H2, Ninja build.
With this change:  pso_stream_test: OK, 0 failure(s)   (exit 0)
On main:           FAIL a stream with a zero-count VIEW_INSTANCING subobject is captured
                   1 failure (exit 1)
ctest -R "pso_stream|native_pso|process_cmdline" --output-on-failure:
                   100% tests passed, 0 tests failed out of 5.
Synthetic descriptor fixtures only. AI-assisted.

The new case is test_view_instancing_is_captured in runtime/test/pso_stream_test.cpp: a synthetic stream built the
same way as the existing cases, plus a zero-count VIEW_INSTANCING entry; it must be captured, keep the entry's
payload offset, and still derive a tag-1 record. No D3D12 device, no Vulkan device, no game files.

GPUs tested: n/a (CPU-only test).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator
    change in this pull request.)
**@⁠ERROR890** on GitHub · 2026-11-26 19:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2399) `ERROR890:fix/pso-stream-view-instancing` → `main` · +39 −1 · 2 files · 2 commits · open Claimed in the coordination issue as: PSO-STREAM-VIEW-INSTANCING (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: none. Fixes: none. ### What and why The parser that decides creation models `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING` (`shims/d3d12_vulkan_device.cpp`): it refuses a non-zero `ViewInstanceCount` and accepts the subobject with a count of 0. The capture walker that keeps a stream for derivation (`layout_of` in `shims/d3d12_xs_pso_stream.cpp`) did not model it, so that same stream created a PSO and was never captured. The PSO carried no `PsoStreamRecord`, and every `CreateDerivedPipelineState` on it failed with E_FAIL ("base PSO has no kept stream") - a silent loss of the derived states the title asks for, with nothing in the trace to say why. The two walkers should agree: a stream the parser accepts has to be capturable. This models the subobject's size and alignment in the capture walker. Only the `ViewInstanceCount == 0` shape reaches it (a non-zero count is refused before a PSO is created), so the payload's `pViewInstanceLocations` is never read; the walk needs the entry's size and alignment to step over it, nothing more, and that is what the comment on the case says. ### Testing ``` Built pso_stream_test with MSVC 19.44 (Windows SDK 10.0.26100) on Windows 11 26H2, Ninja build. With this change: pso_stream_test: OK, 0 failure(s) (exit 0) On main: FAIL a stream with a zero-count VIEW_INSTANCING subobject is captured 1 failure (exit 1) ctest -R "pso_stream|native_pso|process_cmdline" --output-on-failure: 100% tests passed, 0 tests failed out of 5. Synthetic descriptor fixtures only. AI-assisted. ``` The new case is `test_view_instancing_is_captured` in `runtime/test/pso_stream_test.cpp`: a synthetic stream built the same way as the existing cases, plus a zero-count `VIEW_INSTANCING` entry; it must be captured, keep the entry's payload offset, and still derive a tag-1 record. No D3D12 device, no Vulkan device, no game files. GPUs tested: n/a (CPU-only test). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change in this pull request.)
The stream parser that decides creation models `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING`: it refuses a
non-zero `ViewInstanceCount` and accepts the subobject with a count of 0. The capture walker that keeps a stream for
derivation (`layout_of` in `shims/d3d12_xs_pso_stream.cpp`) did not model it, so that same stream created a PSO and
was never captured. The PSO then carried no `PsoStreamRecord`, and every `CreateDerivedPipelineState` on it failed
with E_FAIL ("base PSO has no kept stream"), which is a silent loss of the derived states the title asks for.

Model the subobject's size and alignment in the capture walker. Only the count == 0 shape reaches it (a non-zero count
is refused before a PSO is created), so the payload's `pViewInstanceLocations` is never read: the walk needs the
entry's own size and alignment to step over it, nothing more.

`pso_stream_test` gains `test_view_instancing_is_captured`: a synthetic stream built the same way as the existing
cases, plus a zero-count `VIEW_INSTANCING` entry, must be captured, keep the entry's payload offset, and still derive a
tag-1 record. It fails on `main` ("a stream with a zero-count VIEW_INSTANCING subobject is captured") and passes with
this change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:36:05 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 19:48 UTC · original

Confirmed through the D3D12 proxy and a GPU readback on Windows 11, RTX 4090, NVIDIA 616.64, with Vulkan validation enabled. I built base 2d43417d49 and PR head 3b5b36edd1 with the same local extension to d3d12_mesh_test.cpp.

Placement of a zero-count VIEW_INSTANCING entry Base PR head
Omitted from both streams Draw matched Draw matched
Vertex pipeline only Slot 86 created the base. Slot 55 returned E_FAIL on the first derivation. Chained derivation and draw matched
Console-numbered mesh pipeline only Slot 86 created the base. Slot 55 returned E_FAIL on the mesh derivation. Derivation and draw matched
Both pipelines Stopped at the first vertex pipeline derivation with E_FAIL Both derived pipelines drew correctly

The probe placed the entry first in the vertex stream and immediately before SAMPLE_MASK in the mesh stream. The base sample mask was zero. For the vertex draw I derived twice, restored the full mask on the second derivation and released both earlier PSOs before drawing. For the mesh draw I used the fixture's tag-3 mask override through slot 55. On the PR, all four combinations matched the fixture's expected RGBA values at all 4,096 pixels. Each run also matched the 4,096-pixel indirect mesh readback.

On the base, the failing cases logged base PSO has no kept stream. A separate one-view vertex stream with a valid location still returned E_NOTIMPL and a null PSO on both revisions. The four PR runs reported no Vulkan validation errors. All inputs were synthetic.

**@⁠ecox982745** on GitHub · 2026-11-26 19:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2399#issuecomment-7201979513) Confirmed through the D3D12 proxy and a GPU readback on Windows 11, RTX 4090, NVIDIA 616.64, with Vulkan validation enabled. I built base `2d43417d49` and PR head `3b5b36edd1` with the same local extension to `d3d12_mesh_test.cpp`. | Placement of a zero-count VIEW_INSTANCING entry | Base | PR head | | --- | --- | --- | | Omitted from both streams | Draw matched | Draw matched | | Vertex pipeline only | Slot 86 created the base. Slot 55 returned `E_FAIL` on the first derivation. | Chained derivation and draw matched | | Console-numbered mesh pipeline only | Slot 86 created the base. Slot 55 returned `E_FAIL` on the mesh derivation. | Derivation and draw matched | | Both pipelines | Stopped at the first vertex pipeline derivation with `E_FAIL` | Both derived pipelines drew correctly | The probe placed the entry first in the vertex stream and immediately before SAMPLE_MASK in the mesh stream. The base sample mask was zero. For the vertex draw I derived twice, restored the full mask on the second derivation and released both earlier PSOs before drawing. For the mesh draw I used the fixture's tag-3 mask override through slot 55. On the PR, all four combinations matched the fixture's expected RGBA values at all 4,096 pixels. Each run also matched the 4,096-pixel indirect mesh readback. On the base, the failing cases logged `base PSO has no kept stream`. A separate one-view vertex stream with a valid location still returned `E_NOTIMPL` and a null PSO on both revisions. The four PR runs reported no Vulkan validation errors. All inputs were synthetic.
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 20:43 UTC · original · reviewed

Built pso_stream_test with MSVC on Windows 11 and ran it through CTest. It passed, including capture of a stream with a zero-count VIEW_INSTANCING, its unchanged payload offset, and derivation from the captured stream. I checked the capture walker against the creation parser for that entry. This was a CPU-only check of the stream walker.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 20:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2399#pullrequestreview-6080301241) · **reviewed** Built `pso_stream_test` with MSVC on Windows 11 and ran it through CTest. It passed, including capture of a stream with a zero-count `VIEW_INSTANCING`, its unchanged payload offset, and derivation from the captured stream. I checked the capture walker against the creation parser for that entry. This was a CPU-only check of the stream walker. AI-assisted.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2399/head:github-bot/gh-2399'
git switch 'github-bot/gh-2399'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2399'
git switch 'github-bot/gh-2399'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2399'
git switch 'github-bot/gh-2399'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2399'
git switch 'main'
git merge --squash 'github-bot/gh-2399'
git switch 'main'
git merge --ff-only 'github-bot/gh-2399'
git switch 'main'
git merge 'github-bot/gh-2399'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.