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

Open
github-bot wants to merge 1 commit from github-bot/gh-1470 into main AGit
Owner

@⁠QemmHD on GitHub · 2026-11-25 00:56 UTC · original
ubiquitarianism:claude/slot74-pool-handle → main · +102 −19 · 4 files · 1 commits · open

Claimed in the coordination issue as: RT-SLOT74-POOL-HANDLE (#14)

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

**@⁠QemmHD** on GitHub · 2026-11-25 00:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1470) `ubiquitarianism:claude/slot74-pool-handle` → `main` · +102 −19 · 4 files · 1 commits · open Claimed in the coordination issue as: RT-SLOT74-POOL-HANDLE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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
Since #385 the title's call of device slot 74, (pointer, u32, pointer), returns S_OK and writes nothing, so the title
keeps whatever its handle word held. VIctory (Marvisak/VIctory, GPL-3, crates/victory-gpu/src/resource.rs,
register_page_pool, device method 0x250) reads the method as RegisterPagePool(address, page count, handle out) for a
pool of 64 KiB pages, and writes a handle (index + 1) after refusing a null handle pointer, a page count of 0 or an
address that is not 64 KiB aligned with E_INVALIDARG. This is written anew from that reading.

For a console caller, proxy_slot74 now records {address, page count} in a mutex-guarded registry and writes a non-zero
64-bit handle from a counter (never reused) through the out pointer. It answers E_INVALIDARG and writes nothing for
VIctory's three cases and also for an address of 0 and a handle pointer that VirtualQuery does not show as committed,
writable memory (a write there would fault, so the console method cannot have succeeded on it either). The first call
is logged once. console_page_pool (d3d12_xs_device.h) reads a record back; nothing consumes a handle yet, as queue
slot 31 (CopyPageMappingsBatchX, #968) takes the pool's address directly, so the registry stays in d3d12_xs rather
than xmem. A host caller still gets the PC slot 74 (ID3D12Device9::ShaderCacheControl). VIctory reads slot 75 (0x258)
as UnregisterPagePool(handle); that is left as a TODO, since slot 75 is the PC CreateCommandQueue1 here.

Tested: xs_proxy_mock_test check_slot74 (two calls give distinct non-zero handles and their records; a null, read-only,
0-page, 0-address and misaligned call answer E_INVALIDARG, write nothing and take no handle; a host caller still
reaches ShaderCacheControl at level 9 and E_NOTIMPL at level 0), plain and with LEONIDA_VK_VALIDATION=1. With main's
stand-in put back the test fails at the handle check. Full ctest 309/310 (only d3d12_depth_resolve fails, as on
main); the docs/cmake/make_game consistency set passes (578 passed, 5 skipped). RTX 4070 SUPER, Windows 11. No retail
run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:52:36 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 07:52 UTC · original

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.

**@⁠whoalin1** on GitHub · 2026-11-25 07:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1470#issuecomment-7156357887) 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.
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_xs_device.cpp
  • runtime/shims/d3d12_xs_device.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1470/head:github-bot/gh-1470'
git switch 'github-bot/gh-1470'

Merge

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