Skip to content

d3d12_xs: device slot 74 returns S_OK instead of reaching ShaderCacheControl, again (RT-SLOT74) - #385

Merged
aslan2142 merged 4 commits into
ProjectLeonida:mainfrom
Mumogg:slot74-stand-in
Nov 24, 2026
Merged

aslan2142 merged 4 commits into
ProjectLeonida:mainfrom
Mumogg:slot74-stand-in

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

What and why

After #383 the title calls device slot 74 once, with (pointer, u32, pointer). main forwards it by number to the PC slot 74, ID3D12Device9::ShaderCacheControl, which reads the first word as its flags and fails; the title then stops on its own int3.

Commit cdeee35aa by tedin7 (-x, authorship kept; an ancestor of main whose content is not in the tree) gives the slot a handler that does not call the PC device, writes nothing through the pointers and returns S_OK. It is a stand-in: what the console call does is not measured, and the commit says so.

The commit also moves the Xbox slot routes into one function (route_xbox_device_slot) so that an environment override which moves a route onto slot 74 wins over the built-in handler. Adapted to main, as the commit message says: inside that function the queue route calls proxy_create_command_queue_xbox, the 32-byte description of #350.

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 Traced D3D12 calls Ends with
up to #383 1,657 the title's int3 after ShaderCacheControl fails
+ this 11,916 a call through a null pointer in the host, right after the first call of device slot 108

Of the 11,916, 10,241 are ID3D12Device5::CreateLifetimeTracker, which the layer answers as unsupported; the title goes on regardless. Past this stop the log shows the DirectStorage shim in use (CreateStatusArray, CreateQueue1, zlib requests inflated on the CPU), the first call of device slot 67 (the console's compute pipeline from native code) and of slot 57.

The next stop is device slot 108, past the PC device table. #219 looks like the pull request for it; I will measure it on top of this and report there.

xs_proxy_mock_test under Wine: the default run passes with the new slot 74 case, and --env-slots, --env-slots-invalid and the new --env-slots-74 exit 0.

Not built with MSVC and not run on Windows.

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt

@BadgersMC

Copy link
Copy Markdown
Contributor

Native Windows check of 25826cdd against its parent 6d4cf2ce (Windows 11 26100, MSVC 19.44, Windows SDK 26100). I queried the level-9 mock device proxy for ID3D12Device9, classified the caller as host, and called ShaderCacheControl(APPLICATION_MANAGED, ENABLE) through the typed interface.

Revision Return Calls received by the mock PC device
6d4cf2ce S_OK 1, with both flags intact
25826cdd S_OK 0

The slot 74 stand-in also intercepts the PC call. Can slot 74 use the caller classification introduced for slot 61 in #383, with a host passthrough test alongside the guest case? The route-override precedence exercised by xs_proxy_mock_env_slots_74 also needs coverage.

All seven xs_proxy_mock* CTest cases passed at 25826cdd. device_proxy and device_proxy_trace failed the slot 25 allocation-info assertions on both revisions. On an RTX 3060 Ti, d3d12_vulkan_device also failed the same tiled resource allocation comparison on both revisions.

AI-assisted. The probe uses a mock PC device. No game files used.

@Mumogg

Mumogg commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

You are right, and thank you for testing the host path: the stand-in took a host's ShaderCacheControl as well.

Fixed in 6a9edfe37 on this branch. Slot 74 now asks the same caller classifier slot 61 uses (set_console_caller): a caller in an image the guest loader mapped gets the stand-in; any other caller, and every caller when no classifier is installed, is forwarded to the PC slot 74, or refused past the PC device's table when the device has no slot 74. The route-override precedence is unchanged (--env-slots-74 still passes).

xs_proxy_mock_test has the cases you asked for: the guest case under a classifier, and the host case both with a classifier and with none, on a level-9 device (the call reaches the mock's slot 74 with its words) and on a level-0 one (refused, the mock is not called). It passes under Wine.

Checked on the retail boot as well, since the classifier now decides it: the title's call still gets the stand-in (the slot 74 ... returns S_OK line appears once, no ShaderCacheControl in the trace) and the run reaches the same point as before.

#391, #395 and #396 are rebased onto this.

AI-assisted.

tedin7 and others added 3 commits November 24, 2026 03:52
… of reaching PC ShaderCacheControl (#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.

(cherry picked from commit cdeee35)

Adapted to main by Mumogg: the queue route inside route_xbox_device_slot calls proxy_create_command_queue_xbox
(the 32-byte description of 0cde63d), as the inline route did before this commit moved the routes into a
function.
…gets PC ShaderCacheControl

The stand-in also took a host's ID3D12Device9::ShaderCacheControl call through the proxy and answered S_OK
without reaching the device (found on native Windows by BadgersMC in the review of this change). Slot 74 now
asks the caller classifier slot 61 uses (set_console_caller): a caller in an image the guest loader mapped gets
the stand-in, any other caller, and every caller when no classifier is installed, is forwarded to the PC slot 74
or refused past the PC device's table.

xs_proxy_mock_test: the guest case under a classifier, and the host case with a classifier and with none, on a
device that has ShaderCacheControl and on one that does not.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
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
@BadgersMC

Copy link
Copy Markdown
Contributor

Confirmed on native Windows with the same typed ID3D12Device9::ShaderCacheControl(APPLICATION_MANAGED, ENABLE) probe as before. On current head 3ca10dfe (the rebased caller-classification fix is ad9edee6), it returns S_OK and forwards exactly one call with both flags intact. This is the same probe that saw zero forwarded calls on 25826cdd.

All seven xs_proxy_mock* cases pass with MSVC, including xs_proxy_mock_env_slots_74. Windows 11 build 26100, MSVC 19.44, Windows SDK 26100. AI-assisted mock tests, no game files.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
Brings 58 PRs integration did not have (among them ProjectLeonida#359 ProjectLeonida#360 ProjectLeonida#402 ProjectLeonida#497 ProjectLeonida#557 ProjectLeonida#558
ProjectLeonida#560 ProjectLeonida#561 ProjectLeonida#572 ProjectLeonida#573 ProjectLeonida#574 ProjectLeonida#577) and the newer heads of ProjectLeonida#401 and ProjectLeonida#404. 15 files
conflicted; resolved by hand:

- frame_pacer.h, d3d12_xs_device.h/.cpp: ProjectLeonida#402's pacer (per-event ticks,
  issue_token_locked) now issues from ProjectLeonida#414's shared FrameTokenSource, so a token
  from the device-side WaitFrameEventX is one the pacer accepts (towade's ProjectLeonida#14
  finding: without it every PresentX is refused). The dead frame_next_token and
  issued_ counters are dropped. Queue slot 32 stays ProjectLeonida#414's PresentX; ProjectLeonida#402's
  presentation-handler routes serve slot 30 or LEONIDA_XS_PRESENT_X_SLOT.
  ProjectLeonida#402's GetFrameStatisticsX route moves into ProjectLeonida#385's route_xbox_device_slot.
- acphal.cpp/acphal_test.cpp: upstream's reworked SHAPE allocation and release;
  the release writes nothing through its first argument, as ProjectLeonida#405 requires; both
  sides' tests kept. Upstream's ProjectLeonida#401/ProjectLeonida#404 heads remove lifecycle.cpp and the C++
  xma2_decoder.cpp (replaced by runtime/xma_decoder), so build_runtime.ps1's
  cl.exe list drops them and keeps ProjectLeonida#549's and ProjectLeonida#400's files.
- vulkan_backend.h, statistics_sum.comp, its SPIR-V header, d3d12_mesh_test,
  replay_query_edges_test, d3d12_vulkan_device.cpp, docs: ProjectLeonida#577's clipping
  counter on top of ProjectLeonida#540, which both sides carry; the Timestamps sentence keeps
  integration's corrected wording (c33ce87).
- xs_proxy_mock_test.cpp: both sides' cases; pr_conflict_label.py keeps the
  guarded reconfigure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…ts 86, 101 and 108 to PC Device2/Device5/Device8, rebased on main

Conflicts with integration's ProjectLeonida#385 helper and the fold, resolved by hand: the
dispatcher calls route_xbox_device_slot first and then ProjectLeonida#727's if-constexpr
branches for 86/101/108; device_slot_overridden and its comment list both
sides' slots; xs_proxy_mock_test keeps integration's slot 41/61 checks and
adds ProjectLeonida#727's 86/101/108 cases. Supersedes the local boot-standins slot-108
stand-in (a821895ad).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three files conflicted; in each, both sides had added something and both
are kept.

runtime/shims/d3d12_xs_device.cpp: this branch moved the Xbox device slot
routes into route_xbox_device_slot(), which slot 74's handler asks first,
while main added a sixth route to the inline chain: GetFrameStatisticsX
(routes.frame_statistics, slot 81), answered by the presentation handler
or with S_FALSE and a zero count. The helper is kept and that route is
moved into it unchanged, between wait_event and queue_x as on main.

runtime/test/xs_proxy_mock_test.cpp: run_env_slots keeps this branch's
on_slot74 parameter next to main's EnvPresenter struct, and main() runs
check_slot74() and then check_presentation_wiring().

docs/d3d12_vulkan.md: both table rows, in slot order (74, then 81).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit 16ff597 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 74, where the title stops once #383 is in), so I brought the branch up to date the same way as the three rungs before it: one merge commit of main (d9f0a98e1) on top of 3ca10dfe1 (d7e294475). Mumogg's three commits are untouched and nothing was force-pushed.

What it does: device slot 74, called by the title as (pointer, u32, pointer), now returns S_OK instead of reaching the PC ShaderCacheControl, which failed and sent the title to its own int3. A host caller, and every caller when no classifier is installed, still gets ID3D12Device9::ShaderCacheControl. It is a stand-in: nothing is written through the pointers, and the call is logged once with its three words.

Conflicts: three files, and one of them needed more than keeping two additions side by side, so please look at it.

  • runtime/shims/d3d12_xs_device.cpp: this branch moved the Xbox device slot routes into route_xbox_device_slot(), which slot 74's handler asks first. Meanwhile main had added a sixth route to the old inline chain: GetFrameStatisticsX (routes.frame_statistics, slot 81), answered by the presentation handler, or with S_FALSE and a zero count when there is none. I kept the helper and moved that route into it unchanged, between wait_event and queue_x as on main. All six routes were then compared line by line with main's chain: same arguments, same log names, same results, same order.
  • runtime/test/xs_proxy_mock_test.cpp: run_env_slots keeps this branch's on_slot74 parameter next to main's EnvPresenter struct, and main() runs check_slot74() and then check_presentation_wiring().
  • docs/d3d12_vulkan.md: both table rows, in slot order (74, then 81).

Holds and requests: none from a maintainer on this PR. BadgersMC's request (the caller classification from #383, a host passthrough test, and coverage of the override precedence) was answered in ad9edee61, and they confirmed it on Windows with MSVC.

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

  • Full Windows suite under Wine, the branch against main (the tree of d3d12_xs: device slot 61 is CreateSamplerX for the title's calls, again (RT-SLOT61) #383's merge): nothing changed on either device except the new xs_proxy_mock_env_slots_74, which passes on both (259 pass and 15 fail on llvmpipe, 255 and 21 on the iGPU).
  • xs_proxy_mock and its six variants pass on both. They include main's presenter checks, which now reach GetFrameStatisticsX through the helper, at the default slot and at an overridden one.
  • 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,657 to 11,916 traced calls, ending right after the first call of device slot 108.

Follow-ups, none blocking the boot path:

  • What the console's slot 74 really is, and whether its third pointer is an output the title reads afterwards, is still open. Nobody has looked at what the title does with it after the call.
  • The docs row for slots 48/73/78-80 still says an override onto a handled slot keeps that slot's handler; on 74 the override now wins. An override routed onto 74 also skips note_slot(74).
  • The code comment and the first commit's title cite issue 7231, a number from the original repository that links nowhere now.

#727 (device slots 86, 101 and 108) is the next rung.

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

aslan2142 added a commit to DesertGamer/leonida that referenced this pull request Nov 24, 2026
Three files conflicted; in each, both sides had added something and both
are kept.

runtime/shims/d3d12_xs_device.cpp: this branch still had the Xbox device
slot routes inline, followed by its fixed handlers for slots 86, 101 and
108; main has since moved the same six routes into
route_xbox_device_slot() (ProjectLeonida#385). The generic path now calls the helper and
then the three fixed handlers, so a configured route still wins over
them, as this branch's second commit intends. device_slot_overridden()
has main's list plus 86, 101 and 108.

runtime/shims/d3d12_xs_device.h: the comment lists both sides' slots.

runtime/test/xs_proxy_mock_test.cpp: the mock device keeps main's case 13
(CheckFeatureSupport) and this branch's case 68
(GetResourceAllocationInfo2); check_xbox_slots keeps main's slot 41 and 61
cases, one combined list of handled slots, and this branch's slot 86, 101
and 108 cases.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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