test(agc): require a repeated draw to reuse the cached draw #2980
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2980"
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 JAB-dev on 2026-10-10T19:25:15Z.
What
Follow-up to #2900: a test that catches that draw-cache regression. The same draw submitted twice must reuse the cached draw the second time; with the #2900 fix removed, it fails.
The test registers a vertex and a pixel shader and submits one DCB that issues two identical
DRAW_INDEX_AUTOdraws, then reads the driver's draw-cache counters. It requires 2 lookups, 1 hit and no misses on the push-offset layout. It runs twice:agc_driver_draw_cache_reuse(pipeline libraries on, so the pixel stage uses the fixed push slot) andagc_driver_draw_cache_reuse_off(APS5_NO_GPL=1, registered likeagc_driver_flip_compute). It skips with 77 when there is no Vulkan device, and the first one also skips when the device has no pipeline libraries, since it would not test the fixed slot there.It checks the cache through its counters, the way the other cache tests do:
ShaderDiskCache.cppasserts onShaderDiskCache::Totals()hits and misses,Recorder.cpponRecorder::ReadCounts()andPipelineLibraryCountersOf, andBdaResources.cpponMirrorCounters(). For that the driver gets one small read-only accessor,Driver::DrawCacheCounters(), which returns a copy of the counters underdrawCacheMutex. The device setup andAgcDriverShutdown_nid_postfixfollowDwordPatternFill.cpp.Tested
Windows 11, WinLibs GCC 15.2.0, RTX 4070 SUPER.
DrawLookup.cppremoved:agc_driver_draw_cache_reusefails ("the repeated draw missed the draw cache on its push offset (1 layout misses)");agc_driver_draw_cache_reuse_offstill passes, as expected, since the bug needs fixed push slots.agc_pipeline_library,agc_pipeline_library_off,agc_pipeline_library_fast_only,agc_recorder_kept_bytes,agc_driver,agc_driver_graphicspass.tools/check_conventions.py --base origin/mainpasses. Rebased onmain4a747c487.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T21:54:29Z.
@JAB-dev sorry, I hadn't seen this one when I offered a test on #2900. Yours came first and covers what matters, the repeated draw actually hitting the cache on a real device.
The only thing mine (AlxcBTW/AnyPS5#29) adds is a device-free check of the lookup walk: it moves the stage walk into
Driver::MatchDrawEntryand tests the fixed-slot and packed layouts without Vulkan, so it also runs on CI runners where yours skips (no device on the Windows runner, and no pipeline libraries on some others). If that's useful I can rebase it on top of yours as a small follow-up; if not, I'll close it. Your call.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T22:38:12Z.
Linux run, since the description says it wasn't tested there:
bddcc71e, GCC 16.2.1,ANYPS5_REQUIRE_VULKAN=1 ctest -R agc_driver_draw_cache_reuse --repeat until-fail:100. Bothagc_driver_draw_cache_reuseandagc_driver_draw_cache_reuse_offpass 100 of 100 on an RTX 5080 (NVIDIA 615.78.08) and on a Radeon 610M (RADV).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:46:48Z.
Checked on the PR merged onto main: both new tests pass, and with the
StagePushOffsetline removed fromDrawLookup.cppagc_driver_draw_cache_reusefails with "1 layout misses" while the_offvariant still passes, as described. The accessor is read-only underdrawCacheMutex. Also confirmed on Linux by @fma-rc (RTX 5080 and RADV). Merging once the full Linux/Windows build is green.Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-11T09:39:22Z.
Windows + NVIDIA data point for the new test, since CI skips it without a GPU: on Windows 11 Pro 26300, RTX 4080 driver 616.56, WinLibs GCC 15.2.0 r7,
main09bd4aa1(+#1482),agc_driver_draw_cache_reusecrashed in 2 of 17 runs and passed the other 15 (andagc_driver_draw_cache_reuse_off3/3):ctest --parallel 4), after 6.39 s:FATAL: unhandled exception 0xc0000005,rip nvgpucomp64.dll+0x1a580f,write of 0x0000000000000000;0xc0000374(heap corruption), no AnyPS5 frame reported.Both are inside or right after NVIDIA's shader compiler DLL, so either a driver fault on what the test's pipelines feed it or a corruption on our side that the driver trips over; 10 further serial runs passed, so it is intermittent, not a layout or format gap.
AI-assisted: yes (Claude Code Fable 5.1 xhigh)
Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-11T13:09:04Z.
@orishamir reproduced here (Windows 11, RTX 5070 Laptop, 616.92), and it's ours, not the driver.
With MinGW's emulated TLS, winpthread frees a thread's
thread_localstorage before the module's thread-detach runs thethread_localdestructors. So whenDriver::stopjoins the queue worker, the driver'sthread_localmap, vectors and image memo are destroyed on freed memory.agc_driver_draw_cache_reusestopped there in 127 of 127 runs, also withAPS5_NO_PIPELINE_LTO=1andAPS5_NO_GPL=1.0xc0000374in 2 of 143 runs with a cold NVIDIA shader cache.nvgpucomp64write is most likely the next allocation landing on the damaged heap.It's the teardown bug on #3171; details, and a branch that fixes it with a test, are there.
AI-assisted: yes (Claude Code)