build(agc): compile Lifecycle, GuestMemory and GuestBufferMemory on macOS #11447
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11447"
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 iamthehimansh on 2026-10-26T13:54:55Z.
What
Next part of splitting #8658, as @imellag asked on #11303. With the open macOS PRs for
libkerneland libc, these threelibSceAgcDriverfiles are what still keep the AGC driver from building on macOS. Each change is macOS-only; Linux and Windows compile the same code as before.Execution/src/Driver/Lifecycle.cpp: macOS reserves0xfc0000000-0x1000000000with maximum protection none, so the driver's guest block is placed lower in the same system-reserved guest range. The address is in the newExecution/include/Driver/DriverMemory.hpp. macOS has noMAP_FIXED_NOREPLACE, so the block is mapped with a plain address hint and the driver fails unless the kernel places it exactly there; it never replaces an existing mapping. Stack bounds come frompthread_get_stackaddr_np/pthread_get_stacksize_np.Execution/src/GuestMemory.cpp: describes guest pages withmach_vm_regioninstead of/proc/self/maps. It reports a write-watched page's guest protection rather than thePROT_WRITEthe watch removed.<link.h>is not included on macOS.Graphics/src/GuestBufferMemory.cpp: macOS has no udmabuf, so the dma-buf import probe reports it unsupported and buffers stay host memory.0xfe0040000(found by @tkcm01 on an M4):libSceAgc/tests/StaticBuffer.cppnow reads the static table at the address the driver uses on macOS.libSceAgcDriver/tests/execution/ComputeFsTableCalls.cppis skipped on macOS, as it already is underANYPS5_ENABLE_ASAN: its shader builds the table address from twos_mov_b32literals, and the driver does not rewrite that yet. The gap is listed under Functional indocs/dev/debt/libSceAgcDriver.md.The
GuestMemory.cppprotection reporting is a runtime change, tested below. The other two only choose macOS placement and the host-memory path.Overlap and dependencies
Texture.cppwas in the first version of this PR. It's dropped: @imellag's #10676 already makesPendingList::publishedbuild with Apple's libc++, and @maximilianfv's #10859 already keeps sRGB storage images in their UNORM twin.FrameRecorder.cpp'senvirondeclaration is in @maximilianfv's #10540.describePagesblock toGuestMemory.cpp, was closed without merging on 27 Oct, so that overlap is gone. Re-checked against all 1,234 open PRs on 27 Oct: none adds more than 7 of this PR's added lines to any of these files, and those shared lines are braces and common includes.Tested
Apple M2 Pro, macOS 26.6.2, MoltenVK 1.4.2, x86_64 Release under Rosetta 2, with Ninja. On
mainat2dbe9b99f, the three.cppfiles compile;mainfails all three. Linux and Windowsunifdef -U__APPLE__views (-D__linux__and-D_WIN32) equalmain.libSceAgcDriveronly links on macOS with the other open macOS PRs. So the runtime check uses a local base:mainatb27cc8416, plus #10552, #10898, #8311 and #9738, local-only patches for the files still failing there, and the changes from #10676, #10859, #10540 and a macOS Vulkan loader forVulkanDevice.cpp. That's the base #11303 was tested on.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, 3 runs each:922458fb0agc_write_trackingagc_driver_pooled_buffer_rangeagc_driver_image_table_reuseNo
VUIDmessages in any run.agc_driver_image_table_reusefails the same way with and without this PR ("0 table descriptor writes kept, expected 3"); that is a separate MoltenVK descriptor issue. After theLifecycle.cppmapping change below (af1c552ee), the same base gave the same results:agc_write_tracking3/3,agc_driver_pooled_buffer_rangewith #11303 3/3,agc_driver_image_table_reusefailing as before with the device up, and noVUIDs.The two tests on the same base, 2 runs each:
main's test file0b8115c2c)agc_static_bufferagc_driver_compute_fs_table_callsDriver-block mapping: the block is mapped at
0xee0000000with an address hint only, with noMAP_FIXED. A standalone x86_64 probe of the old and newMapDriverMemorylogic placed an unrelatedPROT_NONEmapping there first. The old logic mapped over it (protection afterwards 3, so it was replaced). The new logic refused, and the unrelated mapping stayed at protection 0. With the address free, both mapped exactly there. @imellag ran this PR's first head on an M4 Pro (see the comment below):libSceAgcDriverlinks, and Planet of Lana reaches gameplay.python3 tools/check_conventions.py --base origin/mainpasses.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)docs/dev/debt/libSceAgcDriver.md: #10760, then #12565, then this PR, which keeps both edits when it mergesmain); none to compile these files; linkinglibSceAgcDriveron macOS also needs #10540, #10676 and #10859libSceAgcDriveron macOSImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T14:05:12Z.
Review: CHANGES_REQUESTED
I reviewed head
d6b304f23e72472410792b45441fecaeb739e41c. The official overlap scan reports exact shared hunks with open #10676 inTexture.cpp'sPendingList(std::atomic<std::shared_ptr<...>>versusAtomicSharedPtr) and #10859 inStorageFormatOrUndefined(the sRGB-to-UNORM choice). The PR description also acknowledges overlapping macOS edits with open #7201 inLifecycle.cpp,GuestMemory.cppandGuestBufferMemory.cpp, but I could not find an agreed merge order in that PR's discussion. CONTRIBUTING.md says to agree on order and declare it withDepends on; please coordinate the overlapping hunks and update the body accordingly.This also changes AGC runtime behavior: the new
mach_vm_regionpermission path and Apple sRGB storage selection are more than compile fixes. AGENTS.md requires the same focused Vulkan tests onmainand the change withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validation, with logs checked for missing-layer messages and newVUID-errors. The report only compiles these files and lists GPUs as n/a. Please add the focused macOS/M2 results (or narrow/defer the runtime changes if that validation is unavailable).The tested base in the description is
9656d366b, while currentmainis263fbcd2d3. The file-level diff remains clean against current main andcheck_conventions.pypasses, but please rebase and rerun the focused validation after resolving the overlaps. I did not run macOS tests locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T14:42:02Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
8257104f8c02254c1f846a1ccad8fb5391d4f46e. The new plain-hintmmappath does avoid replacing an unrelated mapping; the PR description now includes an author-run occupied-address/free-address probe for that behavior. Current-main conventions andgit diff --checkpass, and the merge preview onto currentmainis clean.One integration issue remains with open #7201. I compared current heads
6687cbac29cf7a8759329ef95b5ef1349a11b404and8257104f8c02254c1f846a1ccad8fb5391d4f46ewith a three-way merge preview. Git auto-mergesGuestMemory.cpp, but the resultingdescribePageshas two Apple implementations in sequence: #7201’sHostRegions::FirstAtOrAboveblock and this PR’smach_vm_regionblock. Every path through the first block returns or continues, so the later block is unreachable on macOS. Please coordinate which implementation should remain and resolve the overlap before landing; the overlap is semantic even though Git reports no text conflict.Hosted conventions/eligibility/labels/report pass; all build jobs are skipped by path policy. I did not run macOS tests locally. The runtime results in the description use a composed base, and the new mapping probe is a separate author-run check; please keep those scopes clear when updating validation after resolving the overlap.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T03:07:51Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The overlap and the two address-dependent test issues are addressed. I am keeping changes requested because the current-main-merged PR head has not been built and runtime-tested as an integrated tree. The newest M4 report explicitly says it cherry-picked only the test fix onto an earlier composed tree and did not build the rest of the merged head.
What I ran
0b8115c2c7f6608f614c004bcff660d4cfd2afe8and its merge with currentmain3a2b91981651569163768854a1fcdc7193b6667b.git merge-tree --write-tree upstream/main refs/review/11447-current.python3 tools/check_conventions.py --base upstream/main --head refs/review/11447-current.git diff --check upstream/main...refs/review/11447-current.Results
mainfc8afbcb480461ece4328a59069c3f72749f939fNegative control
The author reports an occupied-address probe: the old mapping logic replaced an unrelated
PROT_NONEmapping, while the new plain-hint mapping refused and left it intact. I did not reproduce this probe locally.Findings
Blocking
main, but the latest M4 comment says the remainder of the new head was not built. The M2 runtime results use the earlier composed base documented in the description. Please run the macOS build and the relevant focused Vulkan tests on a composed tree that includes this exact head, currentmain, and the required macOS prerequisites. Include the exact tested commit(s), test outcomes, confirmation the validation layer loaded, and whether any newVUID-messages appeared. If the complete driver still cannot link without open prerequisite PRs, state the exact composed tree and ensure it includes the merged current-main changes.Non-blocking
describePagesimplementation concern is resolved.agc_static_bufferto use the moved macOS table address and skips the shader-literal FS-table test with a corresponding debt entry. The M4 report says those targeted test outcomes are correct, but only for its cherry-picked test fix.Sources
All current code links are pinned to PR head
0b8115c2c7f6608f614c004bcff660d4cfd2afe8.Not verified
To get to a good state
Build and run the focused macOS validation on an integrated tree containing current
mainand this head, with the required macOS prerequisites. Report the exact source commits, validation-layer load, focused test results, and anyVUID-output.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:54:26Z.
Review: APPROVED
Re-reviewed — approved
Reviewed exact PR head
0b8115c2c7f6608f614c004bcff660d4cfd2afe8against currentmainedf6804cf52c62eacafc592dd6142cb4efe5bd05.What I checked
git merge-tree --write-tree upstream/main refs/review/upstream-11447: clean treedc09b89f463cfac0341966fffe997104a08cfcfd.git diff --check upstream/main...refs/review/upstream-11447: pass.python3 tools/check_conventions.py --base upstream/main: pass.mainwith the reported integrated base2960e9a6e7for the relevantGuestMemory.cppand AGC debt paths; no later changes to those paths were found.2960e9a6e7, and the stated macOS prerequisites. The full build linked the driver; the focused AGC run loadedVK_LAYER_KHRONOS_validation, exercised the lifecycle and guest-memory tests, and reports no new VUIDs attributable to this change.Results
agc_static_bufferpassed;agc_driver_compute_fs_table_callsskipped with its documented reasonNegative control
A full macOS run without this PR was not possible because the driver does not compile on macOS without the platform changes. The author reports a standalone mapping probe: the old address-hint path replaced an unrelated
PROT_NONEmapping, while the new path refused and preserved it. I did not independently reproduce that probe.Findings
Blocking
None. The new integrated report resolves the prior request for an exact-head/current-main macOS build and focused runtime validation. The reviewed source and test changes are consistent with the results reported.
Non-blocking
Sources
Not verified
I did not reproduce the macOS integrated build, focused tests, full CTest run, or negative-control mapping probe locally. Those results are author-reported.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:30:51Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
0b8115c2c7f6608f614c004bcff660d4cfd2afe8after the new review comment. The implementation and M4 validation remain as reviewed, but the newFS table calls on macOSdebt entry still names four games. The repository convention requires titles to be identified by PPSA ID or the #6160 reference; please remove those game names while keeping the supported PPSA IDs/reference. This is a documentation-convention blocker; no code retest is needed for that edit.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T01:53:48Z.
Review: APPROVED
Re-checked — new head, looks good
The reviewed implementation is unchanged; the new head corrects the debt entry and records the dependency order.
What I ran
Reviewed exact head
140c92d3b65c4caa31e18ced01383fc15dd37361against recorded PR base319621ba2e578bd053b0baba2877fe70520e0737and currentmain99b571f879cd1ef3de7b8af21261675826d75943. Compared with previously reviewed implementation head0b8115c2c7f6608f614c004bcff660d4cfd2afe8, the only change is one line indocs/dev/debt/libSceAgcDriver.md. The current-main merge preview is clean (c27e46434a3d8f5b4e2f071055da5fc0603c25c4). Environment: Linux workspace; no build or tests were run locally.Results
Unedited command output
Findings
Blocking
None found in this re-check.
Non-blocking
The author has recorded #12565 before this PR for the shared debt-file edit. The PR also lists #10859 as needed for macOS linking; #12565 and #10859 remain open, so retain that landing order/dependency state. This approval does not indicate that those dependencies have landed.
Sources
Not verified
I did not run a macOS build, the Apple M4 integration tests, or physical-console tests. The CI Windows job did not build the product or execute tests.
To get this to a good state
Land the declared dependencies in the recorded order before integrating this PR. I will re-check if its head changes.