Repository navigation
Conversation
…e PC vtable refuse with E_NOTIMPL The retail title calls device slot 133, past the 128-entry table; the call read an empty entry and jumped to 0. Every slot beyond the PC device's vtable now reaches the generic thunk. Mock test covers slot 133. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ory (VK_EXT_external_memory_host) The retail executable opens the 64 KiB graphics region it has just committed with XMemVirtualAlloc through device slot 48 right after its first queue and fence; the layer answered E_NOTIMPL and the title asserted. The call now answers as the host runtime does on an RTX 4090 and WARP (six cases measured in d3d12_existing_heap_test): the base of a VirtualAlloc allocation committed read-write over its whole size opens a heap of that size, 64 KiB aligned, CUSTOM / WRITE_BACK / L0, SHARED | SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS; an inner address, a partial or reserve-only commit and a read-only range are E_INVALIDARG. The backing is the range itself, imported with VK_EXT_external_memory_host, which the device and the test device enable when present. CheckFeatureSupport(EXISTING_HEAPS) follows the extension. Placed resources in such a heap are refused (E_NOTIMPL, logged) until the placed path addresses memory outside the arena. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… an uncached one is refused Measured on the RTX 4090 and WARP: PAGE_READWRITE | PAGE_WRITECOMBINE is accepted with CPUPageProperty WRITE_COMBINE, PAGE_READWRITE | PAGE_NOCACHE is E_INVALIDARG. Two new cases in d3d12_existing_heap_test; 8 of 8 match both host devices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he title's own pages Xbox device slot 133 is (va, desc, state, clear, riid, out): the title places a buffer at the VA of a physical-page range it has just mapped (docs/retail_boot_chain.md 3.4, ItsNotRexed#6915). The proxy now hands it to a handler the Vulkan layer registers (set_placed_at_va_handler), which imports [va, va + width) with VK_EXT_external_memory_host and binds a VkBuffer to it: the CPU's writes there are the GPU's reads with no copy, and the resource's console VA is the title's VA, so views and immediate writes the title names by that VA resolve to it through the buffer VA index. The Xbox flag bits above the PC ones are dropped and the layout made ROW_MAJOR, as slot 76 does; textures are E_NOTIMPL, a misaligned VA E_INVALIDARG, and with no handler (a PC device) the slot refuses with E_NOTIMPL as ItsNotRexed#6953's table does. Not decided here: a shader that adds heap_base to the title's VA (its own V#s) does not reach these pages; that needs the single address space of docs/d3d12_vulkan.md 3.3. d3d12_existing_heap_test: on a VirtualAlloc range and on a view of a pagefile-backed section (the form xmem's physical pages take), the buffer's GPU VA is the address and a GPU copy to a READBACK buffer reads a pattern the CPU wrote after creation; Vulkan validation clean on an RTX 4090. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ler registered by every Vulkan device The PC flag mask was a D3D12_RESOURCE_FLAGS constant past the SDK's last enumerator, which clang-cl with SDK 10.0.26100 refuses as a constant expression; it is an integer now, cast after the AND. The slot-133 handler was registered in create_vulkan_device only, so the standalone device gta6rt --run creates never served the slot; the Device constructor registers it now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # runtime/shims/d3d12_xs_device.cpp
… found in review) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… not import the title's pages RADV under Wine refuses to import a view of a pagefile-backed section (E_OUTOFMEMORY on an RX 9070 XT, found in review), which is the form xmem's physical pages take, so the retail boot stopped at the first 174 MiB placement. An import failure other than a misaligned VA now gives an ordinary DEFAULT buffer of the same description, as ItsNotRexed#6915's stand-in did, logged once: the boot goes on, and the title's writes at that VA don't reach it on such a driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…commit re-added it, found in review) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge check, immediate free, proxy test - A write-combined (or uncached) page in the range is not imported: an RTX 5090 imported such a range and read wrong bytes back (found in review). It takes the ordinary-buffer fallback. - The whole range must be committed, walked with VirtualQuery across allocations (the retail buffer spans three mapped windows); otherwise E_INVALIDARG instead of undefined behaviour in Vulkan. - The imported memory is freed as soon as the submitted work has retired (wait_retire_ticket), not after the next submission: VK_EXT_external_memory_host needs the caller's pages to outlive it, and a title may free them right after releasing the resource. - The PC flag mask is 0x5ff: 0x200, which the host refuses, is dropped. Slot 133 is listed in device_slot_overridden. - xs_proxy_mock_test registers a handler and checks slot 133's argument positions, the flag mask (0x20204 -> 0x4), the ROW_MAJOR rewrite and the iid; d3d12_existing_heap_test checks the write-combined fallback and the partly committed refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ich varies from run to run The host runtime answers 64 KiB on some runs and 4 MiB on others for the same allocation (RX 9070 XT, RTX 5090, WARP; found in review), which made the test fail about 1 run in 40. The layer's Alignment must still be 64 KiB for an opened heap, and the host's either of the two values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s at the offset; uncommitted pages fall back The title places small buffers inside a page too: a 16-byte UAV at a 64-byte-aligned address on an RTX 5090 (found in review), which the import refused with E_INVALIDARG, halting the boot. The import now starts at the page holding the address and the buffer is bound at the offset; an offset off the buffer's alignment takes the ordinary-buffer fallback. A range not fully committed (xmem commits on first touch) also falls back instead of failing. Only a null address or a zero width are E_INVALIDARG. d3d12_existing_heap_test: a buffer 64 bytes into a page reads back the CPU's writes at its own VA; a 1-byte offset and a partly committed range fall back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad of E_NOTIMPL The retail title places textures at slot 133 too, and asserted on the E_NOTIMPL (found in review). A texture now gets an ordinary committed DEFAULT texture of the same description, as slot 76 gives one, logged once; it is not on the title's pages. The proxy rewrites a texture's Xbox layout word to UNKNOWN (a buffer's to ROW_MAJOR), as slot 76 does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wine can report a requested write-combined allocation as ordinary read/write memory. Check the observed protection and retain the fallback expectation when a cache modifier is present; otherwise verify the read/write import. Add PAGE_NOCACHE to keep the unsafe-protection guard covered under Wine. Claim: ItsNotRexed#7913 (comment) Depends on: ItsNotRexed#7218 AI-assisted: Codex
…e starts in the matching state The title's third word at slot 133 is a D3D12_BARRIER_LAYOUT, not a resource state (measured by @dracbat on a retail boot: 0x6 SHADER_RESOURCE for its RT/DS textures, 0x3 UNORDERED_ACCESS for its RT+UAV ones, 0xFFFFFFFF UNDEFINED for the 182 MiB buffer), as PC CreatePlacedResource2 takes it. The proxy passes it to the handler, and a texture's ordinary committed fallback starts in the equivalent legacy state (UNDEFINED and unlisted values give COMMON; a state the description refuses retries with COMMON, so the title always gets its resource). Buffers are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the title's VA When VK_EXT_external_memory_host refuses the title's pages (write-combined or uncached pages, pages not committed yet, no extension, or the driver's import budget: about 64 MiB on an RTX 3070 Ti), the fallback was an ordinary DEFAULT buffer with neither the title's VA nor its data, so the title's descriptors resolved to nothing (slot 70 wrote a null SRV) and UI draws sampled nothing. The fallback is now a host-visible buffer (VRAM through Resizable BAR where upload buffers use it) whose console VA is the title's address, filled from the title's pages at creation and again before every submission of command lists (VulkanContext::set_before_execute, called from VulkanQueue::execute_now). Only committed, readable pages are read; the rest is zero. GPU writes to the shadow are not copied back. The first per-submission copy of each buffer size is timed and logged. Write-combined pages are read with MOVNTDQA: memcpy read 64 MiB of them in 253 ms on a Core i9-13900K, MOVNTDQA in 13 to 17 ms. Tests: write-combined, uncached, 64 MiB write-combined and half-committed ranges in d3d12_existing_heap_test, two patterns over two submissions each, 0 validation errors on an RTX 4090. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clang's baseline x64 target cannot inline _mm_stream_load_si128 into copy_guarded. Give only that function the target feature the existing intrinsic requires; keep the MSVC path and global build flags unchanged. Depends on: ItsNotRexed#8225. Claimed in ItsNotRexed#8186, comment7110252121. AI-assisted: yes (Codex).
… buffer V#s the layer writes Xbox device slot 133 places a buffer at the title's own VA, about 1.5 TiB on Windows, while a translated shader computes heap_base + console VA with heap_base the arena's device address. A root view or V# naming that VA missed the buffer. The layer now translates an address inside a title-placed buffer where it writes it (root CBV/SRV/UAV, CBV and buffer SRV/UAV V#s): to the arena offset of the slot-133 shadow, which now lives in the GPU address arena when it fits, or to an import's device address minus heap_base. New tests: title_va_alias_test, d3d12_title_va_test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ugh an arena window A root view or buffer V# may name the title's own memory outside any slot-133 buffer (a per-frame constant ring, ItsNotRexed#8862 section 3.5). The layer now makes a 64 KiB-aligned window of those pages in the GPU address arena, copies it before every submission like a slot-133 shadow, and names that copy instead: for root views when set, for V#s the layer writes, and for buffer V#s the title writes into a bound CBV/SRV/UAV table itself, rewritten in place before each submission. Counters per kind, LEONIDA_TITLE_WINDOWS_MB caps the windows (64 MiB). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… declared slots and is timed The xmem shims record what they hand the title (XMemAlloc, XMemAllocDefault, XMemVirtualAlloc, the title's VirtualAlloc); an address outside those ranges is left as it was and counted. The submit-time scan reads only the CBV/SRV/UAV slots the bound table's root signature declares, and its cost is accumulated per ExecuteCommandLists. Section 3.3 describes the three places addresses are replaced and the two kinds of copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, not the GLSL keyword out Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er variables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…are pulled in before the scan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed value Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grimkaaah
left a comment
There was a problem hiding this comment.
Independent Linux CPU review
What changed: title-chosen buffer VAs (slot 133 / root views / V#s) remapped through arena copies (title_va_alias.h); docs in d3d12_vulkan.md; new CPU/GPU test targets.
Checked: diff + docs read; title_va_alias_test.cpp present (full link needs runtime build). Large surface — alias rules look consistent with the doc table.
No game files. Flag: end-to-end d3d12_title_va is Windows/GPU; CPU alias unit test is the portable check.
|
Follow-up to the scan-window note above. I widened both sides locally. The descriptor source now copies the whole changed title-backed heap (#7021 backing, snapshot-diffed) over the layer's heap before each submit. The scan covers max(declared, 64) slots.
So having the title's own table data in the GPU-visible heap is not enough for these draws. My next suspect is how the translated shaders form the table address from the user SGPRs the layer passes (KkelebekK's AI-assisted (Claude Code). |
|
Wine/NVIDIA cross-check of the wider title-backed table pull in the comment above. Local cumulative boot stack with #7021, #9068, #8455, #8225 and #9137, Wine 11.22, RTX 5070 Ti (620.73.04), Intel i9-14900KF, 512 MiB GPU arena. AI-assisted.
Counts and API behavior only. No game data or traces attached. |
|
@AAyberkU @Marukooh, on the empty UI table: we see the same draw on our stack (Windows 11, RTX 5070 Ti Laptop, NVIDIA 621.24, retail 1.0.2.1, with #9368 and #9137). There is one more direction to cover.
What fixes the geometry here, measured:
With all three and every pixel shader replaced by a constant red, the presented 3840x2160 image goes from 0 to 8,294,400 / 8,294,400 red pixels. Without forced positions, the UI VS now covers the screen. With the title's own shaders it is still black: what remains is the UI pixel shader's texture (d1), which we are measuring next. I claimed the fix on #9401 (#9401 (comment)) and will open it as a PR on top of this one. Counts only, no game data. AI-assisted (Claude Code). |
…ader_va The maintainers' forge main adds Resource::alias_title_va(va), which registers a placed buffer at the title's VA in the context's buffer index, guarded by a bool title_alias_. This branch used the same names for a different thing: the shader VA a title_va_aliases range is reached at. Rename the member to alias_title_shader_va and its fields to title_shader_va_ and shader_aliased_ so both can live in one Resource and the commits apply on forge main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e's insertion points The forge's main adds Resource::alias_title_va right after create_host_buffer and VulkanContext::alias_buffer right after add_resource, the two places this branch added alias_title_shader_va and knows_buffer_va. Move them below create_shadow_buffer and above has_resource, so this branch's diff applies on either main without a conflict there. No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
RTX 3090 integration result on Windows for the title-memory windows and slot 70. In this configuration, a successful host import of the 174 MiB placed buffer had a Vulkan device address that the V# could not encode relative to the shader heap base. Opting into the arena shadow for this case restored an encodable range. Its first measured refresh took 19.96 ms. With the slot-70 provider looking up standalone title memory, the title also created a 3,072-element R16_UINT view and a structured view. The added fixture checks a 384-element R16_UINT view and rejects an unregistered address. The title-memory fixture returned 64/64 for a title-written V#, a created CBV and a root view on this card. In a separate test with a directly encodable import, 24 in-bounds shader reads matched CPU writes made after descriptor creation, and 40 out-of-bounds lanes returned zero. The later graphics-layout integration passed the 4,096-pixel draw and direct heap-index fixtures. Retail still yielded 44 black readbacks and then a write exception in VCRUNTIME140. The cause remains open. |
|
@AAyberkU thanks, renamed. Head is now
On forge main Tested (Windows 11 26200, MSVC 14.44 RelWithDebInfo, AI-assisted (Claude Code, Claude Opus 5.5). |
…declared ones A console shader can read slots past the ranges its root signature declares: on the retail boot a vertex shader reads slot 2 of a table declared with one slot. The layer does not know which slots a bound shader reads, so scan_title_table (and the descriptor pull before it) now covers at least kTableScanMinimum = 16 slots, never past the end of the heap: 512 bytes compared per bound table and submission. d3d12_title_va checks that a CPU-written V# one slot past every bound table's declared slot is rewritten, and that one 16 slots past the last bound table keeps its bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
AI-assisted (Gemini). |
|
checked: #9137 | head 70e49fd merged onto main 5d74c27 (clean) | on: native Windows 11 26200, MSVC 14.44, RX 9060 XT (RDNA4, a discrete card next to your 610M), AMD 26.11.2 | result: pass, also with
AI-assisted (Claude Code), no game files. |
|
Independent Windows check of the With the descriptor source registered, the one-slot scan left slots 1 and 2 empty in all 63 sampled native draw tables. The 16-slot scan populated slot 2 in all 63 and slot 1 in 31 of them. The callback observed four or six populated slots in the sampled tables. This matches the slot-2 read in your report. With the game's original shader stages, the sampled window contents were still black. AI-assisted (Codex). |
|
AMD Windows check of
No game files. |
Connect the descriptor-source hook from ProjectLeonida#9137 to the heap backing tracked by ProjectLeonida#7021 and written by ProjectLeonida#9586. Cache observed source bytes so repeated submissions keep their translated V# addresses. The GPU fixture now assigns separate title backing, checks its shader reads, and verifies unchanged source writes retain the translated address. All 15 focused tests passed on Windows 11 and RTX 3060 Ti. AI-assisted with Codex.
Claimed in #8683 (comment)
Depends on: #8225, which contains #7218. This branch is #8225's head (
14dc9af52) plus the commits below. It merges cleanly withmain(867d922f0,git merge-tree).What
A translated shader computes
heap_base + console_va, withheap_basethe GPU address arena's device address (docs/d3d12_vulkan.md§3.3). The title doesn't always use VAs the layer chose:docs/retail_boot_chain.md).These are user-mode Windows addresses far above 4 GiB, past the arena, so
heap_base + VAreads nothing the layer made. #7218's "Not decided here" section leaves this open. This PR makes the layer replace such an address, wherever it sees one, with the console VA of a GPU copy of that memory.Set*Root*View)GraphicsCommandList::address)Create*View, slot 70, counter V#s)ExecuteCommandLists, in place: only tables the submitted lists bind, and only the slots their root signatures declareThe copies:
heap_base(mod 2^64). That is exact for root arguments. For a V# it is exact only when the driver placed the import above the arena; otherwise it is logged, the D3D-53 case in §3.3.LEONIDA_TITLE_WINDOWS_MB(64 MiB by default); past it the address is left as is and counted.XMemAlloc,XMemAllocDefault,XMemVirtualAlloc, and the title'sVirtualAlloc. Any other address, including the runtime's or a host DLL's memory, is left as is and counted. So are arena VAs and buffers the layer made.add_shadow/refresh_shadows), so dirty-page tracking for that refresh (d3d12: a slot-133 shadow buffer is re-copied only where the title wrote since the last submission #9045) applies to both.Unchanged:
GetGPUVirtualAddressstill answers the title's VA. Vertex, index, copy and immediate-write calls still resolve it through the buffer VA index, which knows slot-133 buffers by that VA.For a heap the title backs with its own memory (
__XMemAllocationHooks__, #7021),TitleVaAliases::set_descriptor_sourceis a hook. It lets the layer that keeps that mapping copy the title's own writes into the layer's heap before the scan. This PR adds the hook only; #7021 isn't in its base.Why this option
The title's VA can't sit inside the arena: the arena is at most 4095 MiB, and descriptor tables must stay below 4 GiB. So a dense arena or a single
heap_basecan't cover it. Biasing alone (option 1 of #7218's design note) fails for V#s, as §3.3 measured. A copy in the arena gives every kind of address a small VA, and it reuses #8225's per-submission copy.Tested
Windows 11 26200, MSVC 14.44 RelWithDebInfo,
LEONIDA_VK_VALIDATION=1, 0 validation errors. RTX 5070 Ti Laptop (NVIDIA 621.24) and Radeon 610M (AMD 26.11.2).d3d12_title_va_test(new). It uses the translator's address contract shader (cs_user_data.comp, two new modes). Pass on both GPUs.title_va_alias_test(new, no GPU). Range edges, replacement, the free gap a window must stay in, the title-memory ranges, counters: pass.d3d12_compute_test,d3d12_existing_heap_testandxs_proxy_mock_testpass on both GPUs.Retail boot, counts only. RTX 5070 Ti, my own copy of the game, local boot stack plus this branch, two 120 s runs,
LEONIDA_ARENA_MB=512. The 174 MiB slot-133 shadow, the other slot-133 buffers and a 64 KiB title-memory window all fit in the arena, none refused.ExecuteCommandLists: mean 7.2 µs and 13.5 µs on the two runs, maximum 184 µs.ReadFiles into uncommitted xmem physical pages fail. The second run included a local patch that commits those pages before the read, and the image was still zero. These two runs had noReadFilefailure counter, so they don't say how many reads still failed. This PR is still needed for those draws to read the right memory, but it doesn't make the frame appear here.Related
#8991 keeps a placed buffer's heap range alive after its heap is released. That's a separate arena-lifetime fix with no overlap: this PR's windows live until the device goes, and the arena shadow is released with its resource like a committed buffer.
Known limits
AI-assisted (Claude Code).
🤖 Generated with Claude Code