Repository navigation
fix(kyty): apply a metadata clear issued before its depth target exists - #289
Conversation
|
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, |
|
Pushed Confirmed on An intermediate version recorded a clear only in
Further cases apply records through
This covers your last point only from Limits that remain:
Tests (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.6, Linux):
007, in the setup of series B in this PR's Tested section (on
The description above still describes AI-assisted: yes (Claude Code) |
|
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. |
|
Windows Vulkan result for
Against the requested changes, as I read the diff:
The rest of the shim set on the same build
AI-assisted: yes |
dcc33e7 to
ecb8aa6
Compare
|
Pushed 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 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.
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.
Limits:
Tests that tell the two commits apart. On the first two commits rebased onto
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:
Replay test.
The results:
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 Tests (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.6, Linux):
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
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 @simnJS, ready for another look. AI-assisted: yes (Claude Code) |
|
I re-ran the Windows check on
Here's how I read the new head against the open points:
AI-assisted: yes |
simnJS
left a comment
There was a problem hiding this comment.
The watcher handles writes through the fill’s mapping. A write through a second mapping of the same HTile backing can leave the GPU fill record live and clear depth at the next bind. Please invalidate by shared backing or decline the optimization where alternate writes cannot be tracked. Add a replay that writes through the second mapping after a GPU fill and checks that the bind preserves existing depth, with a control that still clears when there is no overwrite.
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.
A frame capture can now hold an alias range: FrameCaptureWriter::WriteAlias records a range that maps the same memory as the guest memory range of the same size at the address in its group field, and WriteRange refuses the alias kind, which has no target there. The frame recorder still refuses aliased guest allocations, so only captures written by tests hold one. The replay maps the aliased range and each of its aliases to one direct memory allocation with sceKernelMapDirectMemory at their addresses, read-write for the CPU like the committed ranges and for the GPU when the range is GPU-visible, after it commits the other ranges, instead of committing them from the guest memory file, and restores the snapshot through the aliased range; a reset clears the memory once, through the aliased range. A capture whose alias names no guest memory range of its size fails to replay. The capture filter keeps an alias range's target address, and agc_frame_capture_filter checks that it does.
The page watchers of a record of a fill on the GPU see only stores through the address the record was made for, and a record of a fill done in memory, which the bind checks against the backing, misses a GPU write through another address that has not reached memory. A write through another guest mapping of the same memory, by the guest, the GPU or a host write, leaves the record live, and the bind then clears the depth that the write kept. The shim now counts, for each 16 KiB page of the second view of guest memory, the guest pages that map it, together with a generation that every map and unmap of the page increases. OnViewChange updates both, under the hook mutex, before the map or unmap call returns to the guest, and each page keeps them in one atomic word; a page unmapped more often than it was mapped fails. SoleBackingStamp reports whether every page of a range is in the second view and mapped once and, if so, returns a stamp over the pages' view offsets, counts and generations. Otherwise it reports why: a page is mapped more than once, is private (for example a shared memory or file mapping, whose other mappings the shim does not see) or is not in the second view. TextureCache::NoteMetaFill no longer records a fill over memory that is not mapped once, and drops the records it overlaps. ApplyPendingMetaClears applies a record only if the stamp is unchanged, so a second mapping made after the fill blocks it even if it is unmapped before the bind, and so does a remap of the record's address. TestSoleBacking checks that a direct memory range mapped once keeps its stamp; that a second mapping of one of its pages makes the range and the second mapping read as aliased and leaves the first page's stamp unchanged; that the stamp changes after the second mapping is unmapped and after the range is mapped to other memory; and that flexible memory reads as mapped once and a file mapped twice as private. CheckSharedBackingFill checks that a record of a fill on the GPU over direct memory mapped once clears the HTile; that it is not recorded, and does not protect the range, while a second mapping exists; that a second mapping made after the record blocks it, also when it is unmapped before the bind; that a record of a fill done in memory clears the HTile over memory mapped once and is not kept over memory mapped twice; and that mapping other memory at the record's address blocks a record. kyty_shim_depth_meta_fill adds two replays whose HTile is mapped a second time, one with a host store into the second layer through the second mapping after the fill on the GPU and one without it. The record is declined in both, so the bind keeps the depth of both layers.
ecb8aa6 to
f41e7d8
Compare
|
Pushed Second mapping: declined. The page watchers protect guest addresses, so a watcher that follows the backing would need a backing-to-address index and watchers added on every new mapping from the map hook. That hook runs under libkernel's direct-memory lock, and
Limits:
Replay.
Unit cases, all failing without the fix except where noted:
Tests (AMD Radeon RX 9070 XT, RADV GFX1201, Mesa 26.2.6, Linux):
007: no new A/B. One run of a build of these five commits with diagnostic counters (not part of the PR, not scored; built before a change to
@simnJS, ready for another look. AI-assisted: yes (Claude Code) |
|
I ran the Windows check again on
In the first full On simnJS's request: the PR takes the "decline" route. A fill over HTile memory that is mapped more than once isn't recorded, and at the bind a stamp check throws a record out if a second mapping appeared after the fill. AI-assisted: yes |
simnJS
left a comment
There was a problem hiding this comment.
Reviewed this revision and validated it together with the other changes in the integration branch. The Linux, Windows, sanitizer, and offline checks passed on the exact candidate.
What
RenderExecutor::TryConsumeComputeMetaCleartakes a compute dispatch as a metadata clear only when every buffer it writes covers an entry ofm_surface_metas(TextureCache::CoversMeta). Entries are created inTextureCache::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 hashtile_initial_clear.ResolveDepthOverlapclears 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
FindDepthTargetinserts the entry:HTILE_Z_CLEAR_REGandHTILE_ZS_CLEAR_REGinsrc/amd/common/ac_descriptors.hwrite these fields the same way. A dispatch that is not a uniform fill records nothing.BufferCache::FillBufferrecords the fills it performs (uniform compute buffer fills thatTryConsumeComputeFillconsumes, and CP DMA fills). A uniform buffer fill thatTryConsumeComputeFillresolves but does not consume because an image is registered over its range runs on the GPU;DispatchDirectrecords 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.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 intoTextureCache::InvalidateMemorywhatever 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 thatTryPrepareHostWriteprepares through the same call).FindDepthTargetcollects hot-page writes over the metadata range before the insertion. A fill on that path outside the guest address ranges is not recorded.TextureCache::InvalidateMemory,InvalidateMemoryFromGPU,NoteMetadataWrite,CommitGpuWrite,CopyToImageandUnmapMemorydrop every record that overlaps their range, whole (InvalidateMemorydrops 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 throughForgetColorMetadataChecks, image writes throughCommitGpuWrite(render targets, depth targets, storage images, clears and copies, over the image's whole data range), DMA copies into an image throughCopyToImage(over the copied range) and unmaps.RunGarbageCollectordrops 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.OnViewChange, under the hook mutex, before the map or unmap call returns to the guest; one atomic word per page, written with release and read with one acquire load).SoleBackingStampsays whether every page of a range is in the second view and mapped once and, if so, returns a stamp over the pages' view offsets, counts and generations.NoteMetaFillrecords no fill over memory that is not mapped once (mapped twice, private, for example a shared memory or file mapping, whose other mappings the shim does not see, or outside the second view) and drops the records it overlaps;ApplyPendingMetaClearsapplies a record only if the stamp is unchanged, so a second mapping made after the fill blocks it, also when it is unmapped before the bind, and so does a remap of the record's address. libkernel'sDirectMemoryAliasedis not used: it takes the direct-memory lock that the map path holds while the map hook can wait for the GPU thread.TryReadBacking) still holds the fill value, which also catches CPU and host stores the caches do not see.kyty_shim_image_write_back_aliasgetsCheckFilledMetaClearReachesBind:FillBufferfollowed byFindDepthTargeton 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, throughTextureCacheTestAccess, 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 throughRenderContext::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_image_write_back_aliasalso getsCheckSharedBackingFill, on direct memory: a record of a fill on the GPU over memory mapped once clears the HTile; it is not recorded, and does not protect the range, while a second mapping exists; a second mapping made after the record blocks it, also when it is unmapped before the bind; mapping other memory at the record's address blocks it; a record of a fill done in memory clears over memory mapped once and is not kept over memory mapped twice.kyty_shim_memorygetsTestSoleBacking: a direct memory range mapped once keeps its stamp, a second mapping of its second page makes the range and the second mapping read as aliased and leaves the first page's stamp unchanged, the stamp changes after the second mapping is unmapped and after a remap to other memory, flexible memory reads as mapped once and a file mapped twice as a shared mapping.agc_frame_replaymaps alias ranges:FrameCaptureWriter::WriteAliasrecords a range that maps the same memory as another guest memory range of the same size, and the replay maps both to one direct memory allocation (sceKernelMapDirectMemory,MapFixed). The frame recorder still refuses aliased allocations, so only test captures hold one; the capture filter keeps the target, andagc_frame_capture_filterchecks that it does.kyty_shim_depth_meta_fillreplays handwrittenagc_frame_replaycaptures: 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_xattid + 64 * group, value from user data) fills that range, whichTryConsumeComputeFillrefuses as registered so that it runs on the GPU andDispatchDirectrecords 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. Two captures map the HTile a second time: a host store into the second layer through the second mapping after the fill, and the fill without it; the record is declined in both, so both layers keep their depth (the clearing control is the fill over the HTile mapped once). The store case without the second mapping 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.txtleaves 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 the first three (0.00-0.62). In one counter run of all five on90a48455d2, no fill was declined and no record blocked (see Tested). The first version's series on7de61e3451gave 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 inFillBuffer, 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 thatTryConsumeComputeFillrefused 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 inDispatchDirect.Known limits that can start an entry cleared wrongly:
ResolveDepthOverlap.FillBufferfill 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; a store through another mapping of the same memory does not fault, so a fill over memory mapped twice is not recorded and a record whose memory gains a second mapping before the bind is not applied (see What). libkernel installs the host mapping before it reports the view change, so a store through aMAP_FIXEDaddress while another thread's map call for that address is still inside libkernel is not covered. A hot page stays writable, and its writes reach the hooks only at a collect;FindDepthTargetcollects over the metadata range before the insertion.Known limits that can lose a clear:
DispatchDirecttriesTryConsumeComputeFill. Fills fromDispatchIndirectandDispatchIndirectThreadsare not recorded, and neither is a direct dispatch that has specialization reads (it skips both consume attempts), a fill thatTryConsumeComputeFillturns 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 byReplicateBufferare not recorded either. They run as before.TextureCache::InvalidateMemoryanywhere 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.FindDepthTargetinserts the entry. A fill that overlaps an existing entry records nothing and is handled as before this PR: one that reachesClearMetaat the entry's address marks every slice of that entry cleared, any other (for example one that starts inside the entry, or oneTryConsumeComputeFillrefuses 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):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 andtools/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).90a48455d2with diagnostic counters (not part of the PR, not scored; built before a change toagc_frame_replay's mapping protection, which is not in the title's runtime), in the same setup with a new save for the same route: 373,452 records of fills on the GPU and 8,391 of fills done in memory, none declined and none blocked at the bind for any reason; 57,844 records set 57,844 slices at an insertion, against 15 slices from fills done in memory; 51 records of fills on the GPU aged out. So in that run the two commits changed no record decision. Their cost was not measured: two atomic loads per 16 KiB page (the page's view entry and its count word) at the fill and at the bind, and one atomic word update per page on each map and unmap; a remap first releases the old pages.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|agc_frame_capture_filter|agc_driver_frame_replay_submits|agc_driver_frame_replay_shader_output|frame_replay_compare|frame_replay_report)$'selects 121 tests on the AnyKyty tip90a48455d2and 122 on this PR (the new replay test). All pass on both, exceptkyty_shim_rt_corpusandkyty_shim_wave_split_written_reads, which are skipped on both.kyty_shim_image_write_back_aliasandkyty_shim_depth_meta_fillpass withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1; the loader inserts the layer for each of the eight test processes and noVUID-lines appear. They also pass on lavapipe here (Mesa 26.2.6, llvmpipe on LLVM 23.1.4) in 2.9 s and 4.3 s; on RADV the replay test takes 0.6 s. In the earlier run onecb8aa6185, this lavapipe also passed three tests thattools/lavapipe_skip.txtlists (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.kyty_shim_tests, but it reportskyty_shim_image_write_back_aliasandkyty_shim_depth_meta_fillas skipped (as onecb8aa6185, which these tests do when they find no usable Vulkan device), andkyty_shim_memoryis registered on Linux only. Celegans12's run onf41e7d80e3(RTX 3080 Laptop, NVIDIA 621.14, Windows 11, validation layer on), comment: both tests 3 of 3, includingCheckSharedBackingFilland the two second-mapping replays,agc_frame_capture_filterpassed, noVUID-lines; in one of two fullkyty_shim_passeskyty_shim_depth_target_aliastimed out at 120 s aftercontrol: okand passed 3 of 3 on its own and in the other pass. Before that, Celegans12's run onecb8aa6185(RTX 3080 Laptop, NVIDIA 621.14, validation layer on), comment:kyty_shim_image_write_back_aliasandkyty_shim_depth_meta_fill3 of 3 each, thekyty_shim_set 105 of 105 withkyty_shim_rt_corpusskipped, noVUID-lines.dcdde0a389with only the third commit's 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. The third commit'skyty_shim_depth_meta_fillpasses there too: the fill leaves the pages GPU-dirty, so the store faults without the record's own watcher.90a48455d2with only the replay support and the new test files added, every failing check printed:CheckSharedBackingFillfails six checks (all but the two over memory mapped once), and both second-mapping replays clear depth: the record applies there, and nothing cancels it.f19d97375a, with only the check's twelveFillBuffer/FindDepthTargetcases (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".CommitGpuWriteandCopyToImagehooks 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.TryConsumeComputeFill's call toFillBuffermakes (the replay's consumed case checks only that the fill is consumed), theCopyToImagehook (the DMA copy case copies into a buffer), the hot-page collect inFindDepthTarget, in-place memory (KYTY_COMMAND_MEMORY_IN_PLACE=1), the release of the page watchers in the texture cache's destructor, and, in a replay, a second mapping made after the fill (a capture cannot map during the replay;CheckSharedBackingFillcovers it).tools/check_conventions.py --base 90a48455d2andtools/check_kyty_settings.pypass.git merge-treemerges the branch into the AnyKyty tip90a48455d2without conflicts.First version (
f19d97375a), measured before the change request; "the change" below is the first versionDiagnosis (done for the first version), with diagnostic logging (not part of this PR) on
7de61e3451plus #278 (2f755a3c46, the only other change on that line), 850 logged frames per run, of which 776-806 in gameplay:ResolveDepthOverlap(nohtile_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.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, on7de61e3451), with the first version on top. Series B: the first version on7de61e3451. 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.7de61e3451Cost 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
GPUActivestays above 1.5 GB.GPUActive(/proc/meminfo), gameplay, GBamd-requested-vram(title's DRM fdinfo), gameplay, GBGameplay 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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code