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

Merged
Diegobecker07 merged 2 commits from upstream-pr/1390 into main 2026-11-29 08:10:05 +00:00
Diegobecker07 commented 2026-11-24 23:08:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-24T23:08:41Z.


Claimed in the coordination issue as: OLD-9990 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146930294)

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:

  • the includes: main's d3d12_xs_alloc_size.h / d3d12_xs_desc_clean.h stay. The first commit's shims.h is dropped again by the second, as in #260.
  • the generic thunk: main's slot 26 console form stays before note_slot, which now takes the caller.

#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 #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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5481868171 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1390). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-24T23:08:41Z. --- Claimed in the coordination issue as: OLD-9990 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146930294) 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: - the includes: `main`'s `d3d12_xs_alloc_size.h` / `d3d12_xs_desc_clean.h` stay. The first commit's `shims.h` is dropped again by the second, as in #260. - the generic thunk: `main`'s slot 26 console form stays before `note_slot`, which now takes the caller. **#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 #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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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)
Diegobecker07 commented 2026-11-25 13:13:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T13:13:32Z.


Rebased onto current main (0d80bc5df); 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7163468241 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1390#issuecomment-7163468241). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-25T13:13:32Z. --- Rebased onto current main (0d80bc5df); 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.
zmasi commented 2026-11-28 22:10:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:10:52Z.


Independent Verification Report — 94ba78348e + origin/main (c7753ed98a)

Environment: Windows 11 (26200), AMD Ryzen 9 5950X, MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8, /O2 /MD).
Verdict: PASS (Ready to merge) — clean Git merge with origin/main (95c7222149c7) and combined Batch 11 set (6a93c1e1e828).

1. Red -> Green Verification on Windows 11 + MSVC 19.44

  • Red (origin/main d3d12_xs_device.{h,cpp} + #1390 xs_proxy_mock_test.cpp): Fails to compile (error C2039: 'device_slot_first_caller': is not a member of 'rt::d3d12_xs').
  • Green (94ba78348e + origin/main):
    • xs_proxy_mock_test (all 9/9 CTest modes: default, --fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid, --env-slots-70, --env-slots-74, --slot133-layout): PASS, confirming proxy_slot records _ReturnAddress() on the first generic-branch call, formats hex by default, clears on reset_device_proxy_stats(), and re-records on the next call.
    • runtime/src/main.cpp /W4 /permissive- compile (set_device_slot_caller_formatter(&rt::shims::module_offset)): PASS (0 new warnings).
    • Cleanly avoids pulling module-table dependencies into standalone proxy test binaries.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246552734 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1390#issuecomment-7246552734). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:10:52Z. --- ### Independent Verification Report — `94ba78348e` + `origin/main` (`c7753ed98a`) **Environment:** Windows 11 (`26200`), AMD Ryzen 9 5950X, MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8`, `/O2 /MD`). **Verdict:** **PASS (Ready to merge)** — clean Git merge with `origin/main` (`95c7222149c7`) and combined Batch 11 set (`6a93c1e1e828`). #### 1. Red -> Green Verification on Windows 11 + MSVC `19.44` - **Red (`origin/main` `d3d12_xs_device.{h,cpp}` + `#1390` `xs_proxy_mock_test.cpp`):** Fails to compile (`error C2039: 'device_slot_first_caller': is not a member of 'rt::d3d12_xs'`). - **Green (`94ba78348e` + `origin/main`):** - `xs_proxy_mock_test` (all **9/9** CTest modes: `default`, `--fail-virtualalloc`, `--fail-virtualprotect`, `--fail-veh`, `--env-slots`, `--env-slots-invalid`, `--env-slots-70`, `--env-slots-74`, `--slot133-layout`): **PASS**, confirming `proxy_slot` records `_ReturnAddress()` on the first generic-branch call, formats hex by default, clears on `reset_device_proxy_stats()`, and re-records on the next call. - `runtime/src/main.cpp` `/W4 /permissive-` compile (`set_device_slot_caller_formatter(&rt::shims::module_offset)`): **PASS** (`0` new warnings). - Cleanly avoids pulling module-table dependencies into standalone proxy test binaries. AI-assisted.
OreoFR commented 2026-11-28 22:12:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:12:06Z.


Verified by OreoFR

  • Base: main a8465211f + PR head 94ba78348 (merged with --no-ff, no conflict; tested in a package with other PRs that share no file with it)
  • Test: ctest -R ^xs_proxy_mock$ (red: the PR's test with the shim and main.cpp from main)
  • Red on main: the test does not compile on main (device_slot_first_caller is not a member of rt::d3d12_xs)
  • Green with the PR: passes; full ctest on the package: no new failure (only the known xbox_present, plus one flaky test that passed 3/3 on rerun)
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11
  • Note: shares runtime/shims/d3d12_xs_device.cpp, runtime/shims/d3d12_xs_device.h and runtime/test/xs_proxy_mock_test.cpp with the open #2566; a rebase may be needed if #2566 lands first.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246567205 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1390#issuecomment-7246567205). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:12:06Z. --- **Verified by OreoFR** - Base: main `a8465211f` + PR head `94ba78348` (merged with --no-ff, no conflict; tested in a package with other PRs that share no file with it) - Test: `ctest -R ^xs_proxy_mock$` (red: the PR's test with the shim and main.cpp from main) - Red on main: the test does not compile on main (`device_slot_first_caller` is not a member of `rt::d3d12_xs`) - Green with the PR: passes; full ctest on the package: no new failure (only the known `xbox_present`, plus one flaky test that passed 3/3 on rerun) - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 - Note: shares `runtime/shims/d3d12_xs_device.cpp`, `runtime/shims/d3d12_xs_device.h` and `runtime/test/xs_proxy_mock_test.cpp` with the open #2566; a rebase may be needed if #2566 lands first. AI-assisted (Claude Code, Claude Opus 5.5).
OreoFR commented 2026-11-29 02:09:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T02:09:39Z.


Verified by OreoFR: link check

  • main 59e65849b + this PR (head 94ba78348, the head verified earlier) merged with --no-ff, built without the XMA decoder (LEONIDA_CARGO=OFF, no LEONIDA_XMA2_DECODER_LIB: configure reports the XMA2 and Opus decoders not built), RelWithDebInfo, Ninja, MSVC 19.44.35230 (VS 2022 BuildTools), LEONIDA_REQUIRE_VULKAN=ON
  • gta6rt.exe links; imports unchanged vs main built the same way (dumpbin /imports: 25 DLLs, 655 functions, no WS2_32)
  • gta6rt was not launched.

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249247957 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1390#issuecomment-7249247957). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T02:09:39Z. --- **Verified by OreoFR**: link check - main `59e65849b` + this PR (head `94ba78348`, the head verified earlier) merged with --no-ff, built without the XMA decoder (`LEONIDA_CARGO=OFF`, no `LEONIDA_XMA2_DECODER_LIB`: configure reports the XMA2 and Opus decoders not built), RelWithDebInfo, Ninja, MSVC 19.44.35230 (VS 2022 BuildTools), `LEONIDA_REQUIRE_VULKAN=ON` - `gta6rt.exe` links; imports unchanged vs main built the same way (`dumpbin /imports`: 25 DLLs, 655 functions, no WS2_32) - gta6rt was not launched. AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
MoonEyes commented 2026-11-29 08:10:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T08:10:07Z.


Merged after OreoFR's red/green check (check: green with this PR merged onto main, red without it; gta6rt.exe still links with unchanged imports when the PR touches the runtime) and a re-check here: no conflict with main 0cbee763d, same head as checked, not frozen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on main or Vulkan).

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7252929406 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1390#issuecomment-7252929406). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T08:10:07Z. --- Merged after **OreoFR**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1390#issuecomment-7249247957): green with this PR merged onto `main`, red without it; `gta6rt.exe` still links with unchanged imports when the PR touches the runtime) and a re-check here: no conflict with `main` 0cbee763d, same head as checked, not frozen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on `main` or Vulkan). _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1390
No description provided.