d3d12_xs: console device slot 74 registers a page pool and writes its handle (RT-SLOT74-POOL-HANDLE) #1470

Closed
QemmHD wants to merge 1 commit from upstream-pr/1470 into main
QemmHD commented 2026-11-25 00:56:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-25T00:56:20Z.


Claimed in the coordination issue as: RT-SLOT74-POOL-HANDLE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148763283)

What and why

Console device slot 74 is called with (pointer, u32, pointer). Since #385, proxy_slot74 logs the call and returns S_OK without writing anything, so the title keeps whatever was in its handle variable. VIctory reads the method as RegisterPagePool(address, page count, handle out): it refuses a null out pointer, a zero page count or a base that isn't 64 KiB aligned with E_INVALIDARG, and otherwise records the pool and writes a handle (Marvisak/VIctory, GPL-3, crates/victory-gpu/src/device.rs, register_page_pool). This PR does the same, written anew for this repository:

  • Same refusals as VIctory, with nothing written and no handle used up. It also refuses a base of 0, and an out pointer that isn't 8-byte aligned or isn't committed writable memory (checked with VirtualQuery), since writing there would fault.
  • On success it records {address, pages} in a mutex-guarded registry and writes a 64-bit handle from a counter that starts at 1, so a handle is never 0 and never reused. console_page_pool(handle, &addr, &pages) reads a record back for later users.
  • The registry lives in d3d12_xs: #968's queue slot 31 takes the pool base directly, so nothing there depends on this.
  • The first call is logged once.
  • Host callers are unchanged: PC slot 74 stays ID3D12Device9::ShaderCacheControl.
  • Not implemented here: VIctory treats console slot 75 as UnregisterPagePool. Leonida still sends every slot 75 call to the PC CreateCommandQueue1. That's noted as a TODO and in docs/d3d12_vulkan.md.

Whether the title reads the handle later hasn't been measured. This just stops it from holding an unset value.

Tested

Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 Build Tools + Ninja, RelWithDebInfo, on main b4b7756e8.

  • xs_proxy_mock_test: check_slot74 covers two calls giving distinct handles with the right records; the five E_INVALIDARG cases (nothing written, no handle used); and host forwarding at levels 9 and 0. It passes both plain and with LEONIDA_VK_VALIDATION=1.
  • Negative control: with main's stand-in put back, the test fails at the distinct-handles check.
  • Full ctest: the only failure is the pre-existing d3d12_depth_resolve.
  • Repository-consistency set (test_cmake_, test_shader_stage_resume, test_runtime_paths, test_docs_, test_make_game_, test_check_no_game_data, test_run_semantic_tests, test_ctest_registration): 578 passed, 5 skipped.
  • git merge-tree: clean against main, #1387, #1390 and #1328. #968 and #984 already conflict with main elsewhere, and this adds no new conflict with #968's slot 31 code.
  • No retail run (that needs game files). One risk: main accepted any arguments, so a retail call with an unaligned base would now get E_INVALIDARG. VIctory refuses the same case and reaches the world, which suggests the title passes valid arguments.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • 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. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5483019590 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1470). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-25T00:56:20Z. --- Claimed in the coordination issue as: RT-SLOT74-POOL-HANDLE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148763283) ### What and why Console device slot 74 is called with `(pointer, u32, pointer)`. Since #385, `proxy_slot74` logs the call and returns `S_OK` without writing anything, so the title keeps whatever was in its handle variable. VIctory reads the method as `RegisterPagePool(address, page count, handle out)`: it refuses a null out pointer, a zero page count or a base that isn't 64 KiB aligned with `E_INVALIDARG`, and otherwise records the pool and writes a handle (Marvisak/VIctory, GPL-3, `crates/victory-gpu/src/device.rs`, `register_page_pool`). This PR does the same, written anew for this repository: - **Same refusals as VIctory**, with nothing written and no handle used up. It also refuses a base of 0, and an out pointer that isn't 8-byte aligned or isn't committed writable memory (checked with `VirtualQuery`), since writing there would fault. - **On success** it records `{address, pages}` in a mutex-guarded registry and writes a 64-bit handle from a counter that starts at 1, so a handle is never 0 and never reused. `console_page_pool(handle, &addr, &pages)` reads a record back for later users. - **The registry lives in d3d12_xs:** #968's queue slot 31 takes the pool base directly, so nothing there depends on this. - **The first call is logged once.** - **Host callers are unchanged:** PC slot 74 stays `ID3D12Device9::ShaderCacheControl`. - **Not implemented here:** VIctory treats console slot 75 as `UnregisterPagePool`. Leonida still sends every slot 75 call to the PC `CreateCommandQueue1`. That's noted as a TODO and in `docs/d3d12_vulkan.md`. Whether the title reads the handle later hasn't been measured. This just stops it from holding an unset value. ### Tested Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 Build Tools + Ninja, RelWithDebInfo, on main b4b7756e8. - `xs_proxy_mock_test`: `check_slot74` covers two calls giving distinct handles with the right records; the five `E_INVALIDARG` cases (nothing written, no handle used); and host forwarding at levels 9 and 0. It passes both plain and with `LEONIDA_VK_VALIDATION=1`. - **Negative control:** with main's stand-in put back, the test fails at the distinct-handles check. - **Full ctest:** the only failure is the pre-existing `d3d12_depth_resolve`. - **Repository-consistency set** (test_cmake_*, test_shader_stage_resume, test_runtime_paths, test_docs_*, test_make_game_*, test_check_no_game_data*, test_run_semantic_tests, test_ctest_registration): 578 passed, 5 skipped. - `git merge-tree`: clean against main, #1387, #1390 and #1328. #968 and #984 already conflict with main elsewhere, and this adds no new conflict with #968's slot 31 code. - **No retail run** (that needs game files). One risk: main accepted any arguments, so a retail call with an unaligned base would now get `E_INVALIDARG`. VIctory refuses the same case and reaches the world, which suggests the title passes valid arguments. GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly. - [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. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
whoalin1 commented 2026-11-25 07:52:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T07:52:58Z.


Independent verification (native Windows 11, validation on):

  • CPU: xs_proxy_mock 7/7 pass including the new slot-74 checks (E_INVALIDARG refusals, read-only/unaligned-base cases, non-zero unique handle write).
  • NVIDIA RTX 4070 SUPER: 8/8 pass — d3d12_draw/compute/geometry/vulkan_device, device_proxy, queue_proxy, allocator_proxy.
  • AMD Radeon iGPU: 5/8 — the 3 failures are the known 144>128 push-constant iGPU limit, identical on baseline; they do not exercise slot 74 (console-caller path).

Heads-up for the author: this PR is CONFLICTING/DIRTY vs current main — git merge-tree shows content conflicts in runtime/shims/d3d12_xs_device.cpp and .h (contextual, not duplicate work). It also sits ~250 commits behind; a rebase onto current main is needed before it can merge. Verified as pushed.

AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7156357887 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1470#issuecomment-7156357887). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T07:52:58Z. --- Independent verification (native Windows 11, validation on): - CPU: `xs_proxy_mock` 7/7 pass including the new slot-74 checks (E_INVALIDARG refusals, read-only/unaligned-base cases, non-zero unique handle write). - **NVIDIA RTX 4070 SUPER**: 8/8 pass — `d3d12_draw`/`compute`/`geometry`/`vulkan_device`, `device_proxy`, `queue_proxy`, `allocator_proxy`. - **AMD Radeon iGPU**: 5/8 — the 3 failures are the known 144>128 push-constant iGPU limit, identical on baseline; they do not exercise slot 74 (console-caller path). Heads-up for the author: this PR is **CONFLICTING/DIRTY** vs current main — `git merge-tree` shows content conflicts in `runtime/shims/d3d12_xs_device.cpp` and `.h` (contextual, not duplicate work). It also sits ~250 commits behind; a rebase onto current main is needed before it can merge. Verified as pushed. AI-assisted verification.
MoonEyes commented 2026-11-28 17:59:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:59:40Z.


Hi @QemmHD, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/shims/d3d12_xs_device.cpp, runtime/shims/d3d12_xs_device.h), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243445795 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1470#issuecomment-7243445795). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:59:40Z. --- Hi @QemmHD, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/shims/d3d12_xs_device.cpp`, `runtime/shims/d3d12_xs_device.h`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
ajussak commented 2026-11-29 14:45:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ajussak on 2026-11-29T14:45:33Z.


Game-run test of this PR (retail 1.0.2.1 package, gta6rt --run under Proton Experimental / Wine 11, Linux)

Setup: Fedora 45, kernel 7.3, NVIDIA GeForce RTX 3060 Ti, driver 620.73.04, 31 GB RAM. Runtime cross-built with clang-cl 23.1.6 + xwin, SDL3 on. Shaders translated on main 5844b6481 with wave64 emulation, without --f16-interp-fallback.

What I tested: this branch merged locally into main a554262ba. The only conflicts were the slot 70/71/73/74 comment lines in d3d12_xs_device.h and the slot-name table in d3d12_xs_device.cpp. I kept main's lines for 70/71/73 and this PR's lines for 74.

Result: the slot 74 call now takes the new path. It records a 64 KiB-aligned pool of 99,776 pages and writes a handle to the title's out pointer, which is 8-byte aligned and writable. But the boot still stops right after it, with the same fault as on plain main:

  • title read fault at t+0xb5a5f8, reading address 0x68 (null base + 0x68), 0xc0000005
  • same title offset and same faulting address with and without this PR
  • it's the first fault of the run, during device and heap setup, before the launch movie

So on this machine the handle write doesn't get the boot past that point. Either the null pointer read at t+0xb5a5f8 doesn't come from slot 74's out value, or slot 74 is expected to do more than write a handle. That's a hypothesis: I haven't traced which pointer the faulting instruction reads. The change itself behaves as described, and nothing regressed in what I could see.

AI-assisted (Claude Code). The test was run on my machine; no game data or log excerpts are included here.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257553344 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1470#issuecomment-7257553344). Originally posted by [ajussak](https://github.com/ajussak) on 2026-11-29T14:45:33Z. --- Game-run test of this PR (retail 1.0.2.1 package, `gta6rt --run` under Proton Experimental / Wine 11, Linux) **Setup:** Fedora 45, kernel 7.3, NVIDIA GeForce RTX 3060 Ti, driver 620.73.04, 31 GB RAM. Runtime cross-built with clang-cl 23.1.6 + xwin, SDL3 on. Shaders translated on `main` 5844b6481 with wave64 emulation, without `--f16-interp-fallback`. **What I tested:** this branch merged locally into `main` a554262ba. The only conflicts were the slot 70/71/73/74 comment lines in `d3d12_xs_device.h` and the slot-name table in `d3d12_xs_device.cpp`. I kept `main`'s lines for 70/71/73 and this PR's lines for 74. **Result:** the slot 74 call now takes the new path. It records a 64 KiB-aligned pool of 99,776 pages and writes a handle to the title's out pointer, which is 8-byte aligned and writable. But the boot still stops right after it, with the same fault as on plain `main`: - title read fault at `t+0xb5a5f8`, reading address `0x68` (null base + 0x68), `0xc0000005` - same title offset and same faulting address with and without this PR - it's the first fault of the run, during device and heap setup, before the launch movie So on this machine the handle write doesn't get the boot past that point. Either the null pointer read at `t+0xb5a5f8` doesn't come from slot 74's out value, or slot 74 is expected to do more than write a handle. That's a hypothesis: I haven't traced which pointer the faulting instruction reads. The change itself behaves as described, and nothing regressed in what I could see. AI-assisted (Claude Code). The test was run on my machine; no game data or log excerpts are included here.
aslan2142 commented 2026-12-01 16:36:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:36:23Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317883773 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1470#issuecomment-7317883773). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:36:23Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!1470
No description provided.