fix(agc): keep a mipmapped DCC color target's keys on its resident image #9597
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9597"
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 milescoviello on 2026-10-22T03:57:26Z.
What
A 2D color target with more than one mip and DCC enabled renders into a resident image without its keys, so later reads of it see the game's fast-clear keys instead of what was drawn.
On
main:DecodeColorBufferdrops the DCC address of a target whoseCB_COLOR_ATTRIB2.MAX_MIPis above 0, and prints "DCC keys of mipmapped color targets are ignored" once.SurfaceForTargetcopiesdccAddressinto the resident surface, so the target's resident image has no keys either. It's uploaded from guest memory, and a draw into it never marks the keys uncompressed.Clear0000: (0,0,0,0), whatever the draws wrote.MXGP 26 (PPSA30839), Borderlands 4 (PPSA01494) and Forspoken (PPSA03984) all print that line. In one 900 s MXGP run (#9510), with a local print of every DCC key read:
The change:
ColorTargetgainschainDccAddress.DecodeColorBuffersets it, plusdccAlphaOnMsbanddccPipeAligned, for a 2D single-layer target with mips.dccAddressstays 0, so the per-draw handling written for one mip's keys (clear materialization, recipe key proofs, CB metadata passes) is unchanged.SurfaceForTargetgives the resident surfacechainDccAddresswhendccAddressis 0. The resident image then handles the keys the way a multi-mip DCC storage image already does: a uniform clear over all keys is cleared on the GPU at upload (ClearColorFor), and the first write marks all of them uncompressed (StorageTexture::MarkDirty).StorageImageServesKeys) takes the surface's address, so recipes keep matching the image.sizeof(State)grows by the one field (832 to 840 on Linux on currentmain, inPipelineJournal.cpp's check). The recipe codec andCanonicalPipelineStatecopy only a color target's format, export index and component mapping, so neither changes, andFileFormatstays.ClearRegisterkeys on such a target, the copied (non-resident) draw path, and the refusal in CB metadata passes.Overlap:
tools/pr_overlap.pyfinds one shared line with #6612, #6639, #6801, #7948 and #9450: thesizeof(State)check inPipelineJournal.cpp. The integration order for that line:sizeof(State).None of them is a prerequisite of this change, so
Depends onstays none. #8707 (LeoFeitosa) changes how a multi-mip DCC storage image stores its units at write-back, which these resident images now are too. The two don't touch the same code.Tested
maincf528e78c6as52f36c8aa2(10-24, after MarcZX10's current-main request). The rebase applied cleanly but dropped the size check's line:mainhad moved it to 832 in the meantime. The build'sstatic_assertcaught it (840 == 832), and the check is now 840,main's 832 plus this PR'schainDccAddress. The journal format staysmain's 10, since the field isn't journaled. Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, 615.71.09):agc_driver_graphicsandagc_driver_dcc_keys_first_writepass 3 of 3. Khronos validation 1.4.363 over both, onmainand on this head: both pass, no layer-missing line, noVUID-message on either side.mainb7a451d62bas7f0f0d89fc, after #6801 merged. #6801 grewStateto 824 bytes, and the one conflict was the size check, now 832 with this PR'schainDccAddress. The build'sstatic_assertconfirms it on the rebased tree.agc_driver_graphicsandagc_driver_dcc_keys_first_writepass 3 of 3 on Linux. With the Khronos validation layer (1.4.363), both pass onmainand on this head with no VUID. On the Windows 11 VM (GT 1030, R580), both pass 3 of 3 on the merge base and on this head.mainf6075c2f4aas2d66748443, after #7948 merged, as the integration order planned. #7948 grewStatefrom 784 to 800 bytes, and the one conflict was the size check, now 808:main's 800 plus this PR's 8. The build confirms it. On that head (Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, 615.71.09),agc_driver_graphicsandagc_driver_dcc_keys_first_writepass 3 of 3. Under Khronos 1.4.363 both pass onmainand on this head, with no VUID on either side.mainb7d1d47a5fas2f1fc22a24, with no conflicts;git range-diffshows the commit unchanged.main'sStatewas still 784 bytes then, so this PR's size check stayed at 792. On that head:agc_driver_graphicsandagc_driver_dcc_keys_first_writepass 3 of 3.mainb7d1d47a5fand on this head, same machine and same command as below: the layer loads, both tests pass on both sides, and no VUID is reported on either.maincc0078595d(c58d567e2d) also passed on the Windows 11 VM, 3 of 3 on the merge base and on that head.main6ef5a1c4c9:agc_driver_graphicsandagc_driver_dcc_keys_first_writepass 3 of 3. The tree is the same as head8bc99610a5; only the commit message changed after the runs.agc_driver_graphics: a decoded mipmapped DCC target keepsdccAddress0, and itsSurfaceForTargethas two mips and the keys. A mipmapped DCC array target's surface still has none.agc_driver_dcc_keys_first_write(RunMipmappedTarget, not on Windows, like the other cases that take the device's context): a 64x64, seven-mip DCC target is decoded from registers, with its texels 0x55 and its keys 0x00. Its resident image is uploaded cleared (UploadedKeys()isClear0000). AfterMarkDirty()the keys read uncompressed, and so does a texture lookup'sTextureClearKeys.main'sState.cpp,State.hpp,Draw.cppandPipelineJournal.cpp, and this branch's tests:agc_driver_graphicsfails with "the surface of a mipmapped DCC color target lost its keys".agc_driver_dcc_keys_first_writefails with "the resident surface of a mipmapped DCC color target has no keys".ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V, onmainand on this branch, same machine. The layer was found, both tests pass on both sides, and there's noVUID-message on either.agc_driver_graphicscheck covers the change.StoredKeyCountskips the store over it.1688e5abb8(currentmainplus the port), with this head's diff applied.^agcsuite (856 tests) shows the same failures as the port's base, apart from one run ofagc_driver_uint8x4_color_target, which is intermittent there without this change too.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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:07:41Z.
Review: CHANGES_REQUESTED
The resident surface now receives the mip-chain DCC address only for single-layer 2D targets, while array/3D behavior remains excluded; the added decode and first-write checks exercise clear-key upload and the transition to uncompressed keys. The report includes a same-machine main/change validation-layer comparison and a measured MXGP run. I found no additional implementation blocker. Hosted conventions, eligibility, intake, labels and report checks pass; hosted product/relinker jobs are skipped. The detailed runtime/test claims are author-reported; I did not run tests locally.
One repository overlap requirement remains: the PR identifies the shared
sizeof(State)assertion with open PRs #6612, #6639, #6801, #7948 and #9450, but does not record an agreed integration order with those authors. Please coordinate which changes land first, keep each assertion at the resultingStatesize, and addDepends onwherever one must land before this PR. The note that the later PR will update the size describes a rebase, but is not yet recorded author agreement.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T04:12:08Z.
@MarcZX10 thanks. A proposed integration order for the one shared line, the
sizeof(State)check inPipelineJournal.cpp:This PR goes after #6612, #6639, #6801, #7948 and #9450. None of them needs this PR, and this PR needs none of them. After each one merges, I'll rebase this onto
mainand set the check tomain's size plus this field's 8 bytes. The other five don't have to rebase for this one.Once you've answered, the
Depends online will say "after #6612, #6639, #6801, #7948 and #9450".AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T09:58:51Z.
I rechecked this against the current queue and exact head
8bc99610a5. The implementation and added tests are scoped to single-layer 2D mipmapped color targets; array/3D targets remain excluded. Exact-head conventions andgit diff --checkpass. Hosted eligibility, conventions, intake, labels and report pass, while product/relinker checks are skipped. The author reports focused Linux/Windows tests, a validation-layer A/B, and an MXGP run, but the tested baseline is6ef5a1c4c9; currentmainhas advanced 100 commits beyond this branch. Please rebase onto currentmain, rerun the focused tests and the paired validation-layer checks, and refresh the title evidence if the merge changes the relevant code path.The report demonstrates a wrong DCC-key result for mipmapped targets used by PPSA30839, even though it says this change does not fix the black surfaces tracked by #9510. I could not find a Game bring-up discussion for PPSA30839. Please locate or create the title discussion, list this PR there, and put
Unblocks: PPSA30839 #<discussion>on the checklist if this is the title-visible wrong result the change fixes. KeepFixes: nonefor #9510 unless the reported black-surface issue is actually resolved.The existing PR overlap review also remains open: the
sizeof(State)line is shared with #6612, #6639, #6801, #7948 and #9450. The proposed order is not yet agreement from the other listed authors. Please record their agreement, add the actualDepends onentries to the checklist where needed, and preserve the size assertion as each preceding change lands. The rebase should refresh this line against currentStatesize.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T10:22:56Z.
@MarcZX10 done:
maincc0078595dasc58d567e2d, with no conflicts.mainor on this head.Draw.cppline is inDrawWithRecipe, which #8992's prepare/record split left unchanged. So the merge doesn't touch the code the MXGP run exercised, and I kept that run's results, marked as from the pre-rebase head.Unblocksstays none (pointing at #9725) andFixesstays none.The order for the
sizeof(State)line still has no answer from the other authors.main'sStateis still 784 bytes, so this PR's check stays at 792 after the rebase.@JJenkx (#6801), @Amoenus (#7948), @fma-rc (#9450): do you agree that this PR lands after yours? Whichever lands later sets the shared
static_assert(sizeof(State) == ...)line to the combined size. If you'd rather have this one first, that works too. I'll add the order toDepends ononce you've answered.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T12:12:32Z.
Review: COMMENTED
Apple GPU / MoltenVK run, for the macOS and non-NVIDIA rows under "Not tested". Both new checks fail without the change and pass with it on MoltenVK.
Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Release,
BUILD_TESTING=ON.Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704.
Base/method: PR #8658
feat/macos-port@1688e5abb8(currentmainplus the macOS port), notmain, which does not build on macOS. This head's diff (merge basecc0078595d, withoutdocs/) applies to it with no conflicts. Full rebuild before each run.agc_driver_graphicsandagc_driver_dcc_keys_first_writepass 3 of 3 on both drivers.State.*,Draw.cppandPipelineJournal.cppat the base): both fail on both drivers, with the texts in the description:the surface of a mipmapped DCC color target lost its keysandthe resident surface of a mipmapped DCC color target has no keys.RunMipmappedTargetis under#ifndef _WIN32, so it runs on macOS as well, not only Linux. The resident image upload (UploadedKeys()isClear0000) andMarkDirty()checks pass on MoltenVK.^agcsuite with the PR:-j1 --timeout 30, 856 tests, no timeouts. Same failures as the base on both drivers (18 with MoltenVK 1.4.2, 17 with main + #2704), exceptagc_driver_uint8x4_color_targetonce on 1.4.2. That test is intermittent on this machine without the PR too, and it passed on main + #2704.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T12:13:48Z.
@jotitadev thanks for the M2 Max runs on both MoltenVK builds, with the tests-only red as well. You're right that
RunMipmappedTargetonly skips Windows, so it runs on macOS too. I fixed the description, and your run is now in Tested and on the GPUs line.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T13:22:13Z.
Review: DISMISSED
The implementation and focused regression remain supported by strong reports: the author has paired current-at-test-time Linux validation, Windows and title data; an independent reviewer reports the new tests fail without the change and pass on both MoltenVK builds. Exact-head whitespace and conventions pass against current main
3ca07d086d5f44fbe3c00370e7f03953ab46ca1b, and the current-main merge tree is clean. I did not run GPU tests locally; hosted product jobs are skipped.The shared
static_assert(sizeof(State))integration order is still unresolved with #6612, #6639, #6801, #7948 and #9450. The proposed sequence in the description is not yet agreement from those authors, and the latest comment asks them but has no replies. Please record their agreement, putDepends onentries only for actual prerequisites, and preserve the combined size assertion as the changes land. The PR is based oncc0078595d, behind current main3ca07d086d5f44fbe3c00370e7f03953ab46ca1b; update to current main and refresh the shared size assertion, overlap checks and focused tests. No new intake objection applies.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T14:47:01Z.
@MarcZX10 rebased onto
mainb7d1d47a5fas2f1fc22a24, with no conflicts; the commit is unchanged.mainb7d1d47a5fand on this head reports no VUID on either side.sizeof(State)line. Its other entries are PRs that conflict withmain, so they can't be compared.git merge-treeis clean against currentmain.main'sStateis still 784 bytes, so the check stays at 792.On the
sizeof(State)order: I've asked @JJenkx, @Amoenus and @fma-rc twice, and none of them has answered yet. None of #6612, #6639, #6801, #7948 or #9450 is a prerequisite for this change, soDepends onstays none. The shared line is the only interaction, and whichever lands later only has to set the combined size, which I'll do here if any of them lands first.Is that enough for this PR, or should it wait for their replies?
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T15:29:52Z.
@Amoenus thanks for checking both diffs and agreeing. I've recorded it in the description: #7948 after this PR. My own #6612 and #6639 will also go after it and rebase over it.
@JJenkx (#6801) and @fma-rc (#9450), that leaves yours: is this PR landing first fine with you? Your rebase then only has to set the combined
sizeof(State).AI-assisted: yes (Claude Code)