Skip to content

d3d12_xs: console command-list IID, and slot 70 takes three arguments (measured) #523

Done

Description

@rocobalt1

Two findings for the Leonida continuation, with a patch

Measured 2026-11-24 on a retail 1.0.2.1 package with a local build of
ubiquitarianism/leonida @ 8f481cf1 (MSVC, RelWithDebInfo, Vulkan layer,
LEONIDA_D3D12=vulkan, LEONIDA_ARENA_MB=3072).

1. Console command-list IID (patch attached)

leonida-command-list-iid.patch, 17 insertions in runtime/shims/d3d12_xs_device.cpp.

Without it, --run stops after 13 D3D12 calls:

[rt] d3d12: QueryInterface: unknown IID {c3827890-4024-474c-98cf-645b51dc4874}
[d3d12-trace] #13 ID3D12Device::CreateCommandList failed
int3 at game_scarlett_master.exe+0x2478b7b

Two separate causes, both in the same path:

  1. proxy_create_command_list_x passed the console IID straight to the PC device.
    The PC device cannot answer an IID outside the SDK, so it fails. Creating the list
    with __uuidof(ID3D12GraphicsCommandList) and letting wrap_list answer the
    console IID fixes it.
  2. ListProxy::QueryInterface refused the console IID, so the title's own
    QueryInterface on the returned list still failed. The proxy now records the IID
    it was created with and answers exactly that one.

With both: 1 639 D3D12 calls, 581 command lists created and closed, 439
allocators, CreateCommittedResource3 (slot 127) succeeds. The run then stops at the
title's own int3 at +0x247AF2D, the same place a differently-patched build stops,
so the IID is not the remaining blocker.

2. Device slot 70 takes three arguments, not seven

docs/retail_boot_chain.md does not describe slot 70. Disassembling the return address
from the trace (tools/disasm_at.py, capstone over the PE section table) gives:

04ECC800  push rsi
04ECC801  sub  rsp, 0x20
04ECC805  mov  rsi, r8
04ECC808  mov  r8, rdx
04ECC80B  mov  rdx, rcx
04ECC80E  mov  rcx, [device]      ; this
04ECC815  mov  r9, rsi
04ECC818  mov  rax, [rcx]
04ECC81B  call [rax + 0x230]      ; slot 70 = 0x230/8

No stack stores, three register arguments. The console ABI is:

Word Meaning (measured)
rdx D3D12_RESOURCE_DESC (reads correctly: Width 182 MiB, Height 1, Layout ROW_MAJOR)
r8 result slot, a writable caller stack address
r9 a heap VA, which is the address the title expects the resource to live at

Anything a proxy reads past r9 is a leftover register: at this call site a7 held an
address inside the title's .text, so forwarding the PC signature wrote a resource
pointer into the title's own code. That is why the call must not be forwarded by slot
number.

3. The title patches its own .text

A write fault at 0x144DAC5FA is RVA 0x4DAC5FA, which the section table places in
.text (flags XR). On the console .text is writable and the title patches itself.
Mapping executable sections read-execute makes the first such write a fatal access
violation; mapping them read-write-execute lets the patch land.

What this is not

These are observations from one machine and one package, not a claim about the console
ABI beyond what the call sites show. The patch is offered as a starting point; the
slot 70 ordering is documented so someone with a debugger can confirm it.

Activity

  1. rocobalt1 commented on Nov 24, 2026

    @rocobalt1
    Author

    The patch the report refers to, applied to 8f481cf1:

    diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp
    index 7f7040fdd..864aef79a 100644
    --- a/runtime/shims/d3d12_xs_device.cpp
    +++ b/runtime/shims/d3d12_xs_device.cpp
    @@ -909,6 +909,8 @@ struct ListProxy {
         alignas(8) std::uint8_t console_fields[0x600];
         std::atomic<unsigned long> refs;    // past the console body
         unsigned pc_slot_count;             // slots the real list implements; mapped slots past it are refused
    +    IID console_iid;                    // the console command-list IID this proxy answers (97: local)
    +    bool has_console_iid;               // (97: local)
     
         void pin_cursor_at_limit() {
             const std::uint64_t at_limit = static_cast<std::uint64_t>(
    @@ -1018,6 +1020,13 @@ inline HRESULT list_query_interface(ListProxy* self, const IID* riid, void** out
         if (!out) return E_POINTER;
         *out = nullptr;
         if (!riid) return E_POINTER;
    +    // 97 local: the console command-list IID is not in the PC SDK, so the real object cannot answer it. The title
    +    // asks for exactly the IID it created the list with, so answer that one ourselves.
    +    if (self->has_console_iid && IsEqualIID(*riid, self->console_iid)) {
    +        *out = self;
    +        list_add_ref(self);
    +        return S_OK;
    +    }
         if (!is_list_iid(*riid)) {
             if (supports_iid(self->real, *riid)) log_refused_iid("list", *riid);
             return E_NOINTERFACE;
    @@ -1136,6 +1145,11 @@ HRESULT wrap_list(IUnknown* created, DeviceProxy* device, const IID* riid, void*
         proxy->device = device;
         proxy->refs.store(1, std::memory_order_relaxed);
         proxy->pc_slot_count = detect_list_slot_count(created);
    +    proxy->has_console_iid = false;
    +    if (riid && !is_list_iid(*riid)) {
    +        proxy->console_iid = *riid;  // 97 local: the console IID this list answers
    +        proxy->has_console_iid = true;
    +    }
         proxy->pin_cursor_at_limit();
         proxy_add_ref(device);
     
    @@ -1442,8 +1456,10 @@ HRESULT proxy_create_command_list_x(DeviceProxy* self, std::uint64_t desc_word,
         if (!allocator) allocator = reinterpret_cast<ID3D12CommandAllocator*>(allocator_word);
         auto* initial_state = reinterpret_cast<ID3D12PipelineState*>(initial_state_word);
         void* created = nullptr;
    +    // 97 local: `riid` is the console command-list IID, which is not in the PC SDK and makes the PC device's
    +    // QueryInterface fail. Create the PC list with the PC IID; wrap_list answers the console one.
         const HRESULT hr = self->real->CreateCommandList(0, type, allocator, initial_state,
    -                                                     *riid, &created);
    +                                                     __uuidof(ID3D12GraphicsCommandList), &created);
         if (FAILED(hr)) return hr;
         return wrap_list(static_cast<IUnknown*>(created), self, riid, out);
     }
    
  2. rocobalt1 commented on Nov 24, 2026

    @rocobalt1
    Author

    The same patch as the diff above, as a file you can git apply: https://gist.github.com/rocobalt1/ef3bb582335f93805c9c7f5598b8739f

  3. slauko commented on Nov 24, 2026

    @slauko

    Reproduced independently under Wine on Linux, both stops — and one prerequisite stop before yours that a Windows host cannot see

    Retail 1.0.2.1 package, --run under Wine on Arch Linux (RTX 3080 Ti, NVIDIA 595.112.07, Vulkan 1.4.329), build from ubiquitarianism/leonida main + this patch + a test update for xs_proxy_mock (its line 956 compared the IID the proxy forwards to the PC device by address; with the patch it is the proxy's own GUID object, so it is compared by value now — plus a creation-with-console-IID case).

    Before this patch, there is an earlier stop that only shows up where the host has no GameInput.dll: the artifact builds without SDL3, so GameInputCreate fails and the title asserts at its GameInput call site — 13 D3D12 calls, zero command lists, and the unknown IID from your report does not even appear yet. A Windows host masks this by serving the host's GameInput.dll (docs/gameinput.md's fallback path). Building with -DLEONIDA_SDL3_FETCH=ON (workflow tweak, the shim is otherwise never compiled) clears it, and the run proceeds to exactly your measurement. Worth having in the artifact CI so a Wine user's first --run does not die before your stop.

    With this patch, your numbers reproduce one to one on this machine:

    yours (Windows) this run (Wine/Linux)
    calls before the patch 13 13
    unknown list IID {c3827890-…} same
    title int3 before the patch +0x2478b7b same
    calls with the patch 1 639 1 639
    CreateCommittedResource3 (slot 127) ok ok
    next stop +0x247af2d same

    The next stop decodes to a span check: ([rsp+0x78] - [rsp+0x70]) + [global] asserted <= 0x1fffff (2 MiB − 1), reached right after the descriptor heap, GetCPUDescriptorHandleForHeapStart and a few hundred view creations — which points at the same descriptor-model question as boot.md Q4 and retail_boot_chain's stop 13. The three calls inside that loop are internal title functions, so we are reading them next; no findings to add there yet.

    Happy to rerun anything on this GPU or driver.

  4. slauko commented on Nov 24, 2026

    @slauko

    One addition your patch needs to land green: xs_proxy_mock pins the OLD forwarding behaviour, and two of its assertions fail against the patch. The test change we run on top of it:

    1. line 956 compares the IID the proxy forwards to the PC device by address (mock->args[12][4] == word(&list_iid)); the patch passes the proxy's own GUID object, so compare by value (IsEqualIID(*reinterpret_cast<const IID*>(mock->args[12][4]), __uuidof(ID3D12GraphicsCommandList))), and
    2. a creation with a console IID is worth pinning: the PC call still carries the public IID, the returned proxy answers the console IID (QueryInterface on it returns the proxy itself), and both references unwind.

    Diff: https://gist.github.com/slauko/b351c8780d2b0feea6ffa91d54f70cc8 — applies on top of your d3d12_xs_device.cpp change; with both, the artifact's 295 CPU tests are green here (and the retail --run under Wine proceeds from 13 to 1,639 D3D12 calls, matching your numbers; see our comment above). Happy to fold this into your PR however you prefer.

  5. iiiirokuuug-rgb commented on Nov 24, 2026

    @iiiirokuuug-rgb

    The patch works on Intel Arc too, and it carries the boot much further than the AMD run. Measured 2026-11-24 on ubiquitarianism/leonida 21625bc with leonida-command-list-iid.patch applied on top (nothing else), MSVC 2022 RelWithDebInfo, LEONIDA_D3D12=vulkan, own 1.0.2.1 copy on an Intel Arc A770 (Alchemist, 16 GB; Intel Windows driver 32.0.101.9033, Vulkan 1.4.356), Windows 11 26200.

    Without the patch, exactly the reported stop:

    [rt] d3d12: QueryInterface: unknown IID {c3827890-4024-474c-98cf-645b51dc4874}
    [d3d12-trace] #13 ID3D12Device::CreateCommandList failed
    exception 0x80000003 at game_scarlett_master.exe+0x2478b7b
    

    With it, the D3D12 call trace goes from 13 to 1,639 calls and the title gets through resource creation:

    [d3d12-trace] #1632 ID3D12Device10::CreateCommittedResource3 ok
    [d3d12-trace] #1633 ID3D12Device::CreateShaderResourceView called
    [d3d12-trace] #1634 ID3D12Device::CreateRenderTargetView called
    [d3d12-trace] #1635 ID3D12Device::CreateUnorderedAccessView called
    ...
    [d3d12-trace] #1639 ID3D12Device::CreateUnorderedAccessView called
    exception 0x80000003 at game_scarlett_master.exe+0x247af2d
    

    So the IID fix is not AMD-specific: it moves the run past the list creation on a second vendor and a different driver.

    New stop, if it helps whoever takes it next. It is a bounds assert, not a null call. The site is +0x247af2d; the instruction before it computes a span and compares it with 2 MiB − 1:

    sub  rax, [rsp+0x70]        ; end - start, from a loop that just filled an array of the objects created
    add  rax, [rip+...]         ; + a module-relative bias
    cmp  rax, 0x1fffff
    jbe  +2
    int3
    

    That reads like "this span (+ bias) has to fit in 21 bits", and the value is assembled over the array the loop above it fills. I did not chase what the array holds: the traces are on my machine and I am not quoting anything from the executable beyond the instruction shapes.

    Separately, and only if it is new information: this run also throws a C++ exception out of the Vulkan driver before that assert, which I have not seen reported:

    {"kind":"exception","code":"0xe06d7363","cpp":true,"at":"host:KERNELBASE.dll+0xc41ca",
     "stack":["host:KERNELBASE.dll+0xc41ca","host:igvk64.dll+0x314ea7","host:igvk64.dll+0x4e0d8e",...,"host:igvk64.dll+0x1207a4"]}
    

    igvk64.dll is the Intel Vulkan driver, and the whole stack is inside it: no game frames. It is caught and the run continues, but an exception escaping a Vulkan driver is worth knowing about on an Intel path, and it may be the Intel equivalent of whatever the AMD result looked like at the same call count.

  6. whoalin1 commented on Nov 25, 2026

    @whoalin1
    Contributor

    Checked on current main (b4b7756): both halves of this are already in the tree — kXboxGraphicsCommandListXIid + is_list_iid answer the console IID (d3d12_xs_device.cpp:1144-1195) and proxy_create_command_list_x creates the PC list with __uuidof(ID3D12GraphicsCommandList) for it (:1736-1740), landed via the #359/#445 slot mapping lineage; xs_proxy_mock_test already pins the new behavior (:2515-2525) and all xs proxy tests pass locally. Slot 70's three-argument signature is implemented (:1764, :2842) and .text writable mapping is in pe_loader.cpp:1871. Nothing left to port — the remaining open variant is PR #728's E_NOINTERFACE-retry approach. AI-assisted check (Devin).

  7. ateezie commented on Nov 25, 2026

    @ateezie

    Same +0x247af2d stop on Windows/NVIDIA at current main, and what follows it with LEONIDA_SKIP_INT3=1

    Retail 1.0.2.1 package, ubiquitarianism/leonida main @ 32950551e, built with make_game.py (runtime from scripts/build_runtime.ps1, MSVC 19.44). Windows 11 Pro (build 26200), Ryzen 9 5900X, RTX 5090 (driver 621.14, Vulkan 1.4.357), wave64 emulation on (32-wide subgroups).

    $env:LEONIDA_D3D12 = 'vulkan'
    gta6rt.exe --run <package>\game_scarlett_master.exe --trace-d3d12 --trace run.jsonl
    

    Plain run: this is the stop reported above. There are 1,639 D3D12 calls, none of them failed or unsupported. The last ones are two CreateCommittedResource3 (slot 127, dimension=3, xbox flags 0x300005 -> PC 0x5), each followed by SRV/RTV/UAV creation. Then, at t = 4.58 s:

    exception 0x80000003 at game_scarlett_master.exe+0x247af2d
    stack: +0x247af2d <- +0x2479430 <- +0x19f4f54 <- +0x580437e <- +0x43a4911 <- +0x224070b <- +0x23cf00a <- +0x2215eca
    

    With LEONIDA_SKIP_INT3=1: the assert is stepped over (int3_skipped at +0x247af2d, t = 3.79 s). It makes no further D3D12 trace calls, but it does reach the first root signature and compute pipeline:

    [rt] d3d12_xs: device slot 16 (CreateRootSignature) first call
    [rt] d3d12_xs: device slot 62 (Xbox CreateComputePipelineState) first call
    [rt] d3d12: 28258 translated shaders from <work>\shaders\spirv
    [rt] d3d12: root signature usable for graphics only: root parameter 8 does not fit in the user SGPRs from s4 (spill array not modelled)
    

    Then, at t = 32.26 s:

    exception 0xc0000005 (write to 0x0) at game_scarlett_master.exe+0x2215c35
    stack: +0x2215c35 <- +0x2215eca <- KERNEL32 <- ntdll
    

    Caveats:

    • Stepping over the span assert leaves the title in a state it doesn't expect, so the null write may just be a consequence of it.
    • The root-signature line is a separate data point. The first compute root signature the title creates already has a parameter past the user SGPRs, so the spill-array model (root_signature.cpp:77, d3d12_vulkan.md §8.2) is needed before compute pipelines past this point can be bound. Whether that's related to the crash isn't established.
  8. BubsMcgee commented on Nov 25, 2026

    @BubsMcgee
    Contributor

    Both halves are in on main: proxy_create_command_list_x (runtime/shims/d3d12_xs_device.cpp:3803) answers the console command-list IID instead of asking the PC device for it (the measured call sites are noted at :3824), and the slot-70 view path takes the three measured arguments (:3858, :3916). Re-checked at 9e7720c9e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions