Skip to content

d3d12_xs: the first call of a forwarded device slot names its caller (OLD-9990, RT-526) - #1390

Open
Diegobecker07 wants to merge 2 commits into
ProjectLeonida:mainfrom
Diegobecker07:old-9990-slot-caller
Open

Diegobecker07 wants to merge 2 commits into
ProjectLeonida:mainfrom
Diegobecker07:old-9990-slot-caller

Conversation

@Diegobecker07

Copy link
Copy Markdown

Claimed in the coordination issue as: OLD-9990 (#14 (comment))

Carries over #260 (old upstream PR 9990 by Amzi-01; the two commits are kept with their author), rebased on current main. #260 can be closed in favour of this once it is reviewed.

What and why

RT-526's caller half. The first call of each device slot that the proxy's generic thunk takes by number now names its caller:

[rt] d3d12_xs: device slot 78 (Xbox SetFrameIntervalX) first call from game_scarlett_master.exe+0x…

Without this, finding the call site of a new Xbox-only slot took a debugger. The caller is _ReturnAddress() in the thunk. It is printed through a formatter hook that gta6rt points at rt::shims::module_offset, so d3d12_xs_device.cpp does not depend on the module table and test targets link it alone; with no formatter it is the bare address in hex. reset_device_proxy_stats clears it with the first-call flag.

Rebase on main: two conflicts, both in runtime/shims/d3d12_xs_device.cpp, both resolved by keeping main's side and adding this PR's:

#228 overlap: #228 (old PR 9961, RT-526) has its own version of this logging (set_caller_describer). Its other half, LEONIDA_SKIP_ASSERTS, is carried over separately (OLD-9961) without that logging, so the two do not collide.

Tested

  • scripts\build_runtime.ps1 (MSVC 19.44, VS 2022 Build Tools, CMake 3.31.6 + Ninja, Vulkan SDK 1.4.363.0): builds.
  • ctest -R "xs_proxy_mock|device_proxy|d3d12_xs|pe_loader|run_tiny_game": 22/22 passed. xs_proxy_mock includes d3d12_xs: the first call of a forwarded device slot names its caller (RT-526) #260's check: slot 78's first caller recorded in hex without a formatter, forgotten on reset, recorded again.
  • Retail boot (own 1.0.2.1 copy, LEONIDA_D3D12=vulkan, --trace, --trace-d3d12, overlay outside the package): six slots name their callers as module+offset, five in the executable and one in XboxBvhBuilder.dll (slot 16, CreateRootSignature). The run otherwise ends as on main (the same 1,639 D3D12 calls, then the title's fail-fast about 27 s later). No address from the executable is quoted here.

GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 621.24, Vulkan 1.4.357, Windows 11 Pro 26300

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • 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)

Amzi-01 and others added 2 commits November 25, 2026 09:33
…(RT-526)

The first call of every Xbox device slot the proxy forwards by number now
logs the title code that made it as module+offset, and
device_slot_first_caller(slot) returns the same text. Finding a new
Xbox-only slot in the executable no longer needs a debugger.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…of #9990)

- The proxy no longer calls rt::shims::module_offset itself: gta6rt sets it
  with set_device_slot_caller_formatter; with none set the address is shown
  in hex, so xs_proxy_mock_test links d3d12_xs_device.cpp alone as before.
- reset_device_proxy_stats() clears the stored caller with the first-call
  flag; xs_proxy_mock_test checks call -> caller -> reset -> empty -> call.
- The accessor comment says which slots it covers and that it is a
  diagnostic observation (flag set before the caller is stored).

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diegobecker07 pushed a commit to Diegobecker07/leonida that referenced this pull request Nov 25, 2026
…e (RT-526)

A diagnostic for the retail boot (RT-5 follow-ups), off the hot path and with no behaviour change unless asked
for: LEONIDA_SKIP_ASSERTS=N (src/assert_skip.h, installed by main.cpp before any image code runs under
--init/--run): a vectored handler, added last, steps over up to N int3 (0xCC) at addresses in no host module and
logs each one as module+RVA (and as an int3_skipped trace event when --trace is open). After N it says so once
and the next int3 ends the run as before. An int3 in a host module, a breakpoint with no 0xCC at its address, or
a RIP that is neither at nor one past the 0xCC is passed on. Needs no --trace and no debugger.

Tests (synthetic, no game files): assert_skip_test (int3 in a VirtualAlloc'd page, the limit, a host-module int3,
a two-byte int 3, value parsing) and run_tiny_game_skip_asserts (two int3 in the mapped stand-in game, stepped
over end to end).

Carried over from old upstream PR 9961 (ProjectLeonida#228) without its caller logging for forwarded device slots, which the
carry-over of old PR 9990 (ProjectLeonida#1390) brings instead.

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

Copy link
Copy Markdown
Author

Rebased onto current main (0d80bc5); the needs rebase label should clear on the next hourly run. Lucy's two commits are kept as they were (git range-diff shows context changes only). The conflicts were include lists: main already includes <intrin.h> and <string>, and main.cpp now registers the formatter right after main's new page hooks.

Re-verified on Windows 11 Pro (26300), MSVC 19.44, NVIDIA RTX 5070 Ti (driver 621.24): full runtime build, ctest 438/441. xs_proxy_mock and its variants pass. The three failures were the xmem tests (writing to 512 of them charges about those 512 pages): they failed while two other runtime builds ran on the same machine and passed 3/3 when rerun alone. This PR does not touch xmem. I did not rerun the retail boot on this base; the boot check in the description (six slots named) was on the previous base.

For the reviewer: main now forwards host callers of device slots 61 and 74 to the PC methods in their own branches, which call note_slot(Slot) without the caller. They are outside this PR's scope (the generic branch, as the header says); passing _ReturnAddress() there is a one-line change each if wanted.

CI for this push is waiting for workflow approval (first-time contributor).

AI-assisted.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
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.

2 participants