Skip to content

fix(agc): build the pending image snapshot and the queued index read order test with Apple's libc++ - #10676

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
imellag:fix/agc-libcxx-build-macos
Oct 27, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
imellag:fix/agc-libcxx-build-macos

Conversation

@imellag

@imellag imellag commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

What

Two files of libSceAgcDriver don't compile with Apple clang and libc++ on current main:

  • Graphics/src/Texture.cpp: the pending storage image list keeps its published snapshot in a std::atomic<std::shared_ptr<const Snapshot>>. Apple's libc++ has no std::atomic<std::shared_ptr>:
    libc++/__atomic/atomic.h:238:17: error: static assertion failed due to requirement 'is_trivially_copyable<std::shared_ptr<const AgcDriver::Graphics::(anonymous namespace)::PendingList::Snapshot>>::value': std::atomic<T> requires that 'T' be a trivially copyable type
    
    The member now uses AtomicSharedPtr from prx/libc/include/general/AtomicSharedPtr.hpp, the helper that the rest of the driver already uses (DeviceAccess, DispatchCache, DrawCache, GuestBufferMemory, Recorder). Where __cpp_lib_atomic_shared_ptr is defined, as with libstdc++ on Linux and MinGW, the helper is std::atomic<std::shared_ptr<T>> itself, so those builds compile the same code as before. Its load and store take the same memory orders, so the two call sites are unchanged.
  • tests/execution/QueuedIndexReadOrder.cpp: four reinterpret_cast<std::uint64_t> of a std::uintptr_t. On macOS these are different types (unsigned long and unsigned long long), and reinterpret_cast between integer types is ill-formed:
    QueuedIndexReadOrder.cpp:259:34: error: reinterpret_cast from 'std::uintptr_t' (aka 'unsigned long') to 'std::uint64_t' (aka 'unsigned long long') is not allowed
    
    These are now static_cast. This hunk is mugurc's b84909f34e from the macOS series, and he is co-author of the commit.

Neither change is in an open PR. #7332 (closed) and mugurc's integration branch carried a different fix for the snapshot, std::atomic_load_explicit and std::atomic_store_explicit on a plain shared_ptr; the helper on main makes that unnecessary. #7201's base predates both of these main changes.

Tested

Apple M4 Pro, macOS 27.0.1, Apple clang, x86-64 Release (-DCMAKE_OSX_ARCHITECTURES=x86_64, Ninja, BUILD_TESTING=ON).

On main 3fcb5e4d76, with each file compiled using its own command from the build:

  • Without this change, both files fail with the errors above.
  • With it, both compile.

Tests. libSceAgcDriver doesn't link on main on macOS yet, because other files still fail. So I ran the tests on main 3fcb5e4d76 plus the open macOS PRs (#10562, #10641, #10366, #10419, #7631, #7804, #10552, #4630, #10659, #10660, #10669, #10540) and the AGC parts of mugurc's macOS series that aren't in a PR yet. On that tree everything builds except one unrelated libkernel test, and with MoltenVK 1.4.2 from the Vulkan SDK 1.4.363.0:

  • ctest -R '^agc_' with ANYPS5_REQUIRE_VULKAN=1: 967 tests, 833 passed, 76 skipped. 58 fail with this change and with the series' version of the snapshot alike: MoltenVK feature gaps, and tests that load libvulkan.so.1 themselves.
  • agc_driver_queued_index_read_order passes.
  • The tests that use the pending image list (the agc_recorder_* tests, agc_driver_sampled_cache_budget*, agc_driver_dcc_keys_first_write, agc_driver_store_idle_results*, agc_driver_store_over_untracked) pass.
  • agc_driver_image_srgb_sample_copy fails with both versions: it samples 0.030769 where 0.002428 is expected.

Validation layer. main doesn't build on macOS, so instead of a main run I compared this change against the series' version of the snapshot. I ran those 16 tests with ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS. Both logs show the same VUID- errors for the same tests:

  • VkDeviceCreateInfo-pProperties-04451: the test fixtures don't enable VK_KHR_portability_subset.
  • VkImageViewCreateInfo-imageViewFormatReinterpretation-04466 and -imageViewFormatSwizzle-04465.

So this change adds none.

Not built on Linux or Windows. There AtomicSharedPtr is the same std::atomic<std::shared_ptr>, and static_cast of a std::uintptr_t to std::uint64_t is what the old double cast meant.

check_conventions.py --base upstream/main passes. pr_overlap.py reports no conflicting lines. It lists 38 pull requests that it couldn't compare on Texture.cpp because they conflict with main. I checked their Texture.cpp patches, and none touches the snapshot member or its two call sites. None touches the test.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 (Vulkan SDK 1.4.363.0), macOS 27.0.1, x86-64 under Rosetta 2
  • AI-assisted: yes

…order test with Apple's libc++

Co-authored-by: mugurc <mceker@gmail.com>

@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 exact head e6c1d21ae8f1866a3ee4990c530c40a435b40b19 against current upstream main (dc9f1ef656367272f8485b8ed1e11378adf45a2e). The production fix replaces the unsupported std::atomic<std::shared_ptr<const Snapshot>> with the repository’s AtomicSharedPtr helper; its load/store call sites and memory orders remain unchanged, and the helper selects the same C++20 atomic specialization on standard libraries that provide it. The four pointer-to-integer casts in the test now use static_cast, which is valid for the integral conversion on Apple’s distinct uintptr_t/uint64_t typedefs. git diff --check, python3 tools/check_conventions.py --base upstream/main --head upstream/pr/10676, and git merge-tree --write-tree in both merge orders pass locally. Required hosted eligibility, intake, conventions, labels, and report checks pass; product build jobs are skipped by path policy. I could not reproduce the Apple libc++ compilation locally on this Linux host; the reported Apple M4 Pro compile and focused test results are the author’s evidence.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6187 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6960 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6973 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7048 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7604 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8484 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9431 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9432 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9672 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9673 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9674 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9675 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9676 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9842 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9891 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9892 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9893 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10064 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10194 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10435 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10773 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10940 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11485 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp

@github-actions github-actions Bot added the agc libSceAgc* label Oct 24, 2026
iamthehimansh added a commit to iamthehimansh/AnyPS5 that referenced this pull request Oct 26, 2026
…0859

imellag's earlier boykopovar#10676 already makes PendingList::published build with
Apple's libc++, and maximilianfv's earlier boykopovar#10859 keeps sRGB storage images
in their UNORM twin on every driver, which covers MoltenVK. Drop both hunks
here and depend on those PRs.
@adriadam10 adriadam10 self-assigned this Oct 26, 2026
@adriadam10
adriadam10 merged commit f5e3dc5 into boykopovar:main Oct 27, 2026
11 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked that both published.load(acquire) / published.store(release) call sites match AtomicSharedPtr's API, that the helper is std::atomic<std::shared_ptr<T>> wherever __cpp_lib_atomic_shared_ptr is defined (Linux/MinGW unchanged), and that the four static_casts are the same conversion as before. Approved by @MarcZX10 and tested on macOS per the description; merged.

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.

3 participants