fix(agc): wait for recorded writes over a sampled texture's DCC keys before reading them #4554
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4554"
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 queeeef on 2026-10-12T15:33:57Z.
What
Fixes #4552.
textureClearKeysreads a sampled texture's DCC keys through a raw pointer, past the flush hook, so GPU writes the recorder holds for the key range are not in the bytes yet. A title that clears a target's keys with a kernel and samples the target in the same batch had its keys read from the memory's previous contents. In Palworld those were float data from a reused transient heap, so the keys read as mixed and the texels were read as stored.textureClearKeyscallsWaitForKeyWriters, the functionProvedKeysalready uses for storage images, and reads the keys again.WaitForKeyWritersanswers from the pending fills and stores it knows, and otherwise waits for the batch that writes the keys.Tested
Windows 11 Pro 26300, RTX 2080 Ti (NVIDIA 610.74), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
BUILD_TESTING=ON, atmaind592d54e1.RunSampledKeysBehindKernelinagc_driver_dcc_keys_first_write.00 00 80 3f(1.0f), and the sampled texture's keys first read as stored, as before.0000clear kernel over both halves of the keys, without waiting, and reads the keys again.Clear0000, and after the batch the key bytes are0x00.a sampled texture whose keys a recorded kernel stores 0000 over read uncompressed before the kernel ran.ctest --timeout 120 --parallel 12 -E '^agc_driver_bda_device$': 970 tests passed, 7 of them skipped (expected percheck_skips.py --job windows).agc_driver_bda_devicewas not run: on this machine an older base lost the device in it, which also resets the display.check_conventions.py,check_test_registration.pyandgit diff --checkpass.Palworld (PPSA23126):
The menu has no texture this change applies to, so the difference there is run-to-run variation, not a cost. The change does not restore the colours of Palworld's world, which have another cause.
Not tested: Linux.
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 MarcZX10 on 2026-10-12T18:29:44Z.
I built the exact PR head
c6c8cedccbdc9970bc24d39d6d6892ca21dbe40aon Linux x86-64 with GCC 12.2, Release,BUILD_TESTING=ON, andANYPS5_ENABLE_SPIRV_TOOLS=ON.agc_driver_dcc_keys_first_writepassed 1/1 under Vulkan llvmpipe (LLVM 15.0.6). This validates the focused regression on a software Vulkan driver; I did not run Palworld or test on GPU hardware.Imported from boykopovar/AnyPS5. Originally posted by Nesyth on 2026-10-12T21:03:09Z.
I hit the same bug in Ready or Not (#4184) and opened #4699 before I saw this PR. I'll close mine in favour of this one.
PR waits only when the keys don't decode, so stale keys that do decode are used while a recorded write is about to change them. A copy of your
RunSampledKeysBehindKernelwhose keys start as0xffinstead of float data fails with this PR:TextureClearKeysreturnsUncompressedbefore the new check, where the test expectsClear0000. Checking for a recorded writer over the key range first, ascurrentDccKeysalready does for render targets, covers it and passes your test.On my Ready or Not build (#4184), a counter found 7 reads in one session where this check would have used keys that a recorded write then changes. I couldn't see a visible symptom from them. Happy to post the test if it's useful.
Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-13T01:38:17Z.
A second GPU vendor, and the full suite with
agc_driver_bda_deviceincluded.Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head c6c8cedcc merged into
main284a1c334.agc_driver_dcc_keys_first_writepasses on both GPUs with--repeat until-fail:3. WithDccMetadata.cppas onmainit fails on both witha sampled texture whose keys a recorded kernel stores 0000 over read uncompressed before the kernel ran, as in the description.ctest --timeout 120 --parallel 4, nothing excluded): 1020 of 1020 on both GPUs.agc_driver_bda_devicepasses on both, and neither device was lost.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T01:39:24Z.
Windows NVIDIA cross-test of #4554 at c6c8cedccbdc9970bc24d39d6d6892ca21dbe40a, author-preserved on
codex/first-light-dcc-key-writer-cross-testat 861fe25b9 (parent 010477a53, experimental #757/#758 title integration).With ANYPS5_REQUIRE_VULKAN=1, agc_driver_dcc_keys_first_write and the full mocked agc_driver_graphics suite passed (2/2, 5.37 s). I then removed only the production DccMetadata.cpp change, retaining the new test: the native test failed because a sampled texture read uncompressed before the recorded kernel stored 0000 over its keys. Restored production and rebuilt: 2/2 passed again (5.08 s), without a Vulkan skip.
Next is a separate 007 run with only this DCC change on the previous diagnostic integration. No mixed-table optimization in that comparison. The user reports mostly black frames with bright shapes on our recent runs; this native result does not establish that DCC explains or fixes that rendering.
AI-assisted (Codex). No title code, captures, or assets uploaded.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T01:51:06Z.
007 comparison result for 861fe25b9da540f293554445598265986e5dfb84 (#4554 c6c8cedcc on diagnostic 010477a53): title/menu/background rendered, then Resume at 2026-10-13 01:47:56.4034561 UTC (observed frame 1044). Process exited with 0xc0000005 at 01:49:25.9162966 UTC, about 90 s later. Same RenderThread null read as the preceding diagnostic/mixed-table runs: guest executable RVA 17bd927, read 0x40, rsi=0. This run does not establish #4554 as the cause or a fix for that fault.
Last memory sample: private 20.823 GB, free 4.206 GB; no guard-limit termination. Runtime-table deferred write-back unsupported-operation warnings remain. No steady cinematic/BDA interval or game FPS improvement established. The title/menu images already worked before this change.
One reported indirect-dispatch interval spent 9047 ms in the device call, including 8822 ms of resource construction. Its longest resource build was 4795.5 ms; new sampled snapshots accounted for 4569.6 ms inside it. These are nested CPU wall timings, not additive GPU times or a steady-scene benchmark. The substantial snapshot cost is still present.
Native #4554 positive/production-only negative/restored-positive evidence remains valid; it is separate from this title outcome. Next probe keeps this graphics binary and changes only APS5_SYNC_DRAWS to examine ordering/stability, not to claim an FPS optimization.
AI-assisted (Codex). No title code, dump contents, or captures uploaded.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:43:40Z.
Nesyth's case above is still open: keys that decode (his
0xffexample) return atDccMetadata.cpp:452, before the new check, so a recorded write over them isn't waited for. Please check for a recorded writer over the key range first, as he suggests, and add the0xffvariant ofRunSampledKeysBehindKernel.Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T03:50:02Z.
Confirmed the unresolved uniform-key case on our Windows/RTX5070Ti integration carrying #4554 c6c8cedcc. I extended the synthetic RunSampledKeysBehindKernel fixture with initial uniform 0xff and 0x40 metadata: both fail (returns uncompressed / 0001 while the recorded kernels overwrite the metadata to 0000); the existing mixed-key suite passes. This matches Nesyth and Dean's review above, so I will not open a duplicate PR. I am cross-testing the suggested currentDccKeys ordering locally, including both uniform variants and the original suite. Please send an updated canonical head when ready. No evidence yet that this explains 007's black scene. AI-assisted (Codex); synthetic inputs only.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T03:52:37Z.
Uniform-key follow-up cross-test now available: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-dcc-uniform-writer-probe at 5900427f5c4cbebdb49f985061726d7033e5fa67, parent f8381ecbe (our experimental title integration). Uses Nesyth/Dean's suggested currentDccKeys ordering before decoding any sampled key; keeps the pending known-store memo. No duplicate upstream PR opened.
Production unchanged negative with the new synthetic fixture: initial 0xff returns stale uncompressed, initial 0x40 returns stale 0001 instead of the recorded kernels' 0000. The original mixed-key suite passes. With the local correction both standalone uniform modes pass, and full DCC + mocked graphics pass 2/2, 5.20 s, Vulkan required on Windows/RTX5070Ti. Both variants also run in the regular DCC suite. Scoped conventions/diff checks pass.
Only patched graphics changed to 4673C2C7195228116178AB6C744DB81EB0742C6C3F8F80F21DC7A0D935D21E9C for the next separate warm 007 run; libc/kernel/settings unchanged. No game rendering/FPS benefit claimed yet. Synthetic code only; no title captures or assets uploaded. AI-assisted (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T04:03:55Z.
007 outcome for compiled5900427f5c4cbebdb49f985061726d7033e5fa67 (uniform-DCC ordering + sparse-hole restoration on886; graphics4673C2C7..., libc/kernel unchanged): rendered title/menu/background, then Resume around04:01:12 UTC/frame1051. The loaded scene remained black. Fatal RenderThread read0x40 with rsi=0 at guest executable RVA17bd927 appeared about100s after Resume; process exited0xc0000005 at04:03:07.7847501 UTC. This is the same signature as previous runs, not a newly established cause. Last private memory19.790 GB, free6.225 GB; no memory guard stop.
Unsupported runtime image-table deferred-writeback operations remain. No visible rendering/FPS gain established, and this was a combined-stack comparison, not isolated attribution to DCC or sparse initialization. Post-Resume8 draw-report intervals/48605draws: resources7.235s, lookup7.528s, pipeline0.612s. Includes loading and nested phases, not a steady-frame benchmark. Shader disk cache reached2897hits/0misses.
Native uniform-key reproduction/fix evidence remains separate and valid. Next build is the prepared range-local comparison memo (#2802) + incremental write snapshots (#4889), at b45e164b0; game has exited before starting the build. AI-assisted (Codex); no title code/captures/dumps/assets uploaded.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:24:55Z.
Rebased onto current
main(conflict with the comp-to-single key handling intextureClearKeys) and applied the change @oneandonlydean and @Nesyth asked for:textureClearKeysnow checks for a recorded writer over the key range first (WaitForKeyWriters, ascurrentDccKeysdoes for render targets), before deciding whether the keys decode, so keys that decode (0xff) are covered too. TheClearSinglepath is kept.RunUniformKeysBehindKernel(keys start as0xff, a recorded kernel stores0000over them) next toRunSampledKeysBehindKernel.Checked:
agc_driver_dcc_keys_first_writepasses and fails without the production change; the rest of the libSceAgcDriver ctest passes exceptagc_driver_tessellation, which segfaults inside RADV's pipeline link on this host. Merging once the full Build is green.