d3d12_xs: route device slots 86, 101 and 108 to PC Device2/Device5/Device8, rebased on main (RT-SLOT108-REBASE) #727

Manually merged
github merged 3 commits from gh-pr/727/head into gh-pr/727/base 2026-11-26 09:18:18 +00:00
Owner

@⁠DesertGamer on GitHub · 2026-11-24 12:59 UTC · original
DesertGamer:fix/slot108-rebase → main · +368 −13 · 5 files · 3 commits · merged 2026-11-24 23:32 UTC

Claimed in the coordination issue as: RT-SLOT108-REBASE (#14)

Depends on: none to merge. The retail boot reaches slot 108 only past the command-list IID stop at device slot 73, which #641, #359 and #142 each cover; I measured the slot-108 fault on a stack with #142, and #641 alone gave the same 1,639-call stop point on main before it. Supersedes #219, which conflicts with main.

What and why

#219 (old PR 9954 by justr4mzi, carried over as a draft) rebased onto main 21625bca8. The commit is the original one, cherry-picked with -x, so the author credit is kept; the only changes are the resolution of its conflicts with main: three hunks in runtime/shims/d3d12_xs_device.cpp (the new proxy functions go after proxy_slot74, the Slot == 86 / 101 / 108 branches after the kCreateCommittedResource3X one, and 86 || 101 || 108 is added to device_slot_overridden) and the comment in d3d12_xs_device.h. The tests and docs/d3d12_vulkan.md apply as they are.

What it fixes, measured on a retail run: on the stack main + #142 + #427 (the slot-73 fix is #142 there; #641 is the equivalent open one) the title calls console device slot 108 with the device in RDX and RCX not an object (the slot-26 shape); proxy_slot takes self from RCX and faults in the host after 11,916 D3D12 calls. With slot 108 routed to GetResourceAllocationInfo2 the run goes on, and with #602 (A8_UNORM) it reached the frame loop (888,983 PresentX ok in 420 s with #357 #387 #432 too; details in #14).

Tested

  • ctest -R "xs_proxy_mock|device_proxy": 8 of 8 pass (MSVC, Windows 11, Vulkan SDK 1.4.363).
  • scripts/check_no_game_data.py on the five changed files, and all tests/test_docs_*.py: pass.
  • Retail run as above, RTX 5070, driver 617.14.

GPUs tested: NVIDIA GeForce RTX 5070, driver 617.14, Windows 11

AI-assisted: yes (Claude Code, Sonnet 5.5)

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. (Not a translator change.)
**@⁠DesertGamer** on GitHub · 2026-11-24 12:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/727) `DesertGamer:fix/slot108-rebase` → `main` · +368 −13 · 5 files · 3 commits · merged 2026-11-24 23:32 UTC Claimed in the coordination issue as: RT-SLOT108-REBASE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) Depends on: none to merge. The retail boot reaches slot 108 only past the command-list IID stop at device slot 73, which #641, #359 and #142 each cover; I measured the slot-108 fault on a stack with #142, and #641 alone gave the same 1,639-call stop point on `main` before it. Supersedes #219, which conflicts with `main`. ### What and why #219 (old PR 9954 by `justr4mzi`, carried over as a draft) rebased onto `main` 21625bca8. The commit is the original one, cherry-picked with `-x`, so the author credit is kept; the only changes are the resolution of its conflicts with `main`: three hunks in `runtime/shims/d3d12_xs_device.cpp` (the new proxy functions go after `proxy_slot74`, the `Slot == 86 / 101 / 108` branches after the `kCreateCommittedResource3X` one, and `86 || 101 || 108` is added to `device_slot_overridden`) and the comment in `d3d12_xs_device.h`. The tests and `docs/d3d12_vulkan.md` apply as they are. What it fixes, measured on a retail run: on the stack `main` + #142 + #427 (the slot-73 fix is #142 there; #641 is the equivalent open one) the title calls console device slot 108 with the device in RDX and RCX not an object (the slot-26 shape); `proxy_slot` takes `self` from RCX and faults in the host after 11,916 D3D12 calls. With slot 108 routed to `GetResourceAllocationInfo2` the run goes on, and with #602 (A8_UNORM) it reached the frame loop (888,983 `PresentX ok` in 420 s with #357 #387 #432 too; details in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). ### Tested - `ctest -R "xs_proxy_mock|device_proxy"`: 8 of 8 pass (MSVC, Windows 11, Vulkan SDK 1.4.363). - `scripts/check_no_game_data.py` on the five changed files, and all `tests/test_docs_*.py`: pass. - Retail run as above, RTX 5070, driver 617.14. GPUs tested: NVIDIA GeForce RTX 5070, driver 617.14, Windows 11 AI-assisted: yes (Claude Code, Sonnet 5.5) ### 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not a translator change.)
Reopened from #7201 (closed in the PR reset), rebased on current main.

Slot 86 (CreatePipelineState stream) -> PC slot 47, slot 101
(CreateStateObject) -> PC slot 62, slot 108 (GetResourceAllocationInfo2)
-> PC slot 68. Slot 108 accepts the console C-ABI order (return buffer
first) and the PC order, reads the title's 56-byte D3D12_RESOURCE_DESC
entries, expands each into a zeroed D3D12_RESOURCE_DESC1, normalizes
Xbox layout words and flag bits, and refuses a count with a null array.

Rebase: kept main's slot 133 (CreatePlacedResourceX) next to the new
slots, and slot 108 now masks flags with slot 133's PC set (0x5FF, which
keeps USE_TIGHT_ALIGNMENT and drops 0x200) instead of 0x1FF.

(cherry picked from commit 1b07215c84)
The fixed handlers for slots 86, 101 and 108 were matched before the generic branch, which is where xbox_device_slot_routes() is read, so a route that LEONIDA_XS_FRAME_STATISTICS_SLOT or another LEONIDA_XS_*_SLOT variable put on one of those slots never ran. After the rebase onto main, xs_proxy_mock_env_slots failed for that reason: slot 101 reached CreateStateObject instead of GetFrameStatisticsX.

The three handlers now sit after the route checks and before the refusal for slots beyond the PC device table, and their own note_slot calls are gone because the generic branch already counts the slot once, so the hit counters stay at 1.
Three files conflicted; in each, both sides had added something and both
are kept.

runtime/shims/d3d12_xs_device.cpp: this branch still had the Xbox device
slot routes inline, followed by its fixed handlers for slots 86, 101 and
108; main has since moved the same six routes into
route_xbox_device_slot() (#385). The generic path now calls the helper and
then the three fixed handlers, so a configured route still wins over
them, as this branch's second commit intends. device_slot_overridden()
has main's list plus 86, 101 and 108.

runtime/shims/d3d12_xs_device.h: the comment lists both sides' slots.

runtime/test/xs_proxy_mock_test.cpp: the mock device keeps main's case 13
(CheckFeatureSupport) and this branch's case 68
(GetResourceAllocationInfo2); check_xbox_slots keeps main's slot 41 and 61
cases, one combined list of handled slots, and this branch's slot 86, 101
and 108 cases.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:18:15 +00:00
github manually merged commit 7234bcd7a5 into gh-pr/727/base 2026-11-26 09:18:18 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 13:15 UTC · original · approved these changes

LGTM. Critical D3D12 XS slot routing for Xbox slots 86 (CreatePipelineState -> PC 47), 101 (CreateStateObject -> PC 62), and 108 (GetResourceAllocationInfo2 -> PC 68 with C-ABI struct return support and Xbox resource desc normalization). Unit tests in d3d12_xs_test.cpp verify all calling conventions.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 13:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/727#pullrequestreview-6039839855) · **approved these changes** LGTM. Critical D3D12 XS slot routing for Xbox slots 86 (CreatePipelineState -> PC 47), 101 (CreateStateObject -> PC 62), and 108 (GetResourceAllocationInfo2 -> PC 68 with C-ABI struct return support and Xbox resource desc normalization). Unit tests in d3d12_xs_test.cpp verify all calling conventions.
Author
Owner

@⁠moffington on GitHub · 2026-11-24 14:29 UTC · original

Independently tested 3c8b583e under Wine against merge base 21625bca8 and a trial merge onto main at d0da7dade.

The slot 86/101/108 changes pass all six xs_proxy_mock tests on the PR head. A synthetic Wine ID3D12Device8 probe also confirms the slot routing, struct-return ABI and resource-description normalization. The two existing device_proxy failures remain unchanged.

However, the trial merge onto main introduces a regression in xs_proxy_mock_env_slots (5/6 tests pass).

The fixed slot 86/101/108 handlers in proxy_slot take precedence over xbox_device_slot_routes(). This shadows the environment-configured GetFrameStatisticsX route to slot 101 introduced by #402:

[rt] d3d12_xs: device slot 101 (Xbox CreateStateObject -> PC CreateStateObject (slot 62)) first call
xs_proxy_mock line 1196: hr_of(raw(device, 101, 77, 0x1a, word(&count), 0)) == S_FALSE && env.stats == 1

Could you rebase onto current main and preserve the configurable routing behavior? The new fixed-slot handlers otherwise look good.

**@⁠moffington** on GitHub · 2026-11-24 14:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/727#issuecomment-7134465468) Independently tested `3c8b583e` under Wine against merge base `21625bca8` and a trial merge onto `main` at `d0da7dade`. The slot 86/101/108 changes pass all six `xs_proxy_mock` tests on the PR head. A synthetic Wine ID3D12Device8 probe also confirms the slot routing, struct-return ABI and resource-description normalization. The two existing `device_proxy` failures remain unchanged. However, the trial merge onto main introduces a regression in `xs_proxy_mock_env_slots` (5/6 tests pass). The fixed slot 86/101/108 handlers in `proxy_slot` take precedence over `xbox_device_slot_routes()`. This shadows the environment-configured `GetFrameStatisticsX` route to slot 101 introduced by #402: ``` [rt] d3d12_xs: device slot 101 (Xbox CreateStateObject -> PC CreateStateObject (slot 62)) first call xs_proxy_mock line 1196: hr_of(raw(device, 101, 77, 0x1a, word(&count), 0)) == S_FALSE && env.stats == 1 ``` Could you rebase onto current main and preserve the configurable routing behavior? The new fixed-slot handlers otherwise look good.
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 14:45 UTC · original

@⁠moffington thanks, rebased and fixed; the head is now ac73a8412 (two commits on main f3e26be7c: the carried-over one, with its author kept, and a fix of mine on top).

Reproduced first. After the rebase, xs_proxy_mock_env_slots failed here too (7 of 8 of xs_proxy_mock* and device_proxy passed, native Windows 11, MSVC, no Wine). The cause is the one you named: in proxy_slot the Slot == 86 / 101 / 108 branches came before the generic branch, where xbox_device_slot_routes() is read, so a LEONIDA_XS_FRAME_STATISTICS_SLOT pointing at 101 never ran.

Fix. The three handlers now sit after the route checks and before the refusal for slots past the PC device table (the remainder of that branch is an else of the same if constexpr chain, so there is no new C4702). Their own note_slot calls are removed, since the generic branch already counts the slot once; the hit counters stay at 1. A configured route wins over the fixed handler on that slot; without the variable, 86, 101 and 108 behave as before.

Result. xs_proxy_mock, its four variants including xs_proxy_mock_env_slots and xs_proxy_mock_env_slots_invalid, device_proxy and device_proxy_trace: 8 of 8 pass. I did not run under Wine, so your two device_proxy failures there are not reproduced or checked; I did not run the rest of the CTest suite or the game on this head.

AI-assisted: yes (Claude Code, Sonnet 5.5)

**@⁠DesertGamer** on GitHub · 2026-11-24 14:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/727#issuecomment-7134899730) @⁠moffington thanks, rebased and fixed; the head is now `ac73a8412` (two commits on `main` `f3e26be7c`: the carried-over one, with its author kept, and a fix of mine on top). **Reproduced first.** After the rebase, `xs_proxy_mock_env_slots` failed here too (7 of 8 of `xs_proxy_mock*` and `device_proxy` passed, native Windows 11, MSVC, no Wine). The cause is the one you named: in `proxy_slot` the `Slot == 86 / 101 / 108` branches came before the generic branch, where `xbox_device_slot_routes()` is read, so a `LEONIDA_XS_FRAME_STATISTICS_SLOT` pointing at 101 never ran. **Fix.** The three handlers now sit after the route checks and before the refusal for slots past the PC device table (the remainder of that branch is an `else` of the same `if constexpr` chain, so there is no new `C4702`). Their own `note_slot` calls are removed, since the generic branch already counts the slot once; the hit counters stay at 1. A configured route wins over the fixed handler on that slot; without the variable, 86, 101 and 108 behave as before. **Result.** `xs_proxy_mock`, its four variants including `xs_proxy_mock_env_slots` and `xs_proxy_mock_env_slots_invalid`, `device_proxy` and `device_proxy_trace`: 8 of 8 pass. I did not run under Wine, so your two `device_proxy` failures there are not reproduced or checked; I did not run the rest of the CTest suite or the game on this head. AI-assisted: yes (Claude Code, Sonnet 5.5)
Author
Owner

@⁠Mouad-Scriptz-0 on GitHub · 2026-11-24 21:59 UTC · original

This conflicts with main, and it's on the path to the frame loop, so here's a rebase to save a step: rebased/pr727 (a50472cfd). It has the same 2 commits and authors on main 4a50cafc7. git range-diff against this branch shows no commit's own change was altered.

The one conflict: in runtime/test/xs_proxy_mock_test.cpp, main added case 13 (CheckFeatureSupport FEATURE_LEVELS) to the mock device switch where this PR adds case 68 (GetResourceAllocationInfo2). I kept both, each with its own block.

Not compiled or run here: I have no Windows SDK on this machine, so CI is the first build.

To take it (maintainer edits are on):

git fetch https://github.com/Mouad-Scriptz-0/leonida rebased/pr727
git push --force-with-lease=fix/slot108-rebase:ac73a8412 https://github.com/DesertGamer/leonida FETCH_HEAD:fix/slot108-rebase

AI-assisted.

**@⁠Mouad-Scriptz-0** on GitHub · 2026-11-24 21:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/727#issuecomment-7145656336) This conflicts with `main`, and it's on the path to the frame loop, so here's a rebase to save a step: [`rebased/pr727`](https://github.com/Mouad-Scriptz-0/leonida/tree/rebased/pr727) (`a50472cfd`). It has the same 2 commits and authors on `main` `4a50cafc7`. `git range-diff` against this branch shows no commit's own change was altered. **The one conflict:** in `runtime/test/xs_proxy_mock_test.cpp`, `main` added `case 13` (CheckFeatureSupport FEATURE_LEVELS) to the mock device switch where this PR adds `case 68` (GetResourceAllocationInfo2). I kept both, each with its own block. **Not compiled or run here:** I have no Windows SDK on this machine, so CI is the first build. To take it (maintainer edits are on): ```sh git fetch https://github.com/Mouad-Scriptz-0/leonida rebased/pr727 git push --force-with-lease=fix/slot108-rebase:ac73a8412 https://github.com/DesertGamer/leonida FETCH_HEAD:fix/slot108-rebase ``` AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 23:32 UTC · original

Merged. This is the next rung on main's boot path: with #375, #377, #383 and #385 in, the title's next reported stop is the first call of device slot 108. The branch conflicted with main, so I brought it up to date the way the Mumogg rungs were: one merge commit of main (2376e7d56) on top of ac73a8412 (7234bcd7a). justr4mzi's and DesertGamer's commits are untouched and nothing was force-pushed. Thanks to both, and to @⁠Mouad-Scriptz-0 for the earlier rebase, whose case 13 / case 68 resolution this one matches.

What it does:

  • Device slot 108 goes to the PC ID3D12Device8::GetResourceAllocationInfo2 (slot 68). It takes the console's C-ABI struct return (return buffer in RCX, device in RDX) as well as the PC order, and cleans the title's 56-byte descriptions on a copy. This removes the measured fault in proxy_slot<108>.
  • Slots 86 and 101 go to the PC CreatePipelineState (47) and CreateStateObject (62).
  • A route configured with a LEONIDA_XS_*_SLOT variable still wins over the three fixed handlers.

Conflicts: three files; in each, both sides had added something and both are kept.

  • runtime/shims/d3d12_xs_device.cpp: this branch still had the six Xbox device slot routes inline, followed by its handlers for 86, 101 and 108; main has since moved those routes into route_xbox_device_slot() (#385). The generic path now calls the helper and then the three handlers. The six inline routes were compared with the helper line by line and are identical, so nothing is lost. device_slot_overridden() has main's list plus 86, 101 and 108.
  • runtime/shims/d3d12_xs_device.h: the comment lists both sides' slots.
  • runtime/test/xs_proxy_mock_test.cpp: the mock device keeps main's case 13 and this branch's case 68; check_xbox_slots keeps main's slot 41 and 61 cases, one combined list of handled slots, and this branch's slot 86, 101 and 108 cases. The two groups use different mock counters.

Holds and requests: none from a maintainer. moffington's request (rebase and keep the configurable routing) is answered by ac73a8412 and by this merge.

Tests (clang-cl with the xwin SDK; Wine, headless; llvmpipe and an RDNA2 iGPU):

  • Full Windows suite under Wine, the branch against main: no test changed state on either device (259 pass and 15 fail on llvmpipe, 255 and 21 on the iGPU, on both sides). xs_proxy_mock with its six variants, device_proxy and device_proxy_trace pass on both.
  • That run was on main 2376e7d56. #1055 went into main afterwards; it changes the command list and the replay, not these files, and the branch still merges cleanly.
  • The 12 test_docs_* files and check_no_game_data.py on the changed files are clean.
  • Not run here: MSVC, native Windows, and the game itself. DesertGamer's run on Windows 11 with MSVC and an RTX 5070 passes 8 of 8.

Follow-ups, none blocking the boot path:

  • Slot 108 cleans the descriptions with its own code instead of main's helpers (pc_resource_desc, d3d12_xs_desc_clean.h), and the results differ: its flag mask is 0x5FF where main uses 0x1FF (the comment calling it slot 133's mask is out of date); it maps every layout above 3, where slot 25 maps only 0x101; and it skips the console render-target placement, so for a listed render-target shape it returns the PC size where slot 25 and the lease return the console tile size. Worth making the two agree before resources are created from these sizes. The depth-stencil unordered-access strip is claimed as RT-DS-UAV-SLOT108.
  • Slots 86 and 101 are not measured from the title's calls yet; the docs paragraph does not say which of the three mappings are measured.
  • The closing printf of check_xbox_slots does not mention 86, 101 and 108.

#391 is the next rung.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 23:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/727#issuecomment-7147514859) Merged. This is the next rung on `main`'s boot path: with #375, #377, #383 and #385 in, the title's next reported stop is the first call of device slot 108. The branch conflicted with `main`, so I brought it up to date the way the Mumogg rungs were: one merge commit of `main` (`2376e7d56`) on top of `ac73a8412` (`7234bcd7a`). justr4mzi's and DesertGamer's commits are untouched and nothing was force-pushed. Thanks to both, and to @⁠Mouad-Scriptz-0 for the earlier rebase, whose `case 13` / `case 68` resolution this one matches. **What it does:** - Device slot 108 goes to the PC `ID3D12Device8::GetResourceAllocationInfo2` (slot 68). It takes the console's C-ABI struct return (return buffer in `RCX`, device in `RDX`) as well as the PC order, and cleans the title's 56-byte descriptions on a copy. This removes the measured fault in `proxy_slot<108>`. - Slots 86 and 101 go to the PC `CreatePipelineState` (47) and `CreateStateObject` (62). - A route configured with a `LEONIDA_XS_*_SLOT` variable still wins over the three fixed handlers. **Conflicts:** three files; in each, both sides had added something and both are kept. - `runtime/shims/d3d12_xs_device.cpp`: this branch still had the six Xbox device slot routes inline, followed by its handlers for 86, 101 and 108; `main` has since moved those routes into `route_xbox_device_slot()` (#385). The generic path now calls the helper and then the three handlers. The six inline routes were compared with the helper line by line and are identical, so nothing is lost. `device_slot_overridden()` has `main`'s list plus 86, 101 and 108. - `runtime/shims/d3d12_xs_device.h`: the comment lists both sides' slots. - `runtime/test/xs_proxy_mock_test.cpp`: the mock device keeps `main`'s `case 13` and this branch's `case 68`; `check_xbox_slots` keeps `main`'s slot 41 and 61 cases, one combined list of handled slots, and this branch's slot 86, 101 and 108 cases. The two groups use different mock counters. **Holds and requests:** none from a maintainer. moffington's request (rebase and keep the configurable routing) is answered by `ac73a8412` and by this merge. **Tests** (clang-cl with the xwin SDK; Wine, headless; llvmpipe and an RDNA2 iGPU): - Full Windows suite under Wine, the branch against `main`: no test changed state on either device (259 pass and 15 fail on llvmpipe, 255 and 21 on the iGPU, on both sides). `xs_proxy_mock` with its six variants, `device_proxy` and `device_proxy_trace` pass on both. - That run was on `main` `2376e7d56`. #1055 went into `main` afterwards; it changes the command list and the replay, not these files, and the branch still merges cleanly. - The 12 `test_docs_*` files and `check_no_game_data.py` on the changed files are clean. - Not run here: MSVC, native Windows, and the game itself. DesertGamer's run on Windows 11 with MSVC and an RTX 5070 passes 8 of 8. **Follow-ups, none blocking the boot path:** - Slot 108 cleans the descriptions with its own code instead of `main`'s helpers (`pc_resource_desc`, `d3d12_xs_desc_clean.h`), and the results differ: its flag mask is `0x5FF` where `main` uses `0x1FF` (the comment calling it slot 133's mask is out of date); it maps every layout above 3, where slot 25 maps only `0x101`; and it skips the console render-target placement, so for a listed render-target shape it returns the PC size where slot 25 and the lease return the console tile size. Worth making the two agree before resources are created from these sizes. The depth-stencil unordered-access strip is claimed as `RT-DS-UAV-SLOT108`. - Slots 86 and 101 are not measured from the title's calls yet; the docs paragraph does not say which of the three mappings are measured. - The closing `printf` of `check_xbox_slots` does not mention 86, 101 and 108. #391 is the next rung. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.