Skip to content

d3d12_xs: Xbox device slot 74 answers S_OK in the proxy and never reaches the PC ShaderCacheControl (retail boot, after stop 20) - #7323

Open
tedin7 wants to merge 2 commits into
ItsNotRexed:mainfrom
tedin7:fast-slot74
Open

tedin7 wants to merge 2 commits into
ItsNotRexed:mainfrom
tedin7:fast-slot74

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in #7231 (comment)

@ItsNotRexed: an exe PR, as you asked.

What

Gives Xbox device slot 74 its own handler in the d3d12_xs device proxy. It returns S_OK, does not call the PC device, does not write through the pointers, and logs the three words once with an [rt] line. device_slot_overridden(74) is now true. An env slot override that moves one of the Xbox routes (LEONIDA_XS_*_SLOT) onto 74 still wins over the built-in handler, the same rule as slot 70 (d5c9490). The route table is now one helper, route_xbox_device_slot, shared by the generic path and slot 74 (same helper as in the slot 70 branch).

Why

kapitche measured (#7231) that the retail title calls device slot 74 once with the shape (pointer, u32, pointer). The proxy forwarded it to PC slot 74, ID3D12Device9::ShaderCacheControl(kinds, control), which reads the first pointer as kinds and returns E_INVALIDARG, so the title hits an int3. A stand-in returning S_OK gets past it. Thanks to kapitche for the measurement. The words are not measured beyond that, so this is a stand-in, not a model of what the title wants.

Tested

  • xs_proxy_mock_test (Wine, RunPod pod, clang-cl cross build): new check_slot74 calls slot 74 through the proxy with (ptr, 7, ptr) on a level 9 and a level 0 mock. It returns S_OK, the mock PC slot 74 is never called, and the memory behind both pointers is unchanged.
  • New --env-slots-74 mode (and ctest entry): SetFrameIntervalX moved onto 74 still routes as a frame interval and reaches no PC slot.
  • Negative control: the same test file on origin/main fails (device_slot_overridden(74) is false and the call is forwarded). Default, --env-slots, --env-slots-invalid and --env-slots-74 all pass with the change.

… of reaching PC ShaderCacheControl (ItsNotRexed#7231)

The retail title calls slot 74 once; the PC slot 74 reads the first pointer as kinds and returns E_INVALIDARG, so the title hits an int3. The proxy handler does not call the PC device, writes nothing, logs the three words once, and yields to an env slot override that moves a route onto 74.
@MartinIndra02

Copy link
Copy Markdown

Independent Windows test of a30e78ee7: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24), Vulkan SDK 1.4.363.1, no game files.

  • xs_proxy_mock_test.exe: PASS (exit 0, 9 allocations refused on purpose) — includes check_slot74 on both Device9 and Device0 without touching either pointer or forwarding to PC ShaderCacheControl.
  • xs_proxy_mock_test.exe --env-slots, --env-slots-invalid, and --env-slots-74: all PASS (exit 0), confirming an env override onto slot 74 takes precedence over the built-in stand-in.

AI-assisted review/test.

@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Static check on the retail 1.0.2.1 executable for the open question in #6982 ("the title keeps the handle in a global; I haven't seen it read back yet"). This supports leaving the out pointer unwritten, as this PR does.

  • Only one call site passes a global as slot 74's third argument. That global has exactly one rip-relative reference in the whole image: the lea that passes it to slot 74. No later load, compare or call reads it. No base-plus-offset access covers it either: the references around it are different globals with their own users. So the title never uses the value written there. The only thing checked is the HRESULT (test eax, eax / jns, else int3).
  • Order inside the same function: an XMemVirtualAlloc whose result is asserted non-null, then XMemAllocatePhysicalPages, then XMemMapPhysicalPages into that range, then slot 74 as (that range's base, the page count as a 32-bit value, &handle). That fits a pool or range registration for the physical allocation, not a cache control.
  • Right after slot 74, the same function calls device slot 8 with a constant 16-byte description and keeps the queue in a global. Besides its store, that queue global is only read next to the XMemMapPhysicalPagesScatter caller. That is where quackottu's census on Coordinating who works on what (41) (moved to #7231) #7049 found queue slot 31, the 5-argument page-mapping call. So slot 74's range and that queue belong to the same page-mapping path. That's for whoever models queue 31. This PR doesn't need it.

Method: capstone over .text. Each rip-relative disp32 that resolves to the global was confirmed by decoding the instruction. Import names, slot numbers and counts only.

AI-assisted (Claude Code).

@umnitus

umnitus commented Nov 23, 2026

Copy link
Copy Markdown

Independent native Windows clang-cl/xwin check at a30e78e. All seven xs_proxy_mock CTests passed, including xs_proxy_mock_env_slots_74. AI-assisted testing.

@memorypressure

Copy link
Copy Markdown

Verified at a30e78e, clean against current main 9177299. The route-dispatch refactor preserves order; slot 74 answers S_OK writing nothing, never reaching the PC ShaderCacheControl, log-once for measurement; env-routed overrides onto 74 win per the --env-slots-74 test, and device_slot_overridden(74) now matches the header. One behavior delta for a reviewer nod: slot 74 answers S_OK even for proxies with slot_count<75, where it previously hit the beyond-device refusal — presumably intended, worth saying in the body. C++ tests pending on CI. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run, C++ review-only).

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.

5 participants