Skip to content

fix(kyty): apply a metadata clear issued before its depth target exists - #289

Open
SleglJan wants to merge 3 commits into
simnJS:AnyKytyfrom
SleglJan:kyty-c1-pending-meta-clear
Open

SleglJan wants to merge 3 commits into
simnJS:AnyKytyfrom
SleglJan:kyty-c1-pending-meta-clear

Conversation

@SleglJan

@SleglJan SleglJan commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

RenderExecutor::TryConsumeComputeMetaClear takes a compute dispatch as a metadata clear only when every buffer it writes covers an entry of m_surface_metas (TextureCache::CoversMeta). Entries are created in TextureCache::FindDepthTarget, at a bind that finds none at the target's metadata address. When the guest clears a depth target's HTile before that bind, no entry exists yet, the clear is executed as an ordinary write and nothing marks the entry cleared. At the bind, a new entry starts cleared only when the image has htile_initial_clear. ResolveDepthOverlap clears that flag for the image it creates in place of an overlapping one, and copies the old image's contents into it where the copy is supported. A depth target created that way therefore keeps the copied contents although the guest cleared it.

This PR remembers uniform fills whose value has ZMask 0 (bits 3:0, the cleared state of an HTile word) and that overlap no metadata entry, and applies them, per slice, when FindDepthTarget inserts the entry:

  • What is recorded: a uniform buffer fill whose value has ZMask (bits 3:0) 0, the cleared state in both HTile layouts, and that overlaps no metadata entry (any entry that starts inside the fill counts, and so does the nearest entry below it if it reaches into the fill or its owner is gone or no longer starts there). For a stencil-compressed target SMem (bits 9:8) must be 0 as well, since its bind clears stencil too. Mesa's HTILE_Z_CLEAR_REG and HTILE_ZS_CLEAR_REG in src/amd/common/ac_descriptors.h write these fields the same way. A dispatch that is not a uniform fill records nothing.
  • Where: BufferCache::FillBuffer records the fills it performs (uniform compute buffer fills that TryConsumeComputeFill consumes, and CP DMA fills). A uniform buffer fill that TryConsumeComputeFill resolves but does not consume because an image is registered over its range runs on the GPU; DispatchDirect records it once the dispatch is recorded, after the dispatch's own bindings, since the dispatch's written binding of that range drops the records under it.
  • What keeps a record of a fill on the GPU visible to the hooks: in the default configuration the buffer cache keeps the pages such a fill wrote inaccessible while they are GPU-dirty, and since Kyty requires a 32 KiB-aligned HTile with slices of whole 32 KiB units, a store into any slice a record can clear faults and overlaps the record. That protection depends on the buffer cache's state (in-place memory, KYTY_COMMAND_MEMORY_IN_PLACE=1, is kept out of it; a hot page, KYTY_HOT_PAGE_WRITE_WATCH=1, is writable once it is no longer GPU-dirty), so the texture cache holds one page write watcher on every 4 KiB page the record covers, from the fill until the last record on the page is applied, dropped, replaced, aged out or unmapped (records do not overlap, so only a record's first and last pages are counted). A guest store to the range then faults into TextureCache::InvalidateMemory whatever the buffer cache's state, unless the page is hot, and that call drops the records of fills on the GPU on every 4 KiB page it touches (the fault reports one byte, and the faulting store has to get through, as does a host write that TryPrepareHostWrite prepares through the same call). FindDepthTarget collects hot-page writes over the metadata range before the insertion. A fill on that path outside the guest address ranges is not recorded.
  • What cancels a record: TextureCache::InvalidateMemory, InvalidateMemoryFromGPU, NoteMetadataWrite, CommitGpuWrite, CopyToImage and UnmapMemory drop every record that overlaps their range, whole (InvalidateMemory drops the records of fills on the GPU on every 4 KiB page it touches): CPU-side and GPU-side buffer writes, emulator writes, written buffer bindings, readbacks through ForgetColorMetadataChecks, image writes through CommitGpuWrite (render targets, depth targets, storage images, clears and copies, over the image's whole data range), DMA copies into an image through CopyToImage (over the copied range) and unmaps. RunGarbageCollector drops records older than one GC tick. The records have their own annotated mutex, and the hooks test an address range and a 64 KiB granule bitmap (rebuilt at each GC tick) before taking it.
  • At the insertion the entry starts cleared only in the slices a record covers completely. For a fill done in memory, it starts cleared only where the slice's backing (TryReadBacking) still holds the fill value, which also catches stores the caches do not see.
  • kyty_shim_image_write_back_alias gets CheckFilledMetaClearReachesBind: FillBuffer followed by FindDepthTarget on a two-layer D16 target, for a clear of both layers and of each layer alone, a fill that does not clear, a fill on the GPU path, overwrites before the bind by a DMA fill, a DMA copy, a written buffer binding and a host store, the GC age and an unmap; and, through TextureCacheTestAccess, a record noted without a fill in memory, a GPU write to an image over the range before the bind, fills that overlap a metadata entry (starting before it and inside it), and stencil-compressed metadata with SMem 0 and SMem 1; and the page watcher of a record of a fill on the GPU: held until the apply, also after a replacement, by two records and by 300 (more than the page manager's 8-bit watcher count) on one page until they are gone, on all three pages of a record over three pages and on its last page while another record there is live, none for a fill done in memory; released and the record dropped by a write fault elsewhere on its page through RenderContext::HandleFault, an invalidation elsewhere on the page, the GC age, an unmap and a written binding; and two fills in memory of the two layers on one page still clearing both.
  • kyty_shim_depth_meta_fill replays handwritten agc_frame_replay captures: a compute image store registers an R8 image over the HTile range of a two-layer Z32 depth target, a uniform buffer fill (buffer_store_format_x at tid + 64 * group, value from user data) fills that range, which TryConsumeComputeFill refuses as registered so that it runs on the GPU and DispatchDirect records it, and the target, recreated over a one-layer target without HTile, is drawn per layer with a LESS test against stored depth below the clear value. A fill with ZMask 0 over both layers clears both, over the first layer only the first, with ZMask 15 none, and a host store into the second layer's HTile between the fill and the bind (a memory delta of the replay) drops the record, so both layers keep their depth. The test passes on the previous commit too: the fill leaves the pages GPU-dirty, so the store faults without the record's watcher. tools/lavapipe_skip.txt leaves the test out of the lavapipe job, like the other replay tests. The replay child logs consumed fills (KYTY_PRINTF_DIRECTION=Console): none of the fills over a registered range is consumed, and a fill over an unregistered range is, which shows that this check can fail.

In 007, the one-frame black band on the player character (Refs #98), events per 10 s of gameplay (see Tested): on the AnyKyty tip dcdde0a389, 3 runs each, 11.86 without this PR (9.82-13.42), 0.30 with its first two commits (0.00-0.91) and 0.21 with all three (0.00-0.62). The first version's series on 7de61e3451 gave 10.0-15.2 without it and 2.7-4.9 with it; on top of #278, 10.6-13.1 against 0.3-1.9, 4 runs each. The title clears the HTile of its 1024×1024 D16 depth targets (shadow maps) with a compute fill before binding them. 2.8-2.9 of the 5.1-5.2 entries inserted per frame for those targets belong to a D16 image created as a replacement of a 1024×1024 R16Unorm image at the same memory, and started from the copied R16 contents. 512×512 D16 targets of the same kind (1.6-1.7 per frame) start cleared with the first version as well. In one run of an intermediate version that recorded only in FillBuffer, with diagnostic counters, 42,728 of the 42,817 records that the first version's rule would have applied at an insertion came from uniform buffer fills with ZMask 0 that TryConsumeComputeFill refused only because an image is registered over the range (the other 89 from fills it consumed), which is why this version also records those fills in DispatchDirect.

Known limits that can start an entry cleared wrongly:

  • Only entries that would otherwise start without a clear are affected, that is images created by ResolveDepthOverlap.
  • A uniform fill of ordinary data whose value has ZMask 0, such as any zero fill, still records. That record acts only if a depth target whose HTile slices lie inside the filled range is inserted within one GC tick and, for a fill done in memory, the slice still holds the fill value.
  • A record of a fill done on the GPU (a refused fill, or a FillBuffer fill that takes its GPU path) has no word check at the bind, since that fill need not have reached guest memory by then; only the hooks above cancel it. Its page watcher makes a guest store to the range fault into them, but a store through another mapping of the same memory does not fault, as for images: the record then still applies, and the bind discards the depth that store wrote. Such a store is neither detected nor declined. A hot page stays writable, and its writes reach the hooks only at a collect; FindDepthTarget collects over the metadata range before the insertion.

Known limits that can lose a clear:

  • Only DispatchDirect tries TryConsumeComputeFill. Fills from DispatchIndirect and DispatchIndirectThreads are not recorded, and neither is a direct dispatch that has specialization reads (it skips both consume attempts), a fill that TryConsumeComputeFill turns into an image clear (ClearImageFromBuffer: an image with exactly the fill's range), or one it refuses for any reason other than a registered range. Fills done by ReplicateBuffer are not recorded either. They run as before.
  • A hooked write that overlaps a record drops all of it, slices it does not touch included; an image write uses the image's whole data range, and a write that reaches TextureCache::InvalidateMemory anywhere on a 4 KiB page that a record of a fill on the GPU covers (a guest store's fault, a host write, a completion write) drops that record. A readback of the range before the bind drops the record too.
  • A record older than one GC tick is dropped.
  • An insertion drops every record that overlaps the entry, whether or not it applies it (partial cover, word mismatch, SMem other than 0 on a stencil-compressed target, which also skips its depth clear). One record over the HTile of two targets is used up by the first insertion, and a slice cleared by several smaller fills is not applied.
  • Records apply only when FindDepthTarget inserts the entry. A fill that overlaps an existing entry records nothing and is handled as before this PR: one that reaches ClearMeta at the entry's address marks every slice of that entry cleared, any other (for example one that starts inside the entry, or one TryConsumeComputeFill refuses because an image is registered over it) marks nothing, and a later bind at that address finds the entry present and applies no record.

Tested

007 First Light (PPSA11386), Linux (CachyOS, kernel 7.3.4), Ryzen 9 7950X3D, AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.2.6). Release builds, SDL_VIDEODRIVER=x11, scripted pad input, one save and route, shader caches warmed from one earlier run, the local 5-byte title patch described in #98.

This PR on dcdde0a389, the AnyKyty tip when the runs were planned, in the setup of series B below, events per 10 s of gameplay (the full rules are in the reply):

  • Nine runs, in the order T B S, B S T, S T B. T is dcdde0a389: 12.33, 13.42 and 9.82 (mean 11.86). B is the first two commits on it: 0.91, 0.00 and 0.00 (mean 0.30). S is all three, built from an earlier version of the third commit with the same runtime code (the pushed commit differs only in test files and tools/lavapipe_skip.txt): 0.62, 0.00 and 0.00 (mean 0.21). The rules were fixed before the runs: B's mean at most 0.7 × T's for the comparison to count (met), and S's mean at most B's plus 1.0 and at most 0.7 × T's, with no run at 9.0 or above (met).
  • Cost over the same spans. FPS from the frame counter at 4-6 screen samples per run, so coarse: T 39.70 (38.81-40.30), B 38.94 (36.70-41.48), S 38.18 (35.25-40.93). Title cgroup CPU: T 4.85 (4.71-5.04) cores, B 4.88 (4.69-5.13), S 4.77 (4.75-4.78). S against B is within the run-to-run spread on both.
  • One run with diagnostic counters that are not part of the PR (not scored): 368,677 records of fills on the GPU covering 32,115,593 tracker pages, none of them unwatched when recorded; no write fault on a page with a record (no extra fault); no record dropped only because a write landed elsewhere on its page; 2,639 protection changes inside the watcher's adds and releases (including other threads' changes in those windows; a window across the page manager's 10 s counter reset counts 0); 57,907 records set 57,907 slices at an insertion, against 16 slices from fills done in memory; 57 aged out.
  • Earlier, on 7de61e3451: the second version (dcc33e7251, the first two commits) against the first version, six runs on one day, 6.08, 4.03 and 2.81 (mean 4.31) against 3.82, 4.92 and 4.95 (mean 4.56), its rule met (reply).

Tests (RADV GFX1201):

  • ctest -R '^(kyty_shim_.*|guest_gpu_fault|guest_host_write_filter|agc_kyty_shaders)$' selects 115 tests on the AnyKyty tip 688dbf145d and 116 on this PR (the new replay test). They give the same result per test, the alias test included: all pass, except kyty_shim_rt_corpus and kyty_shim_wave_split_written_reads, which are skipped on both. The same holds for the third commit on dcdde0a389.
  • kyty_shim_image_write_back_alias and kyty_shim_depth_meta_fill pass with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1; the loader inserts the layer for each of the six test processes and no VUID- lines appear. They also pass on lavapipe here (Mesa 26.2.6, LLVM 23.1.4) in 2.8 s and 3.2 s; on RADV the replay test takes 0.4 s. This lavapipe also passes three tests that tools/lavapipe_skip.txt lists (kyty_shim_depth_target_alias, kyty_shim_buffer_null_range, kyty_shim_empty_buffer_replay); CI's lavapipe was not run here, and the new entry gives the same reason as theirs.
  • Windows: Celegans12's run on ecb8aa6185 (RTX 3080 Laptop, NVIDIA 621.14, validation layer on), comment: kyty_shim_image_write_back_alias and kyty_shim_depth_meta_fill 3 of 3 each, the kyty_shim_ set 105 of 105 with kyty_shim_rt_corpus skipped, no VUID- lines.
  • On the first two commits on dcdde0a389 with only the new test files added, every failing check printed, six cases fail (eight checks; the three-page case fails three): the page watcher held until the apply (also after a replacement), the drop by an invalidation and by a write fault elsewhere on the page, two and 300 records on one page, and the record over three pages. kyty_shim_depth_meta_fill passes there too: the fill leaves the pages GPU-dirty, so the store faults without the record's own watcher.
  • On f19d97375a, with only the check's twelve FillBuffer / FindDepthTarget cases (the others call functions this PR adds), the check fails at its first case: "a fill that clears the HTile of both layers before the bind did not clear them".
  • On an earlier, unpushed version without the CommitGpuWrite and CopyToImage hooks and with the overlap test reduced to an entry at the fill's address, with every failing case printed, exactly three cases fail: the image write, the fill that overlaps a live entry and the fill inside one.
  • Not covered by a test: the record that TryConsumeComputeFill's call to FillBuffer makes (the replay's consumed case checks only that the fill is consumed), the CopyToImage hook (the DMA copy case copies into a buffer), the hot-page collect in FindDepthTarget, in-place memory (KYTY_COMMAND_MEMORY_IN_PLACE=1) and the release of the page watchers in the texture cache's destructor.
  • tools/check_conventions.py --base 688dbf145d and tools/check_kyty_settings.py pass. git merge-tree merges the branch into the AnyKyty tip 688dbf145d without conflicts.
First version (f19d97375a), measured before the change request; "the change" below is the first version

Diagnosis (done for the first version), with diagnostic logging (not part of this PR) on 7de61e3451 plus #278 (2f755a3c46, the only other change on that line), 850 logged frames per run, of which 776-806 in gameplay:

  • Without the change, 2,270 of 4,002 and 2,266 of 4,094 entry insertions per run for 1024×1024 D16 targets (2.93 and 2.81 per gameplay frame) started without a clear: entries for a D16 image created by ResolveDepthOverlap (no htile_initial_clear), each replacing a 1024×1024 R16Unorm image at the same memory when the D16 image was bound as a depth target. 1,267 and 1,401 insertions for 512×512 D16 targets started without a clear the same way.
  • One compute fill shader found no entry in 48,185-50,093 of its dispatches per run (about 62 per gameplay frame).
  • A diagnostic switch that remembered that shader's uncovered fills and applied them at the insertion, in a series without / with / with / without (rule fixed before the runs: band frames per gameplay frame below 0.010 with the switch, at least 0.019 without; met): gameplay frames with a band 26 of 776, 0 of 784, 3 of 781, 27 of 806. Insertions without a clear for 1024×1024 targets went from 2.93 and 2.81 per frame to 0 and 0.004. Of 48,752 and 48,532 remembered fills, 4,057 and 4,048 matched an insertion; the rest were never applied.
  • The first version on the same diagnosis line (f19d97375a's change plus one log line, no switch; one run, 791 gameplay frames): all 2,323 such insertions for 1024×1024 targets (of 4,113) and all 1,337 for 512×512 targets started cleared; 3 band events, all in the head region, none on the body.

The first version against the same build without it, in two series of 4 runs each, run in the order without / with / with / without, with / without / without / with, 300 s per run, Kyty's defaults with no KYTY_* set. Series P: #278 (2f755a3c46, on 7de61e3451), with the first version on top. Series B: the first version on 7de61e3451. Band events per 10 s of gameplay, counted by the frame-difference detector used in #98 on 60 s of video recorded from 150 s after the game window opens, over the 30-34 s of gameplay after the area has loaded. The rule for each series was fixed before its runs: confirmed if every run with the change is below 2.0 and every run without at least 4.0; not confirmed if any run with the change is at 4.0 or above.

Series Without With Result
P, on #278 11.07 / 13.11 / 11.25 / 10.56 1.20 / 1.88 / 0.30 / 0.65 confirmed
B, on 7de61e3451 10.00 / 15.24 / 11.15 / 12.72 2.70 / 4.63 / 3.22 / 4.86 not confirmed: all four runs with the change above 2.0, two above 4.0
  • Exact permutation test on the mean difference, 4 against 4, planned before the runs: 10.49 per 10 s in P and 8.43 in B, one-sided p = 1/70 in both (two-sided 2/70); every run with the change is below every run without.
  • By position (counted after the runs), events per run, without / with. On the body: P 28 / 34 / 26 / 33 and 2 / 3 / 0 / 2; B 21 / 31 / 28 / 23 and 0 / 0 / 1 / 1. In the head region: P 6 / 9 / 9 / 1 and 2 / 3 / 1 / 0; B 13 / 19 / 8 / 20 and 9 / 15 / 9 / 15. A head-region rule fixed before series P (every run with the change at most 3, every run without at least 6) was not met: one run without the change had 1.

Cost of the first version, means without / with on the same runs of series P and B, exact two-sided permutation test, 4 against 4 (p in parentheses). "Whole run" is the title's systemd scope or process from start to exit; "gameplay" starts when GPUActive stays above 1.5 GB.

P B
FPS, median of 200-300 s 30.082 / 30.005 (0.80) 28.633 / 28.900 (0.49)
Title scope CPU, whole run, CPU-s/s 4.865 / 4.910 (0.46) 4.825 / 4.827 (1.00)
Title user CPU, whole run, CPU-s/s 4.567 / 4.577 (0.91) 4.515 / 4.508 (0.83)
Title user CPU, gameplay, CPU-s/s 3.877 / 4.008 (0.086) 3.737 / 3.830 (0.49)
Title system CPU, gameplay, CPU-s/s 0.333 / 0.408 (0.11) 0.338 / 0.367 (0.54)
Peak anonymous resident memory, GB 5.450 / 5.535 (0.49) 5.617 / 5.495 (0.46)
GPUActive (/proc/meminfo), gameplay, GB 3.442 / 3.515 (0.54) 3.473 / 3.522 (0.83)
amd-requested-vram (title's DRM fdinfo), gameplay, GB 18.897 / 18.893 (1.00) 18.966 / 18.977 (0.97)

Gameplay CPU is higher with the first version in both series: user by 0.130 CPU-s/s (3.4 %) and 0.093 (2.5 %), system by 0.075 (23 %) and 0.030 (9 %). In both measures and both series at least one run without the change is above a run with it; pooled over the two series (computed after the runs), p 0.082 for user and 0.131 for system.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.6, Linux (CachyOS, kernel 7.3.4)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@simnJS

simnJS commented Nov 25, 2026

Copy link
Copy Markdown
Owner

A write-only compute output at address A can leave a pending clear even when the dispatch wrote ordinary data. A later CPU, DMA or compute write at A leaves that record intact. If a depth target then binds with HTile at A within the next GC tick, FindDepthTarget sets every slice clear and discards valid depth contents. The current test exercises the pending map directly and accepts a one-layer-sized range as a clear of the whole target. Could you tie the record to a verified HTile clear and the slices it covers, invalidate it on intervening overlapping writes, and test the dispatch-to-bind path with a genuine clear and a later overwrite?

@SleglJan

Copy link
Copy Markdown
Contributor Author

Pushed dcc33e7251 (fast-forward from f19d97375a).

Confirmed on f19d97375a: a dispatch whose written buffers were all write-only and had no metadata entry recorded them all, whatever it wrote; no later write removed a record; and a record of one layer's size set every slice of the new entry.

An intermediate version recorded a clear only in BufferCache::FillBuffer, where the fill value is known. In 007 it lost the effect: the black band came back at 12.93 and 11.04 events per 10 s, against 2.70 to 4.86 on f19d97375a and 10.00 to 15.24 without the PR (series B of the Tested section). One run of that version with diagnostic counters shows why. Of the 42,817 records that f19d97375a's rule would have applied at a depth-target insertion, 42,728 came from uniform buffer fills with ZMask 0 that TryConsumeComputeFill resolved but refused only because an image is registered over the range (IsRegionRegistered). Such fills run on the GPU and never reach FillBuffer. The other 89 came from fills that TryConsumeComputeFill consumed, and no other dispatch contributed.

dcc33e7251 therefore records both kinds, and cancels a record on every write it can see, image writes included:

  • What is recorded: a uniform buffer fill that overlaps no live metadata entry (an entry just before the fill whose owner is gone or no longer starts there counts as overlapping), whose value has ZMask (bits 3:0) 0, the cleared state in both HTile layouts. For a stencil-compressed target SMem (bits 9:8) must be 0 as well, since its bind clears stencil too. Mesa's HTILE_Z_CLEAR_REG and HTILE_ZS_CLEAR_REG in src/amd/common/ac_descriptors.h write these fields the same way. The record in TryConsumeComputeMetaClear is removed, so a dispatch that is not a uniform fill records nothing. A uniform fill of ordinary data whose value has ZMask 0 still records; that record acts only if a depth target whose HTile slices lie inside the filled range is inserted within one GC tick.
  • Where: BufferCache::FillBuffer records the fills it performs (consumed by TryConsumeComputeFill, or CP DMA fills). For a fill that TryConsumeComputeFill resolved and refused only because an image is registered over the range, DispatchDirect records it once the dispatch is recorded, after its bindings, since the dispatch's own written binding of that range drops the records under it.
  • TextureCache::InvalidateMemory, InvalidateMemoryFromGPU, NoteMetadataWrite, CommitGpuWrite, CopyToImage and UnmapMemory drop every record that overlaps their range, whole: CPU-side and GPU-side buffer writes, emulator writes, written buffer bindings, readbacks through ForgetColorMetadataChecks, image writes through CommitGpuWrite (render targets, depth targets, storage images, clears and copies, over the image's whole data range), DMA copies into an image through CopyToImage (over the copied range) and unmaps. The records have their own annotated mutex, and the hooks test the records' address range and a 64 KiB granule bitmap before taking it.
  • At the insertion in FindDepthTarget the entry starts cleared only in the slices a record covers completely. For a fill done in memory, it starts cleared only where the slice's backing (TryReadBacking) still holds the fill value, which also catches stores the caches do not see.

CheckFilledMetaClearReachesBind replaces the record-map check. It runs FillBuffer followed by FindDepthTarget on a two-layer D16 target, for:

  • a clear of both layers and of each layer alone;
  • a fill that does not clear;
  • a fill on the GPU path;
  • overwrites before the bind by a DMA fill, a DMA copy, a written buffer binding and a host store;
  • the GC age and an unmap.

Further cases apply records through TextureCacheTestAccess:

  • a record noted without a fill in memory applies;
  • a GPU write to an image over the range before the bind cancels it;
  • a fill that overlaps a live metadata entry, starting before it or inside it, records nothing;
  • stencil-compressed metadata, which needs a stencil plane: a clear with SMem 0 sets both slices, one with SMem 1 none.

This covers your last point only from FillBuffer and NoteMetaFill on. No test dispatches a fill and then binds a depth target, so neither TryConsumeComputeFill's call to FillBuffer nor the record DispatchDirect makes for a refused fill is covered by a test. A test of that path needs a hand-assembled uniform-fill shader over a registered HTile range and a depth bind in an agc_frame_replay capture, as kyty_shim_depth_target_alias builds for its depth target; this PR does not add one. In 007, the intermediate version started 75 slices cleared at insertions in its counter run; this commit started 45,450 and 41,779 in the two counter runs below. I can add the replay test as a follow-up if you want it.

Limits that remain:

  • Only DispatchDirect tries TryConsumeComputeFill. Fills from DispatchIndirect and DispatchIndirectThreads are not recorded, and neither is a direct dispatch that has specialization reads (it skips both consume attempts), a fill that TryConsumeComputeFill turns into an image clear (ClearImageFromBuffer: an image with exactly the fill's range), or one it refuses for any reason other than a registered range. Fills done by ReplicateBuffer are not recorded either. They run as before.
  • A record of a fill done on the GPU (a refused fill, or a FillBuffer fill that takes its GPU path) has no word check at the bind, since that fill need not have reached guest memory by then; only the hooks above cancel it.
  • An image write cancels the records under the image's whole data range, even where it writes only part of it. That loses clears; it never adds one.
  • A record older than one GC tick is dropped, and its clear is lost.
  • Records apply only when FindDepthTarget inserts the entry. A bind that finds an entry already present applies none and leaves them in place.
  • A readback of the range before the bind drops the record.
  • One record over the HTile of two targets is used up by the first insertion.
  • On a stencil-compressed target, a fill with ZMask 0 and SMem other than 0 is not applied, its depth clear included.
  • A fill at an address that already has a metadata entry still marks every slice of that entry cleared through ClearMeta, as before this PR.

Tests (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.6, Linux):

  • ctest -R '^(kyty_shim_.*|guest_gpu_fault|guest_host_write_filter|agc_kyty_shaders)$' selects 110 tests (107 Kyty shim tests and the three others). They give the same result per test on 7de61e3451 and on this commit, the alias test included: 107 pass, kyty_shim_rt_corpus is skipped, and kyty_shim_wave64_cross_lane and kyty_shim_wave_split_written_reads fail on both.
  • kyty_shim_image_write_back_alias passes with VK_LAYER_KHRONOS_validation, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1 and no validation messages, as on 7de61e3451.
  • On f19d97375a, with only the check's twelve FillBuffer / FindDepthTarget cases (the others call functions this PR adds), the check fails at its first case: "a fill that clears the HTile of both layers before the bind did not clear them".
  • On an earlier, unpushed version of this commit without the CommitGpuWrite and CopyToImage hooks and with the overlap test reduced to an entry at the fill's address, with every failing case printed, exactly three cases fail: the image write, the fill that overlaps a live entry and the fill inside one.
  • tools/check_conventions.py --base 7de61e3451 and tools/check_kyty_settings.py pass.
  • git merge-tree merges the branch into the AnyKyty tip eb5103d101 without conflicts.

007, in the setup of series B in this PR's Tested section (on 7de61e3451, without #278), the one-frame black band on the player character in events per 10 s of gameplay, by the frame-difference detector from #98:

  • Two runs of this commit plus diagnostic counters that are not part of the PR: 5.79 and 2.03. Their rule, fixed before the runs: pass if both are at most 5.0 and clear at least 0.8 as many slices as f19d97375a's rule has records, fail if either is at 9.0 or above or below 0.5 of them, else undecided. It read undecided: 5.79 is above 5.0, and the slice ratios were 0.957 and 0.950. The six runs below were planned only if these passed; the decision to run them anyway, with their rule unchanged, was recorded before them. In the same two runs, 2,040 and 2,193 of the insertions that f19d97375a's rule would have cleared started without a clear, and of 328,181 and 320,567 records made, image writes cancelled 133,172 and 128,940.
  • Then six runs on one day, in the order this commit, f19d97375a, f19d97375a, this commit, this commit, f19d97375a (that build differs from f19d97375a only in a test file): this commit 6.08, 4.03 and 2.81 (mean 4.31), f19d97375a 3.82, 4.92 and 4.95 (mean 4.56). Rule fixed before the runs: this commit's mean at most 1.0 above f19d97375a's and no run at 9.0 or above; met.

The description above still describes f19d97375a; I will update it to this commit.

AI-assisted: yes (Claude Code)

@simnJS

simnJS commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks for narrowing this to uniform fills and checking coverage per slice. One case from the earlier review is still open. When DispatchDirect records a GPU fill over a registered range, ApplyPendingMetaClears trusts that record without checking the backing. A later host store that bypasses the write hooks can leave the record live and cause the bind to discard valid depth.

Could you make that path detect an intervening overwrite or conservatively decline the clear when freshness cannot be established? Please include the replay test you proposed in this PR. Dispatch a handwritten uniform fill over a registered range, bind a two-layer depth target, and check which layers clear. Repeat with a host overwrite before the bind and verify that the affected layer keeps its depth. Please rebase onto current AnyKyty and rerun the focused tests. The alias test passed on lavapipe but was skipped in the Windows job, so a Windows Vulkan result would also help.

@Celegans12

Copy link
Copy Markdown
Collaborator

Windows Vulkan result for dcc33e7251 (the PR head, built as is on 7de61e3451): i9-11900H, RTX 3080 Laptop, NVIDIA 621.14, Windows 11. Plain non-DLL Release build with BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1, and the Khronos validation layer on (SDK 1.4.363, KYTY_VULKAN_VALIDATION=1 plus VK_INSTANCE_LAYERS).

kyty_shim_image_write_back_alias passed 3 of 3 runs (1.10, 1.11 and 1.08 s). Each printed kyty_shim_image_write_back_alias: ok, the layer loaded, and there were no VUID lines. Its neighbours kyty_shim_depth_target_alias and kyty_shim_buffer_cache_pages passed in the full shim pass too. This laptop also has an Intel iGPU, and the default loader order put the alias test on it, so these runs used VK_LOADER_DRIVERS_SELECT=*nv-vk64.json and ANYPS5_GPU=NVIDIA. The logs confirm the RTX 3080 was the device.

Against the requested changes, as I read the diff:

  • HTile tie per slice: looks addressed. Only uniform fills with ZMask 0 (and SMem 0 on stencil-compressed targets) are recorded, the record in TryConsumeComputeMetaClear is gone, and ApplyPendingMetaClears sets only the slices a record fully covers.
  • Invalidation on intervening writes: looks addressed for writes the caches see. There are drop hooks in InvalidateMemory, InvalidateMemoryFromGPU, NoteMetadataWrite, CommitGpuWrite, CopyToImage and UnmapMemory, and fills done in memory are rechecked against the backing at the bind.
  • Host overwrite after a GPU fill (your latest point): not yet. A record from the refused-fill path in DispatchDirect has in_memory == false, so the bind skips the HoldsFill check, and a host store that bypasses the hooks leaves it live. The host-store case in CheckFilledMetaClearReachesBind only covers the in-memory fill. This head predates your comment, so that's expected.
  • Replay test (dispatch, then bind through agc_frame_replay): not in the PR yet.
  • Rebase: not yet. The branch is still on 7de61e3451, 2,066 commits behind AnyKyty (dcdde0a389). git merge-tree shows no conflicts with it.
The rest of the shim set on the same build

ctest -R '^kyty_shim_' with validation on: 95 of 98 pass, kyty_shim_rt_corpus skips (no corpus), and kyty_shim_bda_load_forms and kyty_shim_wave_split_written_reads time out at 120 s. They also time out without the layer and on #220's head (a different base). This PR doesn't touch them, so they look like an existing NVIDIA/Windows issue. No VUID lines in the whole pass.

AI-assisted: yes

A compute dispatch that clears HTile metadata is taken as a clear only when
the metadata entry already exists. When the guest clears the HTile of a depth
target that is created afterwards, for example a depth replacement of a color
image at the same memory, which gets no initial clear, the clear is lost and
the first bind keeps the copied color content.

Remember such writes for the current and the next GC tick, and start the
entry cleared when a depth target inserts it at that address with a size the
clear would have covered.
The pending metadata clear recorded every write-only output of a compute
dispatch that found no metadata entry, so an ordinary output at a later
HTile address marked every slice of the new entry cleared. Later writes
to the range did not cancel the record, and a record of one layer's size
cleared every layer.

Record a clear only for a uniform buffer fill whose value has ZMask
(bits 3:0) 0, the cleared depth state in both HTile layouts, and that
overlaps no live metadata entry. A stencil-compressed target also needs
SMem (bits 9:8) at 0, since its bind clears stencil too.
BufferCache::FillBuffer records the fills it performs: uniform compute
buffer fills that TryConsumeComputeFill consumes, and CP DMA fills. A
uniform buffer fill that TryConsumeComputeFill resolves but does not
consume because an image is registered over its range runs on the GPU;
DispatchDirect records it once the dispatch is recorded, after the
dispatch's own buffer bindings.

TextureCache::InvalidateMemory, InvalidateMemoryFromGPU,
NoteMetadataWrite, CommitGpuWrite, CopyToImage and UnmapMemory drop the
records that overlap their range: CPU-side and GPU-side buffer writes,
emulator writes, written buffer bindings, readbacks through
ForgetColorMetadataChecks, image writes (render targets, depth targets,
storage images, clears and copies) and unmaps. At the insertion the
entry starts cleared only in the slices a record covers fully, and for a
fill done in memory only where the slice's backing still holds the fill
value. The records have their own annotated mutex, and an address range
and a 64 KiB granule bitmap, rebuilt at each GC tick, that the hooks
test before taking it.

The check now goes from FillBuffer to FindDepthTarget on a two-layer D16
target: whole and one-slice clears, a fill that does not clear, a fill
on the GPU path, overwrites by a DMA fill, a DMA copy, a written buffer
binding and a host store, the GC age and an unmap. Further cases apply
records through TextureCacheTestAccess: a record noted without a fill
in memory, one cancelled by an image write, fills that overlap a live
entry (starting before it and inside it), and stencil-compressed
metadata with SMem 0 and SMem 1.
A pending metadata clear for a fill that runs on the GPU (a fill that
TryConsumeComputeFill refuses because an image is registered over its
range, or a FillBuffer fill on its GPU path) has no backing to check at
the bind, so only the write hooks cancel it, and a guest store reaches
them only through a write fault. That fault came from the buffer
cache's state. It makes the pages such a fill wrote inaccessible while
they are GPU-dirty, and a depth target's HTile is 32 KiB-aligned with
slices of whole 32 KiB units, so a store into a slice that the record
would clear faults and drops the record. But the buffer cache keeps
in-place memory (KYTY_COMMAND_MEMORY_IN_PLACE=1) out of its dirty
state, a hot page (KYTY_HOT_PAGE_WRITE_WATCH=1) stays writable once it
is no longer GPU-dirty, and the record relied on that state lasting
until the bind. A store the hooks miss leaves the record live, and the
bind then discards the depth the store wrote.

The texture cache now holds one page write watcher on every 4 KiB page
that such a record covers, from the fill until the last record on the
page is applied, dropped, replaced, aged out by the GC or unmapped.
Records do not overlap, so only a record's first and last pages are
counted. A guest store to the range through the mapping the record was
made for then faults whatever the buffer cache's state, unless the
page is hot, into TextureCache::InvalidateMemory, which drops the
records of fills on the GPU on every page it touches: the fault
reports one byte, and the faulting store, like a host write that
TryPrepareHostWrite prepares, has to get through. Records of fills
done in memory are still dropped only over the written range.
FindDepthTarget collects hot-page writes over the metadata range before
the insertion. A fill on that path outside the guest address ranges is
not recorded.

CheckFilledMetaClearReachesBind checks that such a record holds a page
watcher until it is applied, also after it is replaced, and none for a
fill done in memory; that two records, and 300 records, more than the
page manager's 8-bit watcher count, hold one page until they are gone;
that a record over three pages protects all three and keeps its last
page protected while another record on it is live; that a write fault
elsewhere on its page through RenderContext::HandleFault, an
invalidation elsewhere on the page, the GC age, an unmap and a written
binding drop it and release the page; and that two fills in memory of
the two layers on one page still clear both layers.

kyty_shim_depth_meta_fill replays handwritten agc_frame_replay
captures: a compute image store registers an image over the HTile range
of a two-layer depth target, a handwritten uniform buffer fill
(buffer_store_format_x) then fills that range on the GPU path, and the
depth target, recreated over a one-layer target without HTile, is drawn
per layer with a LESS depth test against stored depth below the clear
value. A fill with ZMask 0 over both layers clears both, over the first
layer only the first, and a fill with ZMask 15 none. A host store into
the second layer's HTile between the fill and the bind, applied by the
replay as a memory delta, drops the record, so both layers keep their
depth. No fill over a registered range is consumed in memory, and a
fill over an unregistered range is, which shows that check can fail.
tools/lavapipe_skip.txt leaves the test out of the lavapipe job, with
the device requirement it gives for kyty_shim_depth_target_alias.
@SleglJan
SleglJan force-pushed the kyty-c1-pending-meta-clear branch from dcc33e7 to ecb8aa6 Compare November 26, 2026 12:59
@SleglJan

Copy link
Copy Markdown
Contributor Author

Pushed ecb8aa6185. The branch is rebased onto the current AnyKyty tip 688dbf145d. Its first two commits are unchanged apart from hunk context, and a third commit handles the records of fills on the GPU.

Detect or decline. The third commit detects an intervening overwrite through the mapping the record was made for. The record holds its own page watcher, so such a store faults into the write hooks whatever the buffer cache's state. On a hot page the store does not fault, but FindDepthTarget collects the page's writes before the bind. A store through another mapping of the same memory still bypasses the hooks, as for images, and that case is neither detected nor declined. I did not decline records of fills on the GPU instead: in the counter run below they set 57,907 of the 57,923 slices that records cleared at an insertion (the other 16 came from fills done in memory), so declining them would leave 16 of those clears. The counter does not separate entries that would have started cleared anyway.

Records of fills on the GPU. At the bind such a record has no backing to check, so only a write hook cancels it, and a guest store reaches the hooks only through a write fault or, on a hot page, a collect.

  • On the previous head, in the default configuration, a guest store into a slice that a record can clear already faults and drops the record, as long as the fill's pages stay GPU-dirty until the bind. This covers stores through the mapping the record was made for.
    • Kyty requires a 32 KiB-aligned HTile (depthRenderTarget.cpp), and each layer's HTile is a whole number of 32 KiB units (TileGetHtileSize in tile.cpp). So every slice a record can clear lies on 4 KiB pages that the record covers whole, and a store into such a slice overlaps the record.
    • The buffer cache keeps those pages inaccessible while they are GPU-dirty. A refused dispatch fill writes its range through a written buffer binding: BufferCache::SynchronizeBuffer calls MemoryTracker::ForEachUploadRange with is_written, and UploadWritten marks the range GPU-dirty (RegionManager::ChangeState<DirtySource::Gpu, true>), so its pages have no access. FillBuffer takes its GPU path only for a range that is GPU-modified, served in place, or has a deferred label pending.
    • A store into such a slice therefore faults into RenderContext::HandleFault, then TextureCache::InvalidateMemory, which drops the record. That is why the overwrite case of the replay test below also passes on the previous head.
  • That protection is the buffer cache's state, not the record's:
    • In-place memory (KYTY_COMMAND_MEMORY_IN_PLACE=1) is kept out of that state.
    • A hot page (KYTY_HOT_PAGE_WRITE_WATCH=1) has no access while it is GPU-dirty, but is writable once it is not, and its writes reach InvalidateMemory only at a collect.
    • I have not traced every change to that state between a fill and a bind.

The third commit makes the protection the record's own, independent of the buffer cache's state. In 007 it keeps the band-event reduction, with FPS and CPU within the run-to-run spread (below). If you'd rather rely on the buffer cache's state, I'll drop the third commit.

  • Page watcher. The texture cache holds one page write watcher on every 4 KiB page such a record covers. It holds it from the fill until the last record on the page is applied, dropped, replaced, aged out by the GC or unmapped. Records do not overlap, so only a record's first and last pages are counted.
  • Write faults. A store to the range then faults into TextureCache::InvalidateMemory whatever the buffer cache's state, unless the page is hot. That call drops the records of fills on the GPU on every page it touches. The fault reports one byte, and the faulting store has to get through, as does a host write that TryPrepareHostWrite prepares through the same call.
  • Fills done in memory. Their records are still dropped only over the written range, and keep the word check at the bind.
  • Hot pages. FindDepthTarget collects hot-page writes over the metadata range before the insertion.
  • Outside guest ranges. A fill on that path outside the guest address ranges is not recorded.

Limits:

  • Other mappings. A store through another mapping of the same memory does not fault, as for images. The record then still applies, and the bind discards the depth that store wrote (see the top).
  • Whole records. A record is dropped whole, so a store into one layer's HTile also drops the other layers' clear.
  • Whole pages. A write that reaches TextureCache::InvalidateMemory anywhere on a page the record covers drops it, also outside the record's range: a guest store's fault, a host write, or a completion write through WriteFromCompletion. The other hooks drop over the exact range. In the counter run below, no record was dropped only because of that widening.
  • Cost. The watcher is added and released on every 4 KiB page a record covers (32,115,593 pages over the counter run's 368,677 records). A page that had no watcher also costs a protection change at the fill and at the release, and a CPU write to it one fault; in the counter run no page was unwatched at record time and no extra fault occurred. The FPS and CPU numbers below include that cost.

Tests that tell the two commits apart. On the first two commits rebased onto dcdde0a389, with only the new test files added and every failing check printed, these six cases of CheckFilledMetaClearReachesBind fail (eight checks; the three-page case fails three):

  • a record of a fill on the GPU, also after it is replaced, holds a page watcher until it is applied;
  • an invalidation elsewhere on its page drops it;
  • a write fault elsewhere on its page, through RenderContext::HandleFault, drops it;
  • two records on one page hold it until both are gone;
  • 300 records on one page hold it until they are dropped (one watcher per page, since the page manager's count has 8 bits);
  • a record over three pages protects all three, and its last page stays protected while another record on it is live.

These cases test the third commit's mechanism. They do not show a store that the previous head misses in 007.

These new cases pass on both commits:

  • no watcher for a fill done in memory;
  • the release on the GC age, on an unmap and on a written binding (on the previous head trivially, since it holds no watcher);
  • two fills in memory of the two layers on one page still clearing both.

Replay test. kyty_shim_depth_meta_fill replays five handwritten agc_frame_replay captures:

  1. A compute image store registers an R8 image over the HTile range of a two-layer Z32 depth target.
  2. A uniform buffer fill then fills that range: buffer_store_format_x at tid + 64 * group, value from user data. TryConsumeComputeFill refuses it because the range is registered, so it runs on the GPU and DispatchDirect records it.
  3. The depth target is recreated over a one-layer target without HTile, since a new target starts fully cleared.
  4. Each layer is drawn with a LESS test at 0.25 against stored depth 0.0 and clear value 1.0. The second layer is drawn first, because the bind clears the whole view from its base layer.

The results:

  • A fill with ZMask 0 over both layers clears both. A fill over the first layer clears only the first, and a fill with ZMask 15 clears neither.
  • A host store of four expanded HTile words into the second layer's HTile, which the replay applies as a memory delta between the fill and the bind, drops the record, so both layers keep their depth.
  • The replay child runs with KYTY_PRINTF_DIRECTION=Console, so consumed fills are logged. No fill over the registered range is consumed in memory. A fill over an unregistered range is consumed, which shows that this check can fail.

The replay test passes on both commits. It shows the path end to end: in these captures the fill leaves the pages GPU-dirty, so the store faults without the watcher. The unit cases above are what tell the two commits apart. The commit adds the test to tools/lavapipe_skip.txt, like the other replay tests through the Kyty renderer, so CI's lavapipe job does not run it.

Tests (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.6, Linux):

  • ctest -R '^(kyty_shim_.*|guest_gpu_fault|guest_host_write_filter|agc_kyty_shaders)$': 115 tests on 688dbf145d and 116 on this branch (the new replay test). The result is the same per test: all pass, except that kyty_shim_rt_corpus and kyty_shim_wave_split_written_reads are skipped on both. The third commit on dcdde0a389, where the 007 runs below were made, gives the same.
  • kyty_shim_image_write_back_alias and kyty_shim_depth_meta_fill pass with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1. The loader inserts the layer for each of the six test processes (the alias test and five replays), and no VUID- lines appear. On 688dbf145d the alias test's validation run also shows the layer inserted and no VUID- lines.
  • The same two tests pass on lavapipe here (VK_DRIVER_FILES set to the lavapipe manifest only, Mesa 26.2.6, LLVM 23.1.4), in 2.8 s and 3.2 s. On RADV the replay test takes 0.4 s. This lavapipe also passes kyty_shim_depth_target_alias, kyty_shim_buffer_null_range and kyty_shim_empty_buffer_replay, which tools/lavapipe_skip.txt lists, so the reason given there does not hold for this lavapipe. I have not run CI's lavapipe. The new entry gives the same reason as those tests; if you'd rather let CI decide, I'll remove it.
  • tools/check_conventions.py --base 688dbf145d and tools/check_kyty_settings.py pass.

007 (the one-frame black band on the player character, Refs #98): band events per 10 s of gameplay, counted by the frame-difference detector of #98, in the setup of series B in the PR's Tested section (24-34 s of gameplay per run). Three builds on dcdde0a389, the AnyKyty tip when the runs were planned, three runs each, in the order T B S, B S T, S T B, with the rules fixed before the runs:

Build Runs Mean
T: dcdde0a389 12.33, 13.42, 9.82 11.86
B: the first two commits on it 0.91, 0.00, 0.00 0.30
S: all three commits on it 0.62, 0.00, 0.00 0.21
  • Rules. The comparison is read only if B's mean is at most 0.7 × T's: met, 0.30 against 8.30. The third commit keeps the effect if S's mean is at most B's plus 1.0 and at most 0.7 × T's, and no S run reaches 9.0: met, 0.21, with a highest run of 0.62.
  • What S is. S was built from an earlier version of the third commit with the same runtime code. The pushed commit differs from it only in the two test files and tools/lavapipe_skip.txt.
  • FPS over the same spans: T 39.70 (38.81-40.30), B 38.94 (36.70-41.48), S 38.18 (35.25-40.93). They come from the frame counter at 4-6 screen samples per run, so they are coarse.
  • CPU of the title's cgroup per second: T 4.85 (4.71-5.04) cores, B 4.88 (4.69-5.13), S 4.77 (4.75-4.78). For both FPS and CPU, S against B is within the run-to-run spread, by a rule fixed before the runs.
  • Counter run. One run of a build with diagnostic counters (not part of the PR; same setup, not scored):
    • 368,677 records of fills on the GPU, covering 32,115,593 tracker pages in all.
    • None of those pages was unwatched when recorded, so the watcher did not change a page's protection at the fill.
    • No write fault hit a page with a record, so the watcher caused no extra fault.
    • No record was dropped only because a write landed elsewhere on its page.
    • 2,639 protection changes fell inside the watcher's adds and releases. The count includes other threads' changes in the same windows, and a window that spans the page manager's 10 s counter reset counts 0.
    • 57,907 records set a slice at an insertion (57,907 slices; records of fills done in memory set 16), and 57 aged out.

Windows: @Celegans12, thanks for the Windows Vulkan run (RTX 3080 Laptop, NVIDIA 621.14, validation layer on), where the alias test passed 3 of 3 with no VUID lines. It was on the previous head dcc33e7251 (on 7de61e3451), so it covers neither the third commit nor kyty_shim_depth_meta_fill. I have no Windows machine with Vulkan here, so this push has no Windows result.

@simnJS, ready for another look.

AI-assisted: yes (Claude Code)

@Celegans12

Copy link
Copy Markdown
Collaborator

I re-ran the Windows check on ecb8aa6185, built as is on 688dbf145d, and everything passes on the RTX 3080 with no validation errors. Same setup as last time: i9-11900H, RTX 3080 Laptop, NVIDIA 621.14, Windows 11, plain Release with BUILD_TESTING=ON, ANYPS5_REQUIRE_VULKAN=1, the Khronos validation layer on (SDK 1.4.363), and the loader limited to NVIDIA's driver (VK_LOADER_DRIVERS_SELECT=*nv-vk64.json, ANYPS5_GPU=NVIDIA).

kyty_shim_image_write_back_alias passed 3 of 3 (1.90, 1.86 and 1.81 s), and the log names the RTX 3080 as the device. kyty_shim_depth_meta_fill passed 3 of 3 too (3.00, 2.71 and 2.75 s), with the layer inserted in all five replays each time. The replay test only passes on its VUID and layer lines, so it doesn't show the device, but with that loader setting the 3080 is the only Vulkan device there is. The full ^kyty_shim_ set came out at 105 of 105, with kyty_shim_rt_corpus skipped (no corpus here), and there are no VUID lines anywhere. bda_load_forms and wave_split_written_reads now pass in about 1 s each, so the old timeouts are gone.

Here's how I read the new head against the open points:

  • Host overwrite after a GPU fill: covered for stores through the guest mapping. A record of a GPU fill now keeps a write watcher on its pages until it's applied, dropped or aged out, so a store faults into InvalidateMemory and drops the record even when the buffer cache leaves the page writable. Hot pages are collected before the bind. As you say, a store through a second mapping of the same memory doesn't fault and still isn't caught.
  • Replay test: in. kyty_shim_depth_meta_fill covers both layers, one layer, ZMask 15, and a host store into the second layer before the bind. As you note, it passes on the previous head as well, so the unit cases in CheckFilledMetaClearReachesBind are what tell the new commit apart.
  • Rebase: done. The branch is on the current AnyKyty (688dbf145d), with nothing new upstream since.

AI-assisted: yes

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.

3 participants