feat: macOS host support (Apple Silicon via Rosetta 2, Vulkan on MoltenVK) #8658

Closed
iamthehimansh wants to merge 289 commits from upstream-pr/8658 into main
iamthehimansh commented 2026-10-20 20:13:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-20T20:13:04Z.


What

macOS host support for AnyPS5 on Apple Silicon: the emulator runs as x86_64 under Rosetta 2 and renders through Vulkan on MoltenVK. The relinker and the web converter build natively.

Every platform-specific change is behind __APPLE__ / elseif(APPLE) or sits in specifics/macos/. Before every commit I compared the Linux and Windows preprocessed views of each changed file against main; they are unchanged.

Graphics driver address

  • macOS reserves the AGC driver's fixed 2 MB window at 0xfe0000000 for itself; mmap there fails with EPERM even in an empty process, natively and under Rosetta.
  • On macOS the driver memory moves to 0xee0000000, and the converted shaders are retargeted to that address.

Kernel, libc and networking

  • Directory listing and directory-relative paths.
  • Disk-space queries, rename and same-file checks.
  • Memory locking and unlocking, and write watching.
  • Per-thread CPU time from the Mach thread counter.
  • nanosleep errno, precise waits, and kqueue file and socket events.
  • Socket options, SO_ACCEPTCONN, the UDP pending-bytes count and the stream-send error after a peer close.
  • EPROTOTYPE → NET_EPROTONOSUPPORT in sceNetSocket, which is what FreeBSD reports.
  • IPv4 parsing that rejects leading zeros.
  • acosf precision under Rosetta.
  • The guest TLS entry points, and guest unwinding over Mach-O __eh_frame.

Graphics and video output

  • The macOS Vulkan loader name and portability enumeration.
  • Integer colour targets on Metal, which need uint/int fragment outputs.
  • A shutdown-order fix: the registration-preparation lifecycle mutex outlives static destruction.

Relinker

  • 1 KB of header room in the Mach-O image, so code signing does not overlap the entry stub.

Build

  • macOS-only fixes for headers and linker flags that only exist on Linux, such as link.h, if_link.h, AF_PACKET and --exclude-libs.
  • A few tests use macOS names where the macOS SDK defines a macro with the same name (SIGUSR1).

Tested

Machine: macOS 26 (Darwin 25.6, arm64) on an Apple M2 Pro. The emulator ran as x86_64 under Rosetta 2, with the Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2. To test the GPU path, source setup-env.sh from the SDK and point VK_DRIVER_FILES at MoltenVK_icd.json. The SDK also installs the arm64-only KosmicKrisp ICD, which an x86_64 process cannot load; with VK_DRIVER_FILES set, it no longer logs that.

Builds and conventions:

  • cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON with the full build: 0 failed objects.
  • The relinker-only build: 230/230 tests pass.
  • The web converter build: tools/test_web.py passes.
  • python3 tools/check_conventions.py --base origin/main: all checks pass.

Full ctest on this machine (M2 Pro, macOS 26.6, at 51a06b126): 1,804 tests; 90 are skipped by the tests themselves, and 19 fail. Main does not build on macOS, so before this branch none of these ran. Full runs on an M1 (@Mauro42K) and an M4 (@prosperkartik) are in the thread.

16 of the 19 failures are graphics features that Apple GPUs or MoltenVK do not provide, or graphics paths still open:

  • clip and cull distances (4)
  • denormal and tininess handling (2)
  • sampler min/max reduction, multisample storage images, robust reads past a pooled buffer's end
  • pixel interlock, per-sample masks and sample iteration
  • agc_driver_sample_order, which passes with #9193
  • image-table descriptor reuse: MoltenVK's image limits keep the table in the shared pools, which are not kept
  • tessellation of a merged LS+HS hull program, and indexed indirect rect-list draws (both still open)

The other 3:

  • guest_floating_point: Rosetta ignores the MXCSR exception mask bits.
  • guest_math_exact: Rosetta canonicalises x87 pseudo-denormals.
  • agc_write_tracking: on macOS a host import opens its whole range for writing, so an untouched block in the import window is reported as possibly written by the CPU.

On the M4, agc_driver_ds_permute also fails. SPIRV-Cross forwards the recompiler's unconditional OpGroupNonUniformShuffle into a short-circuit &&/?: operand, which makes the shuffle conditional in MSL; @prosperkartik reduced and filed it as KhronosGroup/SPIRV-Cross#2722.

On the M1 (@Mauro42K, macOS 27.0.1), agc_driver_pass_input_hazard and agc_driver_uint8x4_color_target also fail; both pass on the M2 Pro and the M4 with the same MoltenVK, and the cause is still open.

I have not tested on Linux or Windows. For every changed C/C++ file I compare its Linux and Windows preprocessor views (unifdef with __APPLE__ undefined) with main. 14 files are not macOS-only, and they change what Linux and Windows compile:

  • Whitespace or a comment only: ExportMacros.hpp, DisplayWindow.cpp, ApplicationProcessParameters.cpp.
  • New headers that are empty off macOS: MainThread.hpp, DriverMemory.hpp.
  • The same behaviour, written portably:
    • FileStream.hpp calls feof_unlocked/ferror_unlocked unqualified, so macOS can supply them.
    • CxxAbiSupport.cpp names the __cxa_thread_atexit lambda.
    • Jit.cpp adds #include <filesystem>.
    • QueuedIndexReadOrder.cpp changes 4 reinterpret_casts to static_cast.
    • GuestGenericCategory.cpp adds const_cast before the vtable casts.
    • Formatting.cpp adds <cstdarg> and a clang __builtin_sysv_va_list alias.
    • GuestRaiseException.cpp renames its SIGUSR1 constant to GuestSigUsr1 and uses the shared assembly macros.
  • New macOS target in shared converter code: the relinker's macOS image writer (MacOsImage.cpp) and the web converter's "macos" target option (wasm/Bindings.cpp).

Every other changed file has identical Linux and Windows views.

Homebrew: ccleste (PPSA59322) converts, gets signed, starts, reads its settings and assets and runs into gameplay. It stops at its first mesh-path draw whose pixel shader reads barycentrics, because MoltenVK exposes neither VK_EXT_mesh_shader nor a usable VK_KHR_fragment_shader_barycentric. That needs a non-mesh fallback and is left for a follow-up PR.

Checklist

  • Based on current main; no other open PR implements the same functions. Overlap: #7201 is another full macOS port and conflicts with main. The smaller macOS PRs (#4630, #7631, #7804, #7850, #7937, #8118, #8279, #8477) cover parts of the same ground, and I am happy to rebase onto whichever lands first. The following open PRs each change one hunk that this PR also changes; whichever lands first, the other drops its copy:
    • #9738: ShaderRegistry.cpp lifecycle mutex.
    • #9654: GuestHostStandardError.cpp.
    • #9625: Udp.cpp shutdown_nid_postfix.
    • #9668: Math.cpp acosf.
    • #9789: State.cpp, the uint4 output for raw 32-bit exports into a UINT target (here metalUintOutput, macOS only).
    • #9728: libSceNetCtl/Export.cpp HostTraffic on macOS. Here it reads each interface's 64-bit counters from IFMIB_IFDATA, as @jotitadev measured; #9728 reads getifaddrs, which wraps every 4 GiB.
    • #9971: PerformanceOverlay.cpp ReadProcessPrivateBytes, the same TASK_VM_INFO / phys_footprint hunk split out by @tkcm01. #9971 lands first and this branch takes main's copy.
  • One topic per PR; follow-ups go in a new PR. The topic is the macOS host; it is large, and I can split it by library if you prefer.
  • No comments in code except technical debt. The __APPLE__ blocks carry one-line comments explaining the macOS difference; I will move them into docs/dev/debt/ if you prefer.
  • Unimplemented paths throw (NotImplemented_nid_no_patch); no new silent stubs.
  • No notes, investigation .md files or images added to the repository.
  • New third-party code is a submodule built from source: none added.
  • Generic behaviour, not specific to one title.
  • Depends on: none
  • Fixes: none
  • Unblocks: none yet. ccleste, PPSA59322, starts but stops at the mesh-path draw described above.
  • GPUs tested: Apple M2 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), macOS 26 / Darwin 25.6, x86_64 under Rosetta 2. I have not run the VK_LAYER_KHRONOS_validation comparison against main, because main does not build on macOS.
  • AI-assisted: yes. Every change was built, run and checked by me, and I am responsible for every line.

cc @boykopovar @oneandonlydean @adriadam10. It would help if one of you could start the full Linux/Windows build for this PR (gh workflow run build.yml --repo boykopovar/AnyPS5 --ref main --field pr=8658).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4941849648 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-20T20:13:04Z. --- ### What macOS host support for AnyPS5 on Apple Silicon: the emulator runs as x86_64 under Rosetta 2 and renders through Vulkan on MoltenVK. The relinker and the web converter build natively. Every platform-specific change is behind `__APPLE__` / `elseif(APPLE)` or sits in `specifics/macos/`. Before every commit I compared the Linux and Windows preprocessed views of each changed file against `main`; they are unchanged. **Graphics driver address** - macOS reserves the AGC driver's fixed 2 MB window at `0xfe0000000` for itself; `mmap` there fails with `EPERM` even in an empty process, natively and under Rosetta. - On macOS the driver memory moves to `0xee0000000`, and the converted shaders are retargeted to that address. **Kernel, libc and networking** - Directory listing and directory-relative paths. - Disk-space queries, rename and same-file checks. - Memory locking and unlocking, and write watching. - Per-thread CPU time from the Mach thread counter. - `nanosleep` errno, precise waits, and kqueue file and socket events. - Socket options, `SO_ACCEPTCONN`, the UDP pending-bytes count and the stream-send error after a peer close. - `EPROTOTYPE` → `NET_EPROTONOSUPPORT` in `sceNetSocket`, which is what FreeBSD reports. - IPv4 parsing that rejects leading zeros. - `acosf` precision under Rosetta. - The guest TLS entry points, and guest unwinding over Mach-O `__eh_frame`. **Graphics and video output** - The macOS Vulkan loader name and portability enumeration. - Integer colour targets on Metal, which need `uint`/`int` fragment outputs. - A shutdown-order fix: the registration-preparation lifecycle mutex outlives static destruction. **Relinker** - 1 KB of header room in the Mach-O image, so code signing does not overlap the entry stub. **Build** - macOS-only fixes for headers and linker flags that only exist on Linux, such as `link.h`, `if_link.h`, `AF_PACKET` and `--exclude-libs`. - A few tests use macOS names where the macOS SDK defines a macro with the same name (`SIGUSR1`). ### Tested **Machine:** macOS 26 (Darwin 25.6, arm64) on an Apple M2 Pro. The emulator ran as x86_64 under Rosetta 2, with the Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2. To test the GPU path, `source setup-env.sh` from the SDK and point `VK_DRIVER_FILES` at `MoltenVK_icd.json`. The SDK also installs the arm64-only KosmicKrisp ICD, which an x86_64 process cannot load; with `VK_DRIVER_FILES` set, it no longer logs that. **Builds and conventions:** - `cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON` with the full build: 0 failed objects. - The relinker-only build: 230/230 tests pass. - The web converter build: `tools/test_web.py` passes. - `python3 tools/check_conventions.py --base origin/main`: all checks pass. **Full ctest on this machine (M2 Pro, macOS 26.6, at `51a06b126`):** 1,804 tests; 90 are skipped by the tests themselves, and 19 fail. Main does not build on macOS, so before this branch none of these ran. Full runs on an M1 (@Mauro42K) and an M4 (@prosperkartik) are in the thread. 16 of the 19 failures are graphics features that Apple GPUs or MoltenVK do not provide, or graphics paths still open: - clip and cull distances (4) - denormal and tininess handling (2) - sampler min/max reduction, multisample storage images, robust reads past a pooled buffer's end - pixel interlock, per-sample masks and sample iteration - `agc_driver_sample_order`, which passes with #9193 - image-table descriptor reuse: MoltenVK's image limits keep the table in the shared pools, which are not kept - tessellation of a merged LS+HS hull program, and indexed indirect rect-list draws (both still open) The other 3: - `guest_floating_point`: Rosetta ignores the MXCSR exception mask bits. - `guest_math_exact`: Rosetta canonicalises x87 pseudo-denormals. - `agc_write_tracking`: on macOS a host import opens its whole range for writing, so an untouched block in the import window is reported as possibly written by the CPU. On the M4, `agc_driver_ds_permute` also fails. SPIRV-Cross forwards the recompiler's unconditional `OpGroupNonUniformShuffle` into a short-circuit `&&`/`?:` operand, which makes the shuffle conditional in MSL; @prosperkartik reduced and filed it as KhronosGroup/SPIRV-Cross#2722. On the M1 (@Mauro42K, macOS 27.0.1), `agc_driver_pass_input_hazard` and `agc_driver_uint8x4_color_target` also fail; both pass on the M2 Pro and the M4 with the same MoltenVK, and the cause is still open. I have not tested on Linux or Windows. For every changed C/C++ file I compare its Linux and Windows preprocessor views (`unifdef` with `__APPLE__` undefined) with `main`. 14 files are not macOS-only, and they change what Linux and Windows compile: - **Whitespace or a comment only:** `ExportMacros.hpp`, `DisplayWindow.cpp`, `ApplicationProcessParameters.cpp`. - **New headers that are empty off macOS:** `MainThread.hpp`, `DriverMemory.hpp`. - **The same behaviour, written portably:** - `FileStream.hpp` calls `feof_unlocked`/`ferror_unlocked` unqualified, so macOS can supply them. - `CxxAbiSupport.cpp` names the `__cxa_thread_atexit` lambda. - `Jit.cpp` adds `#include <filesystem>`. - `QueuedIndexReadOrder.cpp` changes 4 `reinterpret_cast`s to `static_cast`. - `GuestGenericCategory.cpp` adds `const_cast` before the vtable casts. - `Formatting.cpp` adds `<cstdarg>` and a clang `__builtin_sysv_va_list` alias. - `GuestRaiseException.cpp` renames its `SIGUSR1` constant to `GuestSigUsr1` and uses the shared assembly macros. - **New macOS target in shared converter code:** the relinker's macOS image writer (`MacOsImage.cpp`) and the web converter's `"macos"` target option (`wasm/Bindings.cpp`). Every other changed file has identical Linux and Windows views. **Homebrew:** ccleste (PPSA59322) converts, gets signed, starts, reads its settings and assets and runs into gameplay. It stops at its first mesh-path draw whose pixel shader reads barycentrics, because MoltenVK exposes neither `VK_EXT_mesh_shader` nor a usable `VK_KHR_fragment_shader_barycentric`. That needs a non-mesh fallback and is left for a follow-up PR. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions. Overlap: #7201 is another full macOS port and conflicts with `main`. The smaller macOS PRs (#4630, #7631, #7804, #7850, #7937, #8118, #8279, #8477) cover parts of the same ground, and I am happy to rebase onto whichever lands first. The following open PRs each change one hunk that this PR also changes; whichever lands first, the other drops its copy: - #9738: `ShaderRegistry.cpp` lifecycle mutex. - #9654: `GuestHostStandardError.cpp`. - #9625: `Udp.cpp` `shutdown_nid_postfix`. - #9668: `Math.cpp` `acosf`. - #9789: `State.cpp`, the `uint4` output for raw 32-bit exports into a UINT target (here `metalUintOutput`, macOS only). - #9728: `libSceNetCtl/Export.cpp` `HostTraffic` on macOS. Here it reads each interface's 64-bit counters from `IFMIB_IFDATA`, as @jotitadev measured; #9728 reads `getifaddrs`, which wraps every 4 GiB. - #9971: `PerformanceOverlay.cpp` `ReadProcessPrivateBytes`, the same `TASK_VM_INFO` / `phys_footprint` hunk split out by @tkcm01. #9971 lands first and this branch takes `main`'s copy. - [x] One topic per PR; follow-ups go in a new PR. The topic is the macOS host; it is large, and I can split it by library if you prefer. - [x] No comments in code except technical debt. The `__APPLE__` blocks carry one-line comments explaining the macOS difference; I will move them into `docs/dev/debt/` if you prefer. - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); no new silent stubs. - [x] No notes, investigation `.md` files or images added to the repository. - [x] New third-party code is a submodule built from source: none added. - [x] Generic behaviour, not specific to one title. - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none yet. ccleste, PPSA59322, starts but stops at the mesh-path draw described above. - [x] GPUs tested: Apple M2 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), macOS 26 / Darwin 25.6, x86_64 under Rosetta 2. I have not run the `VK_LAYER_KHRONOS_validation` comparison against `main`, because `main` does not build on macOS. - [x] AI-assisted: yes. Every change was built, run and checked by me, and I am responsible for every line. cc @boykopovar @oneandonlydean @adriadam10. It would help if one of you could start the full Linux/Windows build for this PR (`gh workflow run build.yml --repo boykopovar/AnyPS5 --ref main --field pr=8658`).
iamthehimansh commented 2026-10-21 01:41:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-21T01:41:07Z.


The branch is merged with main at a806c69bf, so the conflict is gone. The one conflict was the docs/dev/debt/libkernel.md line @MarcZX10 pointed out in #7741: I kept "Linux and macOS" on the SIGUSR1 line and took the new Windows line from main.

Checked on an Apple M2 Pro (macOS, x86_64 under Rosetta 2, Vulkan through MoltenVK):

  • macOS build: 0 failed objects
  • relinker tests: 226/226 passed
  • web converter build and tools/test_web.py: passed
  • Linux and Windows preprocessed views: the only differences from main are the macOS-gated files this PR already touched; nothing new from the merge
  • tools/check_conventions.py --base origin/main: passed

On #7741: the two PRs change different parts of MacOsImage.cpp. #7741 adds bytes to EntryStub; this PR changes where the stub is placed after the load commands. As @MarcZX10 found, they merge without a conflict and neither needs changes for the other. @jotitadev's Rosetta 2 run in #7741 showed the guest 0x9fc0 MXCSR takes effect under Rosetta. Once #7741 lands, I'll recheck whether guest_floating_point still fails on macOS; it is one of the three failures I currently attribute to Rosetta.

Requesting review. @boykopovar @oneandonlydean @adriadam10, and @MarcZX10 and @jotitadev, who checked the macOS entry stub in #7741 and its overlap with this PR. Please take a look when you have time.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305901078 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6305901078). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-21T01:41:07Z. --- The branch is merged with `main` at `a806c69bf`, so the conflict is gone. The one conflict was the `docs/dev/debt/libkernel.md` line @MarcZX10 pointed out in #7741: I kept "Linux and macOS" on the SIGUSR1 line and took the new Windows line from `main`. Checked on an Apple M2 Pro (macOS, x86_64 under Rosetta 2, Vulkan through MoltenVK): - macOS build: 0 failed objects - relinker tests: 226/226 passed - web converter build and `tools/test_web.py`: passed - Linux and Windows preprocessed views: the only differences from `main` are the macOS-gated files this PR already touched; nothing new from the merge - `tools/check_conventions.py --base origin/main`: passed On #7741: the two PRs change different parts of `MacOsImage.cpp`. #7741 adds bytes to `EntryStub`; this PR changes where the stub is placed after the load commands. As @MarcZX10 found, they merge without a conflict and neither needs changes for the other. @jotitadev's Rosetta 2 run in #7741 showed the guest `0x9fc0` MXCSR takes effect under Rosetta. Once #7741 lands, I'll recheck whether `guest_floating_point` still fails on macOS; it is one of the three failures I currently attribute to Rosetta. Requesting review. @boykopovar @oneandonlydean @adriadam10, and @MarcZX10 and @jotitadev, who checked the macOS entry stub in #7741 and its overlap with this PR. Please take a look when you have time.
iamthehimansh commented 2026-10-21 01:48:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-21T01:48:46Z.


Follow-up on the guest_floating_point note above: I applied #7741 on top of this branch and rebuilt (0 failed objects). guest_floating_point and guest_math_exact still abort on macOS with exactly the same output as without it. guest_math passes either way. guest_floating_point stops at "floating-point environment: flag updates preserve exception masks". That check is outside the entry MXCSR that #7741 sets, so #7741 doesn't change these two failures. Both PRs are still independent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305999003 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6305999003). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-21T01:48:46Z. --- Follow-up on the `guest_floating_point` note above: I applied #7741 on top of this branch and rebuilt (0 failed objects). `guest_floating_point` and `guest_math_exact` still abort on macOS with exactly the same output as without it. `guest_math` passes either way. `guest_floating_point` stops at "floating-point environment: flag updates preserve exception masks". That check is outside the entry MXCSR that #7741 sets, so #7741 doesn't change these two failures. Both PRs are still independent.
Mauro42K commented 2026-10-21 11:41:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mauro42K on 2026-10-21T11:41:58Z.


Hi @iamthehimansh,

I’ve recently completed the Apple M1 MoltenVK shader comparisons requested by @imellag for #8578 and #8612.

I noticed that your macOS host support PR has been tested on an M2 Pro. I have an M1 MacBook Pro (8 GB RAM, macOS 27.0.1) with MoltenVK 1.4.2 and the Vulkan SDK already configured.

I’d be happy to independently validate this PR on M1 hardware, including a focused build/test run and, if useful, a small open-source homebrew title such as ccleste.

Would an M1 validation be helpful, and is there a specific commit or test scenario you would prefer?

I’d like to coordinate first to avoid duplicating existing work. Thanks!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315043077 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6315043077). Originally posted by [Mauro42K](https://github.com/Mauro42K) on 2026-10-21T11:41:58Z. --- Hi @iamthehimansh, I’ve recently completed the Apple M1 MoltenVK shader comparisons requested by @imellag for #8578 and #8612. I noticed that your macOS host support PR has been tested on an M2 Pro. I have an M1 MacBook Pro (8 GB RAM, macOS 27.0.1) with MoltenVK 1.4.2 and the Vulkan SDK already configured. I’d be happy to independently validate this PR on M1 hardware, including a focused build/test run and, if useful, a small open-source homebrew title such as ccleste. Would an M1 validation be helpful, and is there a specific commit or test scenario you would prefer? I’d like to coordinate first to avoid duplicating existing work. Thanks!
imellag commented 2026-10-21 14:40:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-21T14:40:35Z.


Tried this PR with two retail Unity titles on Apple silicon. The build is clean, but neither title gets past loading yet.

Machine: Apple M4 Pro (24 GB), macOS 27.0.1, x86-64 under Rosetta 2, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), Apple clang 21.0.0.

Build: this PR at its current head 1f687d621 (with main 1b5d7021a merged in), and earlier at 4a7efd236 merged with main 27bcd6a29; the results below are the same on both. cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DBUILD_TESTING=ON, full build: 0 failed objects, 361 system libraries. Both titles converted with --macos --to-rosetta --registry and their Media/Modules and Media/Plugins directories. Both titles reach gameplay on the closed #7332 branch on the same machine.

God of War Sons of Sparta (PPSA28997): stops about 4 s after start, right after opening the first scene's assets:

[src/Open.cpp:282 sceKernelOpen] path=/app0/Media/sharedassets0.assets flags=0x0 nativeFlags=0x0 mode=00
[src/Open.cpp:282 sceKernelOpen] path=/app0/Media/level0 flags=0x0 nativeFlags=0x0 mode=00
[src/Open.cpp:282 sceKernelOpen] path=/app0/Media/sharedassets0.assets.resS flags=0x0 nativeFlags=0x0 mode=00
Terminating due to uncaught exception of type Il2CppExceptionWrapper
[coredump] uncaught C++ exception 0x200527d80 of type Il2CppExceptionWrapper
[src/Exception.cpp:742 sceKernelDebugRaiseException] sceKernelDebugRaiseException c1=0xa0020008 c2=0x00000000 caller=0x14ac77a20

Same result in five runs (two with only this PR, three with #8083 and #8339 also merged). It is a managed (IL2CPP) exception, and the title's devlog/app/debug.log stays empty. What I could rule out:

  • No NotImplemented_nid_no_patch stub is reached: with a local log line in it, nothing is printed before the exception.
  • No file is mapped at that point: APS5_TRACE_MEMORY=1 shows only reserve, allocate and remap calls between the .resS open and the exception, so the new macOS file mmap path (#7974) is not involved.
  • On #7332, at the same point the next call is an open of /dev/urandom; here that call never comes.

Planet of Lana (PPSA19450): stops at its first draw whose pixel shader reads barycentrics:

[videoout] presentation failed: AGC driver: a pixel shader that reads barycentrics without VK_KHR_fragment_shader_barycentric or geometry shaders needs a triangle list without primitive restart

That is the ccleste stop from the description on the vertex path. On #7332 these draws do not need the emulation: yripper's 376079ada4 (fragmentBarycentricBuiltins, the I/J reads from BaryCoordKHR on MoltenVK) handles them, and main does not have it. With #8083 and #8339 merged on top, Lana gets past that draw and then stops with the same Il2CppExceptionWrapper as God of War, right after opening level7.resS.

Not checked: where the exception is raised. Under lldb the process exits on its own before that point, so I have no backtrace yet. Also not checked: Linux and Windows, the CTest suite and the validation layer.

If you have an idea which call could make IL2CPP throw while loading a scene, I can test a candidate on both titles.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318761582 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6318761582). Originally posted by [imellag](https://github.com/imellag) on 2026-10-21T14:40:35Z. --- Tried this PR with two retail Unity titles on Apple silicon. The build is clean, but neither title gets past loading yet. **Machine:** Apple M4 Pro (24 GB), macOS 27.0.1, x86-64 under Rosetta 2, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), Apple clang 21.0.0. **Build:** this PR at its current head 1f687d621 (with `main` 1b5d7021a merged in), and earlier at 4a7efd236 merged with `main` 27bcd6a29; the results below are the same on both. `cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DBUILD_TESTING=ON`, full build: 0 failed objects, 361 system libraries. Both titles converted with `--macos --to-rosetta --registry` and their `Media/Modules` and `Media/Plugins` directories. Both titles reach gameplay on the closed #7332 branch on the same machine. **God of War Sons of Sparta (PPSA28997):** stops about 4 s after start, right after opening the first scene's assets: ```text [src/Open.cpp:282 sceKernelOpen] path=/app0/Media/sharedassets0.assets flags=0x0 nativeFlags=0x0 mode=00 [src/Open.cpp:282 sceKernelOpen] path=/app0/Media/level0 flags=0x0 nativeFlags=0x0 mode=00 [src/Open.cpp:282 sceKernelOpen] path=/app0/Media/sharedassets0.assets.resS flags=0x0 nativeFlags=0x0 mode=00 Terminating due to uncaught exception of type Il2CppExceptionWrapper [coredump] uncaught C++ exception 0x200527d80 of type Il2CppExceptionWrapper [src/Exception.cpp:742 sceKernelDebugRaiseException] sceKernelDebugRaiseException c1=0xa0020008 c2=0x00000000 caller=0x14ac77a20 ``` Same result in five runs (two with only this PR, three with #8083 and #8339 also merged). It is a managed (IL2CPP) exception, and the title's `devlog/app/debug.log` stays empty. What I could rule out: - No `NotImplemented_nid_no_patch` stub is reached: with a local log line in it, nothing is printed before the exception. - No file is mapped at that point: `APS5_TRACE_MEMORY=1` shows only reserve, allocate and remap calls between the `.resS` open and the exception, so the new macOS file `mmap` path (#7974) is not involved. - On #7332, at the same point the next call is an `open` of `/dev/urandom`; here that call never comes. **Planet of Lana (PPSA19450):** stops at its first draw whose pixel shader reads barycentrics: ```text [videoout] presentation failed: AGC driver: a pixel shader that reads barycentrics without VK_KHR_fragment_shader_barycentric or geometry shaders needs a triangle list without primitive restart ``` That is the ccleste stop from the description on the vertex path. On #7332 these draws do not need the emulation: yripper's 376079ada4 (`fragmentBarycentricBuiltins`, the I/J reads from `BaryCoordKHR` on MoltenVK) handles them, and `main` does not have it. With #8083 and #8339 merged on top, Lana gets past that draw and then stops with the same `Il2CppExceptionWrapper` as God of War, right after opening `level7.resS`. **Not checked:** where the exception is raised. Under lldb the process exits on its own before that point, so I have no backtrace yet. Also not checked: Linux and Windows, the CTest suite and the validation layer. If you have an idea which call could make IL2CPP throw while loading a scene, I can test a candidate on both titles. AI-assisted: yes
iamthehimansh commented 2026-10-21 15:31:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-21T15:31:56Z.


@imellag thank you for testing on the M1 Pro, and for #9193.

Planet of Lana: #9193 is the right fix for that stop, so I'm not adding a copy of it here. The cause: MoltenVK does report VK_KHR_fragment_shader_barycentric (an M2 Pro shows fragmentShaderBarycentric = true), but FragmentBarycentric.hpp switches it off for MoltenVK because Metal rejects PerVertexKHR inputs. With no geometry shaders either, a pixel shader that reads I/J falls back to the triangle-list emulation in Draw.cpp, and that game's draw isn't a plain triangle list. Reading I/J from the built-ins, as #9193 does, avoids the fallback. #9193 merges onto this branch with no conflicts. On an M2 Pro (macOS, x86_64 under Rosetta 2, MoltenVK), #9193 merged on top of this PR builds with no failed objects, and the tests it lists pass: request_serializer, agc_shader_memory, agc_driver_graphics, agc_fragment_barycentric, agc_driver_pixel_barycentric_emulation, plus agc_driver_interpolation_modes and interpolation_reference_range. I have no copy of Planet of Lana here, so this covers the tests, not the game.

SteamWorld Dig and Sonic Mania Plus: I have neither game here, so I can't reproduce them yet. Two things should narrow it down:

  1. Trace the calls into each library right before the throw:
    APS5_TRACE_CALLS=libkernel,libc,libSceAgc (comma-separated library names, or all).
    The last few calls before Il2CppExceptionWrapper should show which one returns something IL2CPP doesn't expect.
  2. On #7332 the next call after sharedassets0.assets.resS is the /dev/urandom open, and here it never happens. So the failure is inside the asset load itself, not in random-number setup. On macOS, the paths that behave differently there are file-backed mmap (16 KiB host pages, and PROT_EXEC is removed while mapping, then restored), st_blocks/st_blksize copied straight from APFS, and fread passing through to the host. A short trace from (1) would tell us which one, and I'll fix it here.

If you can post the trace for either title, I'll take it from there.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6319812338 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6319812338). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-21T15:31:56Z. --- @imellag thank you for testing on the M1 Pro, and for #9193. **Planet of Lana:** #9193 is the right fix for that stop, so I'm not adding a copy of it here. The cause: MoltenVK does report `VK_KHR_fragment_shader_barycentric` (an M2 Pro shows `fragmentShaderBarycentric = true`), but `FragmentBarycentric.hpp` switches it off for MoltenVK because Metal rejects `PerVertexKHR` inputs. With no geometry shaders either, a pixel shader that reads I/J falls back to the triangle-list emulation in `Draw.cpp`, and that game's draw isn't a plain triangle list. Reading I/J from the built-ins, as #9193 does, avoids the fallback. #9193 merges onto this branch with no conflicts. On an M2 Pro (macOS, x86_64 under Rosetta 2, MoltenVK), #9193 merged on top of this PR builds with no failed objects, and the tests it lists pass: `request_serializer`, `agc_shader_memory`, `agc_driver_graphics`, `agc_fragment_barycentric`, `agc_driver_pixel_barycentric_emulation`, plus `agc_driver_interpolation_modes` and `interpolation_reference_range`. I have no copy of Planet of Lana here, so this covers the tests, not the game. **SteamWorld Dig and Sonic Mania Plus:** I have neither game here, so I can't reproduce them yet. Two things should narrow it down: 1. Trace the calls into each library right before the throw: `APS5_TRACE_CALLS=libkernel,libc,libSceAgc` (comma-separated library names, or `all`). The last few calls before `Il2CppExceptionWrapper` should show which one returns something IL2CPP doesn't expect. 2. On #7332 the next call after `sharedassets0.assets.resS` is the `/dev/urandom` open, and here it never happens. So the failure is inside the asset load itself, not in random-number setup. On macOS, the paths that behave differently there are file-backed `mmap` (16 KiB host pages, and `PROT_EXEC` is removed while mapping, then restored), `st_blocks`/`st_blksize` copied straight from APFS, and `fread` passing through to the host. A short trace from (1) would tell us which one, and I'll fix it here. If you can post the trace for either title, I'll take it from there. AI-assisted: yes
iamthehimansh commented 2026-10-21 15:31:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-21T15:31:57Z.


@Mauro42K yes please, M1 results would help. Everything so far has been checked on an M2 Pro (and imellag's M1 Pro and M4 Pro reports), so another machine catches anything that depends on the chip or the macOS version.

Please test the PR's head commit as it stands (0a6c0fdd2 right now), built as in the PR description (x86_64 under Rosetta 2, Vulkan through MoltenVK):

  1. Full test suite: ctest --test-dir build-macos -j6 --timeout 300. On the M2 Pro, 22 of 1774 tests fail at this commit. Post the names of the ones that fail for you and I'll compare them with that list; anything new is what I'm after, and the test name plus its output is enough.
  2. ccleste: it should reach and play its levels.
  3. Any retail game you have: the title, how far it gets, and the last lines of the log. Unity titles currently stop in IL2CPP while loading the first scene, so those are useful too.

Please include your chip, RAM, macOS version, and MoltenVK / Vulkan SDK version.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6319812858 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6319812858). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-21T15:31:57Z. --- @Mauro42K yes please, M1 results would help. Everything so far has been checked on an M2 Pro (and imellag's M1 Pro and M4 Pro reports), so another machine catches anything that depends on the chip or the macOS version. Please test the PR's head commit as it stands (`0a6c0fdd2` right now), built as in the PR description (x86_64 under Rosetta 2, Vulkan through MoltenVK): 1. **Full test suite:** `ctest --test-dir build-macos -j6 --timeout 300`. On the M2 Pro, 22 of 1774 tests fail at this commit. Post the names of the ones that fail for you and I'll compare them with that list; anything new is what I'm after, and the test name plus its output is enough. 2. **ccleste:** it should reach and play its levels. 3. **Any retail game you have:** the title, how far it gets, and the last lines of the log. Unity titles currently stop in IL2CPP while loading the first scene, so those are useful too. Please include your chip, RAM, macOS version, and MoltenVK / Vulkan SDK version. AI-assisted: yes
imellag commented 2026-10-21 17:00:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-21T17:00:42Z.


@iamthehimansh thanks. A small correction first: my machine is an M4 Pro (not M1 Pro), and SteamWorld Dig and Sonic Mania Plus are not from my report; my two titles are God of War Sons of Sparta (PPSA28997) and Planet of Lana (PPSA19450).

APS5_TRACE_CALLS is not available on macOS (docs/dev/debt/libc.md on this branch says call tracing is missing there), so instead I printed the managed exception in sceKernelDebugWriteCppExceptionInfo with a local, never-pushed log line (class name and message read from the Il2CppException the wrapper points to). That found two causes, both fixed on the closed #7332 branch but in no open PR. With the two fixes below on top of this PR and #9193, both titles reach gameplay.

Machine: Apple M4 Pro (24 GB), macOS 27.0.1, x86-64 under Rosetta 2, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0).
Build: this PR at 0a6c0fdd2 + #9193, full Release build, 0 failed objects.

1. The Il2CppExceptionWrapper at load is a System.DllNotFoundException. Could you add the fix to this PR?

class System.DllNotFoundException
message: Unable to load DLL 'libfmodstudio'. Tried the load the following dynamic libraries: Unable to load dynamic library '/app0/Media/Plugins/libfmodstudio.prx' because of 'Failed to open the requested dynamic library (0x06000000) (SCEError:0x80020002)
dlerror: dlopen(.../app0/Media/Plugins/libfmodstudio.prx.guest.prx, 0x0006): symbol not found in flat namespace '_5o-pWj4G91E#guest'

So it is not the asset load: libfmodstudio imports from libfmod, which sceKernelLoadStartModule opened RTLD_LOCAL, and dyld's flat lookup skips local images. Ycaro Gabriel fixed this on #7332 in 2d500a0d36 ("make guest modules visible to later modules' imports on macOS": host dlopen always RTLD_GLOBAL on macOS, dlsym with the default handle still skips modules the guest opened locally, plus a guest_dynamic_loader check and a debt line) and split it out as #8481, which the open-PR limit closed. It cannot go to main on its own, because the macOS DefaultScopeSymbol/FromGuestModule it changes exist only in this PR, so this PR is the place for it. It applies here with two trivial conflicts: the new image field goes in its own #ifdef __APPLE__ next to globalOrder in Module, and the debt line goes after the existing entries.

2. God of War then stops on an exception it is meant to catch: opened as #9263.

class FMODUnity.BusNotFoundException
message: [FMOD] Bus not found 'bus:/Master Bus/Dialogue'

sceKernelGetModuleInfoForUnwind left eh_frame_addr/eh_frame_size at zero for a relinked image on macOS, and sceSysmoduleGetModuleInfoForUnwind threw on every call (failed to open /proc/self/maps), so the title's own unwinder could not reach its handler. #9263 fixes both on main (carried over from mugurc's 92d7098f1 on #7332). Your DWARF unwind tables in the libraries already cover the host frames, so #7332's libunwind fallback is not needed on top of this PR.

Title this PR + #9193 + 2d500a0d36 + #9263
God of War (PPSA28997) FMODUnity.BusNotFoundException ends in terminate during the first scene load Cyclops fight, 27.0 fps, GPU 34.8 ms per frame
Planet of Lana (PPSA19450) gameplay in the village, 21.7 fps, GPU 33.8 ms per frame not run

Frames dumped through menus and gameplay in both titles look correct. Each cell is one run (automated input, restored save), so the fps values are a reference, not an A/B.

Tests on this stack: guest_dynamic_loader, guest_dynamic_loader_variant_names, guest_sysmodule, guest_unwind_module_info (new on macOS in #9263), unwind_record_bounds and the unwind_callback_abi_* tests pass.

Not checked: Linux and Windows, the full CTest suite and the validation layer on this stack.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321721302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6321721302). Originally posted by [imellag](https://github.com/imellag) on 2026-10-21T17:00:42Z. --- @iamthehimansh thanks. A small correction first: my machine is an M4 Pro (not M1 Pro), and SteamWorld Dig and Sonic Mania Plus are not from my report; my two titles are God of War Sons of Sparta (PPSA28997) and Planet of Lana (PPSA19450). `APS5_TRACE_CALLS` is not available on macOS (`docs/dev/debt/libc.md` on this branch says call tracing is missing there), so instead I printed the managed exception in `sceKernelDebugWriteCppExceptionInfo` with a local, never-pushed log line (class name and message read from the `Il2CppException` the wrapper points to). That found two causes, both fixed on the closed #7332 branch but in no open PR. With the two fixes below on top of this PR and #9193, both titles reach gameplay. **Machine:** Apple M4 Pro (24 GB), macOS 27.0.1, x86-64 under Rosetta 2, MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0). **Build:** this PR at 0a6c0fdd2 + #9193, full Release build, 0 failed objects. **1. The `Il2CppExceptionWrapper` at load is a `System.DllNotFoundException`. Could you add the fix to this PR?** ```text class System.DllNotFoundException message: Unable to load DLL 'libfmodstudio'. Tried the load the following dynamic libraries: Unable to load dynamic library '/app0/Media/Plugins/libfmodstudio.prx' because of 'Failed to open the requested dynamic library (0x06000000) (SCEError:0x80020002) dlerror: dlopen(.../app0/Media/Plugins/libfmodstudio.prx.guest.prx, 0x0006): symbol not found in flat namespace '_5o-pWj4G91E#guest' ``` So it is not the asset load: `libfmodstudio` imports from `libfmod`, which `sceKernelLoadStartModule` opened `RTLD_LOCAL`, and dyld's flat lookup skips local images. Ycaro Gabriel fixed this on #7332 in 2d500a0d36 ("make guest modules visible to later modules' imports on macOS": host `dlopen` always `RTLD_GLOBAL` on macOS, `dlsym` with the default handle still skips modules the guest opened locally, plus a `guest_dynamic_loader` check and a debt line) and split it out as #8481, which the open-PR limit closed. It cannot go to `main` on its own, because the macOS `DefaultScopeSymbol`/`FromGuestModule` it changes exist only in this PR, so this PR is the place for it. It applies here with two trivial conflicts: the new `image` field goes in its own `#ifdef __APPLE__` next to `globalOrder` in `Module`, and the debt line goes after the existing entries. **2. God of War then stops on an exception it is meant to catch: opened as #9263.** ```text class FMODUnity.BusNotFoundException message: [FMOD] Bus not found 'bus:/Master Bus/Dialogue' ``` `sceKernelGetModuleInfoForUnwind` left `eh_frame_addr`/`eh_frame_size` at zero for a relinked image on macOS, and `sceSysmoduleGetModuleInfoForUnwind` threw on every call (`failed to open /proc/self/maps`), so the title's own unwinder could not reach its handler. #9263 fixes both on `main` (carried over from mugurc's 92d7098f1 on #7332). Your DWARF unwind tables in the libraries already cover the host frames, so #7332's libunwind fallback is not needed on top of this PR. | Title | this PR + #9193 + 2d500a0d36 | + #9263 | |---|---|---| | God of War (PPSA28997) | `FMODUnity.BusNotFoundException` ends in `terminate` during the first scene load | Cyclops fight, 27.0 fps, GPU 34.8 ms per frame | | Planet of Lana (PPSA19450) | gameplay in the village, 21.7 fps, GPU 33.8 ms per frame | not run | Frames dumped through menus and gameplay in both titles look correct. Each cell is one run (automated input, restored save), so the fps values are a reference, not an A/B. **Tests on this stack:** `guest_dynamic_loader`, `guest_dynamic_loader_variant_names`, `guest_sysmodule`, `guest_unwind_module_info` (new on macOS in #9263), `unwind_record_bounds` and the `unwind_callback_abi_*` tests pass. **Not checked:** Linux and Windows, the full CTest suite and the validation layer on this stack. AI-assisted: yes
iamthehimansh commented 2026-10-21 17:26:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-21T17:26:02Z.


@imellag thank you, and sorry for both mistakes in my last reply: your machine is an M4 Pro, your titles are God of War Sons of Sparta and Planet of Lana (SteamWorld Dig and Sonic Mania Plus were my mix-up), and APS5_TRACE_CALLS does not work on macOS, as docs/dev/debt/libc.md says. Printing the managed exception was the right way to find it.

Ycaro Gabriel's fix is now in this PR: 2d500a0d36 is cherry-picked as c8a1d75e5 with Ycaro Gabriel as author (-x keeps the reference), resolved as you described: the image field sits in its own #ifdef __APPLE__ next to globalOrder in Module, and the debt line goes after the existing entries.

One change from the original: on this branch git applied the RTLD_LOCAL filter to the Linux DefaultScopeSymbol rather than the macOS one, since both have the same body here. I moved it into the macOS DefaultScopeSymbol and put the new guest_dynamic_loader checks under #ifdef __APPLE__, so the Linux and Windows views of DynamicLoader.cpp and GuestDynamicLoader.cpp are unchanged.

Checked on an M2 Pro (x86-64 under Rosetta 2, MoltenVK, Vulkan SDK 1.4.363.0):

  • build: 0 failed objects
  • guest_dynamic_loader, guest_dynamic_loader_variant_names, guest_sysmodule, guest_needed_modules, guest_deferred_dependencies pass
  • full suite: 20 of 1775 tests fail, none new compared with the branch before this commit; the Linux and Windows views of every changed file are unchanged; conventions pass

I don't have either title, so the gameplay result is yours, not mine. #9263 stays a separate PR against main, as you opened it.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322239421 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6322239421). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-21T17:26:02Z. --- @imellag thank you, and sorry for both mistakes in my last reply: your machine is an M4 Pro, your titles are God of War Sons of Sparta and Planet of Lana (SteamWorld Dig and Sonic Mania Plus were my mix-up), and `APS5_TRACE_CALLS` does not work on macOS, as `docs/dev/debt/libc.md` says. Printing the managed exception was the right way to find it. **Ycaro Gabriel's fix is now in this PR:** 2d500a0d36 is cherry-picked as c8a1d75e5 with Ycaro Gabriel as author (`-x` keeps the reference), resolved as you described: the `image` field sits in its own `#ifdef __APPLE__` next to `globalOrder` in `Module`, and the debt line goes after the existing entries. One change from the original: on this branch git applied the `RTLD_LOCAL` filter to the Linux `DefaultScopeSymbol` rather than the macOS one, since both have the same body here. I moved it into the macOS `DefaultScopeSymbol` and put the new `guest_dynamic_loader` checks under `#ifdef __APPLE__`, so the Linux and Windows views of `DynamicLoader.cpp` and `GuestDynamicLoader.cpp` are unchanged. Checked on an M2 Pro (x86-64 under Rosetta 2, MoltenVK, Vulkan SDK 1.4.363.0): - build: 0 failed objects - `guest_dynamic_loader`, `guest_dynamic_loader_variant_names`, `guest_sysmodule`, `guest_needed_modules`, `guest_deferred_dependencies` pass - full suite: 20 of 1775 tests fail, none new compared with the branch before this commit; the Linux and Windows views of every changed file are unchanged; conventions pass I don't have either title, so the gameplay result is yours, not mine. #9263 stays a separate PR against `main`, as you opened it. AI-assisted: yes
Mauro42K commented 2026-10-21 22:45:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mauro42K on 2026-10-21T22:45:06Z.


Hi @iamthehimansh — I completed the full CTest suite on an Apple M1 MacBook Pro (MacBookPro17,1; 8 GB RAM).

Environment: macOS 27.0.1 (build 26A434), with the test binaries built for x86_64 and run under Rosetta 2. The build used Release, Ninja, Apple clang 21.0.0, CMake 4.4.0, and -j2. Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2 were available; Vulkan reported an Apple M1 device.

Tested commit: 3d649b8a47 from #8658.

The unfiltered CTest run discovered 1,780 tests:

Result Count
Passed 1,665
Failed 25
Skipped 90
Timed out 0

CTest exited with code 8. I then reran two failures individually three times each with -j1:

  • guest_refused_connect failed 3/3 with SIGABRT (Abort trap: 6), including in the full run. It produced no test stdout/stderr. The crash reports consistently show r14=259, r15=22. The test expects SceNet errno 61 (ECONNREFUSED); the register and Release-binary disassembly evidence points to errno 22 (EINVAL) instead. That errno interpretation is inferred from the available evidence, not printed directly by the test.
  • guest_kernel_app_archive_plain passed 3/3 in isolation, although it failed in the full suite. Its original run aborted with an uncaught std::runtime_error while opening /app0/Plain.txt: app0.zar is not a readable ZArchive. The test is intended to cover a plain file without an archive, but I could not establish why the archive was treated as unreadable in the full run.

All 25 failures from the full run

  1. guest_floating_point — floating-point environment: flag updates preserve exception masks
  2. guest_math_exact — SIGABRT (Abort trap: 6); no test stdout/stderr.
  3. agc_write_tracking — write tracking test failed: a block the import window did not touch reads as written
  4. agc_driver_vertex_target_range_imported — host imports stay watched / AGC graphics: the draw did not consume the GPU-produced vertex offset
  5. agc_driver_f32_constant_factor_tininess — AGC graphics: f32 tininess after rounding: lane 2 no float mode v_mul_f32 0x3f7ffffe is 0x00000000, expected 0x00800000
  6. agc_driver_f32_denormal_flush — AGC graphics: f32 denormal flush: lane 8 no float mode v_fma_f32 v14, v4, v5, v6 is 0x00000000, expected 0x00800000
  7. agc_driver_image_plane_bias_on_single_level_volume — AGC graphics: guest sampler descriptor uses a min or max reduction which the device does not support
  8. agc_driver_image_table_reuse — AGC graphics: image table reuse: three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0
  9. agc_driver_multisample_retirement — AGC graphics: the device cannot write the multisampled color target's format as a storage image at its sample count
  10. agc_driver_pass_input_hazard — AGC graphics: pass input hazard without depth: the draw reading its indices in place did not cover its target, a later pass overwrote them first
  11. agc_driver_pixel_interlock — AGC graphics: vkCreateGraphicsPipelines: Vulkan result -3
  12. agc_driver_pixel_sample_iteration — Barycentric geometry SPIR-V: geometry shaders are unavailable (the log also reported the recompiled-module sample-index/location-table check)
  13. agc_driver_pooled_buffer_range — AGC graphics: a robust read of word 28 of a 100-byte pooled buffer returned 0xabababab
  14. agc_driver_rect_list_indirect — AGC graphics: rect-list requires finite nondegenerate axis-aligned positions with equal positive W; the process terminated on an uncaught std::runtime_error with the same message.
  15. agc_driver_sample_mask_multisample — AGC graphics: 4x per-sample shading with samples 0 and 2 of every pixel: sample 1 of pixel (0, 0) stored (1), the quad pixel's mask is 5
  16. agc_driver_sample_order — Barycentric geometry SPIR-V: geometry shaders are unavailable
  17. agc_driver_tessellation — AGC graphics: merged hull program, unculled: the level-1 patch was not drawn as one flat triangle, centre (16, 24, 40, 255)
  18. agc_driver_uint8x4_color_target — AGC graphics: a UINT16_ABGR export into a SW_64KB_D_X target: byte 0 is 90, expected 35
  19. agc_driver_vertex_clip_cull_distances — AGC graphics: vertex clip or cull distance needs shaderClipDistance or shaderCullDistance, which the device lacks (PA_CL_VS_OUT_CNTL=0x00400100)
  20. agc_driver_vertex_clip_cull_draw — same missing shaderClipDistance/shaderCullDistance capability, with PA_CL_VS_OUT_CNTL=0x00400400; the process terminated on an uncaught std::runtime_error.
  21. agc_driver_vertex_user_data_tail — [gpu] driver failure: AGC graphics: vertex clip or cull distance needs shaderClipDistance or shaderCullDistance, which the device lacks (PA_CL_VS_OUT_CNTL=0x00400100)
  22. agc_driver_vertex_clip_cull_draw_no_key — same missing clip/cull-distance capability with PA_CL_VS_OUT_CNTL=0x00400400; the process terminated on an uncaught std::runtime_error.
  23. guest_refused_connect — SIGABRT (Abort trap: 6); no test stdout/stderr. See the isolated-run evidence above.
  24. guest_kernel_app_archive_plain — libc++abi: terminating due to uncaught exception of type std::runtime_error: app0.zar is not a readable ZArchive (the path was under the test's temporary directory). See the isolated-run results above.
  25. guest_path_name_length — a path of exactly 1023 bytes must not be too long (errno 63)

Comparison with the M2 Pro report

The PR description reports 1,650 passes, 40 failures, and 83 skips on an M2 Pro. Both reports therefore have 1,690 non-skipped tests, while this M1 run has seven more skipped tests. The report identifies 37 of the M2 failures broadly as graphics-related and names three Rosetta/macOS failures—guest_floating_point, guest_math_exact, and guest_path_name_length—which also failed here.

This is not a controlled hardware comparison: the exact M2-tested SHA is not identified in the PR description, and the machines and macOS environments differ. The description does not list the 37 graphics failure names, so their overlap with the M1 failures cannot be established. These results alone do not demonstrate an M1-specific regression.

AI-assisted: yes. Codex was used to run and document the tests; logs and results were retained locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328215301 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6328215301). Originally posted by [Mauro42K](https://github.com/Mauro42K) on 2026-10-21T22:45:06Z. --- Hi @iamthehimansh — I completed the full CTest suite on an Apple M1 MacBook Pro (MacBookPro17,1; 8 GB RAM). **Environment:** macOS 27.0.1 (build 26A434), with the test binaries built for x86_64 and run under Rosetta 2. The build used Release, Ninja, Apple clang 21.0.0, CMake 4.4.0, and -j2. Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2 were available; Vulkan reported an Apple M1 device. **Tested commit:** 3d649b8a477db9f016214b97646e721a0405a6a3 from #8658. The unfiltered CTest run discovered 1,780 tests: | Result | Count | | --- | ---: | | Passed | 1,665 | | Failed | 25 | | Skipped | 90 | | Timed out | 0 | CTest exited with code 8. I then reran two failures individually three times each with -j1: - **guest_refused_connect** failed **3/3** with SIGABRT (Abort trap: 6), including in the full run. It produced no test stdout/stderr. The crash reports consistently show r14=259, r15=22. The test expects SceNet errno 61 (ECONNREFUSED); the register and Release-binary disassembly evidence points to errno 22 (EINVAL) instead. That errno interpretation is inferred from the available evidence, not printed directly by the test. - **guest_kernel_app_archive_plain** passed **3/3** in isolation, although it failed in the full suite. Its original run aborted with an uncaught std::runtime_error while opening /app0/Plain.txt: app0.zar is not a readable ZArchive. The test is intended to cover a plain file without an archive, but I could not establish why the archive was treated as unreadable in the full run. ### All 25 failures from the full run 1. **guest_floating_point** — floating-point environment: flag updates preserve exception masks 2. **guest_math_exact** — SIGABRT (Abort trap: 6); no test stdout/stderr. 3. **agc_write_tracking** — write tracking test failed: a block the import window did not touch reads as written 4. **agc_driver_vertex_target_range_imported** — host imports stay watched / AGC graphics: the draw did not consume the GPU-produced vertex offset 5. **agc_driver_f32_constant_factor_tininess** — AGC graphics: f32 tininess after rounding: lane 2 no float mode v_mul_f32 0x3f7ffffe is 0x00000000, expected 0x00800000 6. **agc_driver_f32_denormal_flush** — AGC graphics: f32 denormal flush: lane 8 no float mode v_fma_f32 v14, v4, v5, v6 is 0x00000000, expected 0x00800000 7. **agc_driver_image_plane_bias_on_single_level_volume** — AGC graphics: guest sampler descriptor uses a min or max reduction which the device does not support 8. **agc_driver_image_table_reuse** — AGC graphics: image table reuse: three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0 9. **agc_driver_multisample_retirement** — AGC graphics: the device cannot write the multisampled color target's format as a storage image at its sample count 10. **agc_driver_pass_input_hazard** — AGC graphics: pass input hazard without depth: the draw reading its indices in place did not cover its target, a later pass overwrote them first 11. **agc_driver_pixel_interlock** — AGC graphics: vkCreateGraphicsPipelines: Vulkan result -3 12. **agc_driver_pixel_sample_iteration** — Barycentric geometry SPIR-V: geometry shaders are unavailable (the log also reported the recompiled-module sample-index/location-table check) 13. **agc_driver_pooled_buffer_range** — AGC graphics: a robust read of word 28 of a 100-byte pooled buffer returned 0xabababab 14. **agc_driver_rect_list_indirect** — AGC graphics: rect-list requires finite nondegenerate axis-aligned positions with equal positive W; the process terminated on an uncaught std::runtime_error with the same message. 15. **agc_driver_sample_mask_multisample** — AGC graphics: 4x per-sample shading with samples 0 and 2 of every pixel: sample 1 of pixel (0, 0) stored (1), the quad pixel's mask is 5 16. **agc_driver_sample_order** — Barycentric geometry SPIR-V: geometry shaders are unavailable 17. **agc_driver_tessellation** — AGC graphics: merged hull program, unculled: the level-1 patch was not drawn as one flat triangle, centre (16, 24, 40, 255) 18. **agc_driver_uint8x4_color_target** — AGC graphics: a UINT16_ABGR export into a SW_64KB_D_X target: byte 0 is 90, expected 35 19. **agc_driver_vertex_clip_cull_distances** — AGC graphics: vertex clip or cull distance needs shaderClipDistance or shaderCullDistance, which the device lacks (PA_CL_VS_OUT_CNTL=0x00400100) 20. **agc_driver_vertex_clip_cull_draw** — same missing shaderClipDistance/shaderCullDistance capability, with PA_CL_VS_OUT_CNTL=0x00400400; the process terminated on an uncaught std::runtime_error. 21. **agc_driver_vertex_user_data_tail** — [gpu] driver failure: AGC graphics: vertex clip or cull distance needs shaderClipDistance or shaderCullDistance, which the device lacks (PA_CL_VS_OUT_CNTL=0x00400100) 22. **agc_driver_vertex_clip_cull_draw_no_key** — same missing clip/cull-distance capability with PA_CL_VS_OUT_CNTL=0x00400400; the process terminated on an uncaught std::runtime_error. 23. **guest_refused_connect** — SIGABRT (Abort trap: 6); no test stdout/stderr. See the isolated-run evidence above. 24. **guest_kernel_app_archive_plain** — libc++abi: terminating due to uncaught exception of type std::runtime_error: app0.zar is not a readable ZArchive (the path was under the test's temporary directory). See the isolated-run results above. 25. **guest_path_name_length** — a path of exactly 1023 bytes must not be too long (errno 63) ### Comparison with the M2 Pro report The PR description reports 1,650 passes, 40 failures, and 83 skips on an M2 Pro. Both reports therefore have 1,690 non-skipped tests, while this M1 run has seven more skipped tests. The report identifies 37 of the M2 failures broadly as graphics-related and names three Rosetta/macOS failures—guest_floating_point, guest_math_exact, and guest_path_name_length—which also failed here. This is not a controlled hardware comparison: the exact M2-tested SHA is not identified in the PR description, and the machines and macOS environments differ. The description does not list the 37 graphics failure names, so their overlap with the M1 failures cannot be established. These results alone do not demonstrate an M1-specific regression. AI-assisted: yes. Codex was used to run and document the tests; logs and results were retained locally.
iamthehimansh commented 2026-10-21 22:54:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-21T22:54:54Z.


@Mauro42K thank you, this is very useful. It's the first full M1 run of this branch.

I compared your 25 failures with my M2 Pro (macOS 26.6, Rosetta 2, MoltenVK 1.4.2). The PR head is now a1fb8e3e9.

20 match failures I already track on M2. These are MoltenVK device limits (clip/cull distance, sampler min/max reduction, multisample storage, robust buffer reads, no geometry shaders), Rosetta x87/FP-environment limits (guest_floating_point, guest_math_exact), the import write-protection trade-off (agc_write_tracking), and the tessellation/rect-list draws that are still open.

  • agc_driver_sample_order passes once #9193 lands.
  • guest_path_name_length is fixed since your commit (4ebe71f2e). Darwin's PATH_MAX is 1024, the same as the guest limit, so a 1023-byte guest path overflowed once the host root was prepended.

5 do not fail on M2. Each one passes 3/3 alone and in my full run at a1fb8e3e9:

  • guest_kernel_app_archive_plain: you saw it pass 3/3 alone too, so I'm treating it as load-sensitive for now.
  • agc_driver_vertex_target_range_imported, agc_driver_pass_input_hazard, agc_driver_uint8x4_color_target: could you rerun these three alone with -j1? If they still fail on M1, they are an M1 GPU / MoltenVK difference and I'll look at them.
  • guest_refused_connect: failing 3/3 alone on M1 looks real. The test makes one blocking connect to a closed loopback port, through libkernel and through libSceNet, and expects ECONNREFUSED (61). The host errno passes straight through on macOS, so EINVAL (22) would mean Darwin's connect() itself returned EINVAL on your machine. That could be a macOS 27 change. A backtrace would show which Require fires:
    lldb -b -o run -o bt -- build-macos/tests/guest_refused_connect_tests
    

The skip difference (90 vs 83) comes from tests added upstream since the description was written. I'll update the numbers in the PR description.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328371473 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6328371473). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-21T22:54:54Z. --- @Mauro42K thank you, this is very useful. It's the first full M1 run of this branch. I compared your 25 failures with my M2 Pro (macOS 26.6, Rosetta 2, MoltenVK 1.4.2). The PR head is now `a1fb8e3e9`. **20 match failures I already track on M2.** These are MoltenVK device limits (clip/cull distance, sampler min/max reduction, multisample storage, robust buffer reads, no geometry shaders), Rosetta x87/FP-environment limits (`guest_floating_point`, `guest_math_exact`), the import write-protection trade-off (`agc_write_tracking`), and the tessellation/rect-list draws that are still open. - `agc_driver_sample_order` passes once #9193 lands. - `guest_path_name_length` is fixed since your commit (`4ebe71f2e`). Darwin's `PATH_MAX` is 1024, the same as the guest limit, so a 1023-byte guest path overflowed once the host root was prepended. **5 do not fail on M2.** Each one passes 3/3 alone and in my full run at `a1fb8e3e9`: - `guest_kernel_app_archive_plain`: you saw it pass 3/3 alone too, so I'm treating it as load-sensitive for now. - `agc_driver_vertex_target_range_imported`, `agc_driver_pass_input_hazard`, `agc_driver_uint8x4_color_target`: could you rerun these three alone with `-j1`? If they still fail on M1, they are an M1 GPU / MoltenVK difference and I'll look at them. - `guest_refused_connect`: failing 3/3 alone on M1 looks real. The test makes one blocking connect to a closed loopback port, through libkernel and through libSceNet, and expects ECONNREFUSED (61). The host errno passes straight through on macOS, so EINVAL (22) would mean Darwin's `connect()` itself returned EINVAL on your machine. That could be a macOS 27 change. A backtrace would show which `Require` fires: ``` lldb -b -o run -o bt -- build-macos/tests/guest_refused_connect_tests ``` The skip difference (90 vs 83) comes from tests added upstream since the description was written. I'll update the numbers in the PR description. AI-assisted: yes
Gonic0 commented 2026-10-21 23:52:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gonic0 on 2026-10-21T23:52:23Z.


One data point on guest_refused_connect: at this PR's head a1fb8e3e9 it passes 3/3 alone (-j1) on an M5 Pro with macOS 27.2 (26B5086k), Release x86_64 under Rosetta 2, Apple clang 21. So it isn't macOS 27 as a whole. It's either something in 27.0.1 or specific to the M1.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329180703 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6329180703). Originally posted by [Gonic0](https://github.com/Gonic0) on 2026-10-21T23:52:23Z. --- One data point on `guest_refused_connect`: at this PR's head `a1fb8e3e9` it passes 3/3 alone (`-j1`) on an M5 Pro with macOS 27.2 (26B5086k), Release x86_64 under Rosetta 2, Apple clang 21. So it isn't macOS 27 as a whole. It's either something in 27.0.1 or specific to the M1. AI-assisted: yes
Mauro42K commented 2026-10-22 00:08:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mauro42K on 2026-10-22T00:08:14Z.


Hi @iamthehimansh — thanks for comparing the M1 and M2 Pro results!

I completed the requested focused retests on my Apple M1 MacBook Pro (8 GB RAM, macOS 27.0.1), using the existing Release x86_64 / Rosetta 2 build with Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2.

Tested commit: 3d649b8a47 from #8658.

All three AGC tests were run individually, three times each, with -j1:

Test M1 result
agc_driver_vertex_target_range_imported 3/3 PASS
agc_driver_pass_input_hazard 3/3 FAIL
agc_driver_uint8x4_color_target 3/3 FAIL

The vertex target test now passes consistently in isolation, although it failed in my earlier full suite.

The other two failures are reproducible:

  • agc_driver_pass_input_hazard: same index-coverage discrepancy as in my original report.
  • agc_driver_uint8x4_color_target: byte 0 remains 90, expected 35.

Regarding guest_refused_connect:

I attempted the requested LLDB investigation. LLDB recognized the x86_64 executable but remained blocked during run, without producing a backtrace. A separate isolated CTest attempt also stalled beyond its configured timeout.

Earlier isolated runs had failed 3/3 with SIGABRT, but these new attempts did not provide a usable backtrace or confirm which Require failed. I therefore cannot establish whether EINVAL is the actual cause.

I also saw @Gonic0’s M5 Pro/macOS 27.2 result (3/3 PASS). That is useful additional evidence, although our macOS versions and tested commits differ.

Additional homebrew result — ccleste (PPSA59322):

I independently tested ccleste v1.00 on this M1 using the same #8658 commit. The official package passed SHA-256 verification, SELF extraction succeeded, and conversion with --macos --to-rosetta completed successfully.

At runtime, Vulkan initialized, game resources loaded, and stereo audio initialized at 48 kHz. Audio playback was not audibly verified.

The process then aborted with exit code 134 at the first mesh-path draw due to the barycentric/mesh capabilities unavailable through this MoltenVK path. It did not reach the menu or playable levels.

This matches the ccleste limitation already documented in the PR description.

All worktrees remain unchanged, and the detailed logs are retained locally.

These comparisons are preliminary because the M1 and M2/M5 reference runs do not all use identical commits or macOS versions.

AI-assisted: yes. Codex was used to run and document the tests; I reviewed the reported results.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329391130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6329391130). Originally posted by [Mauro42K](https://github.com/Mauro42K) on 2026-10-22T00:08:14Z. --- Hi @iamthehimansh — thanks for comparing the M1 and M2 Pro results! I completed the requested focused retests on my Apple M1 MacBook Pro (8 GB RAM, macOS 27.0.1), using the existing Release x86_64 / Rosetta 2 build with Vulkan SDK 1.4.363.0 and MoltenVK 1.4.2. Tested commit: 3d649b8a477db9f016214b97646e721a0405a6a3 from #8658. All three AGC tests were run individually, three times each, with -j1: Test M1 result agc_driver_vertex_target_range_imported 3/3 PASS agc_driver_pass_input_hazard 3/3 FAIL agc_driver_uint8x4_color_target 3/3 FAIL The vertex target test now passes consistently in isolation, although it failed in my earlier full suite. The other two failures are reproducible: * agc_driver_pass_input_hazard: same index-coverage discrepancy as in my original report. * agc_driver_uint8x4_color_target: byte 0 remains 90, expected 35. Regarding guest_refused_connect: I attempted the requested LLDB investigation. LLDB recognized the x86_64 executable but remained blocked during run, without producing a backtrace. A separate isolated CTest attempt also stalled beyond its configured timeout. Earlier isolated runs had failed 3/3 with SIGABRT, but these new attempts did not provide a usable backtrace or confirm which Require failed. I therefore cannot establish whether EINVAL is the actual cause. I also saw @Gonic0’s M5 Pro/macOS 27.2 result (3/3 PASS). That is useful additional evidence, although our macOS versions and tested commits differ. Additional homebrew result — ccleste (PPSA59322): I independently tested ccleste v1.00 on this M1 using the same #8658 commit. The official package passed SHA-256 verification, SELF extraction succeeded, and conversion with --macos --to-rosetta completed successfully. At runtime, Vulkan initialized, game resources loaded, and stereo audio initialized at 48 kHz. Audio playback was not audibly verified. The process then aborted with exit code 134 at the first mesh-path draw due to the barycentric/mesh capabilities unavailable through this MoltenVK path. It did not reach the menu or playable levels. This matches the ccleste limitation already documented in the PR description. All worktrees remain unchanged, and the detailed logs are retained locally. These comparisons are preliminary because the M1 and M2/M5 reference runs do not all use identical commits or macOS versions. AI-assisted: yes. Codex was used to run and document the tests; I reviewed the reported results.
jotitadev commented 2026-10-22 03:39:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T03:39:39Z.

Review: COMMENTED


Checked the MacOsImage.cpp load-command reserve on its own, since no relinker test covers it.

Machine: Apple M2 Max, macOS 27.2 (26B5091g), Xcode 27.0 (27A266a), relinker-only Release build, arm64.
Method: only the core/relinker/elfpatcher/src/macos/MacOsImage.cpp hunk from head 31163870c, applied to main 6ef5a1c4c (the PR's merge base). Relinked the import_fixture and tls_fixture guests from test_macos_output.py with --macos --skip-sce-module, ran codesign -s - -f on the output, and compared the 32 bytes at LC_MAIN's entryoff before and after signing.

gap between load commands and entry stub after codesign -s - codesign -v
main 6ef5a1c4c, import 8 bytes first 8 stub bytes replaced by the tail of the new 16-byte LC_CODE_SIGNATURE (its dataoff/datasize) valid
main 6ef5a1c4c, tls 0 bytes first 16 stub bytes replaced by the whole LC_CODE_SIGNATURE (1d000000 10000000 ...) valid
with the hunk, import 1032 bytes stub intact valid
with the hunk, tls 1024 bytes stub intact valid

So on main an ad-hoc signature silently overwrites the start of the entry stub and codesign -v still reports the file as valid; with the reserve the stub survives. Relinker-only ctest with the hunk: 229/229 (arm64; macos_guest_weak_imports runs its x86_64 output under Rosetta).

Two notes:

  • The code comment says install_name_tool also uses that space. With Xcode 27's install_name_tool -add_rpath /opt/anyps5/libs, both outputs (with and without the reserve) are refused with "larger updated load commands do not fit". __TEXT has no sections in this layout; I did not dig into how install_name_tool finds the end of the header padding.
  • A cheap guard that runs on every host: in test_macos_output.py's check_structure, require macho.entryoff - macho.end >= 0x400 for executables. On Darwin the test could also sign a copy and compare the stub bytes, as above.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608984219 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#pullrequestreview-5608984219). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T03:39:39Z. **Review:** COMMENTED --- Checked the `MacOsImage.cpp` load-command reserve on its own, since no relinker test covers it. **Machine:** Apple M2 Max, macOS 27.2 (26B5091g), Xcode 27.0 (27A266a), relinker-only Release build, arm64. **Method:** only the `core/relinker/elfpatcher/src/macos/MacOsImage.cpp` hunk from head `31163870c`, applied to `main` `6ef5a1c4c` (the PR's merge base). Relinked the `import_fixture` and `tls_fixture` guests from `test_macos_output.py` with `--macos --skip-sce-module`, ran `codesign -s - -f` on the output, and compared the 32 bytes at `LC_MAIN`'s `entryoff` before and after signing. | | gap between load commands and entry stub | after `codesign -s -` | `codesign -v` | |---|---|---|---| | `main` 6ef5a1c4c, import | 8 bytes | first 8 stub bytes replaced by the tail of the new 16-byte `LC_CODE_SIGNATURE` (its `dataoff`/`datasize`) | valid | | `main` 6ef5a1c4c, tls | 0 bytes | first 16 stub bytes replaced by the whole `LC_CODE_SIGNATURE` (`1d000000 10000000 ...`) | valid | | with the hunk, import | 1032 bytes | stub intact | valid | | with the hunk, tls | 1024 bytes | stub intact | valid | So on `main` an ad-hoc signature silently overwrites the start of the entry stub and `codesign -v` still reports the file as valid; with the reserve the stub survives. Relinker-only `ctest` with the hunk: 229/229 (arm64; `macos_guest_weak_imports` runs its x86_64 output under Rosetta). Two notes: - The code comment says `install_name_tool` also uses that space. With Xcode 27's `install_name_tool -add_rpath /opt/anyps5/libs`, both outputs (with and without the reserve) are refused with "larger updated load commands do not fit". `__TEXT` has no sections in this layout; I did not dig into how `install_name_tool` finds the end of the header padding. - A cheap guard that runs on every host: in `test_macos_output.py`'s `check_structure`, require `macho.entryoff - macho.end >= 0x400` for executables. On Darwin the test could also sign a copy and compare the stub bytes, as above. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
iamthehimansh commented 2026-10-22 11:05:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-22T11:05:59Z.


@jotitadev thank you, that is exactly the check this reserve was missing.

I reproduced it on an M2 Pro (macOS 26.6.2, Xcode 27.1, x86_64 relinker output):

output gap before entry stub after codesign -s - -f codesign -v install_name_tool -add_rpath /opt/anyps5/libs
import 1032 bytes stub intact valid refused: "larger updated load commands do not fit"
tls 1024 bytes stub intact valid refused: same

You were right about the comment. It no longer says install_name_tool uses that space. It now says what the reserve is for: codesign appends LC_CODE_SIGNATURE there, and when that lands on the entry stub it corrupts the stub's first instructions while codesign -v still passes. Run paths are written at relink time with --rpath, so install_name_tool is not needed for this output. Like you, I have not looked into why it refuses this layout.

I added both guards you suggested to test_macos_output.py:

  • On every host, check_structure requires entryoff - end >= 0x400 for executables.
  • On Darwin, check_signing_keeps_entry_stub ad-hoc signs a copy of the import and tls outputs and requires the 32 bytes at entryoff to be unchanged.

To check that the guards fail when they should, I set the reserve to 0. The test then fails with import: only 8 bytes between the load commands and the entry stub, so codesign overwrites the stub. With the reserve back it passes, and the converter suite passes (230/230).

Commit: https://github.com/boykopovar/AnyPS5/pull/8658/commits/0c74e5edd426cbf8b3a067b6e7dc1c58909e53a8, test(relinker): guard the macOS load-command reserve against codesign.

AI-assisted: yes (Cana)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339218712 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6339218712). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-22T11:05:59Z. --- @jotitadev thank you, that is exactly the check this reserve was missing. I reproduced it on an M2 Pro (macOS 26.6.2, Xcode 27.1, x86_64 relinker output): | output | gap before entry stub | after `codesign -s - -f` | `codesign -v` | `install_name_tool -add_rpath /opt/anyps5/libs` | |---|---|---|---|---| | import | 1032 bytes | stub intact | valid | refused: "larger updated load commands do not fit" | | tls | 1024 bytes | stub intact | valid | refused: same | You were right about the comment. It no longer says install_name_tool uses that space. It now says what the reserve is for: codesign appends `LC_CODE_SIGNATURE` there, and when that lands on the entry stub it corrupts the stub's first instructions while `codesign -v` still passes. Run paths are written at relink time with `--rpath`, so install_name_tool is not needed for this output. Like you, I have not looked into why it refuses this layout. I added both guards you suggested to `test_macos_output.py`: - On every host, `check_structure` requires `entryoff - end >= 0x400` for executables. - On Darwin, `check_signing_keeps_entry_stub` ad-hoc signs a copy of the import and tls outputs and requires the 32 bytes at `entryoff` to be unchanged. To check that the guards fail when they should, I set the reserve to 0. The test then fails with `import: only 8 bytes between the load commands and the entry stub, so codesign overwrites the stub`. With the reserve back it passes, and the converter suite passes (230/230). Commit: https://github.com/boykopovar/AnyPS5/pull/8658/commits/0c74e5edd426cbf8b3a067b6e7dc1c58909e53a8, `test(relinker): guard the macOS load-command reserve against codesign`. AI-assisted: yes (Cana)
MarcZX10 commented 2026-10-22 11:54:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:54:08Z.


Open #9738 is a standalone PR for the shutdown-order fix already present at this PR head: both make RegistrationPreparePool::Lifecycle() return a never-destroyed new std::mutex on Apple. Their pairwise merge conflicts in ShaderRegistry.cpp. Please coordinate with #9738’s author on which change lands first and ensure the merged result contains this hunk only once; the current overlap is not declared by its Depends on line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6340096054 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6340096054). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:54:08Z. --- Open #9738 is a standalone PR for the shutdown-order fix already present at this PR head: both make `RegistrationPreparePool::Lifecycle()` return a never-destroyed `new std::mutex` on Apple. Their pairwise merge conflicts in `ShaderRegistry.cpp`. Please coordinate with #9738’s author on which change lands first and ensure the merged result contains this hunk only once; the current overlap is not declared by its `Depends on` line.
rooklz commented 2026-10-22 12:11:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T12:11:33Z.


@iamthehimansh three of my open PRs touch lines this port also changes, and reviewers asked us to agree an order. None depends on this PR, and each is small, so I suggest this: whichever lands first, the other drops its copy of the hunk.

  • #9654 core/libs/tests/GuestHostStandardError.cpp: now the same construction as yours on macOS (throw through __cxa_allocate_exception_nid_postfix and __cxa_throw_nid_postfix, original assertion kept), so the hunk becomes a no-op either way.
  • #9625 core/libs/prx/libkernel/Socket/src/Udp.cpp shutdown_nid_postfix: treats XNU's ENOTCONN for an already-shut direction as success only when getpeername still reports a peer, and retries SHUT_WR after SHUT_RDWR. If yours lands first I rebase and keep whatever your version already handles.
  • #9668 core/libs/prx/libc/src/Math.cpp acosf: ports msun's e_acosf.c for |x| <= 1 on every host, which replaces the __APPLE__ double-precision computation on those lines. If yours lands first I rebase onto it; if mine does, your acosf hunk can go.

If you would rather fold any of them into this PR, say so and I will close that one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6340416727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6340416727). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-22T12:11:33Z. --- @iamthehimansh three of my open PRs touch lines this port also changes, and reviewers asked us to agree an order. None depends on this PR, and each is small, so I suggest this: whichever lands first, the other drops its copy of the hunk. - #9654 `core/libs/tests/GuestHostStandardError.cpp`: now the same construction as yours on macOS (throw through `__cxa_allocate_exception_nid_postfix` and `__cxa_throw_nid_postfix`, original assertion kept), so the hunk becomes a no-op either way. - #9625 `core/libs/prx/libkernel/Socket/src/Udp.cpp` `shutdown_nid_postfix`: treats XNU's `ENOTCONN` for an already-shut direction as success only when `getpeername` still reports a peer, and retries `SHUT_WR` after `SHUT_RDWR`. If yours lands first I rebase and keep whatever your version already handles. - #9668 `core/libs/prx/libc/src/Math.cpp` `acosf`: ports msun's `e_acosf.c` for `|x| <= 1` on every host, which replaces the `__APPLE__` double-precision computation on those lines. If yours lands first I rebase onto it; if mine does, your `acosf` hunk can go. If you would rather fold any of them into this PR, say so and I will close that one.
prosperkartik commented 2026-10-22 12:23:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by prosperkartik on 2026-10-22T12:23:07Z.


Full build and ctest of the current head on a base M4, including the GPU tests.

Machine: Mac mini, Apple M4 (10-core GPU), 16 GB, macOS 26.5.1 (25F80), x86_64 under Rosetta 2, Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2. Vulkan SDK 1.4.363.0 (core component only, no system-global install), MoltenVK 1.4.2, apiVersion 1.4.357.

Commit: 1688e5abb (this PR with main merged in).

Build: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON, full build: 0 failed objects. For comparison, main at cc0078595 on the same machine stops with 52 failed objects (feof_unlocked/ferror_unlocked macros in FileStream.hpp, SIGUSR1, missing <initializer_list>, Mach-O inline asm).

ctest: ctest --test-dir build -j6 --timeout 300, then the GPU tests again with -j4 once the SDK was set up (source setup-env.sh, VK_DRIVER_FILES pointed at MoltenVK_icd.json). Combined over 1,801 tests: 1,689 pass, 91 skip, 21 fail.

Not on any list in this thread:

  • agc_driver_ds_permute fails every run, alone included (-j1): ds permute: lane 8 permute is 0x00000000, expected 0x00001019. Lanes 0 to 7 pass. The device reports subgroup=32. The test has been on main since dbb76aa51 (Oct 4) and is not in the M1 or M2 Pro failure lists, so it passes there; it may be specific to the M4's GPU family or to macOS 26.5.1.
  • guest_app_archive_present and guest_app_archive_damaged fail when they run at the same time: both shared one temp root. Fix in #9741 (113 of 300 concurrent pairs fail without it, 0 with it). Not specific to this PR.

Same as the M1 and M2 Pro lists: agc_driver_f32_constant_factor_tininess, agc_driver_f32_denormal_flush, agc_driver_image_plane_bias_on_single_level_volume, agc_driver_multisample_retirement, agc_driver_pixel_interlock (MoltenVK: type 'const constant spvDescriptorSetBuffer0 &' is not valid for attribute 'buffer'), agc_driver_pixel_sample_iteration, agc_driver_pooled_buffer_range, agc_driver_rect_list_indirect, agc_driver_sample_mask_multisample, agc_driver_sample_order, agc_driver_tessellation, the four clip/cull distance tests, agc_write_tracking, guest_floating_point, guest_math_exact.

Fail on the M1, pass here: agc_driver_image_table_reuse, agc_driver_pass_input_hazard, agc_driver_uint8x4_color_target, agc_driver_vertex_target_range_imported, guest_kernel_app_archive_plain, guest_path_name_length, guest_refused_connect (also 3/3 alone; it now passes on 26.5.1, 26.6 and 27.2, and fails only on 27.0.1).

Skips: device limits (13 no shaderFloat64, 8 no shaderBufferInt64Atomics, 8 no graphics pipeline libraries, 2 no VK_EXT_mesh_shader, 2 no native f16 RTE with kept denormals, 2 multisample counts), 2 udmabuf Linux-only, 13 with no message, and display tests that cannot open a window in a ctest run: 16 "Vulkan support is either not configured in SDL", 7 "NSWindow should only be instantiated on the main thread!", 2 vkCreateInstance result -9.

Setup note for other testers: SDK 1.4.363.0 also installs the KosmicKrisp ICD, which is arm64 only; an x86_64 process logs incompatible architecture (have 'arm64', need 'x86_64') for it and continues on MoltenVK. Pointing VK_DRIVER_FILES at MoltenVK_icd.json removes the noise.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6340637557 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6340637557). Originally posted by [prosperkartik](https://github.com/prosperkartik) on 2026-10-22T12:23:07Z. --- Full build and ctest of the current head on a base M4, including the GPU tests. **Machine:** Mac mini, Apple M4 (10-core GPU), 16 GB, macOS 26.5.1 (25F80), x86_64 under Rosetta 2, Apple clang 21.0.0, CMake 4.4.4, Ninja 1.13.2. Vulkan SDK 1.4.363.0 (core component only, no system-global install), MoltenVK 1.4.2, `apiVersion` 1.4.357. **Commit:** `1688e5abb` (this PR with `main` merged in). **Build:** `cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON`, full build: 0 failed objects. For comparison, `main` at `cc0078595` on the same machine stops with 52 failed objects (`feof_unlocked`/`ferror_unlocked` macros in `FileStream.hpp`, `SIGUSR1`, missing `<initializer_list>`, Mach-O inline asm). **ctest:** `ctest --test-dir build -j6 --timeout 300`, then the GPU tests again with `-j4` once the SDK was set up (`source setup-env.sh`, `VK_DRIVER_FILES` pointed at `MoltenVK_icd.json`). Combined over 1,801 tests: 1,689 pass, 91 skip, 21 fail. **Not on any list in this thread:** - `agc_driver_ds_permute` fails every run, alone included (`-j1`): `ds permute: lane 8 permute is 0x00000000, expected 0x00001019`. Lanes 0 to 7 pass. The device reports `subgroup=32`. The test has been on `main` since `dbb76aa51` (Oct 4) and is not in the M1 or M2 Pro failure lists, so it passes there; it may be specific to the M4's GPU family or to macOS 26.5.1. - `guest_app_archive_present` and `guest_app_archive_damaged` fail when they run at the same time: both shared one temp root. Fix in #9741 (113 of 300 concurrent pairs fail without it, 0 with it). Not specific to this PR. **Same as the M1 and M2 Pro lists:** `agc_driver_f32_constant_factor_tininess`, `agc_driver_f32_denormal_flush`, `agc_driver_image_plane_bias_on_single_level_volume`, `agc_driver_multisample_retirement`, `agc_driver_pixel_interlock` (MoltenVK: `type 'const constant spvDescriptorSetBuffer0 &' is not valid for attribute 'buffer'`), `agc_driver_pixel_sample_iteration`, `agc_driver_pooled_buffer_range`, `agc_driver_rect_list_indirect`, `agc_driver_sample_mask_multisample`, `agc_driver_sample_order`, `agc_driver_tessellation`, the four clip/cull distance tests, `agc_write_tracking`, `guest_floating_point`, `guest_math_exact`. **Fail on the M1, pass here:** `agc_driver_image_table_reuse`, `agc_driver_pass_input_hazard`, `agc_driver_uint8x4_color_target`, `agc_driver_vertex_target_range_imported`, `guest_kernel_app_archive_plain`, `guest_path_name_length`, `guest_refused_connect` (also 3/3 alone; it now passes on 26.5.1, 26.6 and 27.2, and fails only on 27.0.1). **Skips:** device limits (13 no `shaderFloat64`, 8 no `shaderBufferInt64Atomics`, 8 no graphics pipeline libraries, 2 no `VK_EXT_mesh_shader`, 2 no native f16 RTE with kept denormals, 2 multisample counts), 2 udmabuf Linux-only, 13 with no message, and display tests that cannot open a window in a ctest run: 16 "Vulkan support is either not configured in SDL", 7 "NSWindow should only be instantiated on the main thread!", 2 `vkCreateInstance` result -9. **Setup note for other testers:** SDK 1.4.363.0 also installs the KosmicKrisp ICD, which is arm64 only; an x86_64 process logs `incompatible architecture (have 'arm64', need 'x86_64')` for it and continues on MoltenVK. Pointing `VK_DRIVER_FILES` at `MoltenVK_icd.json` removes the noise. AI-assisted: yes
iamthehimansh commented 2026-10-22 14:19:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-22T14:19:54Z.


Thanks all. Answers in one place.

@rooklz, agreed: whichever lands first, the other drops its copy of the hunk.

  • #9654 (GuestHostStandardError.cpp): same construction as mine. If #9654 lands first, I drop my hunk on the next rebase.
  • #9625 (shutdown_nid_postfix): this covers what my hunk does: ENOTCONN counts as success while getpeername still finds a peer. It also handles the SHUT_RDWR → SHUT_WR retry, which mine does not, so yours is the better version.
  • #9668 (acosf): porting msun's e_acosf.c for every host is better than my __APPLE__ double-precision workaround, and it is what the console does. If it lands first, my hunk goes.
  • I tried both on top of this branch, but each one conflicts on exactly the lines it replaces, so I could only re-run this branch's own code: 58 socket and math tests, one at a time, all pass except the known Rosetta guest_math_exact. Whichever lands second has to rebase onto the first anyway. I'm happy to run the macOS socket and math tests on the rebased version and post the results.
  • I'd rather keep them as separate PRs than fold them in here. They are small and reviewable on their own, and this PR is already large.

@MarcZX10 / @mugurc, #9738: right, both make RegistrationPreparePool::Lifecycle() return a never-destroyed new std::mutex. Here it is under #ifdef __APPLE__; #9738 does it on every host, which is simpler. I suggest #9738 lands first. On the next rebase I drop my #ifdef block, so the merged result has the hunk once. I've added #9738, #9625, #9654 and #9668 to the overlap line in the description.

@MarcZX10, one more of the same kind, from #7233: Driver::WaitIdle now takes GuestMemory::GpuMutex(), and it runs from the driver's destructor at exit. The mutex is a function-local static that is constructed after the driver, so it is destroyed first. glibc locks a destroyed mutex without complaint, but macOS returns EINVAL, so every video-out test that skips without a display aborted at exit (recursive_mutex lock failed: Invalid argument). Here I fixed it under #ifdef __APPLE__ the same way (new GpuMutexType, never destroyed). It is still undefined behaviour on Linux, so you may want the same change for every host, like #9738.

@prosperkartik, thank you for the full M4 run.

  • agc_driver_ds_permute: it passes on my M2 Pro. The recompiler lowers DS_PERMUTE_B32 with OpGroupNonUniformShuffle only, with no LDS and no barrier: it shuffles each of the 32 source lanes and keeps the one whose target is this lane (SpirvAluEmitterMath.cpp around line 1170). Lane 8's expected 0x1019 comes from source lane 25, so a lane-8 zero means the shuffle from lane 25 didn't return its value or its active bit. Since lanes 0 to 7 pass and the code has no Apple special case, this looks like an M4 GPU family or MoltenVK shuffle issue across 8-lane groups rather than something in this PR. If you can run it once with MVK_CONFIG_LOG_LEVEL=4 and attach the generated Metal for the compute shader, I'll check whether the shuffle survives the translation.
  • #9741: thanks, that matches what I saw under load.
  • guest_refused_connect failing only on 27.0.1: that fits @Mauro42K's M1 report, so it looks like a macOS 27.0.1 connect() regression.
  • The KosmicKrisp/VK_DRIVER_FILES note is useful, and it is now in the description's machine section.

Rebase: merged main up to 8b3e39832 into f3bc0258f; GitHub now shows it as mergeable. The merge needed two macOS follow-ups: the GpuMutex exit fix above, and the Stdio.cpp conflict with #9303. Linux and Windows keep #9303 exactly as written, and the macOS getdirentries uses the same /app0 symlink-type lookup. The full macOS suite shows no new failures.

AI-assisted: yes (Cana)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343052756 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6343052756). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-22T14:19:54Z. --- Thanks all. Answers in one place. **@rooklz**, agreed: whichever lands first, the other drops its copy of the hunk. - #9654 (`GuestHostStandardError.cpp`): same construction as mine. If #9654 lands first, I drop my hunk on the next rebase. - #9625 (`shutdown_nid_postfix`): this covers what my hunk does: ENOTCONN counts as success while `getpeername` still finds a peer. It also handles the `SHUT_RDWR` → `SHUT_WR` retry, which mine does not, so yours is the better version. - #9668 (`acosf`): porting msun's `e_acosf.c` for every host is better than my `__APPLE__` double-precision workaround, and it is what the console does. If it lands first, my hunk goes. - I tried both on top of this branch, but each one conflicts on exactly the lines it replaces, so I could only re-run this branch's own code: 58 socket and math tests, one at a time, all pass except the known Rosetta `guest_math_exact`. Whichever lands second has to rebase onto the first anyway. I'm happy to run the macOS socket and math tests on the rebased version and post the results. - I'd rather keep them as separate PRs than fold them in here. They are small and reviewable on their own, and this PR is already large. **@MarcZX10 / @mugurc**, #9738: right, both make `RegistrationPreparePool::Lifecycle()` return a never-destroyed `new std::mutex`. Here it is under `#ifdef __APPLE__`; #9738 does it on every host, which is simpler. I suggest #9738 lands first. On the next rebase I drop my `#ifdef` block, so the merged result has the hunk once. I've added #9738, #9625, #9654 and #9668 to the overlap line in the description. **@MarcZX10**, one more of the same kind, from #7233: `Driver::WaitIdle` now takes `GuestMemory::GpuMutex()`, and it runs from the driver's destructor at exit. The mutex is a function-local static that is constructed after the driver, so it is destroyed first. glibc locks a destroyed mutex without complaint, but macOS returns EINVAL, so every video-out test that skips without a display aborted at exit (`recursive_mutex lock failed: Invalid argument`). Here I fixed it under `#ifdef __APPLE__` the same way (`new GpuMutexType`, never destroyed). It is still undefined behaviour on Linux, so you may want the same change for every host, like #9738. **@prosperkartik**, thank you for the full M4 run. - `agc_driver_ds_permute`: it passes on my M2 Pro. The recompiler lowers `DS_PERMUTE_B32` with `OpGroupNonUniformShuffle` only, with no LDS and no barrier: it shuffles each of the 32 source lanes and keeps the one whose target is this lane (`SpirvAluEmitterMath.cpp` around line 1170). Lane 8's expected `0x1019` comes from source lane 25, so a lane-8 zero means the shuffle from lane 25 didn't return its value or its active bit. Since lanes 0 to 7 pass and the code has no Apple special case, this looks like an M4 GPU family or MoltenVK shuffle issue across 8-lane groups rather than something in this PR. If you can run it once with `MVK_CONFIG_LOG_LEVEL=4` and attach the generated Metal for the compute shader, I'll check whether the shuffle survives the translation. - #9741: thanks, that matches what I saw under load. - `guest_refused_connect` failing only on 27.0.1: that fits @Mauro42K's M1 report, so it looks like a macOS 27.0.1 `connect()` regression. - The KosmicKrisp/`VK_DRIVER_FILES` note is useful, and it is now in the description's machine section. **Rebase**: merged `main` up to 8b3e39832 into [`f3bc0258f`](https://github.com/boykopovar/AnyPS5/pull/8658/commits/f3bc0258f2f709ea852fb4f69bed70112db45d4a); GitHub now shows it as mergeable. The merge needed two macOS follow-ups: the `GpuMutex` exit fix above, and the `Stdio.cpp` conflict with #9303. Linux and Windows keep #9303 exactly as written, and the macOS `getdirentries` uses the same `/app0` symlink-type lookup. The full macOS suite shows no new failures. AI-assisted: yes (Cana)
iamthehimansh commented 2026-10-22 14:27:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-22T14:27:35Z.


Sorry for the slow reply to these two; I missed them in the thread.

@Gonic0, thank you, that narrows it a lot. With @prosperkartik's M4 run, guest_refused_connect now passes on macOS 26.5.1 (M4), 26.6 (M2 Pro) and 27.2 (M5 Pro). The only failure is @Mauro42K's M1 on 27.0.1. So it is either a 27.0.1 connect() change or something M1-specific, not this PR on macOS 27 in general.

@Mauro42K, thank you for the focused retests and the ccleste run.

  • agc_driver_vertex_target_range_imported passing 3/3 alone means its full-suite failure was load-sensitive, like the few I already treat that way.
  • agc_driver_pass_input_hazard and agc_driver_uint8x4_color_target fail 3/3 on your M1, but pass on my M2 Pro and on @prosperkartik's M4. That points at the M1's GPU family under MoltenVK rather than at this PR's code. If you have time, the output of one run of each with MVK_CONFIG_LOG_LEVEL=4 would show whether MoltenVK reports anything for those pipelines.
  • guest_refused_connect: no need for LLDB. Running the test binary directly prints the failing check before it aborts:
    ./build/tests/guest_refused_connect_tests; echo "exit=$?"
    
    The stall past the timeout is new information too. If it hangs again, sample <pid> 5 from a second terminal shows where it is waiting.
  • ccleste: yes, that matches the known limit. Its first draw goes through the mesh path, which needs barycentrics that MoltenVK does not expose. #9193 (imellag) addresses the barycentrics side; I have not yet confirmed ccleste past that draw with it.
  • Your tested commit 3d649b8a4 is a few merges behind. The current head is f3bc0258f, which adds the 1023-byte path fix (guest_path_name_length), the JSON underflow fix and the exit-time GPU mutex fix. None of those should change the three AGC results above.

AI-assisted: yes (Cana)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343218022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6343218022). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-22T14:27:35Z. --- Sorry for the slow reply to these two; I missed them in the thread. **@Gonic0**, thank you, that narrows it a lot. With @prosperkartik's M4 run, `guest_refused_connect` now passes on macOS 26.5.1 (M4), 26.6 (M2 Pro) and 27.2 (M5 Pro). The only failure is @Mauro42K's M1 on 27.0.1. So it is either a 27.0.1 `connect()` change or something M1-specific, not this PR on macOS 27 in general. **@Mauro42K**, thank you for the focused retests and the ccleste run. - `agc_driver_vertex_target_range_imported` passing 3/3 alone means its full-suite failure was load-sensitive, like the few I already treat that way. - `agc_driver_pass_input_hazard` and `agc_driver_uint8x4_color_target` fail 3/3 on your M1, but pass on my M2 Pro and on @prosperkartik's M4. That points at the M1's GPU family under MoltenVK rather than at this PR's code. If you have time, the output of one run of each with `MVK_CONFIG_LOG_LEVEL=4` would show whether MoltenVK reports anything for those pipelines. - `guest_refused_connect`: no need for LLDB. Running the test binary directly prints the failing check before it aborts: ``` ./build/tests/guest_refused_connect_tests; echo "exit=$?" ``` The stall past the timeout is new information too. If it hangs again, `sample <pid> 5` from a second terminal shows where it is waiting. - ccleste: yes, that matches the known limit. Its first draw goes through the mesh path, which needs barycentrics that MoltenVK does not expose. #9193 (imellag) addresses the barycentrics side; I have not yet confirmed ccleste past that draw with it. - Your tested commit `3d649b8a4` is a few merges behind. The current head is `f3bc0258f`, which adds the 1023-byte path fix (`guest_path_name_length`), the JSON underflow fix and the exit-time GPU mutex fix. None of those should change the three AGC results above. AI-assisted: yes (Cana)
prosperkartik commented 2026-10-22 14:44:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by prosperkartik on 2026-10-22T14:44:14Z.


@iamthehimansh, here is the agc_driver_ds_permute run you asked for, at the current head f3bc0258f on the same M4 (macOS 26.5.1, MoltenVK 1.4.2), with MVK_CONFIG_LOG_LEVEL=4 MVK_CONFIG_DEBUG=1 MVK_CONFIG_SHADER_DUMP_DIR=<dir> ANYPS5_NO_SHADER_CACHE=1. Same result: ds permute: lane 8 permute is 0x00000000, expected 0x00001019. MoltenVK logs no warnings or errors. Of the 12 compute shaders dumped, one contains the shuffles: shader-cs-6a936899f53064c2 (full Metal below).

What the translation does. In the SPIR-V, each candidate source lane gets three unconditional shuffles before any logic (.spvasm line 225 on):

%299 = OpGroupNonUniformShuffle %uint %uint_3 %293 %298
%300 = OpGroupNonUniformShuffle %uint %uint_3 %197 %298
%301 = OpGroupNonUniformShuffle %bool %uint_3 %true %298
...
%305 = OpLogicalAnd %bool %301 %304
%306 = OpSelect %uint %305 %299 %uint_0_0

SPIRV-Cross forwards those shuffles into MSL's short-circuit operators (.metal line 131):

uint _369 = (spvSubgroupShuffle(true, _361) && (((spvSubgroupShuffle(_197, _361) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _361) : (...);

So the second and third shuffles only run on lanes whose own condition held. A lane that reads from a source lane which skipped that simd_shuffle gets no defined value, which fits lane 8 missing lane 25's 0x1019.

Native check on the M4, without AnyPS5. A minimal Metal kernel (repro.swift below), 32 threads, lane 8 reads lane 25, 200 runs each:

Kernel Lane 8 Wrong runs
hoisted: uint got = simd_shuffle(v, from); out = c ? got : x; 0x1019 0 / 200
inlined: out = c ? simd_shuffle(v, from) : x; 0x1008 200 / 200
inlined_and: shuffle behind &&, then in ?: 0x1019 0 / 200

So on this GPU a shuffle inside a divergent ?: arm does not see the source lane's value, while the && form happens to be compiled flat. Whether the M2 Pro compiles the inlined form flat is the open question; running xcrun swiftc -O -o repro repro.swift -framework Metal && ./repro there would show it. If the M2 Pro also prints 200 wrong runs for inlined, the difference is in how the full shader gets compiled per GPU family. Either way, the shuffles in the SPIR-V are unconditional and the MSL makes them conditional, which looks like a SPIRV-Cross issue rather than something in this PR.

repro.swift
import Metal
let src = """
#include <metal_stdlib>
using namespace metal;
kernel void hoisted(device uint* out [[buffer(0)]], uint lane [[thread_index_in_simdgroup]]) {
    uint value = 0x1000u + lane;
    uint from = (lane == 8u) ? 25u : lane;
    uint got = simd_shuffle(value, ushort(from));
    out[lane] = (lane == 8u) ? got : 0xffffffffu;
}
kernel void inlined(device uint* out [[buffer(0)]], uint lane [[thread_index_in_simdgroup]]) {
    uint value = 0x1000u + lane;
    uint from = (lane == 8u) ? 25u : lane;
    out[lane] = (lane == 8u) ? simd_shuffle(value, ushort(from)) : 0xffffffffu;
}
kernel void inlined_and(device uint* out [[buffer(0)]], uint lane [[thread_index_in_simdgroup]]) {
    uint value = 0x1000u + lane;
    uint from = (lane == 8u) ? 25u : lane;
    bool ok = (lane < 16u) && (simd_shuffle(value, ushort(from)) != 0u);
    out[lane] = ok ? simd_shuffle(value, ushort(from)) : 0xffffffffu;
}
"""
let device = MTLCreateSystemDefaultDevice()!
let lib = try! device.makeLibrary(source: src, options: nil)
let queue = device.makeCommandQueue()!
print("device: \(device.name)")
for name in ["hoisted", "inlined", "inlined_and"] {
    var zeros = 0, runs = 200
    var sample: UInt32 = 0
    for _ in 0..<runs {
        let pso = try! device.makeComputePipelineState(function: lib.makeFunction(name: name)!)
        let buf = device.makeBuffer(length: 32 * 4, options: .storageModeShared)!
        let cb = queue.makeCommandBuffer()!, enc = cb.makeComputeCommandEncoder()!
        enc.setComputePipelineState(pso); enc.setBuffer(buf, offset: 0, index: 0)
        enc.dispatchThreads(MTLSize(width: 32, height: 1, depth: 1), threadsPerThreadgroup: MTLSize(width: 32, height: 1, depth: 1))
        enc.endEncoding(); cb.commit(); cb.waitUntilCompleted()
        let v = buf.contents().bindMemory(to: UInt32.self, capacity: 32)[8]
        sample = v; if v != 0x1019 { zeros += 1 }
    }
    print(String(format: "%-12@ lane 8 got 0x%08x (expected 0x00001019); wrong in %d of %d runs", name as NSString, sample, zeros, runs))
}
Generated Metal: shader-cs-6a936899f53064c2.metal
#pragma clang diagnostic ignored "-Wmissing-prototypes"

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

inline uint4 spvSubgroupBallot(bool value)
{
    simd_vote vote = simd_ballot(value);
    // simd_ballot() returns a 64-bit integer-like object, but
    // SPIR-V callers expect a uint4. We must convert.
    // FIXME: This won't include higher bits if Apple ever supports
    // 128 lanes in an SIMD-group.
    return uint4(as_type<uint2>((simd_vote::vote_t)vote), 0, 0);
}

template<typename T>
inline T spvSubgroupShuffle(T value, ushort lane)
{
    return simd_shuffle(value, lane);
}

template<>
inline bool spvSubgroupShuffle(bool value, ushort lane)
{
    return !!simd_shuffle((ushort)value, lane);
}

template<uint N>
inline vec<bool, N> spvSubgroupShuffle(vec<bool, N> value, ushort lane)
{
    return (vec<bool, N>)simd_shuffle((vec<ushort, N>)value, lane);
}

template<>
inline ulong spvSubgroupShuffle(ulong value, ushort lane)
{
    return as_type<ulong>(spvSubgroupShuffle(as_type<uint2>(value), lane));
}

template<>
inline ulong2 spvSubgroupShuffle(ulong2 value, ushort lane)
{
    return ulong2(spvSubgroupShuffle(value.x, lane), spvSubgroupShuffle(value.y, lane));
}

inline ulong3 spvSubgroupShuffle(ulong3 value, ushort lane)
{
    return ulong3(spvSubgroupShuffle(value.xy, lane), spvSubgroupShuffle(value.z, lane));
}

inline ulong4 spvSubgroupShuffle(ulong4 value, ushort lane)
{
    return ulong4(spvSubgroupShuffle(value.xy, lane), spvSubgroupShuffle(value.zw, lane));
}

template<uint N>
inline vec<long, N> spvSubgroupShuffle(vec<long, N> value, ushort lane)
{
    return vec<long, N>(spvSubgroupShuffle(vec<ulong, N>(value), lane));
}

struct BufferResource
{
    uint _m0[32];
};

struct _14
{
    uint _m0[1];
};

struct spvDescriptorSetBuffer0
{
    constant uint* spvBufferSizeConstants [[id(0)]];
    device _14* buffers [[id(1)]][2];
};

kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvBufferSizeConstants [[buffer(29)]], constant BufferResource& vsharp [[buffer(8)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]])
{
    constant uint* spvDescriptorSet0_buffersBufferSize = &spvDescriptorSet0.spvBufferSizeConstants[1];
    uint _35 = (vsharp._m0[8u] >> 0u) & 255u;
    uint _41 = (vsharp._m0[8u] >> 8u) & 255u;
    uint _82 = gl_LocalInvocationID.x << 4u;
    uint _83 = gl_LocalInvocationID.x << 6u;
    uint _196;
    do
    {
        uint _111 = _82 + 0u;
        uint _137 = vsharp._m0[2u] - 0u;
        uint _168 = (((0u + _111) + 0u) >> 2u) + (_35 >> 2u);
        if ((true && (true && ((0u <= vsharp._m0[2u]) && ((_137 >= 4u) && (_111 <= (_137 - 4u)))))) && (_168 < ((spvDescriptorSet0_buffersBufferSize[0u] - 0) / 4)))
        {
            _196 = ((spvDescriptorSet0.buffers[0u]->_m0[_168] >> 0u) | 0u) & 4294967295u;
        }
        else
        {
            _196 = 0u;
        }
        break;
    } while(false);
    uint _197 = _196;
    uint _292;
    do
    {
        uint _215 = _82 + 4u;
        uint _238 = vsharp._m0[2u] - 0u;
        uint _267 = (((0u + _215) + 0u) >> 2u) + (_35 >> 2u);
        if ((true && (true && ((0u <= vsharp._m0[2u]) && ((_238 >= 4u) && (_215 <= (_238 - 4u)))))) && (_267 < ((spvDescriptorSet0_buffersBufferSize[0u] - 0) / 4)))
        {
            _292 = ((spvDescriptorSet0.buffers[0u]->_m0[_267] >> 0u) | 0u) & 4294967295u;
        }
        else
        {
            _292 = 0u;
        }
        break;
    } while(false);
    uint _293 = _292;
    uint _296 = gl_SubgroupInvocationID & 4294967264u;
    uint _297 = gl_SubgroupInvocationID & 31u;
    uint _298 = _296 | 0u;
    uint _307 = _296 | 1u;
    uint _316 = _296 | 2u;
    uint _325 = _296 | 3u;
    uint _334 = _296 | 4u;
    uint _343 = _296 | 5u;
    uint _352 = _296 | 6u;
    uint _361 = _296 | 7u;
    uint _369 = (spvSubgroupShuffle(true, _361) && (((spvSubgroupShuffle(_197, _361) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _361) : ((spvSubgroupShuffle(true, _352) && (((spvSubgroupShuffle(_197, _352) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _352) : ((spvSubgroupShuffle(true, _343) && (((spvSubgroupShuffle(_197, _343) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _343) : ((spvSubgroupShuffle(true, _334) && (((spvSubgroupShuffle(_197, _334) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _334) : ((spvSubgroupShuffle(true, _325) && (((spvSubgroupShuffle(_197, _325) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _325) : ((spvSubgroupShuffle(true, _316) && (((spvSubgroupShuffle(_197, _316) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _316) : ((spvSubgroupShuffle(true, _307) && (((spvSubgroupShuffle(_197, _307) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _307) : ((spvSubgroupShuffle(true, _298) && (((spvSubgroupShuffle(_197, _298) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _298) : 0u)))))));
    uint _370 = _296 | 8u;
    uint _380 = _296 | 9u;
    uint _390 = _296 | 10u;
    uint _400 = _296 | 11u;
    uint _409 = _296 | 12u;
    uint _419 = _296 | 13u;
    uint _428 = _296 | 14u;
    uint _438 = _296 | 15u;
    uint _446 = (spvSubgroupShuffle(true, _438) && (((spvSubgroupShuffle(_197, _438) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _438) : ((spvSubgroupShuffle(true, _428) && (((spvSubgroupShuffle(_197, _428) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _428) : ((spvSubgroupShuffle(true, _419) && (((spvSubgroupShuffle(_197, _419) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _419) : ((spvSubgroupShuffle(true, _409) && (((spvSubgroupShuffle(_197, _409) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _409) : ((spvSubgroupShuffle(true, _400) && (((spvSubgroupShuffle(_197, _400) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _400) : ((spvSubgroupShuffle(true, _390) && (((spvSubgroupShuffle(_197, _390) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _390) : ((spvSubgroupShuffle(true, _380) && (((spvSubgroupShuffle(_197, _380) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _380) : ((spvSubgroupShuffle(true, _370) && (((spvSubgroupShuffle(_197, _370) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _370) : _369)))))));
    uint _447 = _296 | 16u;
    uint _457 = _296 | 17u;
    uint _467 = _296 | 18u;
    uint _477 = _296 | 19u;
    uint _487 = _296 | 20u;
    uint _496 = _296 | 21u;
    uint _506 = _296 | 22u;
    uint _515 = _296 | 23u;
    uint _523 = (spvSubgroupShuffle(true, _515) && (((spvSubgroupShuffle(_197, _515) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _515) : ((spvSubgroupShuffle(true, _506) && (((spvSubgroupShuffle(_197, _506) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _506) : ((spvSubgroupShuffle(true, _496) && (((spvSubgroupShuffle(_197, _496) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _496) : ((spvSubgroupShuffle(true, _487) && (((spvSubgroupShuffle(_197, _487) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _487) : ((spvSubgroupShuffle(true, _477) && (((spvSubgroupShuffle(_197, _477) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _477) : ((spvSubgroupShuffle(true, _467) && (((spvSubgroupShuffle(_197, _467) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _467) : ((spvSubgroupShuffle(true, _457) && (((spvSubgroupShuffle(_197, _457) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _457) : ((spvSubgroupShuffle(true, _447) && (((spvSubgroupShuffle(_197, _447) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _447) : _446)))))));
    uint _525 = _296 | 24u;
    uint _535 = _296 | 25u;
    uint _545 = _296 | 26u;
    uint _555 = _296 | 27u;
    uint _564 = _296 | 28u;
    uint _574 = _296 | 29u;
    uint _583 = _296 | 30u;
    uint _592 = _296 | 31u;
    uint _600 = (spvSubgroupShuffle(true, _592) && (((spvSubgroupShuffle(_197, _592) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _592) : ((spvSubgroupShuffle(true, _583) && (((spvSubgroupShuffle(_197, _583) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _583) : ((spvSubgroupShuffle(true, _574) && (((spvSubgroupShuffle(_197, _574) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _574) : ((spvSubgroupShuffle(true, _564) && (((spvSubgroupShuffle(_197, _564) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _564) : ((spvSubgroupShuffle(true, _555) && (((spvSubgroupShuffle(_197, _555) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _555) : ((spvSubgroupShuffle(true, _545) && (((spvSubgroupShuffle(_197, _545) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _545) : ((spvSubgroupShuffle(true, _535) && (((spvSubgroupShuffle(_197, _535) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _535) : ((spvSubgroupShuffle(true, _525) && (((spvSubgroupShuffle(_197, _525) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _525) : _523)))))));
    uint _605 = (gl_SubgroupInvocationID & 4294967264u) | ((_197 >> 2u) & 31u);
    uint _606 = spvSubgroupShuffle(_293, _605);
    bool _607 = spvSubgroupShuffle(true, _605);
    uint4 _608 = spvSubgroupBallot(true);
    uint _619 = _197 + 8u;
    uint _621 = gl_SubgroupInvocationID & 4294967264u;
    uint _622 = gl_SubgroupInvocationID & 31u;
    uint _623 = _621 | 0u;
    uint _632 = _621 | 1u;
    uint _641 = _621 | 2u;
    uint _650 = _621 | 3u;
    uint _659 = _621 | 4u;
    uint _668 = _621 | 5u;
    uint _677 = _621 | 6u;
    uint _686 = _621 | 7u;
    uint _694 = (spvSubgroupShuffle(true, _686) && (((spvSubgroupShuffle(_619, _686) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _686) : ((spvSubgroupShuffle(true, _677) && (((spvSubgroupShuffle(_619, _677) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _677) : ((spvSubgroupShuffle(true, _668) && (((spvSubgroupShuffle(_619, _668) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _668) : ((spvSubgroupShuffle(true, _659) && (((spvSubgroupShuffle(_619, _659) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _659) : ((spvSubgroupShuffle(true, _650) && (((spvSubgroupShuffle(_619, _650) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _650) : ((spvSubgroupShuffle(true, _641) && (((spvSubgroupShuffle(_619, _641) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _641) : ((spvSubgroupShuffle(true, _632) && (((spvSubgroupShuffle(_619, _632) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _632) : ((spvSubgroupShuffle(true, _623) && (((spvSubgroupShuffle(_619, _623) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _623) : 0u)))))));
    uint _695 = _621 | 8u;
    uint _704 = _621 | 9u;
    uint _713 = _621 | 10u;
    uint _722 = _621 | 11u;
    uint _731 = _621 | 12u;
    uint _740 = _621 | 13u;
    uint _749 = _621 | 14u;
    uint _758 = _621 | 15u;
    uint _766 = (spvSubgroupShuffle(true, _758) && (((spvSubgroupShuffle(_619, _758) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _758) : ((spvSubgroupShuffle(true, _749) && (((spvSubgroupShuffle(_619, _749) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _749) : ((spvSubgroupShuffle(true, _740) && (((spvSubgroupShuffle(_619, _740) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _740) : ((spvSubgroupShuffle(true, _731) && (((spvSubgroupShuffle(_619, _731) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _731) : ((spvSubgroupShuffle(true, _722) && (((spvSubgroupShuffle(_619, _722) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _722) : ((spvSubgroupShuffle(true, _713) && (((spvSubgroupShuffle(_619, _713) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _713) : ((spvSubgroupShuffle(true, _704) && (((spvSubgroupShuffle(_619, _704) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _704) : ((spvSubgroupShuffle(true, _695) && (((spvSubgroupShuffle(_619, _695) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _695) : _694)))))));
    uint _767 = _621 | 16u;
    uint _776 = _621 | 17u;
    uint _785 = _621 | 18u;
    uint _794 = _621 | 19u;
    uint _803 = _621 | 20u;
    uint _812 = _621 | 21u;
    uint _821 = _621 | 22u;
    uint _830 = _621 | 23u;
    uint _838 = (spvSubgroupShuffle(true, _830) && (((spvSubgroupShuffle(_619, _830) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _830) : ((spvSubgroupShuffle(true, _821) && (((spvSubgroupShuffle(_619, _821) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _821) : ((spvSubgroupShuffle(true, _812) && (((spvSubgroupShuffle(_619, _812) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _812) : ((spvSubgroupShuffle(true, _803) && (((spvSubgroupShuffle(_619, _803) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _803) : ((spvSubgroupShuffle(true, _794) && (((spvSubgroupShuffle(_619, _794) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _794) : ((spvSubgroupShuffle(true, _785) && (((spvSubgroupShuffle(_619, _785) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _785) : ((spvSubgroupShuffle(true, _776) && (((spvSubgroupShuffle(_619, _776) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _776) : ((spvSubgroupShuffle(true, _767) && (((spvSubgroupShuffle(_619, _767) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _767) : _766)))))));
    uint _839 = _621 | 24u;
    uint _848 = _621 | 25u;
    uint _857 = _621 | 26u;
    uint _866 = _621 | 27u;
    uint _875 = _621 | 28u;
    uint _884 = _621 | 29u;
    uint _893 = _621 | 30u;
    uint _902 = _621 | 31u;
    uint _910 = (spvSubgroupShuffle(true, _902) && (((spvSubgroupShuffle(_619, _902) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _902) : ((spvSubgroupShuffle(true, _893) && (((spvSubgroupShuffle(_619, _893) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _893) : ((spvSubgroupShuffle(true, _884) && (((spvSubgroupShuffle(_619, _884) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _884) : ((spvSubgroupShuffle(true, _875) && (((spvSubgroupShuffle(_619, _875) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _875) : ((spvSubgroupShuffle(true, _866) && (((spvSubgroupShuffle(_619, _866) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _866) : ((spvSubgroupShuffle(true, _857) && (((spvSubgroupShuffle(_619, _857) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _857) : ((spvSubgroupShuffle(true, _848) && (((spvSubgroupShuffle(_619, _848) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _848) : ((spvSubgroupShuffle(true, _839) && (((spvSubgroupShuffle(_619, _839) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _839) : _838)))))));
    bool _916 = ((65535u >> (gl_SubgroupInvocationID & 31u)) & 1u) != 0u;
    uint _918 = gl_SubgroupInvocationID & 4294967264u;
    uint _919 = gl_SubgroupInvocationID & 31u;
    uint _920 = _918 | 0u;
    uint _929 = _918 | 1u;
    uint _938 = _918 | 2u;
    uint _947 = _918 | 3u;
    uint _956 = _918 | 4u;
    uint _965 = _918 | 5u;
    uint _974 = _918 | 6u;
    uint _983 = _918 | 7u;
    uint _991 = (spvSubgroupShuffle(_916, _983) && (((spvSubgroupShuffle(_197, _983) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _983) : ((spvSubgroupShuffle(_916, _974) && (((spvSubgroupShuffle(_197, _974) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _974) : ((spvSubgroupShuffle(_916, _965) && (((spvSubgroupShuffle(_197, _965) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _965) : ((spvSubgroupShuffle(_916, _956) && (((spvSubgroupShuffle(_197, _956) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _956) : ((spvSubgroupShuffle(_916, _947) && (((spvSubgroupShuffle(_197, _947) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _947) : ((spvSubgroupShuffle(_916, _938) && (((spvSubgroupShuffle(_197, _938) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _938) : ((spvSubgroupShuffle(_916, _929) && (((spvSubgroupShuffle(_197, _929) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _929) : ((spvSubgroupShuffle(_916, _920) && (((spvSubgroupShuffle(_197, _920) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _920) : 0u)))))));
    uint _992 = _918 | 8u;
    uint _1001 = _918 | 9u;
    uint _1010 = _918 | 10u;
    uint _1019 = _918 | 11u;
    uint _1028 = _918 | 12u;
    uint _1037 = _918 | 13u;
    uint _1046 = _918 | 14u;
    uint _1055 = _918 | 15u;
    uint _1063 = (spvSubgroupShuffle(_916, _1055) && (((spvSubgroupShuffle(_197, _1055) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1055) : ((spvSubgroupShuffle(_916, _1046) && (((spvSubgroupShuffle(_197, _1046) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1046) : ((spvSubgroupShuffle(_916, _1037) && (((spvSubgroupShuffle(_197, _1037) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1037) : ((spvSubgroupShuffle(_916, _1028) && (((spvSubgroupShuffle(_197, _1028) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1028) : ((spvSubgroupShuffle(_916, _1019) && (((spvSubgroupShuffle(_197, _1019) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1019) : ((spvSubgroupShuffle(_916, _1010) && (((spvSubgroupShuffle(_197, _1010) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1010) : ((spvSubgroupShuffle(_916, _1001) && (((spvSubgroupShuffle(_197, _1001) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1001) : ((spvSubgroupShuffle(_916, _992) && (((spvSubgroupShuffle(_197, _992) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _992) : _991)))))));
    uint _1064 = _918 | 16u;
    uint _1073 = _918 | 17u;
    uint _1082 = _918 | 18u;
    uint _1091 = _918 | 19u;
    uint _1100 = _918 | 20u;
    uint _1109 = _918 | 21u;
    uint _1118 = _918 | 22u;
    uint _1127 = _918 | 23u;
    uint _1135 = (spvSubgroupShuffle(_916, _1127) && (((spvSubgroupShuffle(_197, _1127) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1127) : ((spvSubgroupShuffle(_916, _1118) && (((spvSubgroupShuffle(_197, _1118) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1118) : ((spvSubgroupShuffle(_916, _1109) && (((spvSubgroupShuffle(_197, _1109) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1109) : ((spvSubgroupShuffle(_916, _1100) && (((spvSubgroupShuffle(_197, _1100) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1100) : ((spvSubgroupShuffle(_916, _1091) && (((spvSubgroupShuffle(_197, _1091) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1091) : ((spvSubgroupShuffle(_916, _1082) && (((spvSubgroupShuffle(_197, _1082) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1082) : ((spvSubgroupShuffle(_916, _1073) && (((spvSubgroupShuffle(_197, _1073) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1073) : ((spvSubgroupShuffle(_916, _1064) && (((spvSubgroupShuffle(_197, _1064) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1064) : _1063)))))));
    uint _1136 = _918 | 24u;
    uint _1145 = _918 | 25u;
    uint _1154 = _918 | 26u;
    uint _1163 = _918 | 27u;
    uint _1172 = _918 | 28u;
    uint _1181 = _918 | 29u;
    uint _1182 = spvSubgroupShuffle(_293, _1181);
    uint _1183 = spvSubgroupShuffle(_197, _1181);
    bool _1184 = spvSubgroupShuffle(_916, _1181);
    uint _1190 = _918 | 30u;
    uint _1191 = spvSubgroupShuffle(_293, _1190);
    uint _1192 = spvSubgroupShuffle(_197, _1190);
    bool _1193 = spvSubgroupShuffle(_916, _1190);
    uint _1199 = _918 | 31u;
    uint _1200 = spvSubgroupShuffle(_293, _1199);
    uint _1201 = spvSubgroupShuffle(_197, _1199);
    bool _1202 = spvSubgroupShuffle(_916, _1199);
    uint _1207 = (_1202 && (((_1201 >> 2u) & 31u) == _919)) ? _1200 : ((_1193 && (((_1192 >> 2u) & 31u) == _919)) ? _1191 : ((_1184 && (((_1183 >> 2u) & 31u) == _919)) ? _1182 : ((spvSubgroupShuffle(_916, _1172) && (((spvSubgroupShuffle(_197, _1172) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1172) : ((spvSubgroupShuffle(_916, _1163) && (((spvSubgroupShuffle(_197, _1163) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1163) : ((spvSubgroupShuffle(_916, _1154) && (((spvSubgroupShuffle(_197, _1154) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1154) : ((spvSubgroupShuffle(_916, _1145) && (((spvSubgroupShuffle(_197, _1145) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1145) : ((spvSubgroupShuffle(_916, _1136) && (((spvSubgroupShuffle(_197, _1136) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1136) : _1135)))))));
    do
    {
        uint _1228 = _83 + 0u;
        uint _1251 = vsharp._m0[6u] - 0u;
        if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1251 >= 4u) && (_1228 <= (_1251 - 4u))))))
        {
            uint _1282 = (((0u + _1228) + 0u) >> 2u) + (_41 >> 2u);
            if (_1282 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4))
            {
                spvDescriptorSet0.buffers[1u]->_m0[_1282] = _600;
            }
        }
        break;
    } while(false);
    do
    {
        uint _1345 = _83 + 4u;
        uint _1368 = vsharp._m0[6u] - 0u;
        if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1368 >= 4u) && (_1345 <= (_1368 - 4u))))))
        {
            uint _1399 = (((0u + _1345) + 0u) >> 2u) + (_41 >> 2u);
            if (_1399 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4))
            {
                spvDescriptorSet0.buffers[1u]->_m0[_1399] = (_607 && (((_608.x & (1u << (_605 & 31u))) != 0u) && (_605 < 32u))) ? _606 : 0u;
            }
        }
        break;
    } while(false);
    do
    {
        uint _1460 = _83 + 8u;
        uint _1483 = vsharp._m0[6u] - 0u;
        if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1483 >= 4u) && (_1460 <= (_1483 - 4u))))))
        {
            uint _1514 = (((0u + _1460) + 0u) >> 2u) + (_41 >> 2u);
            if (_1514 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4))
            {
                spvDescriptorSet0.buffers[1u]->_m0[_1514] = _910;
            }
        }
        break;
    } while(false);
    do
    {
        uint _1575 = _83 + 12u;
        uint _1598 = vsharp._m0[6u] - 0u;
        if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1598 >= 4u) && (_1575 <= (_1598 - 4u))))))
        {
            uint _1629 = (((0u + _1575) + 0u) >> 2u) + (_41 >> 2u);
            if (_1629 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4))
            {
                spvDescriptorSet0.buffers[1u]->_m0[_1629] = _916 ? _1207 : 3735936685u;
            }
        }
        break;
    } while(false);
}

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343572078 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6343572078). Originally posted by [prosperkartik](https://github.com/prosperkartik) on 2026-10-22T14:44:14Z. --- @iamthehimansh, here is the `agc_driver_ds_permute` run you asked for, at the current head `f3bc0258f` on the same M4 (macOS 26.5.1, MoltenVK 1.4.2), with `MVK_CONFIG_LOG_LEVEL=4 MVK_CONFIG_DEBUG=1 MVK_CONFIG_SHADER_DUMP_DIR=<dir> ANYPS5_NO_SHADER_CACHE=1`. Same result: `ds permute: lane 8 permute is 0x00000000, expected 0x00001019`. MoltenVK logs no warnings or errors. Of the 12 compute shaders dumped, one contains the shuffles: `shader-cs-6a936899f53064c2` (full Metal below). **What the translation does.** In the SPIR-V, each candidate source lane gets three unconditional shuffles before any logic (`.spvasm` line 225 on): ``` %299 = OpGroupNonUniformShuffle %uint %uint_3 %293 %298 %300 = OpGroupNonUniformShuffle %uint %uint_3 %197 %298 %301 = OpGroupNonUniformShuffle %bool %uint_3 %true %298 ... %305 = OpLogicalAnd %bool %301 %304 %306 = OpSelect %uint %305 %299 %uint_0_0 ``` SPIRV-Cross forwards those shuffles into MSL's short-circuit operators (`.metal` line 131): ``` uint _369 = (spvSubgroupShuffle(true, _361) && (((spvSubgroupShuffle(_197, _361) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _361) : (...); ``` So the second and third shuffles only run on lanes whose own condition held. A lane that reads from a source lane which skipped that `simd_shuffle` gets no defined value, which fits lane 8 missing lane 25's `0x1019`. **Native check on the M4, without AnyPS5.** A minimal Metal kernel (`repro.swift` below), 32 threads, lane 8 reads lane 25, 200 runs each: | Kernel | Lane 8 | Wrong runs | | --- | --- | --- | | `hoisted`: `uint got = simd_shuffle(v, from); out = c ? got : x;` | `0x1019` | 0 / 200 | | `inlined`: `out = c ? simd_shuffle(v, from) : x;` | `0x1008` | 200 / 200 | | `inlined_and`: shuffle behind `&&`, then in `?:` | `0x1019` | 0 / 200 | So on this GPU a shuffle inside a divergent `?:` arm does not see the source lane's value, while the `&&` form happens to be compiled flat. Whether the M2 Pro compiles the `inlined` form flat is the open question; running `xcrun swiftc -O -o repro repro.swift -framework Metal && ./repro` there would show it. If the M2 Pro also prints 200 wrong runs for `inlined`, the difference is in how the full shader gets compiled per GPU family. Either way, the shuffles in the SPIR-V are unconditional and the MSL makes them conditional, which looks like a SPIRV-Cross issue rather than something in this PR. <details><summary><code>repro.swift</code></summary> ```swift import Metal let src = """ #include <metal_stdlib> using namespace metal; kernel void hoisted(device uint* out [[buffer(0)]], uint lane [[thread_index_in_simdgroup]]) { uint value = 0x1000u + lane; uint from = (lane == 8u) ? 25u : lane; uint got = simd_shuffle(value, ushort(from)); out[lane] = (lane == 8u) ? got : 0xffffffffu; } kernel void inlined(device uint* out [[buffer(0)]], uint lane [[thread_index_in_simdgroup]]) { uint value = 0x1000u + lane; uint from = (lane == 8u) ? 25u : lane; out[lane] = (lane == 8u) ? simd_shuffle(value, ushort(from)) : 0xffffffffu; } kernel void inlined_and(device uint* out [[buffer(0)]], uint lane [[thread_index_in_simdgroup]]) { uint value = 0x1000u + lane; uint from = (lane == 8u) ? 25u : lane; bool ok = (lane < 16u) && (simd_shuffle(value, ushort(from)) != 0u); out[lane] = ok ? simd_shuffle(value, ushort(from)) : 0xffffffffu; } """ let device = MTLCreateSystemDefaultDevice()! let lib = try! device.makeLibrary(source: src, options: nil) let queue = device.makeCommandQueue()! print("device: \(device.name)") for name in ["hoisted", "inlined", "inlined_and"] { var zeros = 0, runs = 200 var sample: UInt32 = 0 for _ in 0..<runs { let pso = try! device.makeComputePipelineState(function: lib.makeFunction(name: name)!) let buf = device.makeBuffer(length: 32 * 4, options: .storageModeShared)! let cb = queue.makeCommandBuffer()!, enc = cb.makeComputeCommandEncoder()! enc.setComputePipelineState(pso); enc.setBuffer(buf, offset: 0, index: 0) enc.dispatchThreads(MTLSize(width: 32, height: 1, depth: 1), threadsPerThreadgroup: MTLSize(width: 32, height: 1, depth: 1)) enc.endEncoding(); cb.commit(); cb.waitUntilCompleted() let v = buf.contents().bindMemory(to: UInt32.self, capacity: 32)[8] sample = v; if v != 0x1019 { zeros += 1 } } print(String(format: "%-12@ lane 8 got 0x%08x (expected 0x00001019); wrong in %d of %d runs", name as NSString, sample, zeros, runs)) } ``` </details> <details><summary>Generated Metal: <code>shader-cs-6a936899f53064c2.metal</code></summary> ```metal #pragma clang diagnostic ignored "-Wmissing-prototypes" #include <metal_stdlib> #include <simd/simd.h> using namespace metal; inline uint4 spvSubgroupBallot(bool value) { simd_vote vote = simd_ballot(value); // simd_ballot() returns a 64-bit integer-like object, but // SPIR-V callers expect a uint4. We must convert. // FIXME: This won't include higher bits if Apple ever supports // 128 lanes in an SIMD-group. return uint4(as_type<uint2>((simd_vote::vote_t)vote), 0, 0); } template<typename T> inline T spvSubgroupShuffle(T value, ushort lane) { return simd_shuffle(value, lane); } template<> inline bool spvSubgroupShuffle(bool value, ushort lane) { return !!simd_shuffle((ushort)value, lane); } template<uint N> inline vec<bool, N> spvSubgroupShuffle(vec<bool, N> value, ushort lane) { return (vec<bool, N>)simd_shuffle((vec<ushort, N>)value, lane); } template<> inline ulong spvSubgroupShuffle(ulong value, ushort lane) { return as_type<ulong>(spvSubgroupShuffle(as_type<uint2>(value), lane)); } template<> inline ulong2 spvSubgroupShuffle(ulong2 value, ushort lane) { return ulong2(spvSubgroupShuffle(value.x, lane), spvSubgroupShuffle(value.y, lane)); } inline ulong3 spvSubgroupShuffle(ulong3 value, ushort lane) { return ulong3(spvSubgroupShuffle(value.xy, lane), spvSubgroupShuffle(value.z, lane)); } inline ulong4 spvSubgroupShuffle(ulong4 value, ushort lane) { return ulong4(spvSubgroupShuffle(value.xy, lane), spvSubgroupShuffle(value.zw, lane)); } template<uint N> inline vec<long, N> spvSubgroupShuffle(vec<long, N> value, ushort lane) { return vec<long, N>(spvSubgroupShuffle(vec<ulong, N>(value), lane)); } struct BufferResource { uint _m0[32]; }; struct _14 { uint _m0[1]; }; struct spvDescriptorSetBuffer0 { constant uint* spvBufferSizeConstants [[id(0)]]; device _14* buffers [[id(1)]][2]; }; kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], constant uint* spvBufferSizeConstants [[buffer(29)]], constant BufferResource& vsharp [[buffer(8)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) { constant uint* spvDescriptorSet0_buffersBufferSize = &spvDescriptorSet0.spvBufferSizeConstants[1]; uint _35 = (vsharp._m0[8u] >> 0u) & 255u; uint _41 = (vsharp._m0[8u] >> 8u) & 255u; uint _82 = gl_LocalInvocationID.x << 4u; uint _83 = gl_LocalInvocationID.x << 6u; uint _196; do { uint _111 = _82 + 0u; uint _137 = vsharp._m0[2u] - 0u; uint _168 = (((0u + _111) + 0u) >> 2u) + (_35 >> 2u); if ((true && (true && ((0u <= vsharp._m0[2u]) && ((_137 >= 4u) && (_111 <= (_137 - 4u)))))) && (_168 < ((spvDescriptorSet0_buffersBufferSize[0u] - 0) / 4))) { _196 = ((spvDescriptorSet0.buffers[0u]->_m0[_168] >> 0u) | 0u) & 4294967295u; } else { _196 = 0u; } break; } while(false); uint _197 = _196; uint _292; do { uint _215 = _82 + 4u; uint _238 = vsharp._m0[2u] - 0u; uint _267 = (((0u + _215) + 0u) >> 2u) + (_35 >> 2u); if ((true && (true && ((0u <= vsharp._m0[2u]) && ((_238 >= 4u) && (_215 <= (_238 - 4u)))))) && (_267 < ((spvDescriptorSet0_buffersBufferSize[0u] - 0) / 4))) { _292 = ((spvDescriptorSet0.buffers[0u]->_m0[_267] >> 0u) | 0u) & 4294967295u; } else { _292 = 0u; } break; } while(false); uint _293 = _292; uint _296 = gl_SubgroupInvocationID & 4294967264u; uint _297 = gl_SubgroupInvocationID & 31u; uint _298 = _296 | 0u; uint _307 = _296 | 1u; uint _316 = _296 | 2u; uint _325 = _296 | 3u; uint _334 = _296 | 4u; uint _343 = _296 | 5u; uint _352 = _296 | 6u; uint _361 = _296 | 7u; uint _369 = (spvSubgroupShuffle(true, _361) && (((spvSubgroupShuffle(_197, _361) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _361) : ((spvSubgroupShuffle(true, _352) && (((spvSubgroupShuffle(_197, _352) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _352) : ((spvSubgroupShuffle(true, _343) && (((spvSubgroupShuffle(_197, _343) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _343) : ((spvSubgroupShuffle(true, _334) && (((spvSubgroupShuffle(_197, _334) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _334) : ((spvSubgroupShuffle(true, _325) && (((spvSubgroupShuffle(_197, _325) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _325) : ((spvSubgroupShuffle(true, _316) && (((spvSubgroupShuffle(_197, _316) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _316) : ((spvSubgroupShuffle(true, _307) && (((spvSubgroupShuffle(_197, _307) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _307) : ((spvSubgroupShuffle(true, _298) && (((spvSubgroupShuffle(_197, _298) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _298) : 0u))))))); uint _370 = _296 | 8u; uint _380 = _296 | 9u; uint _390 = _296 | 10u; uint _400 = _296 | 11u; uint _409 = _296 | 12u; uint _419 = _296 | 13u; uint _428 = _296 | 14u; uint _438 = _296 | 15u; uint _446 = (spvSubgroupShuffle(true, _438) && (((spvSubgroupShuffle(_197, _438) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _438) : ((spvSubgroupShuffle(true, _428) && (((spvSubgroupShuffle(_197, _428) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _428) : ((spvSubgroupShuffle(true, _419) && (((spvSubgroupShuffle(_197, _419) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _419) : ((spvSubgroupShuffle(true, _409) && (((spvSubgroupShuffle(_197, _409) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _409) : ((spvSubgroupShuffle(true, _400) && (((spvSubgroupShuffle(_197, _400) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _400) : ((spvSubgroupShuffle(true, _390) && (((spvSubgroupShuffle(_197, _390) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _390) : ((spvSubgroupShuffle(true, _380) && (((spvSubgroupShuffle(_197, _380) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _380) : ((spvSubgroupShuffle(true, _370) && (((spvSubgroupShuffle(_197, _370) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _370) : _369))))))); uint _447 = _296 | 16u; uint _457 = _296 | 17u; uint _467 = _296 | 18u; uint _477 = _296 | 19u; uint _487 = _296 | 20u; uint _496 = _296 | 21u; uint _506 = _296 | 22u; uint _515 = _296 | 23u; uint _523 = (spvSubgroupShuffle(true, _515) && (((spvSubgroupShuffle(_197, _515) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _515) : ((spvSubgroupShuffle(true, _506) && (((spvSubgroupShuffle(_197, _506) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _506) : ((spvSubgroupShuffle(true, _496) && (((spvSubgroupShuffle(_197, _496) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _496) : ((spvSubgroupShuffle(true, _487) && (((spvSubgroupShuffle(_197, _487) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _487) : ((spvSubgroupShuffle(true, _477) && (((spvSubgroupShuffle(_197, _477) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _477) : ((spvSubgroupShuffle(true, _467) && (((spvSubgroupShuffle(_197, _467) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _467) : ((spvSubgroupShuffle(true, _457) && (((spvSubgroupShuffle(_197, _457) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _457) : ((spvSubgroupShuffle(true, _447) && (((spvSubgroupShuffle(_197, _447) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _447) : _446))))))); uint _525 = _296 | 24u; uint _535 = _296 | 25u; uint _545 = _296 | 26u; uint _555 = _296 | 27u; uint _564 = _296 | 28u; uint _574 = _296 | 29u; uint _583 = _296 | 30u; uint _592 = _296 | 31u; uint _600 = (spvSubgroupShuffle(true, _592) && (((spvSubgroupShuffle(_197, _592) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _592) : ((spvSubgroupShuffle(true, _583) && (((spvSubgroupShuffle(_197, _583) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _583) : ((spvSubgroupShuffle(true, _574) && (((spvSubgroupShuffle(_197, _574) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _574) : ((spvSubgroupShuffle(true, _564) && (((spvSubgroupShuffle(_197, _564) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _564) : ((spvSubgroupShuffle(true, _555) && (((spvSubgroupShuffle(_197, _555) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _555) : ((spvSubgroupShuffle(true, _545) && (((spvSubgroupShuffle(_197, _545) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _545) : ((spvSubgroupShuffle(true, _535) && (((spvSubgroupShuffle(_197, _535) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _535) : ((spvSubgroupShuffle(true, _525) && (((spvSubgroupShuffle(_197, _525) >> 2u) & 31u) == _297)) ? spvSubgroupShuffle(_293, _525) : _523))))))); uint _605 = (gl_SubgroupInvocationID & 4294967264u) | ((_197 >> 2u) & 31u); uint _606 = spvSubgroupShuffle(_293, _605); bool _607 = spvSubgroupShuffle(true, _605); uint4 _608 = spvSubgroupBallot(true); uint _619 = _197 + 8u; uint _621 = gl_SubgroupInvocationID & 4294967264u; uint _622 = gl_SubgroupInvocationID & 31u; uint _623 = _621 | 0u; uint _632 = _621 | 1u; uint _641 = _621 | 2u; uint _650 = _621 | 3u; uint _659 = _621 | 4u; uint _668 = _621 | 5u; uint _677 = _621 | 6u; uint _686 = _621 | 7u; uint _694 = (spvSubgroupShuffle(true, _686) && (((spvSubgroupShuffle(_619, _686) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _686) : ((spvSubgroupShuffle(true, _677) && (((spvSubgroupShuffle(_619, _677) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _677) : ((spvSubgroupShuffle(true, _668) && (((spvSubgroupShuffle(_619, _668) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _668) : ((spvSubgroupShuffle(true, _659) && (((spvSubgroupShuffle(_619, _659) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _659) : ((spvSubgroupShuffle(true, _650) && (((spvSubgroupShuffle(_619, _650) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _650) : ((spvSubgroupShuffle(true, _641) && (((spvSubgroupShuffle(_619, _641) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _641) : ((spvSubgroupShuffle(true, _632) && (((spvSubgroupShuffle(_619, _632) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _632) : ((spvSubgroupShuffle(true, _623) && (((spvSubgroupShuffle(_619, _623) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _623) : 0u))))))); uint _695 = _621 | 8u; uint _704 = _621 | 9u; uint _713 = _621 | 10u; uint _722 = _621 | 11u; uint _731 = _621 | 12u; uint _740 = _621 | 13u; uint _749 = _621 | 14u; uint _758 = _621 | 15u; uint _766 = (spvSubgroupShuffle(true, _758) && (((spvSubgroupShuffle(_619, _758) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _758) : ((spvSubgroupShuffle(true, _749) && (((spvSubgroupShuffle(_619, _749) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _749) : ((spvSubgroupShuffle(true, _740) && (((spvSubgroupShuffle(_619, _740) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _740) : ((spvSubgroupShuffle(true, _731) && (((spvSubgroupShuffle(_619, _731) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _731) : ((spvSubgroupShuffle(true, _722) && (((spvSubgroupShuffle(_619, _722) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _722) : ((spvSubgroupShuffle(true, _713) && (((spvSubgroupShuffle(_619, _713) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _713) : ((spvSubgroupShuffle(true, _704) && (((spvSubgroupShuffle(_619, _704) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _704) : ((spvSubgroupShuffle(true, _695) && (((spvSubgroupShuffle(_619, _695) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _695) : _694))))))); uint _767 = _621 | 16u; uint _776 = _621 | 17u; uint _785 = _621 | 18u; uint _794 = _621 | 19u; uint _803 = _621 | 20u; uint _812 = _621 | 21u; uint _821 = _621 | 22u; uint _830 = _621 | 23u; uint _838 = (spvSubgroupShuffle(true, _830) && (((spvSubgroupShuffle(_619, _830) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _830) : ((spvSubgroupShuffle(true, _821) && (((spvSubgroupShuffle(_619, _821) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _821) : ((spvSubgroupShuffle(true, _812) && (((spvSubgroupShuffle(_619, _812) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _812) : ((spvSubgroupShuffle(true, _803) && (((spvSubgroupShuffle(_619, _803) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _803) : ((spvSubgroupShuffle(true, _794) && (((spvSubgroupShuffle(_619, _794) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _794) : ((spvSubgroupShuffle(true, _785) && (((spvSubgroupShuffle(_619, _785) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _785) : ((spvSubgroupShuffle(true, _776) && (((spvSubgroupShuffle(_619, _776) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _776) : ((spvSubgroupShuffle(true, _767) && (((spvSubgroupShuffle(_619, _767) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _767) : _766))))))); uint _839 = _621 | 24u; uint _848 = _621 | 25u; uint _857 = _621 | 26u; uint _866 = _621 | 27u; uint _875 = _621 | 28u; uint _884 = _621 | 29u; uint _893 = _621 | 30u; uint _902 = _621 | 31u; uint _910 = (spvSubgroupShuffle(true, _902) && (((spvSubgroupShuffle(_619, _902) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _902) : ((spvSubgroupShuffle(true, _893) && (((spvSubgroupShuffle(_619, _893) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _893) : ((spvSubgroupShuffle(true, _884) && (((spvSubgroupShuffle(_619, _884) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _884) : ((spvSubgroupShuffle(true, _875) && (((spvSubgroupShuffle(_619, _875) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _875) : ((spvSubgroupShuffle(true, _866) && (((spvSubgroupShuffle(_619, _866) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _866) : ((spvSubgroupShuffle(true, _857) && (((spvSubgroupShuffle(_619, _857) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _857) : ((spvSubgroupShuffle(true, _848) && (((spvSubgroupShuffle(_619, _848) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _848) : ((spvSubgroupShuffle(true, _839) && (((spvSubgroupShuffle(_619, _839) >> 2u) & 31u) == _622)) ? spvSubgroupShuffle(_293, _839) : _838))))))); bool _916 = ((65535u >> (gl_SubgroupInvocationID & 31u)) & 1u) != 0u; uint _918 = gl_SubgroupInvocationID & 4294967264u; uint _919 = gl_SubgroupInvocationID & 31u; uint _920 = _918 | 0u; uint _929 = _918 | 1u; uint _938 = _918 | 2u; uint _947 = _918 | 3u; uint _956 = _918 | 4u; uint _965 = _918 | 5u; uint _974 = _918 | 6u; uint _983 = _918 | 7u; uint _991 = (spvSubgroupShuffle(_916, _983) && (((spvSubgroupShuffle(_197, _983) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _983) : ((spvSubgroupShuffle(_916, _974) && (((spvSubgroupShuffle(_197, _974) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _974) : ((spvSubgroupShuffle(_916, _965) && (((spvSubgroupShuffle(_197, _965) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _965) : ((spvSubgroupShuffle(_916, _956) && (((spvSubgroupShuffle(_197, _956) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _956) : ((spvSubgroupShuffle(_916, _947) && (((spvSubgroupShuffle(_197, _947) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _947) : ((spvSubgroupShuffle(_916, _938) && (((spvSubgroupShuffle(_197, _938) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _938) : ((spvSubgroupShuffle(_916, _929) && (((spvSubgroupShuffle(_197, _929) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _929) : ((spvSubgroupShuffle(_916, _920) && (((spvSubgroupShuffle(_197, _920) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _920) : 0u))))))); uint _992 = _918 | 8u; uint _1001 = _918 | 9u; uint _1010 = _918 | 10u; uint _1019 = _918 | 11u; uint _1028 = _918 | 12u; uint _1037 = _918 | 13u; uint _1046 = _918 | 14u; uint _1055 = _918 | 15u; uint _1063 = (spvSubgroupShuffle(_916, _1055) && (((spvSubgroupShuffle(_197, _1055) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1055) : ((spvSubgroupShuffle(_916, _1046) && (((spvSubgroupShuffle(_197, _1046) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1046) : ((spvSubgroupShuffle(_916, _1037) && (((spvSubgroupShuffle(_197, _1037) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1037) : ((spvSubgroupShuffle(_916, _1028) && (((spvSubgroupShuffle(_197, _1028) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1028) : ((spvSubgroupShuffle(_916, _1019) && (((spvSubgroupShuffle(_197, _1019) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1019) : ((spvSubgroupShuffle(_916, _1010) && (((spvSubgroupShuffle(_197, _1010) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1010) : ((spvSubgroupShuffle(_916, _1001) && (((spvSubgroupShuffle(_197, _1001) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1001) : ((spvSubgroupShuffle(_916, _992) && (((spvSubgroupShuffle(_197, _992) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _992) : _991))))))); uint _1064 = _918 | 16u; uint _1073 = _918 | 17u; uint _1082 = _918 | 18u; uint _1091 = _918 | 19u; uint _1100 = _918 | 20u; uint _1109 = _918 | 21u; uint _1118 = _918 | 22u; uint _1127 = _918 | 23u; uint _1135 = (spvSubgroupShuffle(_916, _1127) && (((spvSubgroupShuffle(_197, _1127) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1127) : ((spvSubgroupShuffle(_916, _1118) && (((spvSubgroupShuffle(_197, _1118) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1118) : ((spvSubgroupShuffle(_916, _1109) && (((spvSubgroupShuffle(_197, _1109) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1109) : ((spvSubgroupShuffle(_916, _1100) && (((spvSubgroupShuffle(_197, _1100) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1100) : ((spvSubgroupShuffle(_916, _1091) && (((spvSubgroupShuffle(_197, _1091) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1091) : ((spvSubgroupShuffle(_916, _1082) && (((spvSubgroupShuffle(_197, _1082) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1082) : ((spvSubgroupShuffle(_916, _1073) && (((spvSubgroupShuffle(_197, _1073) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1073) : ((spvSubgroupShuffle(_916, _1064) && (((spvSubgroupShuffle(_197, _1064) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1064) : _1063))))))); uint _1136 = _918 | 24u; uint _1145 = _918 | 25u; uint _1154 = _918 | 26u; uint _1163 = _918 | 27u; uint _1172 = _918 | 28u; uint _1181 = _918 | 29u; uint _1182 = spvSubgroupShuffle(_293, _1181); uint _1183 = spvSubgroupShuffle(_197, _1181); bool _1184 = spvSubgroupShuffle(_916, _1181); uint _1190 = _918 | 30u; uint _1191 = spvSubgroupShuffle(_293, _1190); uint _1192 = spvSubgroupShuffle(_197, _1190); bool _1193 = spvSubgroupShuffle(_916, _1190); uint _1199 = _918 | 31u; uint _1200 = spvSubgroupShuffle(_293, _1199); uint _1201 = spvSubgroupShuffle(_197, _1199); bool _1202 = spvSubgroupShuffle(_916, _1199); uint _1207 = (_1202 && (((_1201 >> 2u) & 31u) == _919)) ? _1200 : ((_1193 && (((_1192 >> 2u) & 31u) == _919)) ? _1191 : ((_1184 && (((_1183 >> 2u) & 31u) == _919)) ? _1182 : ((spvSubgroupShuffle(_916, _1172) && (((spvSubgroupShuffle(_197, _1172) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1172) : ((spvSubgroupShuffle(_916, _1163) && (((spvSubgroupShuffle(_197, _1163) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1163) : ((spvSubgroupShuffle(_916, _1154) && (((spvSubgroupShuffle(_197, _1154) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1154) : ((spvSubgroupShuffle(_916, _1145) && (((spvSubgroupShuffle(_197, _1145) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1145) : ((spvSubgroupShuffle(_916, _1136) && (((spvSubgroupShuffle(_197, _1136) >> 2u) & 31u) == _919)) ? spvSubgroupShuffle(_293, _1136) : _1135))))))); do { uint _1228 = _83 + 0u; uint _1251 = vsharp._m0[6u] - 0u; if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1251 >= 4u) && (_1228 <= (_1251 - 4u)))))) { uint _1282 = (((0u + _1228) + 0u) >> 2u) + (_41 >> 2u); if (_1282 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4)) { spvDescriptorSet0.buffers[1u]->_m0[_1282] = _600; } } break; } while(false); do { uint _1345 = _83 + 4u; uint _1368 = vsharp._m0[6u] - 0u; if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1368 >= 4u) && (_1345 <= (_1368 - 4u)))))) { uint _1399 = (((0u + _1345) + 0u) >> 2u) + (_41 >> 2u); if (_1399 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4)) { spvDescriptorSet0.buffers[1u]->_m0[_1399] = (_607 && (((_608.x & (1u << (_605 & 31u))) != 0u) && (_605 < 32u))) ? _606 : 0u; } } break; } while(false); do { uint _1460 = _83 + 8u; uint _1483 = vsharp._m0[6u] - 0u; if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1483 >= 4u) && (_1460 <= (_1483 - 4u)))))) { uint _1514 = (((0u + _1460) + 0u) >> 2u) + (_41 >> 2u); if (_1514 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4)) { spvDescriptorSet0.buffers[1u]->_m0[_1514] = _910; } } break; } while(false); do { uint _1575 = _83 + 12u; uint _1598 = vsharp._m0[6u] - 0u; if (true && (true && ((0u <= vsharp._m0[6u]) && ((_1598 >= 4u) && (_1575 <= (_1598 - 4u)))))) { uint _1629 = (((0u + _1575) + 0u) >> 2u) + (_41 >> 2u); if (_1629 < ((spvDescriptorSet0_buffersBufferSize[1u] - 0) / 4)) { spvDescriptorSet0.buffers[1u]->_m0[_1629] = _916 ? _1207 : 3735936685u; } } break; } while(false); } ``` </details> AI-assisted: yes
iamthehimansh commented 2026-10-22 15:01:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by iamthehimansh on 2026-10-22T15:01:16Z.


@prosperkartik thank you, that is a very clear diagnosis.

Your repro.swift on my M2 Pro (macOS 26.6.2):

device: Apple M2 Pro
hoisted      lane 8 got 0x00001019 (expected 0x00001019); wrong in 0 of 200 runs
inlined      lane 8 got 0x00001008 (expected 0x00001019); wrong in 200 of 200 runs
inlined_and  lane 8 got 0x00001019 (expected 0x00001019); wrong in 0 of 200 runs

So the M2 Pro also gives a wrong value for a simd_shuffle inside a divergent ?: arm. The difference is not in the hardware rule, only in how Metal compiles the full ds_permute shader for each GPU family: on the M2 Pro the forwarded shuffles happen to come out flat, and on the M4 at least lane 25's does not.

I agree it is a SPIRV-Cross issue. The SPIR-V has the shuffles unconditional, and forwarding them into && / ?: operands makes them conditional, which is not valid for subgroup operations. Your reduced kernel is exactly what a KhronosGroup/SPIRV-Cross issue needs. Since you found it, it should be filed under your name; if you file it, I'll link it from this PR's description next to agc_driver_ds_permute.

On our side, I could stop the forwarding by giving each shuffle result a second use, so SPIRV-Cross has to keep it in a temporary. That would change the emitted shader on every host, so I would rather not add it to this PR. A separate small PR could do it, if a maintainer prefers a workaround until SPIRV-Cross is fixed.

AI-assisted: yes (Cana)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343940638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6343940638). Originally posted by [iamthehimansh](https://github.com/iamthehimansh) on 2026-10-22T15:01:16Z. --- @prosperkartik thank you, that is a very clear diagnosis. Your `repro.swift` on my M2 Pro (macOS 26.6.2): ``` device: Apple M2 Pro hoisted lane 8 got 0x00001019 (expected 0x00001019); wrong in 0 of 200 runs inlined lane 8 got 0x00001008 (expected 0x00001019); wrong in 200 of 200 runs inlined_and lane 8 got 0x00001019 (expected 0x00001019); wrong in 0 of 200 runs ``` So the M2 Pro also gives a wrong value for a `simd_shuffle` inside a divergent `?:` arm. The difference is not in the hardware rule, only in how Metal compiles the full `ds_permute` shader for each GPU family: on the M2 Pro the forwarded shuffles happen to come out flat, and on the M4 at least lane 25's does not. I agree it is a SPIRV-Cross issue. The SPIR-V has the shuffles unconditional, and forwarding them into `&&` / `?:` operands makes them conditional, which is not valid for subgroup operations. Your reduced kernel is exactly what a KhronosGroup/SPIRV-Cross issue needs. Since you found it, it should be filed under your name; if you file it, I'll link it from this PR's description next to `agc_driver_ds_permute`. On our side, I could stop the forwarding by giving each shuffle result a second use, so SPIRV-Cross has to keep it in a temporary. That would change the emitted shader on every host, so I would rather not add it to this PR. A separate small PR could do it, if a maintainer prefers a workaround until SPIRV-Cross is fixed. AI-assisted: yes (Cana)
prosperkartik commented 2026-10-22 15:19:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by prosperkartik on 2026-10-22T15:19:37Z.


@iamthehimansh, filed: https://github.com/KhronosGroup/SPIRV-Cross/issues/2722. It reproduces on SPIRV-Cross main (300681b) with an 11-line shader; the generated MSL is wrong 200/200 on the M4 and correct when the shuffle is kept in a temporary.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6344348284 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#issuecomment-6344348284). Originally posted by [prosperkartik](https://github.com/prosperkartik) on 2026-10-22T15:19:37Z. --- @iamthehimansh, filed: https://github.com/KhronosGroup/SPIRV-Cross/issues/2722. It reproduces on SPIRV-Cross `main` (300681b) with an 11-line shader; the generated MSL is wrong 200/200 on the M4 and correct when the shuffle is kept in a temporary.
adriadam10 commented 2026-10-23 18:37:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T18:37:18Z.

Review: CHANGES_REQUESTED


Thanks for the work and the thorough testing notes. This is too large to land as one PR (135 files, ~10 libraries plus relinker, web converter and shader recompiler), and it currently needs changes before it can go in:

  • Conflicts with main: core/libs/prx/libc/src/Interfaces.cpp, core/libs/tests/GuestInterfaces.cpp and core/libs/tests/GuestNetCtlAp.cpp conflict on logic, not just adjacency (reports above also mention Graphics/src/Texture.cpp and DynamicLoader.cpp).
  • Code comments: the diff adds ~190 // comment lines (e.g. the 0xfe0040000 / driver block explanation in DriverMemory.hpp, ShaderRegistry.cpp). CONTRIBUTING allows none outside technical debt; move them to docs/dev/debt/<library>.md, as your description offers.
  • One topic per PR: you offered to split by library, please do. Suggested order: build/portability fixes that make main compile on macOS first, then kernel/libc/net per library, then the AGC driver address move + shader retargeting, then relinker/web. Each PR with its own tests and Depends on.
  • Overlap: #9738, #9654, #9625, #9668, #9789, #9728, #9971 and the other macOS PRs (#4630, #7631, #7804, #7201) cover hunks you also change. Drop your copy of each hunk that another PR already owns, and list real prerequisites under Depends on.
  • Failing tests: 19 tests fail on M2 Pro and more on M1; ones that are macOS/MoltenVK limits should skip with a DEVICE_LIMITATION-matching reason (tools/check_skips.py) instead of failing, and the rest (agc_write_tracking, guest_refused_connect flakes) need a fix or a documented debt line in the PR that introduces the code.
  • Linux/Windows: nothing shared was built by you; keeping the shared-file edits (Formatting.cpp, QueuedIndexReadOrder.cpp, FileStream.hpp, Jit.cpp...) in a small first PR lets the full Linux/Windows Build prove them cheaply.

Welcome to push the split PRs; they'll be reviewed individually.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5632910887 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#pullrequestreview-5632910887). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-23T18:37:18Z. **Review:** CHANGES_REQUESTED --- Thanks for the work and the thorough testing notes. This is too large to land as one PR (135 files, ~10 libraries plus relinker, web converter and shader recompiler), and it currently needs changes before it can go in: - **Conflicts with `main`**: `core/libs/prx/libc/src/Interfaces.cpp`, `core/libs/tests/GuestInterfaces.cpp` and `core/libs/tests/GuestNetCtlAp.cpp` conflict on logic, not just adjacency (reports above also mention `Graphics/src/Texture.cpp` and `DynamicLoader.cpp`). - **Code comments**: the diff adds ~190 `//` comment lines (e.g. the `0xfe0040000` / driver block explanation in `DriverMemory.hpp`, `ShaderRegistry.cpp`). CONTRIBUTING allows none outside technical debt; move them to `docs/dev/debt/<library>.md`, as your description offers. - **One topic per PR**: you offered to split by library, please do. Suggested order: build/portability fixes that make `main` compile on macOS first, then kernel/libc/net per library, then the AGC driver address move + shader retargeting, then relinker/web. Each PR with its own tests and `Depends on`. - **Overlap**: #9738, #9654, #9625, #9668, #9789, #9728, #9971 and the other macOS PRs (#4630, #7631, #7804, #7201) cover hunks you also change. Drop your copy of each hunk that another PR already owns, and list real prerequisites under `Depends on`. - **Failing tests**: 19 tests fail on M2 Pro and more on M1; ones that are macOS/MoltenVK limits should skip with a `DEVICE_LIMITATION`-matching reason (`tools/check_skips.py`) instead of failing, and the rest (`agc_write_tracking`, `guest_refused_connect` flakes) need a fix or a documented debt line in the PR that introduces the code. - **Linux/Windows**: nothing shared was built by you; keeping the shared-file edits (`Formatting.cpp`, `QueuedIndexReadOrder.cpp`, `FileStream.hpp`, `Jit.cpp`...) in a small first PR lets the full Linux/Windows Build prove them cheaply. Welcome to push the split PRs; they'll be reviewed individually.
adriadam10 commented 2026-10-23 19:36:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T19:36:18Z.

Review: CHANGES_REQUESTED


Re-reviewed against 6ee81b979: since the last review the range-diff only has merges of main and a reworded commit message, so the earlier points still stand:

  • The diff still adds ~190 // comment lines (e.g. DriverMemory.hpp, ShaderRegistry.cpp); CONTRIBUTING allows none, move the notes to docs/dev/debt/<library>.md.
  • Still one 131-file PR across ~10 libraries, the relinker, the web converter and the shader recompiler; it can't be reviewed or landed as one topic.
  • Failing macOS tests still need a DEVICE_LIMITATION-matching skip or a debt line in the PR that introduces the code.

You've already agreed to the split, so please continue with the topic PRs. The open-PR limit is what closed #10362, so close this PR (or reduce it to a tracking list) once the first split PRs are up; they will be reviewed individually.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633532602 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8658#pullrequestreview-5633532602). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-23T19:36:18Z. **Review:** CHANGES_REQUESTED --- Re-reviewed against 6ee81b979: since the last review the range-diff only has merges of `main` and a reworded commit message, so the earlier points still stand: - The diff still adds ~190 `//` comment lines (e.g. `DriverMemory.hpp`, `ShaderRegistry.cpp`); CONTRIBUTING allows none, move the notes to `docs/dev/debt/<library>.md`. - Still one 131-file PR across ~10 libraries, the relinker, the web converter and the shader recompiler; it can't be reviewed or landed as one topic. - Failing macOS tests still need a `DEVICE_LIMITATION`-matching skip or a debt line in the PR that introduces the code. You've already agreed to the split, so please continue with the topic PRs. The open-PR limit is what closed #10362, so close this PR (or reduce it to a tracking list) once the first split PRs are up; they will be reviewed individually.

Pull request closed

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!8658
No description provided.