mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 13:58:43 +00:00
A V# or 64-bit pointer the title writes into its own memory names a title address, and the translated shaders read heap_base + sext48(address). Nothing was there: run 63 lost the device on such a V# into the stream pool's GPU-only window, which read zeros before step 2. The mirror puts the title's bytes there. - src/title_mirror_space.h: xmem places every XMemVirtualAlloc reservation the title lets it place (address null) in [16 TiB, 48 TiB), handed out in order at reservation time, so no title pointer ever holds an old address. RADV makes sparse buffers at a chosen address only in its top 64 TiB, where heap_base (the sparse arena) is; heap_base + an address there stays inside it. A reservation the range cannot take is placed by the host, as before. - src/title_mirror.h (TitleMirror, Vulkan through hooks): 2 GiB sparse chunks at heap_base + title address (bufferDeviceAddressCaptureReplay), one home per physical page (64 KiB of a 32 MiB host-visible unit), every page that shows a physical page bound to its one home (aliases share bytes and GPU writes; a remap is a rebind), the binds of a submission in one batch (the last bind of a page wins), homes freed after the retire ticket. - src/title_frames.h Feed/Attach, xmem: every change of what a page of the range shows (host views in note_mapping, table pages in note_table_page), in order, with the physical page's scratch bytes; attaching feeds the pages mapped now under g_phys_mutex. - src/title_mirror_tracking.h: the dirty set behind a small interface (watch, unwatch, collect: re-armed before the caller copies), with GuardTracking (a geometry-watch cell guard per page) until a measured policy replaces it. - DeviceState::create_page_mirror / refresh_page_mirror (first in the before-execute hook): chunks for new reservations, the feed bound, written pages filled again once, the batch on the arena's bind queue signalling a timeline value; VulkanContext::note_mirror_bind makes every queue's next submission wait for it (the ordering rule). Off, with one line saying why, without capture-replay addresses, aliased strict sparse buffers, the bind queue, a sparse arena, signed V# offsets, xmem or the write-fault handler (llvmpipe), or with LEONIDA_PAGE_MIRROR=0. page_mirror_covers / page_mirror_address for the readers that move onto it. A log line every 10 s. Tests: vk_title_mirror_test (native and under Wine, Raphael iGPU and RX 7900 XTX): a title-written V# read from a buffer and dereferenced as the translated shaders do reaches its page, an alias the same, an unbound page reads zero; a remap, a write (one upload for two aliases) and an unmap reach the next dispatch that waits for the batch; a home is freed only after its ticket. d3d12_page_mirror_test (Wine, the game's device over xmem's pages): after slot-31 copies the GPU-only page, its twin and the title's view hold the bytes at heap_base + address; a title write through its view reaches them with one upload; a remap is a rebind with no host remap; an unmapped page reads zero. xmem_test: reservations land in the range, the pair still pairs, the feed reports attach, host maps, table copies and unmaps in order, nothing after detaching. Linux ctest (llvmpipe) 121/121. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.3 KiB
Plaintext
29 lines
1.3 KiB
Plaintext
#version 460
|
|
// The page mirror's acceptance shape (vk_title_mirror_test): a V# the title wrote into its own memory, read from a
|
|
// buffer and then dereferenced as the translated shaders do it (heap_base + sext48(base), docs/design.md
|
|
// "Heap-relative buffer device addresses"), as MS_VS_Depth-style code reads a V# out of a constant buffer with
|
|
// s_buffer_load and loads through it. Each invocation reads V# i's base and the dword at base + 0x40.
|
|
#extension GL_EXT_buffer_reference : require
|
|
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
|
|
layout(local_size_x = 8) in;
|
|
|
|
layout(buffer_reference, std430, buffer_reference_align = 4) readonly buffer Words { uint w[]; };
|
|
layout(buffer_reference, std430, buffer_reference_align = 4) writeonly buffer Out { uint v[]; };
|
|
|
|
layout(push_constant) uniform Push {
|
|
uint64_t heap_base;
|
|
uint64_t vsharps; // 16-byte V#s, one per invocation
|
|
uint64_t out_words;
|
|
uint count;
|
|
} p;
|
|
|
|
void main() {
|
|
const uint i = gl_GlobalInvocationID.x;
|
|
if (i >= p.count) return;
|
|
Words v = Words(p.vsharps + uint64_t(i) * 16ul);
|
|
const uint64_t base48 = uint64_t(v.w[0]) | (uint64_t(v.w[1] & 0xffffu) << 32);
|
|
const int64_t signed_base = (int64_t(base48) << 16) >> 16; // sext48
|
|
Words target = Words(p.heap_base + uint64_t(signed_base) + 0x40ul);
|
|
Out(p.out_words).v[i] = target.w[0];
|
|
}
|