fix(agc): resolve through a copy where the device ignores the destination view's component order #25911
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25911"
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 Plyxen on 2026-11-22T20:57:41Z.
What
A CB resolve into a
B8G8R8A8_SRGBcolor buffer swaps red and blue on some Windows drivers (#14380): the resident image isR8G8B8A8_UNORM, the resolve attachment is aB8G8R8A8_SRGBview of it, and those drivers write the render-pass resolve in the image's component order instead of the view's. AMD 24.30.36 on a Radeon iGPU (1002:13c0) does it here, and AMD 23.19.10.08 on a Vega iGPU does it in cryst4lpepsi's run; #14380 reports AMD 32.0.13058.8001 and NVIDIA 572.16, and the same swap forA2R10G10B10_UNORM_PACK32overA2B10G10R10_UNORM_PACK32on 572.16.ResolveMultisampleTargetprobes the device at the first resolve whose destination format is neither the resident image's format nor its sRGB twin. The probe clears two 8x8 multisampled images the same way, resolves one into a view of the other-order image and the other into an image of the view's own format, and compares the bytes. The result is kept per physical device, format pair and sample count for the process and printed once ([gpu] render-pass resolve of ... follows the view, resolved directly,does not follow the view, resolved through a copy, orthe probe failed (<reason>), resolved through a copy).vkCmdCopyImagecopies that into the resident image. The 11_11_10 averaging path is unchanged.APS5_STAGED_RESOLVEselects the copy on every device.agc_driver_msaa_dcc_srgb_clear_staged_2,_4and_8run the existing sRGB DCC clear test with it, so the copy path is covered on devices that follow the view, lavapipe included (4 samples only there).APS5_STAGED_RESOLVEadded todocs/dev/ENVIRONMENT.md.An earlier version of this description said the swap on AMD 23.19 (#25521, closed into #14380) was in the clear of the multisampled image, a step this change does not touch, and that the probe would report that such a driver follows the view. That was wrong, and it was from reading the code and that report, not from a run. On a Vega iGPU with AMD 23.19.10.08 the probe reports
does not follow the viewfor 2, 4 and 8 samples, the three tests fail on the base and pass with this change, and the report's author has withdrawn the clear finding (run and correction). No run so far shows a swap in the clear.tools/pr_overlap.py --branchconfirms no overlap, and could not compare 65 open pull requests that conflict withmain. Of the 10 of those that changeMultisampleTarget.cpp, #24049 and #23252 edit the packed averaging line ofResolveMultisampleTarget, which this change also edits; whichever merges later rebases that line. The other eight do not touch the resolve.Tested
Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,main8c254da48band the change on it, same machine.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.363),VK_LOADER_DEBUG=layer,ctest -V, GPU selected withANYPS5_GPU. The focused set is every test of the executables that run a CB resolve (agc_driver_alpha_to_coverage_tests,agc_driver_graphics_tests,agc_driver_recorder_tests,agc_driver_target_memo_tests, the EQAA and packed float color target tests): 307 tests onmain, 310 with the three new ones.mainagc_driver_msaa_dcc_srgb_clear_2,_4,_8(an sRGB DCC import or resolve changed an undrawn sample endpoint); 0VUID-VUID-VUID-VUID-The loader logs
Insert instance layer "VK_LAYER_KHRONOS_validation"in 237 of the 307 logs onmainand 240 of the 310 with the change, and neverwas not found but was requested by env var VK_INSTANCE_LAYERS; the other tests create no device.On the previous base,
8763aeffdc, theagc_*,video_out*andshader*tests (2,128) ran without the layer on the Radeon with the change: 2 fail,agc_driver_image_table_cache(#24186) andagc_driver_store_over_untracked(#22670). The same run on the RTX 5080 did not complete; the 950 tests it finished passed exceptagc_driver_image_table_cache. Neither was repeated after the rebase.After review (
7395d6f2d9: the probe owns each image once, uses one source image per pass, and reports a failed probe as such), same machine and environment:VUID-VUID-agc_driver_msaa_dcc_srgb_clear*tests with synchronization validation,98d0454071SYNC-HAZARD-WRITE-AFTER-WRITE, one per probe7395d6f2d9SYNC-HAZARD-SYNC-HAZARD-Driver update, 2026-11-24: this machine now has AMD Adrenalin 26.11.2 (Windows driver 32.0.21045.29003, Vulkan driver 2.0.353) and NVIDIA 621.24, and on the new AMD driver the same iGPU follows the view.
main403fbe6fc1and this branch merged onto it,ctest -R 'msaa|multisample|resolve|eqaa|alpha_to_coverage|packed_float' -V -j 2with the validation layer and the synchronization validation settings:mainagc_driver_msaa_dcc_srgb_cleartests pass; 0VUID-VUID-VUID-, 0SYNC-HAZARD-VUID-, 0SYNC-HAZARD-The one failure on
mainisagc_driver_native_multisample_depth, which is intermittent there and has nothing to do with the resolve (#26649). So this machine no longer shows the bug, and every Radeon result above this paragraph is from 24.30.36.Linux: Ubuntu 24.04.5 under WSL 2 (kernel 6.18.58), GCC 13.3.0, Release, lavapipe (llvmpipe, Mesa 25.2.8),
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, no validation layer (Ubuntu's is older than 1.4.335), the same focused set:main8c254da48b7395d6f2d9agc_driver_msaa_dcc_srgb_clear_4/_staged_4mainlavapipe renders color with 4 samples only, so the
_2and_8tests skip on both sides, and the two extra skips are_staged_2and_staged_8.tools/check_conventions.pypasses. Not run on macOS or on a Linux GPU driver. The cost of the copy on the affected drivers is not measured. No title tested. Runs by others are in the comments below: NVIDIA 572.16 on an RTX 3060, which needs the copy and covers theA2R10G10B10case (andyohyeah), drivers that follow the view (hamdanpor-ctrl, fin-github), an RX 6700 XT (JJenkx), Intel 32.0.101.6127 and NVIDIA 621.01 with synchronization validation (mihiii1337), an RDNA4 card on AMD 32.0.31044.16, which follows the view, with synchronization validation (Helldiverr), and a Vega iGPU on AMD 23.19.10.08, which needs the copy (cryst4lpepsi).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)1002:13c0), driver 24.30.36 (32.0.13036.4), Windows 11; NVIDIA GeForce RTX 5080 (10de:2c02), driver 616.56, Windows 11🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T21:28:18Z.
Review: COMMENTED
Reviewed — comments
Changes are required before merge: confirm the probe and staged copy handle destination image usage and subresource constraints for every supported resolve target.
What I ran
98d045407196e0dc1977c7e8a634ddd3bdb85a25; no commands or tests were run.Results
Findings
Blocking
None verified.
Non-blocking
MultisampleTarget.cpp:2227-2229,MultisampleTarget.cpp:2262). This can hide probe setup or allocation failures and impose an unreported copy. Consider logging the probe failure distinctly so the fallback decision can be diagnosed.Not verified
MultisampleTarget.hpp,Draw.cpp,MultisampleTarget.cpp,agc_driver_alpha_to_coverage_tests.cmake,ENVIRONMENT.md, andagc-resolve-view-component-order.md. No files were excluded.To get this to a good state
Nothing is required. Optional: report probe failures distinctly from a measured component-order mismatch.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T01:30:51Z.
Review: CHANGES_REQUESTED
I reviewed exact head
98d045407196e0dc1977c7e8a634ddd3bdb85a25and its GitHub test merge10f980acd1d13810cf286ca968886b46acfe8609. The probe and staged-copy direction are useful, but the new allocation-failure path can destroy the same Vulkan image twice before the outer probe fallback runs. Details are inline.An independent Intel A78B base/change hardware matrix is in progress; I am not claiming a runtime result from it yet.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T01:41:46Z.
Review: COMMENTED
Follow-up on exact head
98d045407196e0dc1977c7e8a634ddd3bdb85a25: the Intel A78B base/change matrix completed, and ordinary validation passed all 27 runs. Enabling Khronos synchronization validation exposed a separate probe hazard in the change: the candidate reports the same write-after-write error for the 2x, 4x, and 8x probes, while the direct-parent base reports none. Details are inline.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T10:41:11Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation and supplied focused test results support merging.
What I ran
Reviewed head
7395d6f2d9f9d690e57ca6fad34802c5068c3b45. Readdescription.md,commits.md,manifest.json,diff.patch, and the full text of every changed file listed in the manifest. Readrepo_read.pyoutput for targeted functions and call sites. No tests were run during this review; test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently run the test suite or validate behavior on hardware. The description reports runs on an AMD Radeon iGPU, NVIDIA RTX 5080, and lavapipe; those results were not reproduced in this review. No changed files were excluded: the manifest lists six changed files, and all six were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T13:37:50Z.
Review: APPROVED
Both points from my earlier review are resolved at
7395d6f2d9f9d690e57ca6fad34802c5068c3b45. The probe owns each image before allocation, and each render pass now uses a separate multisampled source image.I compiled the old and new image-creation lambdas and the actual
OwnedImagedestructor in a Windows fixture with mocked Vulkan calls and injected failures. The old path recorded two destroys after an allocation failure and one unmatched creation when acquiring the owner threw. The new path passed all five cases covering success and owner, creation, allocation and bind failure.I also built the exact new head in WinLibs GCC 15.2 Release and ran the six normal and forced-staged
agc_driver_msaa_dcc_srgb_cleartests for 2x, 4x and 8x on each adapter. Intel UHD A78B (32.0.101.6127) and RTX 4070 Laptop (621.01) each passed 6/6. Vulkan was required, the shader cache was disabled, and the logs confirm Khronos validation 1.4.369 was inserted in every test with synchronization validation enabled. There were zero SYNC-HAZARD or VUID messages on either adapter. The archived runs from my first review had three write-after-write messages on each adapter at the old head and zero at its base. I reran only the new head on hardware.Both drivers selected the direct resolve. The three staged tests per adapter explicitly forced the copy. I did not test an affected driver that selects the copy automatically.
AI-assisted: yes