Skip to content

d3d12_device_calls: count the ID3D12Device slots the retail executable calls, from the file alone (RT-566) - #7998

Closed
aslan2142 wants to merge 6 commits into
ProjectLeonida:mainfrom
aslan2142:rt566-d3d12-device-calls
Closed

aslan2142 wants to merge 6 commits into
ProjectLeonida:mainfrom
aslan2142:rt566-d3d12-device-calls

Conversation

@aslan2142

@aslan2142 aslan2142 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as RT-566: #7804 (comment) (earlier claimed by pulria).

What and why

The boot chain (docs/retail_boot_chain.md) finds the next device slot by running the title, one stop at a time. This PR adds tools/d3d12_device_calls.py. It reads the file alone and reports the statically resolved ID3D12Device vtable call sites for the device paths it follows. Slot owners can see which slots are coming before the run reaches them. This is a measurement, not a claim on any slot.

python -I tools/d3d12_device_calls.py <game>/game_scarlett_master.exe --out <work>/device_calls
  • --out is required. The tool writes two files there and prints the text one:
    • <exe>.device_calls.txt: slot numbers and counts only
    • <exe>.device_calls.json: the same, plus each site's RVA for local follow-up
  • Standard library only. It reuses tools/gdk_runtime_calls.py's x86-64 decoder and tools/import_call_sites.py's import-table reader.
  • docs/retail_boot_chain.md §5 explains how to run it and what it shows.

Method

  1. Find the creator calls. These are the D3D12XboxCreateDevice / D3D12CreateDevice call sites, in any of three forms:

    • call [rip+IAT]
    • a call to the import thunk
    • call reg after mov reg,[rip+IAT]
  2. Follow the out-pointer in r9.

    • lea r9,[rip+G] makes G a device global.
    • lea r9,[reg+disp] means that slot holds the device after the call.
  3. Walk the functions that reference a device global (bounds from .pdata).

    • The device is followed through register copies, stack slots, and stores to other globals.
    • A global the device is stored to becomes a device global too, and the walk repeats until no new global turns up.
    • Forward branches are followed. A jmp or conditional branch to a later address in the function carries what is known at the branch to its target. At the target it is met with the fall-through state: a fact is kept only when both paths agree. Past a ret or unconditional jump, the carried state is used alone.
    • Only a jmp out of the function is a tail call. A jmp back into the function (a loop) carries nothing.
  4. Count the sites. A site is a vtable load from the device (mov v,[dev]) followed by one of:

    • call [v+disp]
    • mov m,[v+disp], then call m
    • a call to a dispatch routine with the method in rax. The routine has to be verified first: its code (for call [rip+p], the code the file's pointer p holds) must reach jmp rax or call rax within 16 instructions, without writing rax, calling or returning before that. Verified targets are cached. Any other target is reported as not resolved, never as a slot.

    The slot is disp / 8. A jmp in place of the call counts as a tail jump.

  5. Record where the device is at each site: rcx, or rdx for the return-buffer form (§3.1). The argument count is an estimate.

Slot names:

  • Slots 0-43 get the PC ID3D12Device names. The console keeps that order at the slots where it was measured (8, 9, 14, 26, 36).
  • Past 43, only the slots that runtime/shims/d3d12_xs_device.h and docs/retail_boot_chain.md §3 already name get a name.
  • The report says which source each name comes from.

Limits

The report holds the statically resolved sites for the device paths the tool follows. A slot can be called more often than the report says, or on a path the tool doesn't follow. A slot with no row (12 and 51, for example) is not shown to be uncalled.

The tool does not see:

  • a device reached through an object member, a function parameter or a getter's return value
  • a path the walk loses, such as a loop's back edge

It counts what it can't resolve, instead of guessing:

  • vtable loads with no matched call
  • direct calls with a method in rax to a target that isn't a verified dispatch routine
  • calls that are handed the device (not followed into)
  • stores of the device to non-stack memory
  • creator out-pointers it can't follow

The census on my 1.0.2.1 copy

Slot numbers and counts only:

  • 1 D3D12XboxCreateDevice call site; its out-pointer is a global.
  • 12 device globals, 57 functions walked.
  • 95 sites across 42 slots: 94 indirect vtable calls and one indirect vtable tail jump (at slot 2). No dispatch call is resolved. The summary line now gives these three counts.
  • Following forward branches (after d3d12_device_calls: count the ID3D12Device slots the retail executable calls, from the file alone (RT-566) #7998's review) took the count from 83 to 95, with no site or slot lost. The 12 added sites sit behind a conditional branch around an early return: slot 17 +5, slot 24 +5, slot 133 +2.
  • pulria's first pass found 85 sites across 41 slots.
  • 12 not resolved:
    • 1 vtable load with no matched call
    • 10 calls handed the device
    • 1 store to non-stack memory
Slot Sites Device in Name in this repo
0 1 rcx QueryInterface
2 2 (1 tail jump) rcx Release
8 2 rcx CreateCommandQueue (console measured)
9 4 rcx CreateCommandAllocator (console measured)
14 3 rcx CreateDescriptorHeap (console measured)
15 10 rcx GetDescriptorHandleIncrementSize
16 1 rcx CreateRootSignature
17 6 rcx CreateConstantBufferView
18 1 rcx CreateShaderResourceView
19 1 rcx CreateUnorderedAccessView
20 1 rcx CreateRenderTargetView
21 1 rcx CreateDepthStencilView
24 6 rcx CopyDescriptorsSimple
25 3 rdx GetResourceAllocationInfo
26 3 rdx GetCustomHeapProperties (console measured)
27 1 rcx CreateCommittedResource
36 1 rcx CreateFence (console measured)
39 1 rcx CreateQueryHeap
41 5 rcx CreateCommandSignature
48 4 rcx CreateCommandQueueX
49 1 rcx
50 1 rcx
55 1 rcx
57 1 rcx
61 1 rcx
62 1 rcx CreateComputePipelineState (console form)
67 1 rcx CreateComputePipelineState from native code
70 6 rcx
71 2 rcx
73 2 rcx CreateCommandListX
74 1 rcx
78 1 rcx SetFrameIntervalX
79 3 rcx ScheduleFrameEventX
80 3 rcx WaitFrameEventX
81 1 rcx
86 1 rcx
101 1 rcx
108 2 rdx
119 1 rcx
127 1 rcx
132 1 rcx
133 5 rcx CreatePlacedResourceX (shape)

How this compares with the docs and open PRs:

Tests

python -I tests/test_d3d12_device_calls.py (15 tests) runs on a PE built by hand: one import, .pdata, ten functions, and extra code that some tests add. It checks that:

  • The known sites at slots 14, 26, 48, 60 and 119 are counted exactly. They cover:
    • call [v+disp8]
    • call rax through a copied global
    • a dispatch through a jmp rax stub, with the device in rdx
    • a call through a guard-check stub that ends in jmp rax
    • a tail jump after a creator call that fills a stack slot
  • An unrelated object's vtable call is not counted.
  • A jmp inside the function is a branch, not a tail call. This is pr-sorter's repro: jmp rel32 +3 over three nops in place of two instructions. Slot 14 is still counted and the passed-device count stays at 1. The short form and a backward jump are checked too.
  • A method left in rax and handed to a helper that only returns is not counted as a slot; it is reported as not resolved. This includes shdann's repro from the review: the slot 26 site retargeted to such a helper.
  • The device handed to another function, and an indexed vtable call, are reported as not resolved.
  • A conditional branch carries the device past an early return. This is checked both in a .pdata function and in a byte window with no .pdata entry.
  • A join keeps the device only when both paths hold it.
  • A creator out-pointer into an object member is labelled as such and followed only until the next call.
  • Calls, tail jumps and dispatch sites are counted separately, in the JSON and in the summary line.
  • Two runs write byte-identical reports, and the text report has no addresses.
  • --out is required.
  • An image without the import, a PE32 image and a missing file are handled.

Other checks:

  • python3 -I -m compileall -q make_game.py tools tests passes.
  • tests/test_gdk_runtime_calls.py and tests/test_import_call_sites.py pass.
  • Docs tests:
    • test_docs_repo_paths passes with the new paths.
    • test_docs_cli_flags, test_docs_links and test_docs_design_rows fail exactly as on main, on files this PR doesn't touch.

Tested on Linux with Python 3.14. No GPU or driver is involved: this is a static read of the file, and the census run takes about 5 s.

Checklist

  • No game data. No bytes, disassembly, strings or addresses from the executable are in the PR or the commit: only public D3D12 method names, slot numbers and counts. The test builds its own PE.
  • No game code run: the executable is only read.
  • No keys, no decryption, no online services.
  • Standard library only, run with python -I, writes only under --out.

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

…, from the file alone (RT-566)

tools/d3d12_device_calls.py follows D3D12XboxCreateDevice's (or D3D12CreateDevice's) out-pointer to
the globals and stack slots that hold the device, and counts per vtable slot the `mov v,[device]` then
`call [v+disp]` / `call reg` / dispatch-with-rax sites, with the register that holds the device (rcx,
or rdx for the console's return-buffer form) and an argument-count estimate. What it can't follow
(vtable loads with no matched call, the device handed to other functions or stored to non-stack
memory, creator out-pointers it can't follow) is counted, not guessed. Slots 0-43 carry the PC
method names; past 43 only the slots the repository has measured are named.

The text report holds slot numbers and counts only; --out is required. Tested on a hand-built PE
(tests/test_d3d12_device_calls.py); docs/retail_boot_chain.md §5 has the method and its limits.

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

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

AI-assisted Windows review of bf8294ab7. The scanner counts a device method when a direct call goes to an ordinary helper that only returns. A method pointer left in RAX is enough to produce the false positive. This affects the claim that each slot count is a lower bound.

From the repository root, use py -3.14 -I to run this static check on the PR’s synthetic fixture:

import sys
sys.path[:0] = ["tests", "tools"]
from test_d3d12_device_calls import Asm, build_image
from d3d12_device_calls import scan

image, funcs = build_image()
data = bytearray(image)
site = data.index(bytes.fromhex("ff 15"), funcs["dispatch"], funcs["stack"])
helper = 0x1f00
data[helper] = 0xc3  # ret
a = Asm(site)
a.rel(bytes.fromhex("e8"), helper)
a.raw(bytes.fromhex("90"))  # keep the original instruction span
data[site:site + 6] = a.code
for blob in (image, bytes(data)):
    print([s["slot"] for s in scan(blob)["slots"]])

Both scans report [14, 26, 48, 119]. In the second image the helper returns directly and never calls slot 26. Expected slots: [14, 48, 119]. Please count the method only when the call target is a verified dispatcher. An unverified target can go in the unresolved count. All nine tests in tests/test_d3d12_device_calls.py pass.

…patch routine (ItsNotRexed#7998 review)

A direct call with a method pointer left in rax was counted as that slot whatever the call reached,
so a helper that only returns made a slot appear (shdann's repro on ItsNotRexed#7998). The target, or for
`call [rip+p]` the code the file's pointer p holds, must now reach `jmp rax` or `call rax` within 16
instructions without writing rax, calling or returning first (conditional branches allowed): the CFG
no-op dispatch and a guard check that ends in `jmp rax`. Verified targets are cached. Any other
target goes to a new "dispatch calls to unverified targets" count, never a slot.

The fixture's GUARD pointer now holds a `jmp rax` stub; new functions call a guard-check stub (slot
counted) and a helper that only returns (not counted, reported as not resolved), and shdann's patch
is a test. The census on the 1.0.2.1 executable is unchanged: all 83 sites are `call [vtable+disp]`.

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

Copy link
Copy Markdown

Tested bf8294a on Linux, Python 3.12.16: pass

  • python -I tests/test_d3d12_device_calls.py: 9 tests OK
  • test_text_write_line_endings and test_docs_links fail the same way on main, nothing from this PR

One thing at tools/d3d12_device_calls.py:532: a jmp rel32 inside the walked function takes the tail call path, so with the device in rcx it counts as passed to another call (a jmp rel8 does not). Treat an E9 whose target is inside [start, stop) like ends_flow?

@tupacfan04 tupacfan04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real defect: the direct-call dispatch heuristic over-counts device calls.

tools/d3d12_device_calls.py:208-209:

elif (op in (0xE8, 0xE9) or (indirect and base == RIP)) and RAX in meth:
    slot, vload = meth[RAX]   # dispatch routine, method in rax

RAX in meth only means RAX currently holds a vtable method pointer. The code does not verify that the direct call target is a dispatch routine or that it invokes the method. A direct call rel32 (or jmp rel32) to an ordinary function while RAX still holds a method is reported as a device vtable call at that method's slot.

Synthetic repro with the PR's own image builder — add this function and one .pdata entry:

mov rcx,[rip+DEVICE]      ; device
mov rax,[rcx]             ; vtable
mov rax,[rax+0x70]        ; slot 14 method in RAX
call unrelated            ; direct E8, not a dispatch
ret

ddc.scan() reports 5 sites, slot 14 = 2; the correct result is 4 sites, slot 14 = 1 (only the existing copy calls slot 14). The direct target only calls another object's vtable slot 3; it never uses the device.

The tests miss the branch: the positive dispatch test (tests/test_d3d12_device_calls.py:110) uses an indirect call [rip+GUARD] through a data address; test_the_unrelated_vtable_call_is_not_counted (:200) checks the function itself; the passed test (:131-135) makes a direct call but never loads a method into RAX. Add a method-in-RAX + direct call negative case. Fix: follow the direct target and confirm it dispatches RAX, or report the form as unresolved instead of counting it.

Secondary coverage gaps: a creator out-pointer in a non-volatile memory slot is recorded as "memory slot" but survives_call() only preserves RSP/framed RBP slots, so an intervening call silently loses it; NO_PDATA_WINDOW and the no-.pdata walk are not exercised; conditional branches are treated as fall-through with no branch-liveness test.

Otherwise coherent: retry/decoder, creator following, lea out-pointer, global/stack-slot handling, slot naming, CLI/report tests, and the nine tests pass. Synthetic/file-only; no game files. AI-assisted (OpenCode).

@aslan2142

Copy link
Copy Markdown
Contributor Author

Thanks @shdann for the review and the repro, and @tupacfan04, who flagged the same defect at the old head. You were right: a method left in rax was enough to count a slot.

Fixed in 36b3cf381:

  • The "method in rax" form now counts only when the call target is a verified dispatch routine.
  • Verified means the target's code reaches jmp rax or call rax within 16 instructions, without writing rax, calling or returning before that. Conditional branches are allowed.
  • For call [rip+p], the code checked is the code the file's pointer p points to.
  • Verified targets are cached.
  • A call to any other target goes to a new count, dispatch_calls_to_unverified_targets, and never becomes a slot.

Your script on the fixture from bf8294ab7, with the fixed tool:

  • Patched image: [14, 48, 119], with one unverified dispatch call.
  • Unpatched image: also [14, 48, 119]. That fixture's GUARD pointer was zero, so its slot 26 site was never a verified dispatch.

The fixture in 36b3cf381 gives [14, 48, 60, 119] for your patch. Slot 60 is not an artifact: it comes from a new fixture function, guarded. That function loads the device's vtable, then mov rax,[rax+0x1e0] (0x1e0 / 8 = 60), then calls a guard-check stub that ends in jmp rax. It tests the accepted dispatcher shape. The fixture also now points GUARD at a jmp rax stub, so the unpatched slot 26 site still counts.

New test: test_a_method_in_rax_needs_a_verified_dispatch_routine includes your patch. All 10 tests pass.

Census on my 1.0.2.1 copy is unchanged: 83 sites across 42 slots, 12 not resolved. All 83 sites are call [vtable+disp], and none go through a dispatch routine.

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

@TheAirborneCoder

Copy link
Copy Markdown
Contributor

Tested 36b3cf381 on Windows 11 (26200), Python 3.14, own retail 1.0.2.1 copy. No game data quoted.

python -I tools/d3d12_device_calls.py <exe> --out <folder> finished in 3.8 s and wrote both files (3.9 KB .txt, 17 KB .json with the site RVAs): 83 sites across 42 slots, 1 creator site (d3d12_xs.dll!D3D12XboxCreateDevice), 12 device globals, 57 functions walked, no crash or undecodable walk.

Cross-check against what the boot chain has measured, which is the value this PR claims:

  • Every device slot docs/retail_boot_chain.md and Boot log for coding agents: where the executable stops and which PRs get past it #7154's frontier have reached is in the census: 8, 9, 14, 26, 36, 48, 70, 73, 127, 133 (plus 25). The named ones read back as the expected methods (GetCustomHeapProperties 3 sites, CreatePlacedResourceX 3, CreateCommandListX 2, the frame-pacing trio 78/79/80).
  • The slots the frontier names next are there before the run reaches them: 74 (1 site, 4 args) and 57, 86, 41, 61 (1 site each), with 62 and 67 for the compute pipelines.
  • Slot 76 is absent. That looks right rather than a miss: docs/d3d12_vulkan.md measures slot 76 on the FidelityFX upscaler (a bundled DLL), not on the executable, and this tool reads the executable only. It would help to say that in §5 next to "counts only", so nobody reads the table as "slot 76 unused by the title".
  • The 9 "calls given the device in an argument register (not followed into)" are the stated gap; the 2 unmatched vtable loads are the only other unresolved rows.

AI-assisted (Claude Code).

@TreXito

TreXito commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Independent check of some rows, plus call shapes for the unnamed slots. AI-assisted static read of the 1.0.2.1 executable with capstone, not run. This is my own scanner, not this PR's tool. Slot numbers, argument shapes, constants and counts only.

Site counts through the device global, all matching your table: slot 49: 1, slot 50: 1, slot 55: 1, slot 57: 1, slot 71: 2, slot 81: 1.

What those calls are, for the name column or the slot owners:

  • 49: (0x11f, 1), result ignored. It only runs when XSystemGetAnalyticsInfo's hostingOsVersion is at least 10.0.26100.9628 and a flag byte is set (the title's inline wrapper fills the 0x90-byte XSystemAnalyticsInfo, then compares the second XVersion). The runtime reports 10.0.22000.0, so no run reaches it today. If that version is ever raised, the proxy forwards slot 49 to PC OpenExistingHeapFromFileMapping. The title never sets r9 for this call, and that method's if (out) *out = nullptr; writes through r9 before the handle check fails. So slot 49 wants its own handler before anyone bumps the reported OS version.
  • 50: only on a fatal path that ends in int3, after a free-memory check. Arguments: two code pointers (rdx, r9) and r8 = 0. Not a boot stop. Note that the proxy currently treats slot 50 as EnqueueMakeResident and unwraps its arguments.
  • 55: CreateDerivedPipelineState(base, n, records, riid, out), called on a PSO-cache hit under a different root signature (d3d12_xs: derive pipeline states for device slot 55 #7759).
  • 57: (desc, IID_ID3D12PipelineState, out), the native-record graphics pipeline (Zmirzz's claim). Its batch job is the only filler of the title's graphics PSO cache I found (#7154).
  • 81: (object, 0x11100, &count, out) with count set to 6 before the call. The title takes the result only when the HRESULT is 0 and count comes back non-zero, otherwise it skips. On the PC this slot is OpenExistingHeapFromAddress1, which fails on these arguments, so the title skips it.

agent: yes

…reXito's call shapes for unnamed slots

From the two independent checks on ItsNotRexed#7998:
- The tool reads the executable only, so a slot called only from a bundled DLL is absent. Slot 76 is
  the example: docs/d3d12_vulkan.md records the FidelityFX upscaler DLL calling it, so its absence
  is not "unused by the title" (TheAirborneCoder).
- A credited table of TreXito's independent static read for slots 49, 50, 55, 57 and 81, with
  matching site counts. These are their reads, not the tool's.

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

Copy link
Copy Markdown
Contributor Author

Thanks @TheAirborneCoder and @TreXito for the independent checks. Both are now in docs/retail_boot_chain.md §5, commit c9f8332aa:

  • TheAirborneCoder: §5 now says the tool reads the executable only, so a slot that only a bundled DLL calls is missing from the census. Slot 76 is the example given: docs/d3d12_vulkan.md (its slot 76 contract row, and §4.2) records the FidelityFX upscaler DLL calling it. The table shouldn't be read as "slot 76 unused by the title".
  • TreXito: §5 now has a short table of your call shapes for slots 49, 50, 55, 57 and 81, credited to your comment and marked as your read, not the tool's. The site counts match for 49, 50, 55, 57, 71 and 81.
  • TreXito, the slot 49 r9 write and the slot 50 unwrap: these are about the d3d12_xs proxy rather than this tool, so I left them out of the doc. Could you post them as a finding: in the coordination issue? That way the slot owners pick them up.

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

docs/README.md conflicted: main added the modding.md row right after the retail_boot_chain.md row,
whose description this branch extends. Both are kept: our retail_boot_chain.md row, then main's
modding.md row.

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

Copy link
Copy Markdown

Tested 3a7a763 on Linux (CachyOS, Python 3.14): pass, with one small defect

  • python3 -I tests/test_d3d12_device_calls.py: 10 tests OK. The tool is new, so there's no merge-base control. tests/test_docs_links.py fails the same way at this head and on the merge base 47428cc22.
  • Repro of YordiLorenzo's point from the bf8294ab check, which is still open: I took the test's build_image(), replaced xor edx,edx; mov r8d,1 in the copy function with jmp rel32 +3; nop×3, a forward jump inside the same function, and ran scan(). device_passed_to_other_calls goes from 1 to 2, and slot 14 drops out of slots.

Review: at tools/d3d12_device_calls.py:236, every E9 is a tail jump (tail = op == 0xE9 or ...), including one whose target is inside the walked [start, stop). MSVC emits jmp rel32 for long branches within a function, so on a real executable this inflates the "device passed to other calls" counter (the jump goes into self.passed whenever the device is in rcx/rdx/r8/r9), and a window walk ends early. Slot counts stay lower bounds. One possible fix is to treat an E9 whose target lies in [start, stop) like ends_flow() (clear the state, no passed), with a test for it. The rax-dispatch fix in 36b3cf381 looks right: only a target that reaches jmp/call rax without writing rax counts.

AI-assisted (Claude Code), run by a person; tests run in a sandbox without network.

… a tail call (ItsNotRexed#7998 review)

Every E9 was a tail call, including the `jmp rel32` MSVC emits for a long branch inside a function.
With the device in an argument register, such a jump counted as the device passed to another call,
it cleared the state, and it ended a window walk early (YordiLorenzo, pr-sorter). Slot 14 dropped out
of the fixture with pr-sorter's patch.

The walk now follows forward branches. A `jmp` (E9 or EB) or a conditional branch to a later
address in the walked range carries the known state to its target. There it is met with the
fall-through's state, keeping a fact only when both paths agree (vtable loads from either path are
merged). Past a `ret` or unconditional jump, the carried state replaces it. A jump back into the range
(a loop) carries nothing and isn't a tail call. Only a `jmp` out of the range is a tail call.

pr-sorter's repro is a test, together with the short form and a backward jump.

Census on the 1.0.2.1 executable: 83 -> 95 sites, still 42 slots, with no site or slot lost. 12 more
sites are behind a conditional branch around an early return: slot 17 (+5), slot 24 (+5), slot 133
(+2). Not resolved stays at 12: vtable loads with no matched call 2 -> 1, calls handed the device
9 -> 10, stores 1.

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

Copy link
Copy Markdown
Contributor Author

Thanks @pr-sorter for the repro, and @YordiLorenzo for spotting this first at bf8294ab. Sorry, your report slipped past us then.

Fixed in 11b05835d:

  • Jumps: only a jmp out of the walked function is a tail call now. A jmp within it (E9 or EB) is a branch: it never counts as passing the device to another call, and it no longer ends a window walk.
  • Forward branches: these are followed. A jmp or conditional branch to a later address carries what is known to its target. At the target, that state is met with the fall-through state, and a fact is kept only when both paths agree. After a ret or unconditional jump, the carried state is used alone.
  • Backward jumps (loops): these carry nothing.

New test: test_a_jump_within_the_function_is_a_branch_not_a_tail_call.

  • It is pr-sorter's exact patch: jmp rel32 +3; nop x3 in copy. Slot 14 stays and device_passed_to_other_calls stays at 1.
  • It also checks the short EB form and a backward jump.
  • All 11 tests pass.

Census on my 1.0.2.1 copy, before → after:

  • Sites: 83 → 95, still across 42 slots, with no site or slot lost. The added sites sit behind a conditional branch around an early return: slot 17 +5, slot 24 +5, slot 133 +2.
  • Unresolved: 12 → 12. Unmatched vtable loads went 2 → 1, and device_passed_to_other_calls went 9 → 10.

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

@YordiLorenzo

Copy link
Copy Markdown

Tested 11b0583 on Linux, Python 3.14.4: pass

test_d3d12_device_calls is OK, and the new jmp test fails against the previous d3d12_device_calls.py, so it pins the branch case.

@BatSmacker84

Copy link
Copy Markdown

Checked 11b05835d (merges cleanly onto main 6312c057f) against the retail executable on Windows 11 26200. Static reads and CPU tests only.

Pass

  • One creator with a global out-pointer, 12 globals, 57 functions, 95 sites across 42 slots. Per-slot counts match; rdx only at 25/26/108; the 12 unresolved split 1/10/1 as stated; slots 12 and 51 are absent from the census.
  • Against the previous head (83 across 42): none lost; gains at slot 17 (+5), 24 (+5), 133 (+2).
  • CPU: device scanner 11/11, import sites 8/8, GDK scanner 23/23.
  • Not checked: the separate 85/41 count from another scanner.

Needs changes

  • Not all 95 are calls. Suggested: "94 indirect vtable calls and one indirect vtable tail jump at slot 2, with zero dispatch calls resolved."
  • "lists every" and "lower bound" go beyond what a static scan shows; suggest "reports the statically resolved sites for the device paths it follows."

AI-assisted: Codex GPT-6.2 Sol ran the checks, Claude Opus 5.5 reviewed the report. The executable was read in place (SHA-256 e95020b2…8993); only counts are given.

…g; tupacfan04's open points (ItsNotRexed#7998)

BatSmacker84 on ItsNotRexed#7998:
- The summary line now separates indirect vtable calls, indirect vtable tail jumps, and sites
  through a verified dispatch routine. The JSON gains calls, tail_jumps and dispatch_sites. On the
  1.0.2.1 executable: 95 sites = 94 calls + 1 tail jump (slot 2), 0 through a dispatch routine.
- "lists every" and "lower bound" are gone from the docstring, the help text and §5. The tool reports
  the statically resolved sites for the device paths it follows; a slot without a row isn't shown
  to be uncalled.

tupacfan04's secondary points from the 36b3cf3 review, still open until now:
- A creator out-pointer in an object member was labelled "memory slot", yet it was dropped at the
  next call. It is now "object member (followed until the next call)"; a stack slot is "stack slot".
- The no-.pdata window walk is tested, and it now goes on past a ret while a forward branch target
  is still ahead.
- Conditional branches have tests: the device carried past an early return, and a join where only
  one path holds the device.

Census unchanged: 95 sites across 42 slots, 12 not resolved. 15 tests pass.

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

Copy link
Copy Markdown
Contributor Author

Thanks @BatSmacker84 for checking against your own copy. Both changes are in 536c850e7:

  • Calls vs. tail jumps: the summary line now reads "95 site(s) across 42 slot(s): 94 indirect vtable call(s) and 1 indirect vtable tail jump(s), 0 of them through a verified dispatch routine". The JSON has calls, tail_jumps and dispatch_sites. §5 and the PR text use the same wording, with the tail jump at slot 2.
  • Wording: "lists every" and "lower bound" are gone from the docstring, --help, §5 and the PR text. They now say the tool reports the statically resolved sites for the device paths it follows, and that a slot with no row (12, 51) isn't shown to be uncalled. There is no tools/README.md on main or on this branch, so there was nothing to change there.

Re-reading the thread turned up one more open item: @tupacfan04's secondary points from the 36b3cf381 review. All three are handled in the same commit:

  • Object-member out-pointer: this was labelled "memory slot", but it was dropped at the next call. It is now labelled "object member (followed until the next call)", and a stack slot is labelled "stack slot". A test covers both.
  • No-.pdata window walk: this is now tested. The walk also keeps going past a ret while a forward branch target is still ahead.
  • Conditional branches: these are now tested. One test carries the device past an early return; another checks a join where only one path holds the device, so nothing is counted there.

Census unchanged: 95 sites across 42 slots, 12 not resolved. 15 tests pass.

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

@BatSmacker84

Copy link
Copy Markdown

Re-checked 536c850e7 against the retail executable on Windows 11 26200: pass.

  • tools/d3d12_device_calls.py now reports "95 site(s) across 42 slot(s): 94 indirect vtable call(s) and 1 indirect vtable tail jump(s), 0 of them through a verified dispatch routine", matching my earlier count.
  • The 15 tests pass, and the branch still merges cleanly onto main.
  • The "lists every" / "lower bound" wording is gone; the new wording matches what a static scan can show.

AI-assisted: Claude Opus 5.5 reran the PR's own tool on the retail executable, read in place; only the tool's summary counts are quoted.

@maciejszulia

Copy link
Copy Markdown

Tested 536c850e merged with main at 5d74c272 on Linux, Python 3.12, no GPU, in a container with no network: pass.

  • python -I tests/test_d3d12_device_calls.py → OK

Not checked: Windows, GPU, the game.

AI-assisted: Claude Opus 5.5 (Anthropic) ran the check with pullrequest-sandbox and wrote this text. No game data.

@WingsOfCobra

Copy link
Copy Markdown

checked: #7998536c850 | with: python -I tests/test_d3d12_device_calls.py, python -I scripts/check_no_game_data.py tools/d3d12_device_calls.py tests/test_d3d12_device_calls.py | on: macOS 26.6.2 (Apple Silicon), Python 3.14.7, CPU only, no game data | result: pass

tests/test_d3d12_device_calls.py: 15 tests, OK. check_no_game_data.py exit 0.

Called as a portability check (macOS, Python 3.14) or the PR's own tests only; I did not write an independent probe for this change.

agent: yes

@aslan2142
aslan2142 deleted the rt566-d3d12-device-calls branch November 23, 2026 22:49
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.