Skip to content

build(agc): keep the Linux-only parts of three AGC tests off macOS - #11437

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
imellag:build/agc-linux-only-tests
Nov 15, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
imellag:build/agc-linux-only-tests

Conversation

@imellag

@imellag imellag commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What

Three AGC tests don't compile on macOS on current main:

tests/SharedWrites.cpp:62:23: error: use of undeclared identifier 'RUSAGE_THREAD'
tests/HostImportSparseDmaBuf.cpp:231:66: error: use of undeclared identifier 'MFD_CLOEXEC'
tests/execution/SparseDmaBufImport.cpp:123:61: error: use of undeclared identifier 'MFD_CLOEXEC'

Their Linux-only parts are guarded with #ifndef _WIN32, so macOS compiles them too. This change guards them with #ifdef __linux__ instead:

  • HostImportSparseDmaBuf.cpp and execution/SparseDmaBufImport.cpp test udmabuf imports. On Windows they already print skipped, udmabuf imports are Linux only and return the skip code; on macOS they now do the same.

  • In SharedWrites.cpp:

    • the per-thread fault count of the benchmark modes (RUSAGE_THREAD, which macOS lacks). Windows already leaves it at 0;
    • the leak check that counts mappings in /proc/self/maps;
    • the block that writes through GuestArenaWriteSharedBacking. DirectMemory.cpp registers that writer only on Linux, so on macOS it returns false by design and the test fails with shared writer rejected direct backing.

    The partial sceKernelMunmap block stays on macOS, where it passes.

On Linux and Windows the compiled code doesn't change: the unifdef views of the three files with -D__linux__ -U_WIN32 and with -U__linux__ -D_WIN32 equal main's.

Tested

Current head 182c89266a, rebased onto main 98ddd9c179. #12168 merged in the meantime and changed SparseDmaBufImport.cpp's skip to main(int argc, char** argv) with SkipCode; this PR keeps that and only changes its guard to #ifndef __linux__. Nothing else changed.

Apple M4 Pro, macOS 27.2, Apple clang 21, x86-64 Release under Rosetta 2 (-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja, BUILD_TESTING=ON), MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0.

main does not build the AGC driver and its tests on macOS yet, so this ran on a support branch, not main: fork branch support/macos-boot-1030 (6747733e89) = main 98ddd9c179 + only the open macOS PRs #11447 #11554 #10552 #7631 #7804 #4630 and #13220 (the duplicate write_watch test registration that stops main's CMake on macOS), plus one local line that reads environ through _NSGetEnviron() in HostReportSources.cpp (main doesn't compile it on macOS; no open PR covers it yet). The conflicts of #11554, #10552, #7631, #7804 and #4630 with main are resolved in the merge commits. Change: support/macos-boot-1030-pr11437 (f8fe1be811) = that branch + this PR's commit.

  • Build: on the support branch the three objects fail as above; with this commit the three test executables build and link.
  • Run: with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer, ctest -R '^(agc_shared_write|agc_shared_write_partial_collect|agc_host_import_sparse|agc_driver_sparse_dma_buf_import)$' -V, 3 runs:
    • agc_shared_write and agc_shared_write_partial_collect pass;
    • agc_host_import_sparse and agc_driver_sparse_dma_buf_import are skipped with skipped, udmabuf imports are Linux only;
    • the loader lists VK_LAYER_KHRONOS_validation as enabled by VK_INSTANCE_LAYERS, there is no was not found but was requested by env var VK_INSTANCE_LAYERS, and no VUID- line.

Logs attached.

Previous head 2e0a9091cc (main 035ac96edd with the macOS PRs of that day, macOS 27.0.1): the same results. Without #10898, which has merged since, agc_shared_write built but failed with invalid write was accepted.

Not built on Linux or Windows; the unifdef comparison above shows that their code is unchanged.

check_conventions.py --base upstream/main passes. pr_overlap.py reports no conflicting lines. Of the pull requests it couldn't compare:

Checklist

  • Based on current main; no other open PR implements the same functions (except feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, see the end of Tested)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M4 Pro, MoltenVK 1.4.2, macOS 27.2
  • AI-assisted: yes

@MarcZX10

Copy link
Copy Markdown
Contributor

The head 4217176b44 is based on 2db37cf1de, while current main is 035ac96edd (17 commits ahead). The intervening changes include AGC CMake and graphics/test paths, so the reported build and focused runs need rechecking on current main after sync. Please update the branch and rerun conventions; I will then review the macOS guards against the refreshed tree.

@imellag
imellag force-pushed the build/agc-linux-only-tests branch from 4217176 to 2e0a909 Compare October 26, 2026 13:30
@imellag

imellag commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Rebased on 035ac96edd as 2e0a9091cc; none of the 17 commits touch the three files, and check_conventions.py passes. I rebuilt and reran on current main with the open macOS PRs. Without this change the three objects still fail the same way. With it, the test executables build and link, and the four tests give the same results as before: 3 of 3 with the validation layer, no VUID- lines. The refresh showed one more thing: on macOS, agc_shared_write also needs #10898 to pass its read-only check, and my earlier tree already had it. I've updated Tested with the tree commit and that detail.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rechecked the updated head 2e0a9091ccb247d2465d3292dee2de44e225d92 against current main. The three touched files have not changed on main since the reported base, and tools/check_conventions.py --base upstream/main --head upstream/pr-11437 plus git diff --check upstream/main...upstream/pr-11437 pass. The updated macOS build/run report is useful; I have not independently run that macOS suite.

There is one repository-rule overlap to resolve before approval. Open #7201 changes the same HostImportSparseDmaBuf.cpp and SparseDmaBufImport.cpp platform guards to skip those Linux-only cases on macOS, and carries a broader macOS-specific implementation in the same SharedWrites.cpp regions this PR now excludes from macOS. The open draft #5021 also carries related SharedWrites.cpp edits. If this PR is intended as the immediate standalone fix, please clarify the merge order and coordinate the overlapping hunks so the same macOS test handling is not duplicated or regressed when those branches are integrated. I am requesting changes for that overlap only; I found no separate defect in the guards themselves.

@imellag

imellag commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Thanks for checking. On merge order: this PR is the standalone fix for current main. #7201 is a whole macOS port (118 files) that conflicts with main, and #5021 is a draft ARM64 compiler consolidation that edits SharedWrites.cpp along the way. Other focused macOS PRs, such as #11249 and #11447, were split out of the same areas.

How the hunks fit together:

  • In the two udmabuf tests, Macos port #7201's #if defined(_WIN32) || defined(__APPLE__) and this PR's #ifndef __linux__ skip the same platforms, so either line can stay.
  • In SharedWrites.cpp, Macos port #7201 keeps the fault count (RUSAGE_SELF) and the mapping count (mach_vm) on macOS, and its DirectMemory.cpp registers the shared backing writer on macOS too, so the writer block can run there with it. If this PR lands first, Macos port #7201's rebase should keep its own versions of those three blocks, replacing this PR's __linux__ guards there; that keeps its macOS coverage.
  • If Macos port #7201 lands first, I'll close this PR.

I'll post the same note on #7201 for @marion909.

@imellag

imellag commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@MarcZX10 #7201 was closed this morning, so of the overlaps in your review only the draft #5021 is left.

@yabanana, for your rebase: #5021 edits the same SharedWrites.cpp blocks as this PR. Both limit the /proc/self/maps mapping count and the shared backing writer block to Linux. There are two differences:

#5021 doesn't touch the two udmabuf tests. If this PR lands first, keep #5021's versions of those blocks when you rebase. If #5021 lands first, I'll rebase this PR onto it and drop what it already covers.

This was referenced Oct 27, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor

The #12168 ordering is now resolved: its current head has the earlier change, and this PR records Depends on: #12168. The separate SharedWrites.cpp overlap with open draft #5021 remains: both branches change the benchmark fault-count selection, /proc/self/maps mapping count, and shared-backing writer block. I compared the current branch files; these are actual shared blocks, not only a same-file warning. Please coordinate with #5021’s author and record the intended order and retained behavior in both PR checklists. The existing review request remains limited to this unresolved overlap.

@imellag
imellag force-pushed the build/agc-linux-only-tests branch from 2e0a909 to 182c892 Compare October 30, 2026 09:27
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 30, 2026
@imellag

imellag commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@MarcZX10 #12168 has merged, so Depends on is now none. Rebased onto main 98ddd9c179 (head 182c89266a): the only change is that #12168's main(int argc, char** argv) skip now sits under this PR's #ifndef __linux__. Reran on macOS on a support branch of today's main, 3 runs: the same results as before (details and logs in Tested). For the SharedWrites.cpp overlap I asked yabanana on #5021 to agree #11437 first: #5021 (comment). The proposed order is in the description.

build-errors-support-base.txt
t11437-pr11437-1.txt
t11437-pr11437-2.txt
t11437-pr11437-3.txt

@MarcZX10

Copy link
Copy Markdown
Contributor

Re-checked — new head, overlap order pending

The merge preview for head 182c89266a40bf584a7f9a1dd7ba8fe03674cc7e against current main d242221ac1f07c0a0a403b740baa0c071d93205e is clean, but #5021 has not acknowledged the proposed order for the overlapping SharedWrites.cpp blocks, so my existing overlap request remains unresolved.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 182c892 merged onto main 98ddd9c · tested 2026-10-30 10:05 UTC · 17 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 785 passed · 3 failed (0 new, 0 also fail on main, 3 unstable on main) · 8 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 796 of 2,987 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (384 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_bda_device 51.9 s
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)
agc_driver_depth_clear_hle: VUID-vkCmdCopyBuffer-commonparent (6x)
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_depth_clear_hle: failed in 1 of the last 8 main runs
agc_submit_progress: failed in 5 of the last 8 main runs
agc_submit_progress_no_timeline: failed in 6 of the last 8 main runs
Validation IDs already present on main (3 IDs in 105 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (105 tests): agc_driver, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_conservative_rasterization, agc_driver_constant_dword_fill, agc_driver_copied_writer_copy, agc_driver_copied_writer_label_order, agc_driver_copy_surface_bytes, and 97 more
VUID-vkCmdCopyImage-srcImage-01548 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_plane_sampling_evicting, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_plane_sampling_evicting, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
Skipped (8)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
Reproduce
git fetch origin 182c89266a40bf584a7f9a1dd7ba8fe03674cc7e 98ddd9c1792bbab016ceed5db267a93d1d61f00a
git checkout 98ddd9c1792bbab016ceed5db267a93d1d61f00a && git merge --no-ff 182c89266a40bf584a7f9a1dd7ba8fe03674cc7e
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The reviewed change updates the three tests’ platform guards to keep Linux-only code off macOS; the source inspected supports the stated skip behavior for the two DMA-BUF tests and limits the /proc leak check and RUSAGE_THREAD fault count to Linux.

What I ran

No build or tests were run. I read the prepared review description, commit list, manifest, diff, README, and each changed file’s added lines and relevant surrounding code at head 182c89266a40bf584a7f9a1dd7ba8fe03674cc7e, using repo_read.py.

Results

Check Result Note
Changed-line review passed All three changed files inspected
Build and tests not run Author reports macOS support-branch results
Linux and Windows behavior not run Author reports unifdef comparisons

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds and runtime behavior were not independently verified. I did not inspect the remainder of the changed files beyond the added lines and relevant surrounding code. files.json was not available as a review document; the manifest lists all three changed files as included, and the review folder lists no excluded changed files.

To get this to a good state

Nothing is required.

@kali113

kali113 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Tested on macOS: Apple M5 Pro, macOS 27.2.1, x86_64 build under Rosetta, Vulkan SDK 1.4.363.1 (MoltenVK).

I haven't looked into the causes.

AI-assisted: yes (Claude Code)

Edit: corrected the helper head and the macOS version above. The runs merged #17425 at faf53f0, which was that PR's head when I fetched it; the head I first wrote (e039596) is its current head, and I had not rebuilt on it.

@oneandonlydean
oneandonlydean merged commit 03cc6a4 into boykopovar:main Nov 15, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants