Skip to content

RT-STATE-AUDIT-FORMATS: honor D3D12_DSV_FLAG_READ_ONLY_DEPTH and READ_ONLY_STENCIL - #2480

Open
lixonik wants to merge 272 commits into
ProjectLeonida:mainfrom
lixonik:rt-state-audit-formats-dsv-readonly
Open

lixonik wants to merge 272 commits into
ProjectLeonida:mainfrom
lixonik:rt-state-audit-formats-dsv-readonly

Conversation

@lixonik

@lixonik lixonik commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Part of RT-STATE-AUDIT-FORMATS (#2464; based on the format-state audit notes in #1608 by @kevincommits and @Tauwni).

Summary

  • Store validated DSV read-only flags (dsv_read_only_depth, dsv_read_only_stencil) on TargetView (runtime/src/command_list.h; sizeof(TargetView) == 32 <= kDescriptorSize).
  • Validate desc->Flags in CreateDepthStencilView (runtime/shims/d3d12_vulkan_device.cpp), rejecting unknown flag bits and recording D3D12_DSV_FLAG_READ_ONLY_DEPTH / D3D12_DSV_FLAG_READ_ONLY_STENCIL.
  • Replay read-only depth/stencil attachments properly in runtime/src/vulkan_replay.h:
    • Separate VkRenderingAttachmentInfo for depth and stencil with VK_ATTACHMENT_STORE_OP_NONE, read-only access masks (VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT), and per-aspect read-only layouts when separate_depth_stencil_layouts is enabled (or DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL / DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL when coupled).
    • Use VK_IMAGE_LAYOUT_GENERAL for read-only depth/stencil with bindless sampling where the Vulkan attachment access rules allow it. Simultaneous sampling of one aspect of a packed depth/stencil image while storing the sibling on devices without separateDepthStencilAttachmentAccess remains open. When the sampled aspect entered the draw in GENERAL, replay restores that layout for subsequent reads after the attachment scope ends. See the review.
    • Skip redundant intra-layout memory barriers for read-only attachments and mask out read-only aspects in ClearDepthStencil.
    • Add GraphicsPipeline::read_only_depth / read_only_stencil variant bits (runtime/src/vulkan_replay.h, runtime/shims/d3d12_vulkan_device.cpp) so pipelines with DepthWriteMask = ALL or nonzero stencil write masks suppress writes cleanly when drawn against a read-only DSV (no variant is built when the PSO already disables writes).

Tests

  • runtime/test/d3d12_dsv_readonly_test.cpp (d3d12_dsv_readonly, skips with 77 if no Vulkan GPU): exercises unknown-flag rejection, mixed READ_ONLY_DEPTH + writable stencil, mixed writable depth + READ_ONLY_STENCIL, READ_ONLY_DEPTH | READ_ONLY_STENCIL, read-only ClearDepthStencilView masking, and D32_FLOAT READ_ONLY_DEPTH on GPU.
  • runtime/test/dsv_readonly_replay_test.cpp (dsv_readonly_replay, CPU-only, no GPU required): verifies attachment layouts, storeOp, barrier access masks, separate_depth_stencil_layouts true/false, sampled_in_general, write-suppression variant requests, and ClearDepthStencil read-only skipping.

Negative control & verification

  • On unmodified main (ec91d695c), d3d12_dsv_readonly_test failed all 6 GPU checks on RTX 5070 (unknown flag 0x4 accepted, READ_ONLY_DEPTH overwrote depth to 0x400000 causing the second draw to fail depth test, READ_ONLY_STENCIL and READ_ONLY_BOTH modified depth/stencil, partial clear overwrote read-only depth, and D32_FLOAT READ_ONLY_DEPTH overwrote 0.75 with 0.25).
  • With the fix:
    • ctest -R "^(dsv_readonly_replay|d3d12_dsv_readonly|d3d12_state_map|vk_command_replay|d3d12_depth24_draw|d3d12_typeless_depth)$": 6/6 passed.
    • python scripts/check_no_game_data.py: clean.
    • python -m unittest tests/test_ctest_registration.py: 6/6 OK.
    • git diff --check: clean.

GPUs tested: NVIDIA GeForce RTX 5070 (Windows 11, native Vulkan; VK_LAYER_KHRONOS_validation not installed locally).

AI-assisted.
Independent Vulkan validation on RTX 3080: four synthetic DSV tests passed, including the precise-occlusion assertion. That run covers the D32 control. Test report.

Follow-up after merging main

At c6fabd3395 with main bd643e46e7, both sides' CMake test registrations are present. On Windows 10 22H2, RTX 5070 (610.88), MSVC 19.44 and Khronos validation, all four selected tests passed: dsv_readonly_replay, d3d12_dsv_readonly, depth24_cpu, and d3d12_depth24_draw. The same-draw packed depth/stencil case described above remains open.

Independent native Linux GPU follow-up at c6fabd339 on RADV and NVIDIA confirmed that the post-render transition restores shader reads in GENERAL. All eight mixed draws and eight sample-only controls returned the expected pixels with synchronization validation enabled. Removing only the restoration triggered a descriptor/image layout validation error in all eight recordings. Test report

aslan2142 and others added 30 commits November 26, 2026 18:08
…mission (67863b3)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… on several threads, and submits their uploads in order (RT-TITLE-TEXTURE-WRITE-TRACKED)

Run 58: with the watch in effect a pass still read, hashed and detiled every named texture on the title's
submitting thread, one after another: about 1,250 textures and 95 MiB a pass in the world load, 198 ms a pass,
up to 795 ms (read from write-combined title memory, a full hash, the detile into the upload slot).

The upload is split into three steps (TitleImageUpload::reserve, fill, commit). The pass reserves a slot for
each named texture on its own thread, a small pool of threads of ours (TitleReadPool, a quarter of the cores,
at most seven, plus the submitting thread) copies, hashes and detiles them in batches of 16 or 64 MiB, and the
submitting thread then records and submits the transfers one by one in key order, still before the submission
whose draws sample them. The reads of different textures are independent; only the submissions carry the
ordering, and they stay where they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…transfers committed in order (d170028)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d to it; a rewritten V# whose range waits takes that answer

Two findings from one world run (every slot records line: 0 refills; fixing slots 18.2 ms a submission).

T#s: the title rebuilds T#s of the layer's textures from 32 bits. The run's unbound T#s name 0x7f0000021400 for the
layer's 0x100021400 and 0x2ef600 for 0x1002ef600 (bits 32-39 clear, 0x7f or 0 in bits 40-47): "its low 32 bits name
a texture of ours that is gone" (291-3,794 a window) and "no title memory and no texture of ours" (270-4,585, low bits
past the last address handed out: textures still to come). They were recorded under that address, while a texture's
arrival is announced at the layer's address, so no arrival ever reached them, and bind_title_image looked them up by
the exact address only. tsharp_texture_key maps such an address outside the title's memory to the layer's texture
address with the same low 32 bits (while fewer than 2^24 were handed out); the T# waits under it, and
bind_title_image takes the texture there when its shape fits (another shape stays unbound, as before).

V#s: about 2,100 rewritten V# halves a submission, 70% resolving to nothing at about 9 us each (the alias table,
the backings, the geometry copies and the title memory walked again, VirtualQuery included), 63% with words seen
before. A waiting record is fixed again by every change that could let it resolve, so while one waits its answer
stands: a rewritten half whose exact range another half of the heap waits for takes that answer
(ConsoleHeapSlotRecords::waiting_answer, one hash lookup; a half that asks for a geometry copy only from one that did,
and not after geometry room was freed since the refresh). To keep answers current, the submission's changes are
applied before the rewritten slots, and the changes noted during the pass (a window a fix made, a buffer another
thread released) are applied to the heap before an answer is taken (sync_slot_changes). The records keep a third
list per range for waiting halves that asked for a geometry copy. The slot records line counts the answered halves.

Tests: d3d12_tsharp_refill_test also writes the texture's T# in the title's two 32-bit forms before the texture exists
and expects both bound at the first submission after it appears, and gone with it. d3d12_unbound_tsharp_rules_test:
the 0x7f form with the texture's shape binds (it expected "no texture"). console_heap_slot_records_test: in the 400
random rounds half the writes take a waiting answer after applying the changes noted so far, and each answer must be
what resolving at that moment gives (a copy that skips applying them fails); the rounds still equal a full
re-resolution. Linux ctest 115/115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…om it; textures are read at first use and by their written tiles (RT-TITLE-TEXTURE-WRITE-TRACKED)

Blocks of older frames in run 58: a texture without GPU-write flags placed over the memory of a GPU-written
one (a render target, depth or UAV texture) was filled from the title's pages there. Those pages never hold
what our GPU renders into the target's image, only what the CPU last put there, and every write mark over
them (a write-back of a GPU copy, a neighbour's write in the same tile) re-uploaded those old bytes. The
registry now keeps the CPU-view range of every GPU-written texture (DeviceState::gpu_owned), and a texture
over such a range is not watched or filled by the refresh (index_texture); one already watched stops when the
target is registered. Test: d3d12_existing_heap's "texture over a render target's memory" (fails without
this: the written 64 KiB piece shows in the texture).

Upload at first use: a title texture no descriptor names is not read, uploaded or watched. Its first
descriptor of any kind (a D3D12 view, a slot-70 view, a T# the title wrote into a console heap: all reach
Resource::note_shader_view) queues it, and the refresh before that submission reads it whole and uploads it.
A texture whose descriptors are all gone later stays on the write-driven path (nothing counts them down).

Reads by written tiles: each texture keeps a hash of its part in every 64 KiB tile (TilePieces). When some
of its tiles were written, those parts are hashed in place first; equal, and the texture is unchanged
without a whole read. The watch reports writes per 64 KiB tile (the geometry cells' fault reopens a whole
tile), so a neighbour in a written tile costs its share of that tile, not a read of all of it.

The 10 s line: textures written or new, read whole, found unchanged by their parts, uploaded, named for the
first time, not named by any descriptor (not read), ms a pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#s in the title's 32-bit form wait under our address (d94b6c3)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…re's first descriptor, written parts hashed (f7c3df1)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…y resolve to the render target's image (RT-TITLE-TEXTURE-WRITE-TRACKED)

f7c3df1 stopped filling such a texture from the title's pages; its own image then held nothing the GPU
drew. A GPU-written texture placed at the address (render target, depth or UAV) now answers first, for
console T#s (bind_title_image) and slot-70 views (place_title_view), when the description fits: the T#'s
extent and samples, and mips and layers within the target's (TitleGpuPlacements::matches), in any format the
target's image takes a view in (its own, a castable one, or one its view list allows). Otherwise the other
texture answers as before, and the reason is counted (format; extent or samples; mips or layers) in a line
next to the refresh's.

Either order at one address: a render target placed over a texture placed first leaves that texture's
registry entry in place and drops its T# bindings, so they bind again, to the target. The ranges GPU-written
textures cover are kept by the resource (DeviceState::gpu_owned), so a texture placed later at the same
address does not take the target's range away; when the target goes, the texture at its address is filled
from memory again and its T#s find it. D3D12 views the title made of the plain resource itself still name
its own image.

Test: d3d12_existing_heap's "view over a render target" (both orders, and the target's release).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom timestamps

A diagnostic, off by default. Each submission on a queue whose family has
timestamp bits gets a query pool, reset once at the start of its command
buffer, and bottom-of-pipe timestamps: after the opening barrier and
bindless upload, before each run of consecutive draws or dispatches of one
pipeline, after a run that another command follows, and at the end. The
difference between two consecutive timestamps is what lies between them
added to the queue's work: a run's GPU time, or "other" when no draw or
dispatch lies between. The results are read on the fence callback once the
submission is done, never waited for, and summed by pipeline under its
stages' ShaderLibrary names (as the pass trace prints them), else its id.

Every 10 s, [rt] gpu profile lines give per frame the compute, graphics
and mesh totals, other work, per queue kind the busy time (measured as
LEONIDA_GPU_LATENCY does) against the timestamped span and the share in
draws and dispatches, and the 20 pipelines with the most GPU time (ms per
frame, share, kind, calls per frame, ms per call).

PSOs register their names with the context when the profile is on, as
they already do for the device-fault report; the device passes the
families' timestamp bits to the context. Off: one test per submission and
per command. On: about 1 us per timestamp on the Raphael iGPU, submit to
idle (vk_gpu_profile_test).

vk_gpu_profile_test runs known dispatches of two pipelines and a draw
through VulkanQueue and checks each pipeline's name, calls, runs, a time
that grows with its loop count, and that the intervals add up to the span.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e target's image (14d436c)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…reads and writes those pages through the frame table (RT-MEMORY-MODEL)

Step 2 of the memory model. After step 1 the console queue's CopyPageMappingsBatchX gave a paired GPU-only page its
physical page by table, but still host-mapped the paired CPU page (the "twin") for the D3D12 layer and DirectStorage,
which read and write GPU-only memory there: one unmap plus MapViewOfFile3 per page through Wine's server. In the newest
local world run that was 47% of slot 31's pages and most of its 1.7-2.5 s of mapping per 10 s. By the log every host
remap was such a twin (pages by table minus pages by host equals the twins the title mapped itself, which are kept);
destinations with no CPU pair were none.

Now the twin is a table page too (map_table_page), and the host reaches table pages through their frames:
- src/title_frames.h: xmem's lookup (page -> its section's scratch view, held alive), its peers, monotonic bounds so
  other memory costs two loads, and for_each_part / run_end to split a range into table and host parts.
- xmem: g_table_frames under its own SRW lock (readers never wait behind g_phys_mutex), g_page_tables per physical
  page. A table page is aliased, its alias peers being its physical page's host views (note_mapping keeps them in
  step), so ProjectLeonida#1867's alias cells guard it where the title's CPU can write it. The title's unmap of a table page now
  tells its readers. transfer_physical pins and notifies table pages too.
- Readers: copy_guarded, texture_memory_readable, readable_page / readable_run_end (stream-pool extents),
  to_host_view, the ShadowPages walk and fill (a table page is read like a read-only page that is not the tracker's,
  clean while its cells are; a block with no host view anywhere is armed on its own cell), the geometry provider,
  the title buffers for vertex and index views, raw sampled surfaces, console value reads.
- Writers: kernel_writes::write and store write the frame and pin its peers; read_file reads into a bounce buffer
  first. DirectStorage goes through these.
- The slot-31 line keeps "pages N by table, M by host remap" and adds the paths behind them.

Not through the table: imports (a table page has no host pages; such buffers are shadows), GPU write-back into a
table page (left out like every aliased page; per-frame write-back is step 6), the LEONIDA_MAP_READBACK diagnostic,
the fsdraw and compute-input probes (host pages only), the batch hook's LEONIDA_SLOT31_CPU_TWIN mirror (not installed
in retail runs), and the title's own ReadFileEx/ReadFileScatter (the title has no CPU mapping there on the console).

Tests: title_frames_test (portable); xmem_test copy_page_mappings_cpu_view (no host view at either page, no host map,
reads and host writes through the frame, a write through the title's own mapping seen, remaps, kept twins, views
replaced once); d3d12_xmem_placed queue_remap_default_route (slot-133 buffers over the GPU-only pages and the twin read
them, a guarded title write through the pool's own mapping and a remap reach the GPU, no host remap).
Linux ctest (llvmpipe) 119/119; Wine suite on the iGPU against main e5a7c89: no pass-to-fail (432 pass, the same 23
failures).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…le, twins remapped by table (b54413e)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…again, and every fill keeps part hashes (RT-TITLE-TEXTURE-WRITE-TRACKED)

Run 60: 80 % of the looks were whole reads, 89 % of them unchanged. index_texture runs at every Map of a
slot-133 texture, at a layout found by a view and at a first naming, and each call re-tracked the texture:
its tiles were released and acquired again (so not armed) and it was named, so the next pass read it whole
although nothing had been written. Tracking again over the same tiles now changes nothing; a texture that
must be read (never filled, or known changed) is touched instead. Fills made outside the refresh (at a
slot-70 view, on the fill worker) now keep part hashes too, so the next written tile is decided by parts
rather than by a whole read. A line every 10 s counts whole reads by why: never filled, no part hashes,
one tile (its part is all of it), every tile written, no tile written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p; part hashes kept for view and worker fills (cadf432)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…draw that started and did not finish

With LEONIDA_DEVICE_MARKERS=1 every draw the replay records takes a seq from the dispatch numbering and writes the
VK_AMD_buffer_marker pair: started before its helper passes and rendering scope, finished after the scope ends (the
legacy indirect path inside the caller's scope, which the extension allows). The marker history (now 65,536 items)
keeps each draw's kind and counts, pipeline names, execute, list, command and its place among the draws to the same
targets. The loss and stall reports name the last finished item, the likely hang, the rest in flight and an idle
queue's next one not started, for draws and dispatches alike; a device-fault address is followed by the last draw
each queue started. Tests: the CPU marker test records draws and dispatches and checks the lines; the GPU marker
test writes draw markers outside and inside a dynamic-rendering scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… memory behind the number now (RT-MEMORY-MODEL)

Found by two world runs on the step-2 build (60, 61) that lost the device at the start of the 3D opening with a GPU
read of a garbage address, deterministic, where a run without step 2 (62) went past it.

map_table_page returned early when the table page already held the copy's page number. A number is not a page of
memory: XMemFreePhysicalPages puts the slot on g_free_slots and the next XMemAllocatePhysicalPages takes it back
first, naming a page of a new section. A stream pool's pages are freed and allocated again while the title keeps the
table entries, so the next copy of the same number left the table page on the freed page's frame (its entry holds
that section alive), and the readers of the GPU-only page and its CPU twin got the freed page's old bytes. Before
step 2 the twin was a host view, and map_page maps the number's current page every time, so the readers followed;
the GPU-only page had no readers.

The early return now also requires the frame the entry holds to be the number's current page (section and offset).

Test: xmem_test test_copy_page_mappings_reused_number: copy a page onto a paired GPU-only page, free it, allocate
again (the same number, asserted), map and fill it, copy again: the GPU-only page and its twin read the new page.
It failed before the change ("the table pages read the new page behind the number, not the freed one") and passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… guards as its protection (RT-TITLE-TEXTURE-WRITE-TRACKED)

Run 62 died on a write to a title page left read-only with no guard to answer for it ("stray read-only title
page ... no guard owns it"). TitleVirtualProtect passed the title's call straight through: over a page one of
our guards (a slot-133 shadow's, or a geometry-watch cell, which the title texture watch now arms over all
watched texture memory) had made read-only, the call returned that read-only protection in `old`, and its
Event::replaced made the cell forget the page. A title that saves `old` and sets it back later then made the
page read-only for good, with no owner, and its next write faulted.

The call now runs under a kernel-write pin over the range (kernel_writes::begin_write, as ReadFile does): our
guards come off first and no refresh puts one back until it returns, so `old` is the title's own protection.

Test: d3d12_xmem_placed's "title VirtualProtect over a guard" (an armed cell, the title's VirtualProtect to
read-write and back to what it reported, then a write); it fails without this (`old` is PAGE_READONLY).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its range (6edfe23)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…73375f)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, per page, until signalled; aliased; unbinds)

A measurement for the page mirror's layout, not a ctest: a 3 GiB sparse buffer and a 256 MiB pool, binds of 1 to
4,096 64 KiB pages with scattered or ordered memory, unbinds, one page at many offsets, and a remap load of 63
calls of 32 pages. Raphael iGPU (RADV, Mesa 26.3.1), natively: the call returns in microseconds, the binds complete
at about 43 us per page with scattered memory and 21 us per page with memory in order (no coalescing), unbinds about
21 us per page; 2,016 scattered pages took 105 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…read threads, and the pass logs its split (RT-TITLE-TEXTURE-WRITE-TRACKED)

Run 63: with nothing written a pass costs 0.05-0.1 ms; the average comes from the changed textures, about
0.8 ms per MiB uploaded (the opening's video planes and streamed textures: 1,720 uploads, 6.8 GB in 10 s).
Each was read by one thread, start to end: the copy from write-combined title memory, a full hash, the
part hashes (a second pass), and the detile. A burst of three large planes used three threads at most.

Now a texture read whole is copied and hashed in pieces of 16 tiles (1 MiB), spread over all the read
threads; its hash is made of its parts' hashes (TilePieces::combined, at every fill too), so its bytes are
read once and hashed once; the detile stays per texture. The 10 s split line gives, per pass: finding what to
look at, naming/arming/reserving, reading (and detiling, summed over the threads), MiB read whole, and
recording/submitting the transfers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eads, split line (54b4e2f)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… its answer; counters for where V# fixing goes

The heap phase in the 3D opening of one world run: fixing slots 6.4-7.5 ms a submission for about 2,000 changed
V# halves; the V# resolution counters there are device-wide (2,904 resolutions a submission against 1,340 changed
halves) and say nothing about the heap.

A resolved record is fixed again by every release or removal of its range or its copy, so while it stands, a
resolution of the same exact range made the same way gives its answer: a rewritten half now takes it from a current
record of its range (ConsoleHeapSlotRecords::answer, the resolved records kept by whether they asked for a geometry
copy, as the waiting ones), after the changes noted since are applied, as for waiting answers. Nothing else of a
resolution is lost: a window's write-back is noted per submission and an unchanged slot is not resolved again
either.

New per-heap line every log window: halves answered by a resolved record and by a waiting one, halves resolved anew
with their time, the classes of those that resolved to nothing (a copy not backed, an arena offset, bit 47, no copy
asked, not title memory, past its range, a buffer's, private pages, no room, pool alias, other; geometry_va reports
why it gave no copy), the longest refresh with its parts (pages, changes, slots), and the waits for the heap lock,
which the heaps phase of the submit counters includes.

Test: in the 400 random rounds half the writes take a record's answer, resolved or waiting, each checked against a
resolution at that moment (a copy that skips applying the changes noted since fails). Linux ctest 120/120.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…record; resolution counters by class (604c232)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…esses (bufferDeviceAddressCaptureReplay)

Raphael iGPU, RADV, natively: a 3 GiB sparse buffer asked for at 0xffffffb4a0000000, 0xffffffb8a0000000 or
0xffffffff00000000 is made exactly there; one asked for below 0xffffc00000000000 is made 0x400000000000 higher
(RADV's sparse range is the top 64 TiB), and 0xffff800100000000 is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…base + their title address (RT-PAGE-MIRROR)

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>
bobcatchris and others added 20 commits November 29, 2026 19:46
…op unused imports (CHORE-TIER2A-PYTHON-CLEANUP)
… p2 narrow

Update `tests/semantic/test_interp_computed_ij_fallback.py` (ProjectLeonida#2239) to
narrow `v_interp_p2_f16` reference expectations toward zero (`f16_rtz` /
`f16_rtz_bits`), matching `SHADER-468` (ProjectLeonida#1181).

AI-assisted.
…rp-computed-ij-rtz-carry

test(semantic): align computed-I/J f16 interp oracle with toward-zero p2 narrow (TEST-INTERP-COMPUTED-IJ-FALLBACK-RTZ carry)
…_* variables

d3d12/docs/findings.md was reachable from d3d12/README.md alone, so a night of
runs repeated measurements it already holds. Index it, point AGENTS.md at it,
say how to measure (a switch by turns inside one run), and list the variables
the runtime names from its own sources: 415 of 669 were in no Markdown file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thon-cleanup

chore: remove 13 dead one-off scripts, fix /home/nolan test paths, drop unused imports (CHORE-TIER2A-PYTHON-CLEANUP)
…t storm, ShadowPages/TitleTextureCells guard conflict, and streaming budget bursts
…ix/rendering-correctness

# Conflicts:
#	tests/semantic/test_interp_computed_ij_fallback.py
The launcher column saw one way of assigning of four, three kinds were wrong,
names read by turns through a constant, a function or asked_for! were missing,
and test modules with a brace in a raw string were cut short. measuring_fps.md
now says how to give LEONIDA_AB to the launcher and what GPU_TIMING and
PROFILE need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
progress_dashboard: reject non-JUnit XML reports (DASH-JUNIT-ROOT)
…-d3d12-run-fps

tools: frame rate of a D3D12-runtime run by draws a frame, and two runs side by side (TOOLS-D3D12-RUN-FPS)
docs: which imported GDK names have a public page (DOCS-GDK-PUBLIC-PAGES)
…orkers-win-venv

COMPUTE-WORKERS-WIN-VENV: launch Windows compute workers with sys._base_executable
tests/test_tool_stdout_encoding.py asks it of every tool. d3d12_run_fps.py came
in with ProjectLeonida#2594 without it, which left that test red on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f-cpu-gpu-r6

[integration] PageMirror, GPU detile, async queue & RDNA2->SPIR-V performance stack (INTEGRATION-PERF-CPU-GPU-R6)
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 30, 2026
@merzleckeier

Copy link
Copy Markdown
Contributor

Independent Wine A/B on the current DSV revision. I built GitHub merge 717bd241 (a7f11116a over 497bdd039) in Win64 Release using clang-cl 23.1.5 and Windows SDK 10.0.26100. CachyOS, Wine 11.22, RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV 26.3.1). Synthetic shaders and attachments.

  • MEASURED, PR. d3d12_dsv_readonly, d3d12_depth24_draw and dsv_readonly_replay passed on both GPUs. Replay reported 12 checks. The D32 read-only draw retained 0.75, the writable control stored 0.25, and its paired occlusion checks passed.
  • MEASURED, negative control. I built the identical checked-in DSV test against the runtime from main. Both GPUs reported the same six failures. They cover unknown flags, the three D24 depth/stencil read-only combinations, the partial clear, and D32 read-only depth changing to 0.25.
  • The host-forced Khronos layer reported the same vkCreateDevice diagnostic on both arms and both GPUs. VK_EXT_external_memory_dma_buf was enabled without VK_KHR_external_memory_fd (01387). The test logs show no additional validation error class.

AI-assisted with OpenAI Codex. The observations were independently checked against the raw logs.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 30, 2026
@ammonium231

Copy link
Copy Markdown
Contributor

RTX 3090 / 621.40, validation on, a7f1111 merged onto main f9f3ec4: d3d12_dsv_readonly_test OK (all read-only flag cases), dsv_readonly_replay_test 12 pass, d3d12_depth24_draw_test 0 failures (main 0). No validation errors.

@lixonik

lixonik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the replay_state_cache CI failure in a04eff9a4b:

  • Updated replay_state_cache_test.cpp's read-only DSV CPU mock to provide a pipeline variant callback and separate_depth_stencil_attachment_access = true (matching the GENERAL layout path it asserts).
  • Updated both live-GPU read-only depth tests in replay_state_cache_test.cpp to mark the read-only pipelines' depth_writes / stencil_writes accurately and pass the device's VK_KHR_maintenance7 separateDepthStencilAttachmentAccess property into VulkanContext (falling back to D32_SFLOAT when the device lacks separate attachment access).

Verified locally on Windows 11, MSVC 19.44, NVIDIA GeForce RTX 5070 12 GB (driver 610.88, Vulkan 1.4.341, LEONIDA_VK_VALIDATION=1):

  • d3d12_dsv_readonly, dsv_readonly_replay, d3d12_state_map, replay_state_cache: 4/4 passed.
  • Sync validation (VK_VALIDATE_SYNC=1): d3d12_dsv_readonly and replay_state_cache 2/2 passed.
  • python -I scripts/check_no_game_data.py: passed; git merge-tree --write-tree origin/main HEAD: clean.

AI-assisted (Antigravity, Gemini).

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.