fix(agc): fast-clear the viewed mip of a 2D mipmapped DCC colour target #26046
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26046"
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 klosixgaming-arch on 2026-11-23T05:30:27Z.
What
On
main, a 2D mipmapped DCC colour target never gets its viewed mip fast-cleared.DecodeColorBufferkeeps the chain's key base only inchainDccAddressand logs "DCC keys of mipmapped array and 3D color targets are ignored", so the target's image starts from whatever guest memory holds. When the game fast-clears such a target and then blends into it, the draw starts from stale bytes.Cyberpunk 2077 (PPSA03974) hits this on "Set V's appearance" in the character creator: magenta and green noise over the bottom third of the screen. The 3200x1800 RGBA16F character preview (5 mips) shares its memory with 2400x1800 R32U and B10G11R11 targets drawn earlier in the frame. The preview's draws blend with ONE / ONE_MINUS_SRC_COLOR, so the 32-bit bytes left by those targets show through, and read as half floats they hold NaNs, which the composite turns into magenta.
This PR gives the viewed mip its own key range and serves its fast clear:
Gfx10Lib::HwlComputeDccInfo: a 4096-key metadata block covers 1 MiB of texels (512x512 at 4 bytes, 512x256 at 8 bytes); with a mip tail, the tail levels share one block at offset 0; the levels above the tail follow from the smallest to mip 0.0xffclears nothing; mixed, partial or unknown writers fall back to the current keys.APS5_NO_DCC_MIP_FAST_CLEAR(a runtime switch, soAPS5_ABcan toggle it) turns this off.#21479 imports a uniform DCC clear for single-level targets and leaves mips out; this PR covers the mipmapped colour-target chain. They don't overlap.
How it was found
A frame capture of "Set V's appearance" (#21931) replayed the band exactly. Zeroing the 3200x1800 preview at bind removed it, with every other pass running. The colour buffer registers set DCC_ENABLE with a key base that the driver parked, and in that key array the keys change from
0xffto the clear code at key 90112, which is mip 0's offset in the Addrlib layout for this chain (mips 4 to 1 take 1 + 1 + 4 + 16 blocks).Tested
Setup: Ubuntu 26.04.1 (Linux 7.0.0-43), NVIDIA GeForce RTX 4080 (595.99.02), Xeon E5-2699 v3, GCC 15.2.0 Release. Based on
maindb397a73fe.Unit tests:
agc_driver_dcc_keys_first_writegains the key offsets as a pure function (the 3200x1800 8-byte chain, a 1024x1024 4-byte chain and a 2048x1024 8-byte chain with tails, a tail level), a blended draw over a mipmapped target whose mip-0 keys hold a clear code over stale bytes, and three pending-fill cases (clear code,0xff, partial). The pending clear-code case fails without the pending-fill change: the bind syncs the fill and stores the clear on the CPU.agc_suite at6d2124e4f4: 2033 of 2035 with-j8. The two failures,agc_driver_draw_cache_capacityandagc_driver_draw_shader_failure, pass when run on their own.Cyberpunk 2077 PPSA03974, arms alternated,
off=APS5_NO_DCC_MIP_FAST_CLEAR=1. Noise = magenta share of the bottom third, last 4 frames on "Set V's appearance".Body Type is drawn in both arms. Intro, one warm-up per arm, then 3 boots per arm, presents per 10 s: on 56.4 / 58.4 / 56.0, off 57.8 / 56.5 / 56.1. No measurable cost.
Not verified: the layout is checked against one title's chain without a tail; the tail case rests on Addrlib alone. V is still a black silhouette on this screen with the fix on and off; that is a separate bug.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:56:56Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the reported full-suite failures are described as passing when run individually, and the tail-layout limitation is documented.
What I ran
Reviewed head
6d2124e4f4aaf4467850cffb2b58c04cca00044fagainst the prepared diff; I did not run commands or tests.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No test suite or precheck was run. Reviewed changed-line content for
DccMetadata.hpp,DccMetadata.cpp,Draw.cpp,RuntimeSwitches.cpp,State.cpp,Texture.cpp(targeted ranges viarepo_read.py),DccKeysFirstWrite.cpp,ENVIRONMENT.md, andlibSceAgcDriver.md.Texture.hppandRuntimeSwitches.hppwere present in the review bundle but their changed lines were not read;Texture.cppwas excluded from the bundle for size and read through the repository reader. No changed file was excluded by the manifest other thanTexture.cppfrom the bundle.To get this to a good state
Nothing is required.