Skip to content

d3d12: shaders reach buffers at the title's own VAs (slot 133, title memory) through arena copies the layer names in root views and V#s - #9137

Closed
Etr0p wants to merge 30 commits into
ProjectLeonida:mainfrom
Etr0p:title-va-address-space
Closed

Etr0p wants to merge 30 commits into
ProjectLeonida:mainfrom
Etr0p:title-va-address-space

Conversation

@Etr0p

@Etr0p Etr0p commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #8683 (comment)

Depends on: #8225, which contains #7218. This branch is #8225's head (14dc9af52) plus the commits below. It merges cleanly with main (867d922f0, git merge-tree).

What

A translated shader computes heap_base + console_va, with heap_base the GPU address arena's device address (docs/d3d12_vulkan.md §3.3). The title doesn't always use VAs the layer chose:

These are user-mode Windows addresses far above 4 GiB, past the arena, so heap_base + VA reads 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.

Where the address is When it is replaced
Root CBV/SRV/UAV (Set*Root*View) when the argument is set (GraphicsCommandList::address)
CBV and buffer SRV/UAV V#s the layer writes (Create*View, slot 70, counter V#s) when the descriptor is written
Buffer V#s the title writes into a shader-visible CBV/SRV/UAV heap itself before each ExecuteCommandLists, in place: only tables the submitted lists bind, and only the slots their root signatures declare

The copies:

Unchanged: GetGPUVirtualAddress still 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_source is 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_base can'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.
    • Slot-133 buffers on read-write and write-combined pages, data written after creation: buffer V# read 64/64; root view read and written 64/64.
    • Title memory standing for a constant ring: a V# the CPU writes into a bound table itself 64/64 (rewritten before the submission), a created CBV 64/64, a root view 64/64.
    • Negative controls (8 hold): a second title buffer's data is never what the first one's V# reads (0/64); an arena buffer's V# keeps its VA; a range is forgotten when its buffer is released; a raw arena V# and a T#-shaped slot in a scanned table keep their bytes; committed memory that isn't the title's, and a title range with no committed page, are left alone and counted.
    • Not covered: the test device doesn't import pages, so both page kinds took the arena shadow. The import + bias path isn't exercised.
  • title_va_alias_test (new, no GPU). Range edges, replacement, the free gap a window must stay in, the title-memory ranges, counters: pass.
  • Existing tests. d3d12_compute_test, d3d12_existing_heap_test and xs_proxy_mock_test pass 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.

  • Per frame: 1 root view and 3 layer-written V#s name the title's memory, all translated; 0 are left as is. Vertex views in a title range: 2 per frame, resolved through the buffer index.
  • Bound-table scan: no V# with a base outside the arena in the bound slots. With the title's own heap backing (d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles #7021) mirrored into the layer's heap on the second run, 216 slots the title wrote itself were pulled in, and none of them was a buffer V# naming the title's memory: 0 table V#s translated, 0 left untranslated. So the out-of-arena transform V# of docs/retail_boot_chain.md: the first UI draw reads its transform through a V# outside the arena (RT-753) #8862 §3.5 (measured on Linux/Wine/RADV) does not show on this Windows/NVIDIA stack. The root view and layer-written V#s above are the title-memory addresses it uses here.
  • Scan cost per ExecuteCommandLists: mean 7.2 µs and 13.5 µs on the two runs, maximum 184 µs.
  • The presented image and the off-screen target are still all zero (71 + 70 readbacks, 0 non-zero pixels of 8,294,400). So on this stack the addresses are now right but the frame stays black for another reason. One candidate, measured on another branch: most of the title'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 no ReadFile failure 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

Pipodi and others added 27 commits November 23, 2026 16:30
…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 Grimkaaah 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.

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.

@AAyberkU

Copy link
Copy Markdown
Contributor

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.

  • Pull: 354,934 16-byte units on the first submit, then about 0 to 350 per submit. The scan costs about 6 ms per submit on average (max 30 ms) at 64 slots.
  • Counters at 1,200 presents:
    • root views: 1,201 translated, 0 left
    • created views: 4,803 translated, 0 left
    • table V#s: 0 translated, 1,564 left. The extra slots hold V#-shaped words whose bases are outside the title's XMem ranges or uncommitted, so they are not real V#s.
  • Coverage: unchanged. The UI VS still covers nothing (built-in PS probe), and the blit PS still writes zero into its intermediate.

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 heap_base + ((s8 & ~3) | s9 << 32) + offset with s9 forced to 0), rather than the memory contents. I'll log the user-SGPR words the layer emits for that draw and compare them with the table's arena VA.

AI-assisted (Claude Code).

@Marukooh

Copy link
Copy Markdown
Contributor

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.

  • Looking at exactly the declared slot, all of the first 16 ranges had zero nonzero bytes. None matched the sampled CBV/SRV writes into the arena. Looking at eight slots (clamped to the heap) copied 88 nonzero 16-byte units in those 16 scans.
  • The sampled fullscreen VS reads a vertex buffer descriptor through s0:s1, then two constant buffer descriptors through s8 at byte offsets 0 and 64. On the table actually used for those draws, the 16-byte units at both offsets are still empty after the wider pull. The vertex buffer view on the command list resolves successfully.
  • The comparison still recorded zero fragment shader invocations on the four sampled draws and kept the visible window black after 2,119 successful presents. This independently confirms that useful data beyond the declared range can reach the arena, while the specific slots consumed by this draw still need to be located.

Counts and API behavior only. No game data or traces attached.

@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@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.

  • Where the per-frame CBVs land. The title creates them through translated CPU handles in a non-shader-visible title-backed heap (one of its 3,128-descriptor CBV/SRV/UAV heaps). The layer writes them only into its own heap, so the title's backing memory for that heap stays zero.
  • How they reach the table. The title then copies those bytes itself into its shader-visible heap's backing. No CopyDescriptors is traced. A title → layer pull alone therefore only ever moves zeros.
  • What the draw needs. The UI VS reads the table at descriptor offsets 0 and 64 (d0 = 96-byte CB, d1 = texture, d2 = 480-byte CB), while the root signature declares 1 descriptor. A pull limited to the declared count misses d2.

What fixes the geometry here, measured:

  1. Mirror every descriptor the layer writes through a translated handle back into the title's memory at the original handle. That covers CBV/SRV/UAV/sampler creation, the device-slot-70 raw views and the null SRV, with 32 bytes, or 16 for a sampler with d3d12: a sampler heap's slots are 16 bytes, the console's step #9368.
  2. Register set_descriptor_source (title memory → layer heap before the table scan).
  3. Copy at least 16 slots per table instead of the declared count.

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).

Etr0p and others added 2 commits November 23, 2026 22:23
…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>
@danekbiglike

Copy link
Copy Markdown

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.

Incremental source patches, prerequisites and commands.

@Etr0p

Etr0p commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@AAyberkU thanks, renamed. Head is now 8e1e02bdd:

  • 6ec35bbb6: this PR's member is alias_title_shader_va(shader_va), with fields title_shader_va_ and shader_aliased_. The forge's alias_title_va(va) / title_alias_ keep their names, so both fit in one Resource.
  • 8e1e02bdd: renaming was not enough. Forge main inserts its alias_title_va right after create_host_buffer and VulkanContext::alias_buffer right after add_resource, the same two places this PR used. alias_title_shader_va now sits below create_shadow_buffer and knows_buffer_va above has_resource. No change in behaviour.

On forge main 1812e0bd1 (contains 2ac385837), this PR's squashed diff now applies cleanly except runtime/shims/xmem.cpp. Forge main split xmem_virtual_alloc(…, console_windows) out of XMemVirtualAlloc and rewrote TitleVirtualAlloc, so no single hunk fits both mains. The port is small: add_title_memory after the forge's xmem_virtual_alloc call in XMemVirtualAlloc, and the forge's TitleVirtualAlloc body renamed title_virtual_alloc, wrapped by a TitleVirtualAlloc that records its result. The XMemAlloc*/XMemFree* hunks apply as they are.

Tested (Windows 11 26200, MSVC 14.44 RelWithDebInfo, LEONIDA_VK_VALIDATION=1, RTX 5070 Ti Laptop / NVIDIA 621.24 and Radeon 610M / AMD 26.11.2), both on GitHub 8e1e02bdd and on forge 1812e0bd1 + this PR with that port: title_va_alias, d3d12_title_va, d3d12_existing_heap and xs_proxy_mock pass on both GPUs, with 0 validation messages. Counts match the earlier runs: 64/64 for V#, root view, table V# and CBV, and the negative controls hold. On the GitHub head, d3d12_compute also passes. On the forge base, xmem_test passed 10 of 11 runs. The one failure was "the whole window is free afterwards", during heavy machine load. It did not reproduce in the 9 runs after it, and I have not run it on a forge main without this PR.

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>
@OliverMarcusson

Copy link
Copy Markdown

Tested 70e49fd8 (merged cleanly onto main 5d74c272) on NVIDIA GeForce RTX 5070 Ti (driver 621.01, Vulkan 1.4.357), Windows 11 10.0.26200, MSVC 19.44 (RelWithDebInfo, Windows SDK 10.0.26100.0, glslangValidator 16.6.0): pass.

  • ctest -C RelWithDebInfo -R ^(d3d12_title_va|title_va_alias|d3d12_existing_heap|xs_proxy_mock)$: 4/4 PASS
    • d3d12_title_va: PASS (0.30 s, with compiled cs_user_data.comp)
    • title_va_alias: PASS (0.02 s)
    • d3d12_existing_heap: PASS (0.80 s)
    • xs_proxy_mock: PASS (9 allocations refused on purpose, 0.02 s)

AI-assisted (Gemini).

@nullmarsh

Copy link
Copy Markdown
Contributor

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 LEONIDA_VK_VALIDATION=1 (0 validation errors).

  • d3d12_title_va: read-write and write-combined pages both 64/64 through the V# and root view read+write 64/64, 0/64 reading the other buffer. Title memory: table V# 64/64 (rewritten before submission), created CBV 64/64, root view 64/64. The table-scan window and all 8 descriptor-level negative controls hold.
  • title_va_alias, d3d12_existing_heap, device_proxy, queue_proxy, xs_proxy_mock (6 variants): pass. d3d12_vulkan_device stops at main's known tiles == 1.
  • Diff read: no process, network or file-removal calls.

AI-assisted (Claude Code), no game files.

@MarcPique

Copy link
Copy Markdown

Independent Windows check of the 70e49fd87 scan-window change, integrated into the local #9137 and #9586 stack. d3d12_title_va passed on an RTX 4090 and AMD Radeon Graphics. The readback verified that a V# past the declared slot was rewritten and the negative control beyond the scan window kept its bytes. These Windows runs used MSVC 19.44 and the available drivers without the Vulkan validation layer.

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).

@slint6614-dev

Copy link
Copy Markdown
Contributor

AMD Windows check of 70e49fd87 (AI-assisted). Windows 11 26300, MSVC 2022 (Ninja, RelWithDebInfo, full runtime/ build of this head), Vulkan SDK 1.4.363.1, AMD Adrenalin 26.11.2: Radeon RX 9070 (RDNA4, Vulkan driver 2.0.416) and Ryzen 9600X iGPU "AMD Radeon(TM) Graphics" (RDNA2 gfx1036, driver 2.0.353), picked with LEONIDA_VK_DEVICE/LEONIDA_HOST_ADAPTER.

No game files.

Capi360 added a commit to Capi360/Leonida that referenced this pull request Nov 23, 2026
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.
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.