Repository navigation
fix(agc): fast-clear the viewed mip of a 2D mipmapped DCC colour target - #26046
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
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 6d2124e4f4aaf4467850cffb2b58c04cca00044f against the prepared diff; I did not run commands or tests.
Results
| Check | Result | Note |
|---|---|---|
| Diff and source review | passed | Targeted paths and changed lines inspected |
| Programmatic checks | not run | No commands run |
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 via repo_read.py), DccKeysFirstWrite.cpp, ENVIRONMENT.md, and libSceAgcDriver.md. Texture.hpp and RuntimeSwitches.hpp were present in the review bundle but their changed lines were not read; Texture.cpp was excluded from the bundle for size and read through the repository reader. No changed file was excluded by the manifest other than Texture.cpp from the bundle.
To get this to a good state
Nothing is required.
|
Verified on real AMD RADV (Linux) across all three gens — the PR lists NVIDIA (RTX 4080) only. Built the PR head (
All three print Evidence: VERIFIED (reproduced on each GPU under the above conditions). |
|
Head Code.
Windows coverage. As committed, every mipmapped GPU case in
The
So the guards do not appear to be needed on Windows with an AMD GPU. Dropping them would let the test cover the change on Windows. Negative control. On GPU.
The
Validation.
Host:
AI-assisted: yes |
|
A Windows + NVIDIA run of the current head 6d2124e. No regressions, and the DCC tests, including the new mipmapped fast-clear cases, pass. System: Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 4060 (10de:2882, Ada), driver 621.01, Intel Core i5-12400F, WinLibs GCC 15.2.0 r7 (UCRT), Release, Trees, each a full build: Run:
With this PR, I also built a control: this PR's tree with main's
Not tested: Linux, a title, and the new runtime switch in a non-default setting. AI-assisted: yes (Claude Code). It merged the PR, ran the builds and the test sets, and drafted and posted this comment. |
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
…mip's key slice A 2D mipmapped pipe-aligned DCC color target carries the whole chain's metadata, but only the viewed mip is written; the driver parked the key address in chainDccAddress and ignored the keys, so the target uploaded the stored texels (an alias's bytes) instead of starting from the fast clear. Give the viewed mip its own key range -- the AMD addrlib HwlComputeDccInfo layout, small mips first, each a whole number of 4096-key blocks, the viewed mip's slice last -- and settle its range to the clear colour before the resident lookup when that slice is one clear code, so the draw starts from the clear like a single-level target. Arrays and 3D keep the chain address and the existing log line. The key reads keep the historical per-256-bytes count; the viewed mip's padded extent sizes the marks and overlap checks, as the padded console extent already did for single-level targets. APS5_NO_DCC_MIP_FAST_CLEAR turns the fix off. Adds RunMipmappedClearDraw: a 128x128 8-mip R64KBX chain with a 0000 clear over stale texels in the viewed mip's slice; a 0.5 premultiplied draw must see 128 inside the scissor and the clear outside, and the viewed mip's keys must end uncompressed. It fails with APS5_NO_DCC_MIP_FAST_CLEAR=1.
Replace the per-draw CPU settle (store the clear over the whole mip and re-upload it) with a GPU clear of the viewed mip's subresource: the image holds the clear, the guest bytes follow through the write-back, which now stores the filled mip whole (holdsClearFill). The single-level DCC path already serves a uniform clear from the image; this extends it to the mipmapped target whose chain image otherwise starts from the stored texels. The test for the draw reads the guest buffer directly: the GuestMemory access hook would store the pending clear (the very write-back under test) before a hooked read could observe the pre-write-back state.
…ding When the game's DCC key fill is still a recorded GPU write at bind, the old path synced it (CurrentDccKeys) and ClearMip's pending-write refusal still fired over the surface's key extent, so the bind fell back to the CPU store (a full memset of the viewed mip plus a re-upload, every frame the game re-clears the target). Answer the keys from the recorded writes instead (LandedDccKeys, no sync): every pending writer a fill leaving one fillable clear code takes the GPU clear with the clear recorded after the fill in the same queue; a fill of 0xff clears nothing; mixed, partial or an unknown writer falls back to the current keys, as before. ClearMip now skips its pending-write checks when the caller passed a verified code clear. Remove the temporary MIPCLEAR-PROF profiling counter. Tests: three pending-fill scenarios next to the existing mipmapped clear test -- a pending clear-code fill must take the GPU clear with no sync and no guest write at bind (it fails without the change: ClearMip refuses, the CPU fallback writes the guest at bind), a pending 0xff fill must not materialize a clear, and a pending partial fill takes the fallback path and stays correct.
…ip-tail block, register APS5_NO_DCC_MIP_FAST_CLEAR as a runtime switch
…U tests on Windows
6d2124e to
d76afb0
Compare
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)