agc_driver_recorder_tests fails on Windows since #2096: the refresh store check, plus a more frequent device loss #2155
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T10:08:33Z.
Since #2096 merged,
agc_driver_recorder_testsfails on Windows in every run that gets as far asstorageRefreshTests. A device loss at the same spot also happens before #2096, less often. The test isEXCLUDE_FROM_ALLand not in ctest, so CI doesn't run it.Results
Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. The test was built with
cmake --build . --target agc_driver_recorder_tests.mainb7218b3c(just before #2096)VK_ERROR_DEVICE_LOSTa8b032b2(+ its build fix)VK_ERROR_DEVICE_LOST0e1d25a8(texture comparison only)main43972e69(#2096 merged)43972e69with20cfc013(alias tracking) revertedThe two failures:
AGC graphics: the refresh's store of the results did not reach guest memory, atRecorder.cpp:1672instorageRefreshTests. After a draw andimage->Refresh(), the image holds the draw's texels but guest memory doesn't. It appears only with0e1d25a8(avoid redundant transfers for untracked imported textures).AGC graphics: vkQueueSubmit recorder: Vulkan result -4, right afterhost imports are compared, not watched: unit shadows not tested, at the start ofstorageRefreshTests. When it happens, the refresh-store check never runs. It's intermittent before #2096 too, but came up in 3 or 4 of 5 runs with it.The full ctest passes both before and after (494/494).
Not established
0e1d25a8the refresh of an untracked, compared import takes the new comparison path.🤖 Investigated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T11:27:20Z.
Reproduced on
maind70b8998: Windows 11, RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. The refresh store failure happens in 5 of 5 runs. The device loss did not happen in any run on this GPU, so this comment covers only the refresh store.What happens
I added temporary logging to
StorageTexture::RefreshandwriteBackLayers. The failing refresh is the unwatched pass (VirtualAllocblock):ChangedBlocksfails and 0e1d25a8'scompareUntrackedruns. The guest bytes still match the snapshot taken at upload, so every unit isBlockUnchangedandRefreshreturns early throughif (unchanged).else if (direct) continue;, the same rule as for tracked memory). Nothing is stored at the refresh.0e1d25a8, untracked memory could never be proved unchanged. Every refresh treated all units as changed, and sincedroppableis false without tracking, it stored the pending units. The assertion atRecorder.cpp:1672was written against that behaviour.The results are not lost
Directly after the refresh, guest memory is still
55 55 55 55in every unit. AfterStorageTexture::FlushPending(address, surfaceBytes, nullptr, ...), thenrecorder.Submit(),device.WaitQueue()andrecorder.Sync(), it holdsff 00 00 ffin every unit. The write-back's own comparison saw all blocks unchanged (0 0 0 0), so nothing was dropped as a CPU store. With that flush in place the rest ofagc_driver_recorder_testspasses (Recorder read tracking and label tests passed), 8 of 8 runs.Question
Is keeping the results pending in compared (untracked) memory intended? The CPU's reads of that memory aren't trapped, so the results reach it only at the driver's next flush point for that range. Before
0e1d25a8that flush point was the refresh. If this is intended, the test could check it like this, keeping the strict assertion for watched memory:If it isn't intended, the fix belongs in
Refresh: a compared import with pending results would store them, as before. I can open a PR for whichever direction you prefer.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T13:10:50Z.
I checked the existing Refresh contract and
agc_driver_dcc_keys_first_write: an unchanged image with pending results must remain resident for the next GPU use, andRefresh()is not the CPU visibility barrier for untracked imports. My attempted production write-back causedagc_driver_dcc_keys_first_writeto fail with “an unchanged refresh wrote the pending image back,” so I discarded that approach. PR #2248 updates the recorder regression to assert that the image remains pending, then explicitlyFlushPending, wait, and check guest memory. With that test expectation,agc_driver_recorder_testspasses, andagc_driver_dcc_keys_first_writepasses (1/1).Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:01:29Z.
Found the cause of the device loss. It comes from
unitShadowTests, not from #2096.On Windows, host imports are compared, so
unitShadowTestsreturns right after it imports its 17 MiB block. Its cleanup removes the registration and releases the block. The import stays until the next lookup, which is theHostImportForat the start ofstorageRefreshTests. That retire'svkFreeMemoryruns after the pages are gone.I put
vkQueueWaitIdleprobes around each step. In all 7 device losses out of 20 runs, the queue was healthy just before thatvkFreeMemoryand lost right after it.It only happens when the block is released shortly after the import. In a local probe that imports a 17 MiB block, releases it, then lets the next lookup retire the import, the device was lost in:
That would explain why it's intermittent, and why it may not show up on other GPUs or drivers.
#2299 makes the cleanup retire the import before it releases the block. With #2248 and #2299,
agc_driver_recorder_testspasses 30 of 30 here. With #2299 alone, there was no device loss in 30 runs; all 30 still fail at the refresh store, which #2248 fixes.The runtime unmap path uses the same order.
GuestAllocationsUnmap_nid_postfixreleases the pages before the registry changes, and the import is retired at the next lookup. I haven't checked whether any title releases memory within a millisecond of importing it.🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-09T22:11:56Z.
AMD data point: on the AMD Windows driver the test stops much earlier than in the NVIDIA runs above, in
readTrackingTests, before it reachesstorageRefreshTests.Radeon 860M (RDNA 3.5,
0x1114), AMD driver 24.30.58.08 (32.0.13058.8001), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release,main00159cff. Five of five runs:The check right before it calls
device.WaitQueue()(vkQueueWaitIdle) and expects the batch's fence to read as signaled, but on this driver the fence usually lags the idle wait. A standalone probe (source below) submits to one queue, callsvkQueueWaitIdle, thenvkGetFenceStatus, 2000 times per variant:vkQueueWaitIdlevkGetFenceStatuspolls until readyRecorder::Submitdoes)So
vkQueueWaitIdlereturns before the fence reads as signaled on this driver, almost every time. When I polled the overlap query for a short time, that check passed and the test stopped at the next check of the same kind,a signaled batch's write is not settled(line 271), after the sameWaitQueue()pattern. Production code only treats such a batch as still in flight a little longer, which is conservative. The test, though, would need to wait on the batch's fence (vkWaitForFences) or poll briefly to get past these checks on AMD, before it can show whether #2248 helps with the refresh store here.Probe source (fenceprobe.cpp, g++ -std=c++20 -I3rdparty/Vulkan-Headers/include)
AI-assisted: yes (Claude Code).