fix(agc): read-trap a pending image at a label only when it is host imported #20183
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20183"
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 XIIYAZ on 2026-11-14T19:37:03Z.
What
On macOS, both
agc_driver_label_ordered_flushcases fail:On macOS,
StoreReadbackBeforeLabelread-traps a small pending image at a label instead of storing it. Its pages becomePROT_NONE, and the first CPU read faults intoResolveLabelTrap, which stores the image throughFlushGpuWrites. With both cases' label traps off (APS5_NO_LABEL_READ_TRAP=1), both pass.--unimported(APS5_NO_HOST_IMPORT=1). The image has no host import, so its store is a GPU readback whose bytes reach guest memory only through the batch's completion write-back. A trace inResolveLabelTrapshows the image no longer pending onceFlushGpuWritesreturned (pendingAfter=0), yet the read that faulted still found fewer than the 8 stored texels the test requires after the label. The resolver lets that read through without the results. With a host import, the GPU writes the image's bytes through the import, and the trapped read sees them. That is why the default case's 8 runs pass the same data check.A pending image is now read-trapped at a label only when a host import covers it (
HostImportCovers). Otherwise the label stores it, as it does on Linux and Windows, which orders it before the label.Default case. Its check counts label stores that took the GPU-ordered flush (
TakeOrderedSkipCounts().flushes). On macOS the image is trapped instead of flushed at the label, so that count stays 0, although the image is still ordered before the label: the data check passes. The case now runs withAPS5_NO_LABEL_READ_TRAP=1on macOS, so it checks the GPU-ordered flush there as it does elsewhere. The trap path keeps its own coverage inagc_small_tiled_shadow_labeland the otherRecorder.cpplabel-trap cases.Tested
Setup:
-DCMAKE_OSX_ARCHITECTURES=x86_64; tests run under RosettaANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1mainwith the open macOS build fixes appliedResults:
agc_driver_label_ordered_flushandagc_driver_label_ordered_flush_unimportedfail before this change and pass after it.agc_driver_label_ordered_flush_disabledpasses before and after.ctest -R 'label|shadow|recorder_'(57 tests) passes.ctest -R '^(agc|shader|job)'(1578 tests,-j 1) and compared it with the same run before this change: both cases are fixed and nothing that passed before fails because of this change.agc_driver_msaa_dcc_clear_2failed once in that run; it is intermittent on this machine and failed the same way in earlier runs without this change.Linux and Windows have no label traps and are unchanged.
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-14T20:21:57Z.
Review: APPROVED
Reviewed — looks good
The change restricts Apple label read traps to host imported textures and disables that trap for the ordered-flush test on Apple; the inspected code supports the stated intent.
What I ran
No commands or tests were run. Review was against head
1e1d7fd12c5c8f44dd58f9ba71e114fe58b4aef8usingrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppwas excluded from the review bundle; only the relevant function range and theHostImportCoversimplementation were read throughrepo_read.py. The changed CMake test file was read in full. No runtime behavior or reported test results were independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-16T23:50:32Z.
Review: COMMENTED
Tested on macOS 27.2 / Apple M4 with MoltenVK 1.4.2 (LunarG Vulkan SDK 1.4.363.1, validation layer 1.4.363), x86-64 build under Rosetta. This is the only GPU I tested.
Head
1e1d7fd12cmerged alone onto main3b17977ba6, compared with3b17977ba6itself. I ran the 29 AGC tests that fail on main on this Mac, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer, throughctest --test-dir build -R <those 29> -V, three runs per side. Every Vulkan test loggedInsert instance layer "VK_LAYER_KHRONOS_validation"and none loggedwas not found but was requested by env var VK_INSTANCE_LAYERS.agc_driver_label_ordered_flushagc_driver_label_ordered_flush_unimportedThe other 26 tests gave the same result on both sides.
agc_driver_label_after_import_copyis the one other difference: main 1 of 3 failed, this PR 3 of 3. Since this PR changes label read traps, I checked it further. A sequential 15-run repeat failed 15/15, but the machine was heavily loaded by a parallel build at the time. So I built main, this PR and #20172 side by side and ran their test binaries interleaved (A, B, C, A, B, C, ...), 20 runs each, so all three saw the same load:3b17977ba6So this PR doesn't make that test worse. It's main's existing MoltenVK label-visibility flake, which #20172 addresses. 0
VUID-lines in all 60 runs, and every run logged the layer insertion.VUID-lines: identical per test on both sides (30 on main, 30 with this PR, over the three runs). TheVUID-lines on both sides are main's existingVUID-VkDeviceCreateInfo-sType-unique(a duplicatedVkPhysicalDevicePortabilitySubsetFeaturesKHRin the device pNext chain) andVUID-VkSamplerCreateInfo-samplerMipLodBias-04467; this PR adds none.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:23:48Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
38b8426e6c7101de69af653952bb08fe4c52c967. No commands or tests were run. Read the prepared description, commits, manifest, diff, full text ofagc_driver_label_ordered_flush_tests.cmake, and relevant ranges inTexture.cppandGuestBufferMemory.cpp.Texture.cppis listed as too large for the review folder; its relevant lines were read throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported macOS test runs were not independently reproduced. No other files were read;
manifest.jsonlists two changed files and both were reviewed. No files were excluded byfiles.jsonin the available review bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:23:55Z.
Review: COMMENTED
The trial merge onto
a1b75b0947conflicts inTexture.cpp. Please retain a macOS control that proves the imported image still takes the label read-trap route. The default macOS fixture now setsAPS5_NO_LABEL_READ_TRAP=1, and the unimported case can verify eager publication but cannot cover the remaining imported path. My review is source-based and I have no macOS result.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.