Skip to content

[macOS] Add macOS SDL3 EGL runtime substrate#3060

Draft
yeojuny wants to merge 7 commits into
beyond-all-reason:masterfrom
yeojuny:codex/macos-runtime-substrate
Draft

[macOS] Add macOS SDL3 EGL runtime substrate#3060
yeojuny wants to merge 7 commits into
beyond-all-reason:masterfrom
yeojuny:codex/macos-runtime-substrate

Conversation

@yeojuny

@yeojuny yeojuny commented Jun 24, 2026

Copy link
Copy Markdown

Summary

This is a draft PR for the macOS/Apple Silicon runtime substrate used by the BAR.app path.

It adds the platform pieces needed to launch Recoil through SDL3 + EGL on macOS while preserving the Linux/BAR gameplay contract:

  • SDL3/EGL bridge and macOS window/context glue
  • macOS CPU topology, threading, input, sound, Rml/Lua, filesystem/archive portability fixes
  • viewport/scissor scaling and Zink/MoltenVK capability handling needed by the BAR.app runtime
  • build/CMake adjustments for the native macOS engine lane

Commit layout

The branch is split into four reviewable commits:

  1. Add macOS SDL3 EGL platform layer
  2. Adapt GL state for macOS Zink rendering
  3. Fix macOS filesystem and toolchain portability
  4. Adjust Rml and aGui for macOS runtime

Why

The BAR Apple Silicon port should be bar-lobby-first rather than a direct-engine fork. This PR isolates the Recoil-side runtime substrate so the lobby can hand off to a native engine in a reviewable upstream branch.

Validation

  • git diff 9fdfaad501..HEAD --check
  • cmake --build /Users/yeojun/Desktop/BAR-AppleSilicon-App/build/recoil-engine --target engine-legacy -j 8

The engine target builds successfully. Remaining local linker warnings are about duplicate libraries and deployment-target/newer-dylib closure in the local runtime stack, not a compile failure.

Related draft PRs

Notes for reviewers

This is intentionally draft because runtime closure, signing/notarization, and clean-machine packaging are still tracked outside this Recoil-only change. The expected acceptance path is BAR.app through bar-lobby, not direct spring invocation.

@sprunk

sprunk commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

split this into sensible commits

@yeojuny yeojuny force-pushed the codex/macos-runtime-substrate branch from 8cec3e1 to 3ff1357 Compare June 24, 2026 23:06
@yeojuny

yeojuny commented Jun 24, 2026

Copy link
Copy Markdown
Author

Done. I force-pushed the branch as four focused commits: SDL3/EGL platform layer, macOS Zink GL state adaptation, filesystem/toolchain portability, and Rml/aGui runtime adjustments. Re-validated with git diff 9fdfaad501..HEAD --check and cmake --build /Users/yeojun/Desktop/BAR-AppleSilicon-App/build/recoil-engine --target engine-legacy -j 8.

@yeojuny yeojuny changed the title [codex] Add macOS SDL3 EGL runtime substrate [macOS Add macOS SDL3 EGL runtime substrate Jun 25, 2026
@yeojuny yeojuny changed the title [macOS Add macOS SDL3 EGL runtime substrate [macOS] Add macOS SDL3 EGL runtime substrate Jun 25, 2026

@sprunk sprunk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am doubtful about mixing SDL2 and SLD3 and especially about doing it by sprinkling the code with a ton of ifdefs.

Comment thread rts/System/float3.h Outdated

std::string str() const {
return std::format("float3({:.3f}, {:.3f}, {:.3f})", x, y, z);
char buf[64];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

try fmt::format. if that helps, make a small standalone PR that converts existing std::formats to fmt::format

@yeojuny

yeojuny commented Jun 25, 2026

Copy link
Copy Markdown
Author

That's fair feedback. The intent here is not to mix SDL2 and SDL3 as runtime dependencies.

The original engine path is SDL2-shaped, and the first macOS attempts also followed that route. In practice, the SDL2 path made the macOS display / high-DPI / window-size handling messy enough that the SDL3 route became the cleaner runtime substrate. SDL3 gives us a better fit for the Cocoa/Retina window and drawable-size model, while the existing engine code still expects SDL2-style source and CMake contracts.

So under RECOIL_MACOS_SDL3_EGL, FindSDL2 resolves to SDL3 and exposes it as SDL2::SDL2 only as a compatibility facade. The built macOS binary links libSDL3.0.dylib, not SDL2.

I agree the naming and ifdef surface make this easy to misread. I can tighten the PR description and, if maintainers prefer, follow up by isolating or renaming the compatibility layer so the SDL3 runtime boundary is clearer.

@yeojuny

yeojuny commented Jun 25, 2026

Copy link
Copy Markdown
Author

I took another pass at this to make the SDL boundary less ambiguous:

  • renamed the internal CMake compatibility target to RecoilSDL2SourceCompat, while keeping the public SDL2::SDL2 alias only for the existing source/CMake contract
  • moved the SDL3/EGL bridge source behind the RECOIL_MACOS_SDL3_EGL option instead of listing it unconditionally for macOS
  • removed duplicate per-target compat include/define injection from engine-legacy, so the SDL compatibility boundary now comes from one place: the SDL compat target
  • added a short comment in SDLRecoilCompat.h explaining that this is source compatibility and the linked runtime remains SDL3

Revalidated with:

  • git diff --check
  • cmake --build /Users/yeojun/Desktop/BAR-AppleSilicon-App/build/recoil-engine --target engine-legacy -j 8
  • otool -L /Users/yeojun/Desktop/BAR-AppleSilicon-App/build/recoil-engine/spring | rg -i "SDL|EGL|Molten|vulkan|OpenGL|Metal"

The rebuilt binary still links libSDL3.0.dylib and libEGL.1.dylib, with no SDL2 dylib.

@tomjn

tomjn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@sprunk @yeojuny I saw another PR somewhere about SDL 3, perhaps a general SDL 3 upgrade would help both the engine and MacOS porting

@sprunk

sprunk commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Possibly, but I think that is a harder task. Adding mac support only touches existing code in limited ways, but a proper SDL3 migration will affect existing rendering widely so has huge potential for regressions (e.g. check wesnoth which recently migrated and got a ton of problems out of it: https://github.com/wesnoth/wesnoth/issues?q=is%3Aissue%20SDL3%20sort%3Aupdated-desc ). I am not sure if I want it to be done by mac vibecoders who have nothing to lose.

@tomjn

tomjn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Considering the other notable MacOS renderer PR didn't upgrade SDL, I'm inclined to agree on the risk factor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

big mac Part of the big push to support Mac.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants