Skip to content

d3d12_xs: device slot 61 is CreateSamplerX for the title's calls, again (RT-SLOT61) - #383

Merged
aslan2142 merged 4 commits into
ProjectLeonida:mainfrom
Mumogg:slot61-sampler-x
Nov 24, 2026
Merged

aslan2142 merged 4 commits into
ProjectLeonida:mainfrom
Mumogg:slot61-sampler-x

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in #14 as RT-SLOT61. Depends on: #349, #350, #356, #362, #369, #375, #377 (their commits come first here; this pull request is the last two commits).

What and why

After #377 the title calls device slot 61 once per sampler, as (description, destination handle). On the PC that slot is CreateMetaCommand, and main forwards it by number: a host access violation, reading through one of the title's words.

Two commits by mrp1no, cherry-picked with -x (authorship kept; ancestors of main whose content is not in the tree):

  • e22994464: slot 61 is routed to the PC CreateSampler with the same two words.
  • c915e1da4: only for callers in an image the guest loader mapped. The proxy also serves host callers (d3d12_vulkan_device_test calls ID3D12Device5::CreateMetaCommand through it), and they get the PC slot 61 as before.

The first commit conflicted where neighbours have been added since (slot 41's handler and test case, the slot lists, a docs table row); both sides are kept. The second applied cleanly.

Measured

Linux (Nobara 44, kernel 7.3), Wine 11.21 staging, RTX 5070 Ti (driver 615.78.08), clang-cl 22.1.8 + xwin SDK 10.0.26100, own 1.0.2.1 copy, network off, on main ece4ba5b3, with #142 and #328 applied on top for the boot runs (they are not in this branch).

--run D3D12 calls Ends with
up to #377 1,655 host AV at device slot 61
+ this 1,657 the title's own int3; the last traced call is ID3D12Device9::ShaderCacheControl failed, reached through device slot 74 forwarded by number

So the next stop is device slot 74, another console slot at a PC method's position.

xs_proxy_mock_test under Wine passes with the three cases of the second commit: no classifier installed (PC slot 61), a guest caller (PC CreateSampler with the same words; a null description skipped) and a host caller under a classifier (PC slot 61).

Not built with MSVC and not run on Windows; I did not run d3d12_vulkan_device_test, which the second commit is about (it fails under Wine here on main as well).

AI-assisted (Claude Code); built and run on the machine above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

mrp1no and others added 3 commits November 24, 2026 03:52
…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 #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>
(cherry picked from commit e229944)
…t caller gets PC CreateMetaCommand

The proxy also serves host callers: d3d12_vulkan_device_test drives the Vulkan device through it,
and its ID3D12Device5::CreateMetaCommand call (PC slot 61) landed in proxy_create_sampler_x
(found by nullmarsh on #7115: the test stopped at line 5763 instead of main's known line 6574).

Slot 61 now checks the caller's return address with a classifier the runtime installs
(set_console_caller, the name #7490 uses): D3D12XboxCreateDevice installs
rt::shims::mapped_image_base, so only a caller in an image the guest loader mapped gets
CreateSamplerX. Any other caller, and every caller when no classifier is installed, is forwarded
to the PC slot 61.

xs_proxy_mock_test checks all three cases: no classifier (PC slot 61), a guest caller (PC
CreateSampler with the same words; a null description skipped) and a host caller under an
installed classifier (PC slot 61). d3d12_vulkan_device_test again stops at line 6574, as on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8f756ebe048af042638ce51a61490f35f4f44ee3)
(cherry picked from commit c915e1d)
…riptor range

Slot 61 passed the destination handle to the PC CreateSampler as given. With the title's descriptor range
honoured (__XMemAllocationHooks__), a handle in that range has to be translated to the real heap's, as device
slots 17 to 24 do (asked for in review on ProjectLeonida#377).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
@slauko

slauko commented Nov 24, 2026

Copy link
Copy Markdown

Backport check on current main: the routing commits apply and the suite passes, but the retail call is behind the pool gate

I backported the two routing commits (99ba1c085 + 49fd9a427) onto main 6293c1c4f without the dependency stack (#349/#350/#356/#362/#369/#375/#377) and without the descriptor-range translation (484962eb8, which needs translate_cpu_handle from those PRs), to test the slot-61 routing on the retail title under Wine (RTX 3080 Ti, NVIDIA 595.112.07, Wine 11.17, retail 1.0.2.1, 26,555-shader corpus).

  • Windows CI (run 45476785815): 303/304 runtime tests pass. The only failure is the known crt_timed_wait 1-ms flake ("an unnotified wait_for(200 ms) returned after 199 ms"), which also failed twice in three runs on unchanged heads. No slot-61 test failed; the mock cases (PC slot 61 with no classifier, guest caller -> PC CreateSampler, host caller -> PC slot 61) pass.
  • The retail boot reaches CreateRootSignature and CreateComputePipelineState (slot 62), the builder shader (bvh_29_f12431f3) is selected, and there is no root-signature/spill refusal. But slot 61 is never called: with the pool-fill assert skipped (LEONIDA_SKIP_INT3=1), the title's own hang watchdog (+0x2215c35, the 30 s frame-code marker) fires at t~32 s first. Without the skip, the same build stops at the pool-fill assert (used = 0, 64 MiB), which is a separate, currently open gate.
  • So the routing is not exercised by this run. The code is compile/test-clean, but a boot that passes the pool (or a Windows configuration that reaches the sampler path) is needed to confirm the retail call. Our measurement does not contradict the stop-20 report; it places the sampler call behind the pool on this main.

Branch for reference: slauko/leonida:wine-slot61 (base 6293c1c4f + the two commits; not a proposed rebase of the full stack). Counts and call shapes only, no game data.

One conflict, in docs/d3d12_vulkan.md: both sides added a row to the same
table. Both are kept, in slot order: this branch's "Device slot 61" row,
then main's "Device slot 81, queue PresentX/SuspendX/ResumeX" row.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit 22372d8 into ProjectLeonida:main Nov 24, 2026
4 of 5 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

Merged. Mumogg is still away and this is the next rung on main's boot path (device slot 61, where the title stops once #377 is in), so I brought the branch up to date the same way as #375 and #377: one merge commit of main (28a32e190) on top of 484962eb8 (150b75344). Mumogg's three commits are untouched and nothing was force-pushed.

What it does: device slot 61 is CreateSamplerX(desc, dest) for the title. A caller in a guest-mapped image goes to the PC CreateSampler with the destination handle translated; a host caller, and every caller when no check is installed, still reaches the PC slot 61 as before. It puts back mrp1no's routing, which main had lost.

Conflict: one, in docs/d3d12_vulkan.md: both sides added a row to the same table. Both are kept in slot order (slot 61, then slot 81 / PresentX).

Holds and dependencies: there is no hold or maintainer request on this PR itself. The owner's hold on the stack was the ExecuteIndirect regression, resolved before #377 was merged. #349, #350, #356, #362, #369, #375 and #377 are all in main, so only this PR's own three commits come in (5 files, +99 −4 against main).

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

  • Full Windows suite under Wine, the branch against main 28a32e190: no test changed state on either device (258 pass and 15 fail on llvmpipe, 254 and 21 on the iGPU, on both sides).
  • xs_proxy_mock and its five variants and device_proxy pass.
  • The 12 test_docs_* files and check_no_game_data.py on the changed files are clean. The Linux portable subset does not build these files.
  • Not run here: MSVC, native Windows, and the game itself. Mumogg's run reports the title going from 1,655 to 1,657 traced calls, with the next stop at device slot 74.

Follow-ups, none blocking the boot path:

  • The description is still read as a PC D3D12_SAMPLER_DESC, which this PR marks as a hypothesis. Kokonotcu's finding in Coordinating who works on what #14 (Coordinating who works on what #14 (comment)) gives the console's own 0x54-byte field table; decoding from it is the next fix on this slot, and it matters as soon as something is drawn.
  • The translated destination handle has no test yet.
  • The comment above proxy_create_sampler_x ("The handle is passed as given") is out of date since 484962eb8, and the comments and the docs row cite numbers from the original repository (#6910, #7021, #7115, #7490) that link nowhere now.

#385 (device slot 74) is the next rung.

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

aslan2142 added a commit that referenced this pull request Nov 25, 2026
Merges main at 1154976 into the integration branch at 273b3bd (merge base ece4ba5). 42 files conflicted;
this commit is the resolution only. Build and test repairs follow in their own commits.

Rule of resolution: where both sides added different things, both stay; where both made the same change in two
forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two
changed the same code for different purposes, both purposes are kept.

Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, registry.cpp):
- d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device
  routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device
  slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the
  console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and
  list slot 139 (#396).
- Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's
  completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is
  attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider
  pc_resource_desc, S_OK for queue slots past the PC table.
- Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its
  undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base
  list proxy, its null-view slot 70 and its refusing slot 133.

Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp):
- Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra
  cases added; main's --env-slots-74 and #984's --env-slots-70.
- Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy,
  the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases.

D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h,
frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp,
d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp,
vk_pipeline_check.cpp, vk_test_device.h):
- Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's
  ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's
  origin, so both pools run on disjoint sets of textures.
- frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter.
- main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4
  stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980).
- shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it.
- Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count
  refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it.

Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp,
runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp):
- ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on
  ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file.
- gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries.
- Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped.

Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1,
make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py,
runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md,
runtime/README.md):
- Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake.
- rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's
  restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped.
- shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags.
- shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants.

One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC
compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants