Skip to content

d3d12_xs: derive pipeline states for device slot 55 - #7759

Closed
LooperSalty wants to merge 8 commits into
ProjectLeonida:mainfrom
LooperSalty:d3d12xs-slot55-derived-pso
Closed

LooperSalty wants to merge 8 commits into
ProjectLeonida:mainfrom
LooperSalty:d3d12xs-slot55-derived-pso

Conversation

@LooperSalty

@LooperSalty LooperSalty commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in: #7496 (comment) (status in #7694: #7694 (comment))

Depends on: #7201 (slot 86), #7125 (test policy for PC methods behind the proxy). Both are merged into this branch so it builds and tests on its own; the slot-55 change is the last commit.

What and why

Device slot 55 is the console's CreateDerivedPipelineState(pBasePSO, n, pRecords, riid, ppv). The retail 1.0.2.1 title calls it when a requested state differs from a PSO it already has. n is 1 to 4 records of 0x14c bytes, each a u32 tag and a payload at +4. Nothing served slot 55 before this PR.

  • Slot 86 (from d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8 #7201) keeps a deep copy of the stream it creates, on the returned PSO (private data, freed with the PSO).
  • Slot 55 patches a copy of the base stream and creates the PSO through the same path, so a derived PSO can be a base.
  • Tags: 0 = D3D12_DEPTH_STENCIL_DESC (0x34 bytes, or the prefix of DEPTH_STENCIL1), 1 = D3D12_RASTERIZER_DESC (0x2c), 2 = D3D12_BLEND_DESC (0x148), 3 = sample mask (TomBox; the 1.0.2.1 title does not write it), 5 = the StencilReadMask and StencilWriteMask bytes, overlaid on the base's depth-stencil, applied in record order. Tags 0, 1, 2 and 5 were read from the title's record writes in the retail build (static disassembly). The title can send up to four records (rasterizer, depth-stencil, tag 5, blend on independent paths).
  • Tag 5 is inferred from those writes, not measured at run time.
  • Refusals return a failure HRESULT and a null output, each logged once: unknown tag, base without the matching subobject, base not created through slots 86/55, malformed records, n outside 1..4.
  • Slot 55 shadows PC CreateReservedResource1 (PC slot 55) on the proxy, as slot 78 shadows PC CreateReservedResource2 in d3d12_vulkan_device: check PC CreateReservedResource2 behind the Xbox proxy, not through slot 78 #7125. The vulkan device test calls the PC method on the real device behind the proxy.

Tested

Windows 11 26300, RTX 4070 SUPER (driver 610.88), MSVC RelWithDebInfo.

  • pso_stream_test (new, no device): console subobject offsets, deep copy, patching of each tag, tag 5 overlay and record order, refusals. Written first; it failed on the stub, and it passes now.
  • device_proxy_test over WARP: refusals (tag 6, missing subobject, base not kept, null records and riid, n = 0 and n = 5), a graphics base created through slot 86, derivations with n = 3 and n = 4, tag 2 alone, and a derivation from a derived PSO. All pass.
  • d3d12_vulkan_device: passes.
  • Full ctest at rest, on this commit: 262 run, 2 failed: d3d12_indirect_dispatch_count and d3d12_indirect_rt, both already failing on main.
  • Not measured on the game executable: my local boot stack stops before the title's first slot-55 call.

Credit

The record size, payload offset and tag 3 layout come from TomBox's create_derived_pso_x (omonkeyz/xbox-emulator, GPL-3.0, commit f89e4106fe, crates/compat/d3d12_xs/src/device_wrap.rs). The tag 0, 1, 2 and 5 layouts were checked against the title's writes. The code here is new.

Limits

  • Tag 5 is inferred from the title's writes; how the console applies it at run time, and how often calls carry it, are not measured.
  • Tag 3 is served but not written by the 1.0.2.1 title.
  • A stream with an unmodelled subobject type (for example VIEW_INSTANCING) is not kept, so that PSO is refused as a base (logged once).
  • A kept stream lives as long as its PSO; there is no separate cache.

Slot numbers, tags and counts only, no game data. AI-assisted (Claude Code).

cc @ItsNotRexed

Jacob and others added 8 commits November 24, 2026 04:58
… proxy, not through slot 78

ItsNotRexed#6935 routes the Xbox device proxy's slot 78 to the title's SetFrameIntervalX, by design: the proxy is the
title's device, answers ID3D12Device11 with itself, and shadows PC slots the way 62 and 76 already are. The
test still called the PC ID3D12Device10::CreateReservedResource2 through the proxy, so the call reached
SetFrameIntervalX and `tiles == 1` failed (@fever308's finding on ItsNotRexed#7049). The PC method is now checked on
the Vulkan device behind the proxy, the same call and the same expectations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slot 55 is the console's CreateDerivedPipelineState(pBasePSO, n, pRecords,
riid, ppv): n = 1..4 records of 0x14c bytes (a u32 tag, payload at +4) that
patch the base PSO's state before a new PSO is created.

- Slot 86 keeps a deep copy of the stream it creates on the returned PSO
  (ID3D12Object private data, released with the PSO): shader bytecode,
  stream-output and input-layout arrays and strings, cached blobs, and
  AddRef'd root signatures.
- Slot 55 patches a copy of the base stream and creates the PSO through the
  slot 86 path, so a derived PSO can itself be a base.
- Tags: 0 = DEPTH_STENCIL (or the DEPTH_STENCIL1 prefix), 1 = RASTERIZER,
  2 = BLEND, 3 = sample mask (TomBox layout; the 1.0.2.1 title does not write
  it), 5 = StencilReadMask and StencilWriteMask bytes overlaid on the base's
  DEPTH_STENCIL, applied in record order. Other tags are refused.
- A base not created through slots 86/55, a base without the matching
  subobject, malformed records, and n outside 1..4 are refused with E_FAIL or
  E_INVALIDARG and a null output, each logged once.
- Slot 55 shadows PC CreateReservedResource1 (PC slot 55) on the proxy, as
  slot 78 shadows PC CreateReservedResource2 in ItsNotRexed#7125; the vulkan device test
  calls the PC method on the real device behind the proxy.

Tests: pso_stream_test (synthetic streams: console subobject offsets, deep
copy, patching, tag 5 overlay and record order, refusals) and
device_proxy_test over WARP (refusals, graphics base via slot 86, n = 3 and
n = 4 derivations, a derivation from a derived PSO).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwHrL5Lxc1rum25b6tnpo8

@gut0to gut0to left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the new stream ownership and derivation path, slot dispatch, resource-description conversion, and added test coverage. The capture walker bounds each payload before copying, refuses unmodelled subobjects, retains root signatures, and copies pointer-backed stream data; derive applies only modeled tags and validates record count/state before creating the result. The slot 108 conversion zeroes the newer-only field and masks console-only layout/flag bits before forwarding. I found no actionable issue in the diff. I did not independently build this PR in this pass.

@TillusStark26

Copy link
Copy Markdown

Tested d80c40845 on NVIDIA GeForce RTX 3050 (driver 621.14, Vulkan 1.4.357), Windows 11 Pro (10.0.26100 x64), MSVC 19.44.35230.0 (Ninja, Release), Vulkan SDK 1.4.363.1: tests pass, with 4 code/doc findings below

What was run

  • cmake --build runtime/build --target pso_stream_test device_proxy_test xs_proxy_mock_test d3d12_vulkan_device_test
  • runtime/build/pso_stream_test.exe: OK: 0 failure(s) (all 26 stream layout, capture, and derivation checks pass)
  • runtime/build/device_proxy_test.exe: OK (0 failures) (slots 55, 86, 101, 108 verified over WARP)
  • runtime/build/xs_proxy_mock_test.exe: pass (all mock device/queue/fence/Xbox-slot checks pass)
  • runtime/build/d3d12_vulkan_device_test.exe: pass on NVIDIA GeForce RTX 3050 (including the new end-to-end slot 86 base PSO -> slot 55 derived PSO draw and pixel readback)
  • python scripts/check_no_game_data.py: pass

Code & documentation findings

  1. CONTRIBUTING.md Rule-2 / comment cleanup (docs/d3d12_vulkan.md:16, runtime/test/pso_stream_test.cpp:102):
    • docs/d3d12_vulkan.md:16 quotes a specific retail executable RVA in parentheses (checked against the title's record writes in the retail build (RVA ...)), which should be removed per CONTRIBUTING.md Rule 2.
    • runtime/test/pso_stream_test.cpp:102 has a leftover non-English comment (// 0x101 (Xbox tiled, mesure sur l'exe)).
  2. Shallow copy of D3D12_SO_DECLARATION_ENTRY::SemanticName in copy_pointed_data (runtime/shims/d3d12_xs_pso_stream.cpp:701-708):
    • For D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT (lines 715–724), copy_pointed_data deep-copies both the D3D12_INPUT_ELEMENT_DESC array into bytes and each element's SemanticName string into strings.
    • For D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT (lines 701–708), it copies the D3D12_SO_DECLARATION_ENTRY struct array and pBufferStrides into bytes, but leaves each pSODeclaration[i].SemanticName pointing at the caller's original const char* buffer. If the caller frees its semantic name strings after CreatePipelineState (slot 86), so.pSODeclaration[i].SemanticName will dangle when slot 55 later derives a PSO from the captured stream.
  3. CACHED_PSO subobject retained unmodified when patching state in derive_stream (runtime/shims/d3d12_xs_pso_stream.cpp:758-824):
    • copy_pointed_data copies D3D12_CACHED_PIPELINE_STATE (pCachedBlob / CachedBlobSizeInBytes), and derive_stream leaves any CACHED_PSO subobject intact after patching BLEND, RASTERIZER, DEPTH_STENCIL*, or SAMPLE_MASK. On a host D3D12 driver that validates CachedPSO against the stream description (or when stream-form CachedPSO validation is active), forwarding the base PSO's cached blob with modified state can be rejected with D3D12_ERROR_DRIVER_VERSION_MISMATCH. Zeroing pCachedBlob = nullptr; CachedBlobSizeInBytes = 0; on any CACHED_PSO subobject inside derive_stream avoids this.
  4. MSVC /W4 variable-shadowing warnings (C4456) in runtime/test/d3d12_vulkan_device_test.cpp:6978,6985:
    • Building d3d12_vulkan_device_test.cpp under MSVC /W4 emits two C4456 warnings in the new slot 55 test block: local readable at line 6978 shadows readable from line 5931, and local zero at line 6985 shadows zero from line 5980.

AI-assisted.

@Pipodi

Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

tested: #7759 (d80c408, the slot-55 commit cherry-picked) on the retail 1.0.2.1 executable | os: Windows 11, MSVC 14.44 | gpu: RTX 4090, NVIDIA 617.42, LEONIDA_D3D12=vulkan | stack: main + #6982's boot-integration + #7111 #7163 #7201 #7286 #7290 #7330 #7403 #6885 #6981 #7685 #2490's queue PresentX, plus local stand-ins (device slot 57, slot 74)

  • Before: device slot 55 fell through to PC slot 55 (ID3D12Device4::CreateReservedResource1). The title's IID_ID3D12PipelineState and the record array ended up in the session argument, so every call was refused as a protected session: 41,545 failed calls in a 60 s run. The title then read a null record (AV) after 5 frames.
  • With d3d12_xs: derive pipeline states for device slot 55 #7759: 0 CreateReservedResource1 failures. The frame loop stays alive for the whole 240 s run: 37,130 command-list submits and over 7,000 PresentX calls, all S_OK. The title now calls slot 55 only twice, and both times it is refused with base PSO has no kept stream. That is expected on my stack, because those bases come from my local slot-57 stand-in, not from slot 86. Once slot 57 lands upstream, it will need to keep its stream too.

The conflicts against the stack were trivial: includes, the slot name table and device_slot_overridden. Counts only, no game files.

AI-assisted (Claude Code).

@LooperSalty

Copy link
Copy Markdown
Author

Measurement on the retail executable, as the author: the 1.0.2.1 title does not call slot 55 through the frame loop, so this PR is not exercised by the boot yet.

Windows 11 26300, RTX 4070 SUPER (driver 610.88), LEONIDA_D3D12=vulkan, main dde82f27 + #7201 #7323 #7759 #7286 #7290 #7111 #7403 #7417 #7529 #7581 #6891 #7685 #7356 (+ two local-only stand-ins), the title's shaders translated. One 300 s run into the frame loop: 53,830 CreatePipelineState succeeded and 602 were unsupported, 16+ PresentX, 54 ExecuteCommandListsX. With per-tag counters added locally on slot 55: no device slot 55 first call, no record, no refusal, no not kept for derivation.

So the call site at game+0x247a5c2 is real (static) but not reached in that window. It probably sits behind state changes the title only makes once frames render. The PR stays as described; its tests are synthetic and WARP-based. I'll re-measure when the boot draws real frames. AI-assisted (Claude Code).

@Hiiva

Hiiva commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

base: #7759 at d80c40845d7eca9163f937de943b65482b7f0657 | on: Windows, MSVC 19.44, SDK 10.0.26100.0 | checked: unmodified stream capture/derivation sources with authored CPU fixtures; no game inputs or GPU.

Comparison with SweatierKey's new slot-55 description:

  • The record stride, tag-0/tag-2 widths and tag-5 mask offsets agree. A native synthetic probe passed all 24 orderings of tags 0, 1, 2 and 5 in a four-record call, including mask precedence and unchanged input/base streams.
  • Two contract details remain unconfirmed. The new description permits NumOverrides=0, while this PR deliberately refuses zero and documents 1..4. Also, it gives tag 1 a 0x28-byte D3D12_RASTERIZER_DESC, while the native SDK reports sizeof(D3D12_RASTERIZER_DESC)==0x2c and offsetof(ConservativeRaster)==0x28. The PR copies all 44 bytes. Please confirm the intended zero-count behavior and whether that trailing rasterizer DWORD is part of the console payload before changing either behavior. These are specification mismatches; the synthetic checks do not establish which console contract is correct.

Two build-integration findings at this head:

  1. scripts/build_runtime.ps1 never compiles the new d3d12_xs_pso_stream.cpp. It is needed by the direct-compiler runtime source list and the separate root_sig_test and device_proxy_test commands. The existing fallback parity test reports this missing source; adding it to those three lists restores that test.
  2. The new pso_stream_test target is declared outside the if(TARGET gta6rt) block and has no Windows guard, although it includes d3d12.h and receives MSVC-only flags. Please guard its creation with the Windows-runtime condition, preserving the portable test build. This second finding is from source inspection; I did not run a Linux build.

I left the already reported stream-output semantic-name ownership and inherited cached-PSO findings with the existing reviewer. Their affected production code is unchanged at this head.

@Marukooh

Copy link
Copy Markdown
Contributor

checked: A38, #7759 builds and its pso_stream CTest passes.

base: exact PR head d80c408, no local changes.

on: CachyOS x86_64, clang-cl/xwin with Windows SDK 10.0.26100, Release, Wine 11.22. Built gta6rt and pso_stream_test; CTest 1/1 passed. This fixture verifies stream decoding, deep copy and override handling without a GPU. The reviewed runtime stream files and fixture passed check_no_game_data.py. No retail test of this PR head in isolation.

AI-assisted. A38 claim: #7154 (comment)

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

checked: #7759 | with: merge of PR head onto main, then pso_stream_test, xs_proxy_mock_test, d3d12_vulkan_device_test, d3d12_draw_test, device_proxy_test (cross-built, run under Wine), plus a negative control | on: Wine 11 on a RunPod RTX 4090 (Linux, Vulkan), cross-built with clang-cl + xwin through the pod's ccache build script; not native Windows, and the host D3D12/WARP comparisons do not run (there is no WARP adapter under Wine). | result: the new stream logic passes; the slot-55 proxy path itself did not run here

  • PR head tested: d80c408, merged (clean) onto origin/main 867d922. This PR also carries the slot 86/101/108 code of d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8 #7201 (the diff is identical there; merging both gave only a 10-line difference), so those parts are judged in my d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8 #7201 comment.
  • pso_stream_test (new): exit 0, "OK: 0 failure(s)"; it covers tag 0/1/2/3/5 patches, record order (tag 5 then 0 and the reverse), a refused tag 6, a refused tag 1 on a base with no rasterizer subobject, and an unmodelled subobject type not being captured.
  • xs_proxy_mock_test: exit 0 ("PASS (9 allocations refused on purpose)"). d3d12_vulkan_device_test: exit 0. d3d12_draw_test: exit 0, with Vulkan on the RTX 4090 (it links the new file through the CMake change, so the build change is covered).
  • device_proxy_test: exit 77, "SKIP: no WARP adapter (0x80004001)"; main gives the same SKIP. This is the only target with the slot-55 end-to-end cases (12 mentions of slot 55 in it), and the mock test has no slot-55 case, so proxy_create_derived_pso (base lookup from the private data, patch, create) was NOT executed in this run. Only the pure stream logic was.
  • Negative control: with d3d12_xs_device.cpp/.h reverted to main (the new stream file kept so it still links), xs_proxy_mock_test fails with exit 1 at xs_proxy_mock line 411 (slot 86 reaching PC slot 47). That shows the mock test needs the proxy change, but it is the slot-86 expectation, not a slot-55 one.
  • Diff review (10 files, no game files): the stream walker checks every length against the buffer, refuses a stream whose entries do not end exactly at its size, and caps it at 64 KiB. The record is kept as private data on the PSO with an owner object, so it is freed with the PSO, and root signatures are held with AddRef. Every refusal leaves the output null and returns a failure, not a fake success. The CMake change adds the new source to each target that already links d3d12_xs_device.cpp; those I built all link.
  • Concerns: (1) The record sizes the PR copies come from the retail title and a third-party reference. The rasterizer record is copied as the PC D3D12_RASTERIZER_DESC (0x2c bytes), while the finding posted in Boot log for coding agents: where the executable stops and which PRs get past it #7154 describes the Type 1 payload as 0x28 bytes. If the console struct is 4 bytes shorter, a field in the middle moves and the copy is wrong silently; this needs a measurement, and no test here can settle it. (2) The header comment says "up to three state records" while the constant and the doc allow 4. (3) Slot 55 refuses any base PSO that was not created through slot 86 or slot 55 (for example one made by the PC CreateGraphicsPipelineState), with one log line; that is right for the stated purpose but means a base from another path fails. (4) find_pso_record calls GetPrivateData on a pointer the title gives, with no check that it is a PSO of this device; a bad pointer would crash instead of being refused.
  • Not verified: slot 55 against a real device (the device_proxy_test cases), that the derived PSOs match what the console would make (nothing here can show that), and anything on native Windows or with the retail title.

AI-assisted.

@Spaghetih

Copy link
Copy Markdown
Contributor

Measured on the retail 1.0.2.1 executable, since your local stack stopped before the first slot-55 call. I applied this PR on a local boot integration (Windows 11, RTX 4070 Ti, driver 621.24). Only the slot-55 commit, with conflicts resolved against that branch.

Without the PR, the title's first slot-55 call (the return address after game+0x247a5c2, as you found) went through the generic forward to PC slot 55 (CreateReservedResource1) and crashed the runtime with an access violation inside that method. Before that, boot ran for 23 s.

With the PR, there is no crash and boot runs the full 8-minute window. Slot 55 is reached and served, and the title goes on.

One case is refused, and it looks like a real gap. Six calls in one run, all the same shape:

  • one record (n = 1), tag 2 (D3D12_BLEND_DESC);
  • the kept base stream holds only subobject types 0 and 1 (root signature and VS). It has no BLEND subobject.

So derive_stream returns missing_state ("base has no subobject for a record"). In a D3D12 stream an absent subobject means "use the default", so a base without BLEND is a valid PSO with the default blend state. The title derives it with only the blend changed. Appending the record's subobject when the base lacks it (instead of refusing) would match D3D12 semantics. That is my reading: I have not measured what the console does with these calls.

Counts come from a local diagnostic line in derive_stream that prints the tag and the base's subobject types. That line is not part of the PR.

AI-assisted (Claude Code), posted with the user's agreement. Measured on the user's own copy. No game data here, only counts and call shapes.

@MarcPique

Copy link
Copy Markdown

Independent retail result for d80c4084 on Windows 11, RTX 4090 (32.0.16.1656), MSVC 19.44.35228. The local base is the #8890 + #8754 integration with all 10,241 slot-57 PSOs creating successfully.

  • Without this route, the boot logged 41,545 failures in the PC CreateReservedResource1 slot.
  • With d3d12_xs: derive pipeline states for device slot 55 #7759, the same startup completed 41,545 slot-55 derivations, with zero slot-55 failures or old PC-slot failures. The pso_stream CTest passed on the integration.
  • Integration detail: in addition to the PR's slot-86 capture, I packed the already-created slot-57 D3D12_GRAPHICS_PIPELINE_STATE_DESC as a PC stream and attached it using the same PsoStreamRecord path. Slot 55 can then derive from the native deserialization path as well as from the stream path.
  • It continued presenting. A Windows Graphics Capture during the frame loop still showed a black client area.

Both tests used the same local shader indexes. Counts and API names only. AI-assisted.

zneel added a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
… PC CreateReservedResource1

Measured on retail 1.0.2.1: the title calls device slot 55 with five
arguments after the device (base pipeline, record count, a stack array of
0x14c-byte records, riid, output) and uses the output after checking the
HRESULT. By slot number the call reached PC CreateReservedResource1, which
has one more argument, so its output pointer was a stack word the title
never wrote: the PC method stored null through that word on each of about
41,500 calls a boot. Three boots ended in an access violation at that
store (read of a non-canonical address, write to 0x4, write into a
read-only host page), and the store is a wild 8-byte zero write in every
other call.

The slot now answers the base pipeline with one more reference; the
records (tags per upstream ItsNotRexed#7759) are counted and logged but not applied,
which is exact for the LEONIDA_STUB_PIPELINES stand-ins.

Also repairs the dev merge of xs_proxy_mock_test.cpp: the recorded
resolution had kept only this branch's side, dropping dev's depth-format
check and its slot 127 clear-value expectation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@LooperSalty

Copy link
Copy Markdown
Author

checked: #7759d80c408 | with: merged on top of tibzejoker:rt5-integration@4037bd7 (+ #88158e8c5df), gta6rt --run on a RelWithDebInfo build, 5 to 10 minute runs | on: Windows 11 26300, MSVC 19.44, RTX 4070 SUPER (610.88) | result: merges with one trivial conflict (the slot lists in d3d12_xs_device.{h,cpp}), builds, but the retail title never calls device slot 55 in this window.

Slot 55 counts, 4 runs (2 x 300 s, 1 x 300 s, 1 x 600 s), LEONIDA_D3D12=vulkan, LEONIDA_ARENA_MB=4095, LEONIDA_SKIP_INT3=1, translated shaders from make_game:

  • calls to slot 55: 0 in all four runs (no "device slot 55 ... first call" line, no "derived pipeline state (device slot 55) refused" line).
  • successes: 0, refusals: 0, tags seen: none.

What the title does instead:

  • runs 1-2 (stack without a slot 57 handler): the title spends the whole window in device slot 57, forwarded to the PC slot 57 (CreateLifetimeTracker), refused every time (3,600+ calls in 300 s, the trace stops logging after that). No PSO creation, no PresentX.
  • runs 3-4 (same stack + d3d12_xs: slot 57 DeserializeGraphicsPipelineStateX, fspx_gfx index, and pipeline blob input layout #8890, slot 57 -> DeserializeGraphicsPipelineStateX, answering E_INVALIDARG because no fspx_gfx translation exists in my work folder): the loop moves on. Slot 86 CreatePipelineState succeeds 3,356 times in 300 s and 9,012 times in 600 s (7 refusals, all "no translated vs for FSSM"), 585 command lists created and closed, 0 PresentX, still 0 calls to slot 55.

So on this base the title reaches PSO creation through slot 86 only; slot 55 is not on the path before at least 9k PSOs. This does not reproduce the 32,256 slot-55 failures @SweatierKey measured in #8869, so that stack must get further than this one; their base (and whether the calls come after PresentX starts) would settle where slot 55 sits in the boot order. Counts only, no game data.

agent: yes

@simonbronk

Copy link
Copy Markdown
Contributor

I tested this on a local boot build of the retail 1.0.2.1 title.

  • Slot 55 is reached about 30 s into the boot.
  • The base PSOs of the first derivations were not made by slot 86. My branch creates graphics PSOs through a local slot 57 stand-in, so slot 55 refused them with "base PSO has no kept stream" and the title asserted twice.
  • I then kept a stream on those PSOs as well, built from the full graphics desc with keep_pso_stream. After that the refusal and both asserts were gone, and the boot went on to the next stop.

This means slot 55 needs a kept stream on every PSO creation path the title uses, not only slot 86. Whoever lands slot 57 should keep one there too.

AI-assisted (Claude Code). Windows 11, RTX 5070, driver 621.24.

@SweatierKey

Copy link
Copy Markdown
Contributor

@LooperSalty Quick clarification on the 32,256 count: that figure was quoted from the #7154 boot log rather than a local run on my host (I'm on Linux without a Windows/GPU run). Your runs 3–4 actually line up neatly with @MarcPique's measurement right above: when slot 57 returns E_INVALIDARG, the title falls back to creating PSOs via slot 86 and doesn't call slot 55; when slot 57 succeeds (10,241 PSOs in @MarcPique's run), the title immediately follows with 41,545 slot-55 derivations on those base PSOs.

@thedarkcr0w

Copy link
Copy Markdown

Ported onto a local integration of the retail boot chain and run against my own 1.0.2.1 copy (RTX 4090). The record reader works as written: tags 0 depth-stencil, 1 rasterizer, 2 blend, 3 sample mask and 5 stencil masks, applied to a kept copy of the base's stream. One gap for the retail title: it calls slot 55 about 41,500 times per boot, and its bases are slot 57 pipelines (DeserializeGraphicsPipelineStateX from the pipeline library), not slot 86 or 55 ones. So with this PR alone every derivation is refused ("base PSO has no kept stream"), and the title rebuilds each through slot 86.

Our fix is on thedarkcr0w/Leonida:slot57-gfx-pso, commit 071982a0b. Your d3d12_xs_pso_stream.{h,cpp} and pso_stream_test.cpp are taken unchanged and credited. A slot 57 pipeline now keeps the description the proxy built for it as a pipeline-state stream, so slot 55 derives from library pipelines too. Slot 55 also runs inside the host-stall scope (#7858), as slot 57 does: otherwise the title's startup hang check fires once ~41k derivations really build.

Tests: pso_stream and your 11 device_proxy slot 55 cases over WARP pass, with 0 failures. d3d12_slot57_draw gains a 4th pipeline, derived through slot 55 from a slot 57 base (rasterizer record, culling off), drawn and read back on the Vulkan device. It needs the slot 57 handler (see #8890's thread), so it's offered there, not as a competing PR. Feel free to take it.

AI-assisted (Claude Code).

@Yoshi-OOF

Copy link
Copy Markdown

Confirmed the missing ABI route in a real native Windows/RTX 5070 Ti run on the earlier rt5-integration 2bd3841 stack: the host faults in Device::CreateReservedResource1, reached through proxy_slot<55> from the title. The PC method interprets console derived-PSO arguments as resource arguments and dereferences an invalid output pointer. This is not evidence of Vulkan device loss: a breakpoint on the runtime device-loss marker was not reached. I have fetched the new rt5-integration 2229c0a containing this PR and am integrating the actual derived-PSO route; no guest assertion skip.

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…vice slot 55

Squashed from ItsNotRexed#7759 by LooperSalty, head d80c408 (security scan PASS).

Contains ItsNotRexed#7201 and ItsNotRexed#7125 (both already here). Conflicts: slot names, routing, device_slot_overridden and the header add slot 55 to the union; docs, the CreateReservedResource checks in d3d12_vulkan_device_test and device_proxy_test take this PR's version; the mock test keeps the slot 133/41/61 checks.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…t expectations)

ItsNotRexed#7759 carries ItsNotRexed#7201's slot 86/101/108 handlers; its squash added them a second time next to ItsNotRexed#7201's copy (the 101/108 bodies are identical, and ItsNotRexed#7759's slot 86 keeps the PSO stream for slot 55), so ItsNotRexed#7201's copy is removed.

xs_proxy_mock_test: the check_xbox_slots summary line merged for ItsNotRexed#7163 had its \n written as a line break; ItsNotRexed#7235's slot-127 hook check now expects no PC slot 25 call for a listed render target (the console-size port from ItsNotRexed#7240 sizes it, same 33,423,360 B); ItsNotRexed#7821's check_view_heap_cap releases the heaps it makes, since its CreateDescriptorHeap mock case is now ItsNotRexed#7021's, which makes a heap proxy holding the device.

d3d12_vulkan_device_test: the meta-command checks run on the device behind the Xbox proxy, as ItsNotRexed#7125 does for CreateReservedResource2: proxy slot 61 is the title's CreateSamplerX (ItsNotRexed#7115).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ots 86, 101 and 108

Squashed from ItsNotRexed#8517 by Hiiva, head 07b32da (security scan PASS).

Applied as the PR's own diff (gh pr diff): its branch sits on a newer upstream main. The tree already has one handler per slot (ItsNotRexed#7201, with ItsNotRexed#7759's stream-keeping slot 86), and the apply added this PR's copies beside them; the copies are dropped and the single handlers go through the queried interfaces instead: create_pso_from_stream (slots 86 and 55) through ID3D12Device2, slot 101 through ID3D12Device5, slot 108 through ID3D12Device8. Its check_distinct_device_interfaces test is added to the mock test's list.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ompiles are host stalls

Slot 57 now creates every pipeline as one pipeline state stream through the
proxy's create_pso_from_stream (ItsNotRexed#7759), which keeps the stream on the PSO, so
slot 55 can derive from slot-57 pipelines; the stub request goes the same way.
A device without ID3D12Device2 refuses slot 57 as it refuses slot 86.

The Vulkan device's vkCreateGraphicsPipelines now runs inside the same
rt::host_stall::Scope as the compute compile (ItsNotRexed#7858), so a guest Sleep sits
out the slot-57 compile burst instead of tripping the title's hang check.

xs_native_pso_test: the mock answers only PC slot 47, its root signature and
pipelines are COM objects with private data, and a new case derives through
slot 55 from a slot-57 pipeline.
@Yoshi-OOF

Copy link
Copy Markdown

Integration follow-up with #8890 and all demanded native graphics programs: the PC-slot-55 access violation is fixed, but the title now hits the documented refusal, base PSO has no kept stream. Every sampled slot-55 derivation is refused that way on this run. The proxy currently retains creation state at slots 86/55, not the D3D12_GRAPHICS_PIPELINE_STATE_DESC produced by slot 57. I am adding an exact owning stream representation for that already-converted native graphics descriptor, reusing PsoStreamRecord/derive_stream rather than guessing new fixed-function fields. Synthetic coverage and the retail comparison will be reported separately.

@Yoshi-OOF

Copy link
Copy Markdown

Exact native-state retention follow-up: the local slot-57 path now captures the D3D12_GRAPHICS_PIPELINE_STATE_DESC it actually submitted into PsoStreamRecord, before its temporary input-layout strings expire. It uses the same stream decoder/derive_stream path, with no new guessed state fields. The authored regression mutates caller shader/layout/SO/cache buffers, derives four state records, recaptures and releases the base; contents and state changes are checked. Both it and the existing stream oracle pass natively with MSVC. On the retail comparison, 41,545 slot-55 derivations now return success (previously refused for missing base state); the later queue refusal/title breakpoint and black readback remain. This fixes that ABI/base-state boundary, not the final rendered image.

@Maraco91

Copy link
Copy Markdown
Contributor

Two things from reading this code as it runs in the maintainers' integration main (1812e0bd1, where the stream record also serves slot 57). Read from the source, not run: I have no copy of the game, so the sizes below are not measured. File and line numbers are that commit's.

1. Every pipeline keeps a private copy of all its stage bytecode.

  • create_pso_from_stream (d3d12_xs_device.cpp, around 3490) calls keep_pso_stream after every successful CreatePipelineState, for slots 86, 57 and 55.
  • PsoStreamRecord::capture → copy_pointed_data copies each stage's bytes into the record: code.pShaderBytecode = own_blob(blobs_, code.pShaderBytecode, code.BytecodeLength); (d3d12_xs_pso_stream.cpp 222-227, own_blob at 94-98).
  • Slot 57 passes whole containers as stage bytecode: const D3D12_SHADER_BYTECODE bc{code[s.block]->data(), code[s.block]->size()}; (d3d12_xs_native_pso.h, around 426). So the container cache in the same header ("each file is read once", load_container) is followed, one call later, by one private copy per pipeline.
  • A slot 55 derivation starts from the base's stream (out = base.bytes();, derive_stream, 275), whose stage pointers are the base record's blobs, and create_pso_from_stream then captures the patched stream: a second full copy for each derived pipeline.

With the pipeline counts reported in the boot log (tens of thousands created and kept for the whole boot), the records hold one copy of every stage container per pipeline. Whether that is megabytes or gigabytes depends on the container sizes, which I cannot measure; I have asked for the number in #8851.

A way out that keeps the record's contract: hold the stage bytes as std::shared_ptr<const std::vector<…>>, let a derived record share its base's blobs, and let slot 57 hand its cached Container pointers to the record instead of raw bytes.

2. Allocation failures on the same path leave the thunks as exceptions, and one leaves a lock held.
The proxy's rule is "Nothing here throws, since an exception must not leave a thunk for the title's code". On this path nothing catches:

  • new PsoStreamRecord() and record->bytes_.assign(...) in capture (193-194), blobs.emplace_back(...) in own_blob (97), out = base.bytes() in derive_stream (275), new RecordOwner(...) in attach_pso_record (298);
  • in d3d12_xs_native_pso.h: std::make_shared in load_container, np::plan(...) and elements.push_back(...) in the slot 57 handler;
  • self->vb_scratch.assign(...) and so_scratch.assign(...) in list slots 48 and 49 (d3d12_xs_device.cpp, around 2182 and 2193; that part is d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path #2490's).

keep_pso_stream's log line already names "allocation failure" as a reason, but an allocation failure there throws before it can be reported.

The worst one: load_container takes g_lock by hand (AcquireSRWLockExclusive), then does new std::unordered_map<…>() and try_emplace(...) before ReleaseSRWLockExclusive. If either throws, the lock is never released and every later slot 57 call blocks on it. A scope guard for the lock fixes that independently of the rest.

#9091 (slot 67) and #9417 (the root-signature exports) are the same class on GitHub main, with the allocation-failure injection xs_proxy_mock_test already has; the same helper could cover slots 86 and 55 here.

Not checked: any run, any measurement, and whether a later commit on the integration branch already changes this (1812e0bd1 is still its head as I write).

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.