Repository navigation
fix(agc): store uncompressed DCC keys at the first write of a fast-cleared image - #903
Conversation
a976f1e to
c99a7be
Compare
|
Tested c99a7be on an R9 380 (Tonga, GFX8, RADV, Mesa 26.0.8, subgroup 64), Ubuntu 26.04, GCC 15.2, Release build. The new agc_driver_dcc_keys_first_write test fails here every time (5 out of 5 runs, also with ANYPS5_NO_SHADER_CACHE=1). The kernel rejects the command stream ("radv/amdgpu: The CS has been rejected, see dmesg for more information (-14)"), vkQueueSubmit then returns -4 (device lost) and the test ends with "the refresh after the one that cleared the image uploaded it again". Right before that it logs "has mixed DCC keys ... its texels are read as stored" for the 128x128 format 56 storage image. The same binary passes on llvmpipe on this machine, so it looks specific to RADV on GCN. The rest of the suite passes (367 of 368, lod_clamp skipped since the card has no shaderResourceMinLod). I also ran all agc_driver_* binaries under the Khronos validation layer with sync validation on and got no errors or hazards, the same as main. I couldn't read dmesg on this box, so I don't have the kernel side of the rejection. Happy to run anything else on this card if it helps. |
c99a7be to
a8ba1c5
Compare
|
Thanks for running this on the 380. Your log was enough to find it, and I'm fairly confident it's a bug in my test, not in GCN or DCC. When the device starts on Linux, the driver checks whether the kernel driver writes to imported pages, and amdgpu does: it re-faults userptr pages for write on every submission. So on any amdgpu card, host imports are taken off the write watch. My test decided its second block was write-watched before that block got imported, so its last check expected a second refresh to skip the upload, which only holds while the watch is on. I get your exact message on NVIDIA when I run that check on unwatched memory. I'm less sure about the CS rejection, but it looks like a side effect. The failed check skipped the final wait, and the test had already freed its memory when the device was torn down. The teardown then submitted the leftover work with userptr BOs whose pages were gone, which amdgpu rejects with -EFAULT. a8ba1c5 fixes the test. It checks the watch again once its block is imported, as the storage refresh test in I'd expect three lines:
There shouldn't be a teardown line. Details
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
adriadam10
left a comment
There was a problem hiding this comment.
Ran it merged onto current main on RADV (RDNA2, amdgpu): build + ctest 401/401. agc_driver_dcc_keys_first_write also passes on CI's lavapipe. On amdgpu it takes the "host imports are compared, not watched" path and passes, so the R9 380 failure looks fixed by a8ba1c5 (@NahuelGenchi, a rerun on GCN would confirm it).
Negative checks: the new execution test fails without the MarkDirty store, without the wait in ProvedKeys, without the fill value in FillBuffer, and without the value on the key store. Two gaps:
tests/Recorder.cpp:2702-2735:agc_driver_graphicsstill passes with every non-test change of the PR reverted tomain, and also with only theMarkDirtystore disabled. Itsdrawdoesn't reachStorageTexture::MarkDirty, so these new checks don't test this change. Please make them reach the storage-image first write, or drop them.Texture.cpp:2105: nothing covers the!IsDccClear(filledKeys)guard. With it removed, both tests still pass. Recorder.cpp:2733-2735 looks meant to cover it, but see the point above. A case inDccKeysFirstWrite.cppwould pin it: a 0x40 key fill after the clear, then a storage write, and the keys must still read 0x40.
a8ba1c5 to
124375c
Compare
|
Thanks for the negative checks; they're what found both gaps. I've pushed 124375c.
While testing this I found one sequence the guard still gets wrong: a 0x40 fill, then a kernel storing 0000 over the keys, then a storage write. On write-watched memory the refresh sees 0000, which matches the keys the image was uploaded under, so DetailsWithout the store: Without the guard: Both fail the same way on an RTX 3080 and on llvmpipe. The merge with current |
…eared image A storage image uploaded under fast-clear DCC keys left the clear code in guest memory until its write-back, so a title kernel that read the keys after a draw or dispatch into the image saw the clear code. PPSA26344's DCC retile kernel copies such keys into its display buffer's metadata every frame, and the flip presented the clear color. MarkDirty now stores uncompressed keys the first time an image uploaded under a clear code is written, unless the title filled the keys with a clear code since, and the image's uploaded keys become uncompressed. While they are, Refresh and the fast revalidation read the keys as the recorded work writing them leaves them: from the bytes pending uniform fills and driver key stores note (NotePendingFill) when those already make the keys read uncompressed (bytes that differ, 0xff, or a byte the format can't use as a clear code), otherwise after waiting for that work.
Co-Authored-By: Claude <noreply@anthropic.com>
124375c to
cfaa336
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Re-checked 124375c merged onto current main on RADV (RDNA2): build + ctest 407/407. Both earlier points are addressed.
Mutation checks on the new test: it fails without the !IsDccClear(filledKeys) guard, without the first-write store, without the fill value in FillBuffer or on the key store, and when WaitForKeyWriters always or never waits. Two mutants survived, so I added a commit with two rows in DccKeysFirstWrite.cpp:
- a pending 0x10 fill overwritten by a pending 0000 fill reads 0000 after waiting (kills sorting
PendingFillsLeaveUncompressedoldest-first); - a pending 0000 fill over the first key half, with 0x10 already in memory in the other half, reads uncompressed without waiting (kills ignoring the keys in memory that no pending fill covers).
Rebased onto main, build + ctest green. Merging once CI is green.
|
Thanks for the two extra rows, both are good catches. I'll leave this branch as it is so it can go in, and send the stale |
What
A storage image uploaded under fast-clear DCC keys kept the clear code in memory until its write-back, so a kernel reading the keys after a write to the image still read it.
StorageTexture::MarkDirty) stores its keys uncompressed (MarkDccUncompressed, as at the write-back) and marks its uploaded keys uncompressed, unless the title filled them with a clear code since (fix(agc): make DCC key fills clear what reads through the surface's keys #163).StorageTexture::ProvedKeys(Refresh, fast revalidation) reads them as the pending work leaves them: fills and our key stores note their byte (Recorder::NotePendingFill), and it waits only while those bytes still allow a clear code.DccKeyCountthey read 0xff.MarkDirty) get it too.fastRevalidate; whichever lands second keeps both.Details
The splash draw (queue 0 +6617) writes a 3840x2160 image at 0x5005160000; the retile kernel (+6693) copies its keys (0x5007140000), still 0x00. The store covers 0x1fe00 of its 0x28000 keys.
Tested
mainee391a5: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 368/368 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_dcc_keys_first_write(plain and write-watched memory): a key copy after a first write reads 0xff; a pending 0x10 fill skips the wait, 0000 fills take it and the refresh clears the image; a write marked after a 0001 key fill, before a refresh, keeps 0x40. Fails without the store or the fill check; does not build on main.agc_driver_recorder_tests(not in ctest) passes on NVIDIA; its key fills now write the keys.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)