Skip to content

d3d12_xs: Xbox device slot 61 is CreateSamplerX, routed to the PC CreateSampler (RT-5 stop 20) - #7115

Open
mrp1no wants to merge 1 commit into
ItsNotRexed:mainfrom
mrp1no:d3d12-xs-slot61-sampler
Open

mrp1no wants to merge 1 commit into
ItsNotRexed:mainfrom
mrp1no:d3d12-xs-slot61-sampler

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: stop 20 of @KkelebekK's RT-5 finding (#6910 (comment)). Claim: #6910 (comment). Finder's go-ahead in #7049.

What and why

The retail title calls Xbox device slot 61 as CreateSamplerX(desc, dest), once per sampler, after its descriptor heaps exist (@KkelebekK's measurement). The proxy's generic thunk forwarded it to the PC slot 61, which is CreateMetaCommand, so no sampler was ever written.

Slot 61 now has its own handler, like 62 and 67:

  • it passes the description's PC D3D12_SAMPLER_DESC prefix and the handle to the PC CreateSampler (slot 22). Under Wine that got the title past this call;
  • whatever follows the prefix in the console description is not known and is not read (marked HYPOTHESIS in the code);
  • a null description is skipped and logged once;
  • the handle is passed as given. A handle in the title's own heap range is the translation in d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles #7021 (@Khuraie).

d3d12_xs_device.h and the §4.9 table in docs/d3d12_vulkan.md get a row for the slot.

Tested

Windows 11, MSVC RelWithDebInfo, main 2c72b0d2:

  • xs_proxy_mock_test: PASS. The new check calls slot 61 and expects the mock's slot 22 with the same two words, never its slot 61; a null description reaches neither. With main's d3d12_xs_device.cpp it fails (line 763).
  • ctest -R xs_proxy: 6/6.
  • python -I tests/test_docs_links.py and tests/test_docs_design_rows.py: OK.
  • Retail executable, own copy, gta6rt --run, 2 runs: the same stop as main, at the first XMemVirtualAlloc. The boot doesn't reach slot 61 on main yet, so this is the synthetic test plus @KkelebekK's Wine run of the same routing.

No game data. AI-assisted (Claude Code).

🤖 Generated with Claude Code

…ateSampler

The retail title calls device slot 61 as CreateSamplerX(desc, dest handle), once
per sampler, after its descriptor heaps exist (stop 20 of the RT-5 boot
measurements in the coordination issue). The generic thunk forwarded it to the
PC slot 61, which is CreateMetaCommand, so the sampler was never written.

Slot 61 now has its own handler, like 62 and 67. It passes the description's
PC D3D12_SAMPLER_DESC prefix and the handle to the PC CreateSampler (slot 22).
That was enough to get the title past this call under Wine. Whatever follows
the prefix in the console description is not known and is not read. A null
description is skipped and logged once. A handle in the title's own heap range
is ItsNotRexed#7021's translation.

xs_proxy_mock_test: slot 61 reaches the mock's slot 22 with the same two words
and never its slot 61; a null description reaches nothing. With main's
d3d12_xs_device.cpp the new check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Pipodi

Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested on the retail boot: pass. Own 1.0.2.1 copy, Windows 11, RTX 4090 / 617.42, LEONIDA_D3D12=vulkan, on Pipodi:boot-integration (the #6982 stack) with this PR's slot 61 handler in place of the local stand-in I had there.

  • Before this, slot 61 went on to the PC slot 61 (CreateMetaCommand) and ended in an access violation inside gta6rt.
  • With the handler, the title's slot 61 calls arrive as ID3D12Device::CreateSampler on the Vulkan device, and the run continues. It got to 1,661 D3D12 calls, against 1,655 at the old stop.
  • The next stops are later and have nothing to do with slot 61: slot 67 programs with no translation (see docs/retail_boot_chain.md: stops 13-17 (descriptor heap at an address, device slots 70, 127, 25) #6982), then a guest access violation.

I had read slot 61 as a raw view write because it ends in the same descriptor-finishing helper as slot 70. Your sampler reading fits the run better, so I've dropped my stand-in.

AI-assisted (Claude Code).

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Pipodi, that's the retail confirmation this PR was missing (before: an access violation via CreateMetaCommand; now: CreateSampler). The next stop on your stack, slot 41's argument type 105, is #7163. AI-assisted (Claude Code).

@umnitus

umnitus commented Nov 23, 2026

Copy link
Copy Markdown

Independent native Windows check at e22994464b17517624c898ed34b3e03c06ce2261 with clang-cl/xwin. All six xs_proxy_mock CTests passed, including slot 61 CreateSamplerX routing and the null-description case. AI-assisted testing.

@devnull34 devnull34 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.

Verified on Windows 11 (MSVC RelWithDebInfo):

  • Built xs_proxy_mock_test and device_proxy_test cleanly.
  • xs_proxy_mock_test.exe passed: Xbox device slot 61 (CreateSamplerX) correctly forwards the description prefix and handle to PC slot 22 (CreateSampler), ignoring trailing console data and cleanly skipping null descriptions.
  • device_proxy_test.exe passed with 0 failures across all 83 slots.
  • 8/8 CTest targets passed 100% (device_proxy, device_proxy_trace, xs_proxy_mock*).
  • Whitespace clean (git diff HEAD~1..HEAD --check).

@jlric

jlric commented Nov 23, 2026

Copy link
Copy Markdown

Retail A/B on CachyOS / Wine 11.22, RTX 4070 (620.73.04). Before: slot 61 faults in the PC forwarder. With the route from e22994464 using #7021 CPU-handle translation, CreateSampler and the next CopyDescriptorsSimple both return, and startup reaches physical page mapping. AI-assisted testing.

@Stalkerino

Copy link
Copy Markdown

For combining this route with #7021, here is a small cherry-pick with the handler change and a regression test. It applies after both PRs are present. Slot 61 calls the existing CPU descriptor-handle translator before calling the PC device. The mock checks that PC slot 22 receives the host heap start plus the original offset.

I compared the same synthetic guest before and after this change on CachyOS, Wine 11.22 and Mesa lavapipe 26.3.1. With a three-entry sampler heap allocated by the guest hook, two different sampler descriptions both failed the byte-for-byte comparison with PC CreateSampler before the fix. Changing the filter/address mode left the host destination unchanged and modified the guest hook memory. After translating the destination, both descriptions matched their PC references, changing the description updated the host descriptor, and the adjacent descriptor and guest memory guards stayed intact (19/19 checks). The mock also fails on the destination before the change and passes afterwards. AI-assisted.

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Stalkerino, that's the right next step, and the before/after on a guest-allocated sampler heap is convincing. Since it calls #7021's handle translator, I'd keep this PR independent of #7021 so either can land first, and bring your commit in right after both are on main. Feel free to open it as a follow-up PR (Depends on: #7115, #7021), it's your change; if you'd rather not, say so and I'll cherry-pick it with your authorship once both have landed. AI-assisted (Claude Code).

@justr4mzi

Copy link
Copy Markdown
Contributor

Independent native Windows 11 / MSVC 19.44.35230.0 / AMD Radeon RX 6700 XT (gfx1031, Vulkan 1.4.335, driver 2.0.372) verification of e22994464:

  • Build & CTest (standard and LEONIDA_VK_VALIDATION=1):
    • ctest --output-on-failure -R "^(xs_proxy_mock|device_proxy|d3d12_present|d3d12_draw)$": 8/8 passed (2.54 s standard, 1.88 s with LEONIDA_VK_VALIDATION=1, 0 validation errors).
    • xs_proxy_mock_test.exe (all 6 modes, including slot 61 CreateSamplerX routing to PC slot 22 CreateSampler) and device_proxy_test.exe (WARP): PASS (0 failures).
  • Negative control:
    • Reverting runtime/shims/d3d12_xs_device.cpp to parent 66f557b0c while keeping xs_proxy_mock_test.cpp at e22994464 fails at xs_proxy_mock line 763: mock->calls[61] == 0 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 1 (exit 1). Restoring e22994464 passes (exit 0).

AI-assisted (Gemini, Antigravity).

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.

7 participants