[pull] master from libretro:master#945
Merged
pull[bot] merged 24 commits intoAlexandre1er:masterfrom Apr 20, 2026
Merged
Conversation
The convert_bgra4444_to_bgra8888 kernel in Shaders.metal expects input bits laid out as B(15:12) G(11:8) R(7:4) A(3:0) — the D3D10/11/12 packing convention. But when the Metal driver is active, rgui_set_pixel_format_function (menu/drivers/rgui.c:1412-1413) falls through to the else branch and packs with argb32_to_rgba4444, producing R(15:12) G(11:8) B(7:4) A(3:0). The shader then decodes the bytes swapped — a red RGUI pixel 0xF00F gets rendered as blue. This has presumably been wrong since whenever the Metal driver first shipped with 4444 support, but nobody ever pulled the thread.
On SMP PowerPC (G5), the volatile fallback is technically weaker than true release/acquire — you'd want an lwsync to get real ordering. But: (a) the thumbnail status is a single int, aligned, (b) the failure mode is at worst a fade-in animation starting one frame late, not corruption, and (c) the author's own comment acknowledges this tradeoff ("Platforms with weak ordering that lack GCC builtins do not run threaded video in practice"). Single-core G4 is fine. If you specifically want to harden the G5 path later, the right tool is __sync_synchronize() — which did exist in GCC 4.1 — but that's an enhancement, not a blocker for getting the build green.
<stdatomic.h> is C11 (GCC 4.9+, Xcode 5+) and <dispatch/dispatch.h>
requires GCD (Mac OS X 10.6+). Neither exists on Xcode 3.1 / 10.4-
10.5 / PowerPC, so coreaudio.c fails to compile there with:
coreaudio.c:17:23: error: stdatomic.h: No such file or directory
coreaudio.c:20:31: error: dispatch/dispatch.h: No such file or
directory
On SDKs predating 10.7, provide local replacements:
- atomic_size_t / atomic_load_explicit / atomic_fetch_add_explicit
/ atomic_fetch_sub_explicit / atomic_init -> OSAtomicAdd32Barrier
(<libkern/OSAtomic.h>, available since 10.4). The ring-buffer
fill counter fits easily in int32_t (worst case ~200k samples).
- dispatch_semaphore_t / _create / _signal / _wait / dispatch_time /
dispatch_release -> Mach semaphore_t (<mach/semaphore.h>), which
has been on OS X since NeXTSTEP.
The file's logic is unchanged; only the header block at the top is
conditional. Shim macros are #undef'd at EOF so they cannot leak
into later translation units in the griffin unity build.
Modern SDKs take the existing code path unchanged.
The pre-10.7 shim added in 24157a0 typedef'd dispatch_semaphore_t from semaphore_t at file scope, expecting <mach/mach.h> and <mach/semaphore.h> to expose the underlying typedef transitively. On some older SDK and compiler combinations that chain doesn't settle by the time we read it, producing: coreaudio.c:66: error: syntax error before dispatch_semaphore_t Two defensive changes: 1) Include <mach/mach_types.h> (canonical home of semaphore_t) and <mach/sync_policy.h> (SYNC_POLICY_FIFO) explicitly rather than relying on transitive inclusion from other mach headers. 2) Declare dispatch_semaphore_t as uintptr_t so its file-scope typedef depends on nothing from the mach headers. semaphore_t is still used inside function bodies, where the full header chain has been processed regardless of ordering quirks; the uintptr_t handle is cast to semaphore_t at each call site. Modern SDKs take the existing <stdatomic.h> / <dispatch/dispatch.h> path and are unaffected.
The current implementation uses C11 <stdatomic.h> and Grand Central Dispatch (<dispatch/dispatch.h>), both of which require 10.6/10.7-era SDKs and toolchains. On Xcode 3.1 / 10.4-10.5 / PowerPC neither header exists and the file cannot be compiled at all. Earlier shim attempts (24157a0, 1c5c124) tried to reimplement the C11/GCD subset on top of OSAtomic and Mach semaphores, but kept running into header-visibility issues that are impractical to solve portably. Simpler approach: pick one of two full implementations at preprocess time. - Pre-10.7: restore the pre-rewrite implementation (from 5b9763b) that uses RetroArch's slock_t/scond_t and fifo_buffer_t. The audio_driver_t initializer gains a NULL write_raw slot to match the current struct shape; the frontend's generic resampler handles what the hardware-accelerated path used to. - 10.7+: unchanged current code path. Selected via AvailabilityMacros.h: RARCH_COREAUDIO_LEGACY is defined when MAC_OS_X_VERSION_10_7 is absent or MIN_REQUIRED < 10.7. Modern builds are bit-for-bit identical.
audio/drivers/coreaudio_mic_macos.m uses C11 <stdatomic.h>, which
requires a 10.6/10.7-era SDK or newer. On Xcode 3.1 / 10.4-10.5 /
PowerPC the header doesn't exist and the driver fails to compile:
coreaudio_mic_macos.m:27:23: error: stdatomic.h: No such file
or directory
Detect the target macOS version in config.libs.sh and clear
HAVE_MICROPHONE when it's pre-10.7, unless the user explicitly passed
--enable-microphone.
Target version is taken from $MACOSX_DEPLOYMENT_TARGET when set
(authoritative for cross-builds, e.g. someone on a modern macOS host
targeting 10.5 via an older SDK), falling back to sw_vers for native
builds. Both tools have been available since 10.4.
Modern macOS builds are unaffected — they continue to compile the
microphone driver as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )