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

Merged
imellag merged 1 commit from upstream-pr/10676 into main 2026-10-27 04:45:01 +00:00
imellag commented 2026-10-24 16:57:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-24T16:57:58Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4997328908 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10676). Originally posted by [imellag](https://github.com/imellag) on 2026-10-24T16:57:58Z. --- ### 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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Apple M4 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), macOS 27.0.1, x86-64 under Rosetta 2 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 16:59:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T16:59:13Z.

Review: APPROVED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639057933 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10676#pullrequestreview-5639057933). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T16:59:13Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10676
No description provided.