Skip to content

d3d12_xs: Xbox device slot 70 is handled by the proxy (a null SRV for now, its raw words logged), not the PC CreatePlacedResource1 (retail boot chain stop 14) - #7066

Open
tedin7 wants to merge 4 commits into
ItsNotRexed:mainfrom
tedin7:fast-slot70

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in #6910 (comment)

@ItsNotRexed: an exe PR, as you asked.

What

Xbox device slot 70 no longer reaches the PC slot 70. The d3d12_xs device proxy now handles it itself: (texture words, view desc, destination handle), no return value. The destination gets the PC null shader-resource view (CreateShaderResourceView with no resource and a valid 2D description), and the call returns. A null destination is a no-op. It is checked before the PC-vtable length refusal, so it holds on a PC device with or without ID3D12Device8.

Why

Stop 14 of the retail boot chain (#6982, section 3.6): the title's SRV writer calls device slot 70 to make a view from raw descriptions and a GPU address, with no resource object. On the PC, slot 70 is ID3D12Device8::CreatePlacedResource1, so forwarding by number treats the destination handle as a resource description and writes through it.

Limit: the layout of the raw words is not measured (#6982 says the same), so nothing reads them and the view does not reach the GPU address yet. The first call logs the three argument words so a trace can show the layout. Writing a real T# needs that layout. No exe bytes, addresses or IIDs are used.

Merge notes: independent of #6953 (slot 70 is inside the existing 128-slot table). With #7021 the destination must go through its CPU-handle translation; that is one line in proxy_create_srv_from_raw_x, to do in whichever of the two lands second. The slot 71 forwarding check in --env-slots-invalid replaces slot 70, which was only an arbitrary forwarded slot there.

Tested

Cross-built with clang-cl and run under Wine on the pod (xs_proxy_mock_test):

  • Before the fix (test only): fails at the new check, device && xs::device_slot_overridden(70); the exe exits non-zero.
  • After the fix: xs_proxy_mock_test: PASS; with a level-9 device (slot 70 exists on the PC) and a level-0 device (it doesn't) the mock's slot 70 is never called, its slot 18 is called once with no resource, a description and the destination handle; a null destination writes nothing.
  • The variants --fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, --env-slots-invalid all exit 0.
  • device_proxy_test builds; it skips under Wine (no WARP adapter).
    Not run: MSVC, a GPU, or the retail executable.

AI-assisted: yes (Claude Code)

…ead of reaching PC CreatePlacedResource1 (retail boot chain stop 14)
@tikD1337

Copy link
Copy Markdown
Contributor

Request changes: the slot interception is sound, but the unconditional null-SRV fallback needs a narrower safety contract and native test evidence.

The change correctly intercepts Xbox device slot 70 before generic PC forwarding and the PC interface-length check. This prevents the three-argument Xbox call from reaching the unrelated, longer ID3D12Device8::CreatePlacedResource1 signature. Handling the slot independently of the real device’s interface level is appropriate: the implementation calls CreateShaderResourceView, which is available on the base PC device.

The slot name, dispatch branch, and device_slot_overridden(70) agree. The helper preserves the three argument positions, avoids dereferencing either unmeasured input, records the hit, and skips descriptor creation for a zero destination. Returning zero from the generic thunk is consistent with accommodating a void Xbox method; it should not be interpreted as an HRESULT success guarantee.

Findings requiring attention:

  1. [P2] A fixed Texture2D null descriptor does not guarantee zero reads for every SRV access.
    At runtime/shims/d3d12_xs_device.cpp:1233, every nonzero destination receives an R8G8B8A8_UNORM TEXTURE2D descriptor, regardless of texture_words or view_desc. The descriptor is a reasonable null 2D texture view: it has an explicit format, default component mapping, and one mip. Microsoft supports creating null descriptors with a null resource and a valid description. CreateShaderResourceView documentation.

    However, Microsoft explicitly limits defined null-binding behavior to compatible shader accesses. A descriptor dimension mismatch can produce undefined behavior, including device reset. Since the input layout is unmeasured, this implementation has not established compatibility with buffer, array, cube, or other accesses. The comment that a shader reads this view as zeros therefore overstates the guarantee. Null-descriptor requirements.

    Please establish and document the compatible view type for the supported calls, or constrain this fallback to an explicit boot-investigation mode until that information is available. Merely changing the comment would leave the unconditional substitution in normal execution. The missing GPU-address/resource mapping also means this remains a stand-in rather than implementation of the requested SRV.

  2. [P2] The cited measurement is absent from the referenced document.
    Both the implementation and header cite docs/retail_boot_chain.md, stop 14, as evidence for the Xbox call shape. In the reviewed checkout, that document ends at stop 13 and still identifies it as the current stop. Please add the corresponding sanitized measurement, or identify the prerequisite documentation PR and dependency. Record what was actually observed—argument positions, destination-handle provenance, and evidence for the void return—separately from the hypothesized SRV semantics. No executable bytes or raw game-derived descriptor contents are needed.

Regression coverage: check_slot70() adds useful assertions for Device9 and base-device mocks: neither forwards slot 70; both call PC slot 18 with a null resource and the unchanged destination; a zero destination produces no additional write; and references balance. Moving the forwarding sentinel to slot 71 is consistent with slot 70 becoming overridden.

The mock currently checks only that the description pointer is nonzero. Please copy the description inside the slot-18 mock while the call is active and assert its format, dimension, component mapping, and mip fields. Inspecting the recorded pointer after the helper returns would access an expired stack object. Such coverage would validate descriptor construction, although shader compatibility still requires separate evidence.

Verification without game files: the supplied Windows 11 / CPython 3.13 report records these passes:

Check Reported result
git diff --check PASS
Python compileall PASS
check_no_game_data.py PASS
make_game.py --help PASS

The targeted-test list is empty. Its All passed: True result provides no evidence that xs_proxy_mock_test compiled or executed. Before merge, provide an MSVC build and run the xs_proxy_mock CTest family, including the environment-slot variants affected by the forwarding-sentinel change. No GPU or game files are required for those mock tests. The supplied checks establish neither native C++ correctness nor successful retail boot progression.

Project adherence: the diff introduces no game assets, encryption bypass, or online-service access. The synthetic fixtures are appropriate. The logger records argument values once per slot, not the pointed-to descriptor contents; “raw words logged” should be understood accordingly. The routing correction follows fix-don’t-disable, but the null substitution must remain explicitly documented as incomplete SRV behavior. No shader-translator rule changes here, so a new translator-contract entry is not required.

AI-assisted.

…0 wins over the built-in slot 70 handler

With LEONIDA_XS_FRAME_INTERVAL_SLOT=70, (0, 16667, 1, 0) reached the null-SRV writer and sent latency 1 as the CPU descriptor handle. The routes now live in route_xbox_device_slot, which slot 70 asks first. New xs_proxy_mock_env_slots_70 test fails before and passes after.
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review. You were right.

Fixed in the new commit on this branch: with LEONIDA_XS_FRAME_INTERVAL_SLOT=70, slot 70 used to run the null shader-resource-view writer and take latency 1 from (0, 16667, 1, 0) as the CPU descriptor handle. The Xbox routes now sit in one helper, route_xbox_device_slot, and the slot 70 handler asks it first, so an override that moves a route onto 70 wins, as it did before this PR. Without an override, slot 70 is unchanged.

Test: new xs_proxy_mock_env_slots_70 (xs_proxy_mock_test --env-slots-70). It calls slot 70 with (0, 16667, 1, 0) and expects a frame-interval call with no CreateShaderResourceView (mock slot 18 count 0). On the previous commit it fails (exit 1, line 792). After the fix it passes. --env-slots, --env-slots-invalid and the default run also pass (default: PASS, 9 allocations refused on purpose), under Wine on a clang-cl cross build.

AI-assisted.

@dadsmallbuk1

Copy link
Copy Markdown

Tested d5c9490 natively (the native evidence @tikD1337 asked for) on NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (26200), MSVC 2022 RelWithDebInfo: pass.

  • ctest -R ^xs_proxy_mock: 7/7 pass, including the new xs_proxy_mock_env_slots_70.
  • With --env-slots-70, the log shows device slot 70 routed to SetFrameIntervalX (args 0x0 0x411b 0x1 0x0 0x0). The moved route wins over the built-in null-view writer, so the latency word is no longer used as a descriptor handle, which was the case raised in review.
  • Code read: the five existing routes moved into route_xbox_device_slot unchanged; the new handler writes only the PC null SRV into the destination it is given. Not checked: the retail title under gta6rt --run (stop 14 needs the earlier stops' stand-ins).

AI-assisted (Claude Code).

@jlric

jlric commented Nov 23, 2026

Copy link
Copy Markdown

Retail A/B on CachyOS / Wine 11.22, RTX 4070 (620.73.04), default slot routing. Before: slot 70 hit a write access violation. After adding the null-SRV handler from d5c949061 with #7021 CPU-handle translation, startup passed slot 70 and reached GetResourceAllocationInfo. Same local build otherwise. This verifies boot progression. AI-assisted testing.

@kapitche

Copy link
Copy Markdown
Contributor

@tedin7 a data point for slot 70 from a local retail boot run (a merge of current main with several open boot-chain PRs; native Windows, RTX 4080 SUPER):

  • With slot 70 forwarded by number to the PC CreatePlacedResource1, the run ends in an access violation inside the runtime at the first slot-70 call. So the console's slot 70 is not the PC CreatePlacedResource1, as this PR says.
  • With a local stand-in that writes nothing and returns E_NOTIMPL, the title goes on past that point to the next stop (slot 127). So at least on this path the title doesn't check a return value, which fits your void reading. This doesn't show that a null SRV is enough for later frames.

I'm leaving slot 70 to this PR.

@eugen1763

Copy link
Copy Markdown

I measured the first retail slot-70 call on a local Windows 11 / Vulkan integration stack. It is a raw buffer SRV: the first argument starts with the desktop D3D12_RESOURCE_DESC layout (buffer), and the second starts with the desktop D3D12_SHADER_RESOURCE_VIEW_DESC layout (R32_TYPELESS, buffer dimension, RAW flag). A D3D12_GPU_VIRTUAL_ADDRESS immediately after the desktop view description is the same console VA that the preceding slot-133 call registered. The third argument is the CPU destination and needs #7021 translation.

I tested writing a genuine GFX10 raw V# for that registered range, using the existing Vulkan buffer index and descriptor encoder rather than a null view. The run recorded one successful slot-70 descriptor write, then advanced to the unhandled slot 127 after 1,632 D3D12 trace records. This confirms descriptor creation, not shader reads from that VA (the shader address-space limitation in #7218 still applies). No assumptions about texture views from this one call. Leaving the slot with this PR rather than opening a duplicate.

AI-assisted (Codex).

…sured raw-buffer shape and the VA is a buffer the layer knows (retail boot chain stop 14)

AI-assisted.
@kormocicsaba

Copy link
Copy Markdown

Tested d5c949061, merged alone into main 8575d36: pass. 258/260, baseline only.

Setup: RTX 4070 (driver 621.01), Windows 11 Pro 26300, MSVC (VS 18) RelWithDebInfo with Ninja, Vulkan SDK 1.4.363.0. The PR head was merged alone into main 8575d36 and runtime/ was built. I ran the full ctest -j8 --timeout 300; no game files were used.
Baseline on main: d3d12_vulkan_device and d3d12_indirect_dispatch_count fail on main 8575d36 as well. d3d12_bindless_churn fails now and then under -j8 on main too: it failed in main's -j8 run and passed 3 of 3 times run alone there.

AI-assisted review (Claude Code). How this compares with the other boot-chain PRs: #7333 (comment)

…and asks for a buffer that holds the whole width (review of the raw view)

AI-assisted.
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @eugen1763, that measurement was exactly what slot 70 needed.

New commits on this branch (9c8522d and the one after it) use your shape. When arg1 starts with a buffer D3D12_RESOURCE_DESC and arg2 starts with a raw R32_TYPELESS buffer SRV description followed by the D3D12_GPU_VIRTUAL_ADDRESS, slot 70 now looks the VA up in the layer's buffer index (the same index vertex and index views use). If a buffer holds it, the destination gets a raw view of that resource with FirstElement = (VA - resource start) / 4 and NumElements = Width / 4, cut at the end of the resource. Any other shape, or a VA no buffer holds, keeps the null SRV, with one log line saying why.

  • Not done here: the CPU destination is still written as given. The hook point is marked in proxy_create_srv_from_raw_x, so d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles #7021's handle translation goes there.
  • Review found two real problems, both fixed: the resource reference is now taken under the registry lock (new Object::try_add_ref, so a resource being destroyed is skipped), and the lookup asks for a buffer that holds the whole width, so a shorter placed alias does not truncate the view.
  • Test: xs_proxy_mock_test now has check_slot70_raw_buffer. It checks the resource, FirstElement 0x10, NumElements 0x40 and the RAW flag, a width cut at the buffer end, an unknown VA, a non-raw view, a texture description and no provider (all null view), and balanced references. It also copies the description inside the slot-18 mock, as asked earlier. On the previous head (with a stub setter) it fails at line 917; with the change it passes. Wine on a clang-cl cross build: default run PASS, --env-slots, --env-slots-invalid, --env-slots-70 exit 0, and gta6rt_d3d12_com builds.
  • Not checked: the retail run, shader reads from that VA (d3d12_xs: device slot 133 (CreatePlacedResourceX) makes a buffer on the title's own pages (VK_EXT_external_memory_host) #7218), and a native MSVC run.

AI-assisted.

@Zunraz

Zunraz commented Nov 23, 2026

Copy link
Copy Markdown

Independent native Windows/Vulkan integration test of 1d8d1d355d9b37ac1fb88103433f88d2d0975a52.

On the same startup integration as my #7021 report (main 8575d36ed, TLS/XMem/DirectStorage, #6964, #7037, #7076, #6953, #7218 310773a01, #7021, #6991 and RT-488 cache change), adding this head clears the host CreatePlacedResource1 write fault at the old slot-70 frontier. The run reaches 1,632 traced D3D12 calls; the next access violation symbolizes to proxy_slot<25> (GetResourceAllocationInfo), a separate known struct-return ABI issue. No frame/menu.

Local combination resolutions explicitly kept #7037's proxy_create_command_queue_x in the new route helper, and wired #7021 at the marked destination hook:
destination = translate_cpu_descriptor_handle(self, D3D12_CPU_DESCRIPTOR_HANDLE{static_cast<SIZE_T>(destination)}).ptr;
The existing #7218 fallback does not share the title's pages; boot progress must not be read as validation of shader access to those pages.

Mocks: all seven modes pass (default, three guard-setup failure modes, normal/invalid env routes, and --env-slots-70) after fixing one test-fixture interaction with #7021. Its heap translation case passes made-up SRV-description address 0x33; this PR's new slot-18 snapshot correctly tries to copy it, so the combined test initially AVs in mock_call's memcpy. Replacing that sentinel with a readable synthetic null-SRV description makes all seven modes pass. Reusable test-only change on #7021: Zunraz@14a176d32 . This fixes the fixture, not production descriptor parsing; I did not disable the snapshot or any assertion.

Windows 26300, RTX 5090 / driver 32.0.16.2124; clang-cl 21.1.8 + xwin SDK 10.0.26100, static CRT. Vulkan validation unavailable locally. Retail socket creation, DNS and transmission debugger-guarded. Outcomes only, no game files, traces, addresses or title offsets attached. AI-assisted (Codex).

@zohaiblazuli

Copy link
Copy Markdown

Tested d5c949061 on the retail executable (before the latest push): pass.

Retail Xbox Series 1.0.2.1 package + executable (sizes match game/xbox-1.0.2.1.json), Windows 11 10.0.26300, MSVC 14.50, GeForce RTX 3060 (driver 32.0.16.1742). Vulkan backend (LEONIDA_D3D12=vulkan, Vulkan SDK 1.4.363). gta6rt --run with --overlay to a scratch folder, outbound network blocked, LEONIDA_UNIMPLEMENTED=stop. Base: main 8575d36ed plus my local console-queue-flag and struct-return (slots 25/26/43) changes, with these PRs merged in this order: #6953, #7187, #7076, #7075, #7021, #7066, #7235 (which carries #7052). Conflicts resolved locally.

Outcomes only; no game data.

zneel added a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
Slot 70 now translates its CPU destination through ItsNotRexed#7021's hook-backed heap
ranges before either write (the hook point ItsNotRexed#7066 left for it). The mock's slot 18
reads a description only from a real pointer: ItsNotRexed#7021's heap-hook check passes
small marker words there and crashed once ItsNotRexed#7066 started copying them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zneel added a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
Resolved against ItsNotRexed#7066 by hand: both PRs added the same route_xbox_device_slot
(one copy kept), slot 74's proxy_slot branch is placed in slot order, and the
env-slot test takes the slot it moves a route onto (70 or 74) instead of two
competing bool parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor

Tested on the retail boot (head 1d8d1d355) on top of #6954, #7076, #7218, #7550 and #7240. Before: slot 70 is forwarded to the PC vtable, and the run faults inside gta6rt writing into the executable's image. After: slot 70 wrote a raw buffer view (… 45,613,056 elements). The run then passes slots 25/127/20/16 and stops in XboxBvhBuilder's constructor (no translated shaders in my tree yet): 1,640 D3D12 calls ok. One merge hazard: route_xbox_device_slot re-creates the slot 48/73 routing with the PC queue desc. Merged after #6954 it would undo #6954's 32-byte desc handling (stop 8), so I kept the current routing and took only the slot-70 branch.

Setup: native Windows 11, RTX 5060 Ti (NVIDIA), Ryzen 7 8700F, MSVC RelWithDebInfo, LEONIDA_D3D12=vulkan, my own 1.0.2.1 copy with the full package as --game-dir. Local integration tree: main + #4313, #6582, #4348, #3410 (+SDL3), #6885, #6981, #6891, #7009, #4531, #6964, #6953, #7110, #7078, #7403, #7330, then the PRs below, one at a time.

Counts and stop numbers only, no game files. AI-assisted (Claude Code).

rndrmu added a commit to rndrmu/Leonida that referenced this pull request Nov 23, 2026
…iption)

Conflict notes: the stack routes Xbox slots through route_xbox_device_slot
(ItsNotRexed#7066/ItsNotRexed#7323); its CreateCommandQueueX branch now calls ItsNotRexed#6954's
proxy_create_command_queue_xbox instead of ItsNotRexed#6954's inline routing copy.

Measured here (Wine, own 1.0.2.1 copy): the title's second compute queue
passes Flags=2, which the Vulkan layer refused before this merge.

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

Copy link
Copy Markdown

@GreemSC @tibzejoker I tested the raw-buffer SRV question from RT-753 on Arch Linux, Wine 11.20, an i9-10900K and an RTX 3080 Ti (NVIDIA 615.78.08). The retail executable ran offline with the Vulkan backend and title assertions enabled. RT-753 question

The remaining comparison is the active fullscreen PSO's input descriptor and sampled image against its output attachment. Counts and API observations only. AI-assisted with Codex.

@XIIYAZ

XIIYAZ commented Nov 23, 2026

Copy link
Copy Markdown

Retail boot test (RT-5): own 1.0.2.1 copy, Windows 11, i9-12900KF, RTX 3070 (NVIDIA 617.42), MSVC 2022 RelWithDebInfo, LEONIDA_D3D12=vulkan, gta6rt --run with the network shimmed by #6943. Local integration branch on main dde82f27e with, in order: #6943, #7125, #6010, #7133, #4313, #6582, #4348, #6964, #6953, #6954, #2490, #7218, #7021, #7066, #7110 (+#7078, #6973), #7052. Each PR was merged, rebuilt and the game rerun; the stop named below is the first failure without it and is gone with it. With all of them the run reaches stop 17 of docs/retail_boot_chain.md (#6982) after 1,640 D3D12 calls. Counts and outcomes only; nothing from the executable is quoted.

Result: clears stop 14 (slot 70).

Bug when combined with #6954: route_xbox_device_slot()'s queue_x branch calls proxy_create_command_queue(self, (const D3D12_COMMAND_QUEUE_DESC*)a1, ...). #6954 makes slot 48 read the console's 32-byte description through proxy_create_command_queue_xbox; merged as-is, the router reverts that and the compute queue is refused again (stop 8). Calling proxy_create_command_queue_xbox(self, (const std::uint32_t*)a1, ...) there fixes it; tests pass.

AI-assisted test run.

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.