Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f9f6d5f
metal: Metal renderer integration for macOS
JoeMatt Oct 16, 2026
f1befcd
metal: Metal renderer
JoeMatt Oct 16, 2026
f99a693
metal: per-pixel (OIT) renderer
JoeMatt Oct 16, 2026
1822e5a
metal: VMU screens and lightgun crosshairs
JoeMatt Oct 16, 2026
e86f75b
metal: write the OIT frame back to VRAM under EmulateFramebuffer
JoeMatt Oct 16, 2026
d9fcf27
metal: size the OIT screen drawer to the render resolution
JoeMatt Oct 16, 2026
cb6260c
metal: video routing (Syphon)
JoeMatt Oct 16, 2026
667999a
metal: optional MetalFX spatial upscaling
JoeMatt Oct 16, 2026
0931fef
metal: fix buffer lifetime and renderer parity issues
JoeMatt Nov 8, 2026
a74c562
metal: separate MetalFX from the renderer submission
JoeMatt Nov 8, 2026
12e7e9d
metal: select texture storage per GPU and fix Intel builds
JoeMatt Nov 8, 2026
07ab5b9
metal: align fragment uniforms to the shader ABI
JoeMatt Nov 8, 2026
5ca6f58
sdl: defer game loading until the outer UI loop
JoeMatt Nov 8, 2026
d8956ef
metal: use the renderer's shaders for framebuffer scaling
JoeMatt Dec 3, 2026
9685452
metal: remove the unused upload helpers and screen target vectors
JoeMatt Dec 3, 2026
f49b2c1
metal: allocate one per-pixel screen target, none for RTT
JoeMatt Dec 3, 2026
344f34c
metal: end the screen render pass before the next texture pass
JoeMatt Dec 3, 2026
9d826d8
metal: keep video routing output opaque under overlays
JoeMatt Dec 3, 2026
2496930
metal: make the macOS 12 requirement message translatable
JoeMatt Dec 3, 2026
e5efd63
Revert "sdl: defer game loading until the outer UI loop"
JoeMatt Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum macOS deployment version")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
endif()
set(ZLIB_LIBRARY "-lz" CACHE STRING "Use generic linker flag for Xcode to support multiple SDKs")
if(CMAKE_GENERATOR STREQUAL "Xcode")
# Ninja/Makefiles treat this as a file dependency of the final link and fail
# with "no known rule to make -lz"; only the Xcode generator needs it.
set(ZLIB_LIBRARY "-lz" CACHE STRING "Use generic linker flag for Xcode to support multiple SDKs")
endif()
endif()

if(LIBRETRO)
Expand Down Expand Up @@ -90,6 +94,7 @@ option(USE_HOST_LIBCHDR "Use host libchdr" OFF)
option(USE_HOST_LIBJUICE "Use host libjuice" OFF)
option(USE_OPENMP "Use OpenMP if available" ON)
option(USE_VULKAN "Build with Vulkan support" ON)
option(USE_METAL "Build with Metal support (macOS only)" ON)
set(MOLTENVK_DYLIB "" CACHE FILEPATH "Path to macOS MoltenVK dylib for macOS Vulkan builds")
option(USE_DX9 "Build with Direct3D 9 support" ON)
option(USE_DX11 "Build with Direct3D 11 support" ON)
Expand All @@ -113,6 +118,10 @@ if(IOS AND NOT LIBRETRO)
set(USE_VULKAN OFF CACHE BOOL "Force vulkan off" FORCE)
endif()

if(NOT APPLE OR IOS OR LIBRETRO)
set(USE_METAL OFF CACHE BOOL "Force metal off" FORCE)
endif()

if(WEBOS)
if(CMAKE_CXX_COMPILER MATCHES "aarch64")
set(USE_GLES ON CACHE BOOL "Use GLES[3] API" FORCE)
Expand Down Expand Up @@ -1426,6 +1435,9 @@ if(NOT LIBRETRO)
# gets its main() from gtest_main and stubs the rest (tests/src/test_stubs.cpp).
if(NOT BUILD_TESTING)
add_subdirectory(core/deps/Syphon)
# Syphon's prefix header is meant for its own sources. Don't let it propagate:
# flycast would get a C++-only PCH that can't be used for .mm files.
set_target_properties(Syphon PROPERTIES INTERFACE_PRECOMPILE_HEADERS "")
target_link_libraries(${PROJECT_NAME} PRIVATE Syphon)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SYPHON_METALLIB}
Expand Down
78 changes: 78 additions & 0 deletions core/deps/imgui/backends/imgui_impl_metal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// dear imgui: Renderer Backend for Metal
// This needs to be used along with a Platform Backend (e.g. OSX)

// Implemented features:
// [X] Renderer: User texture binding. Use 'MTLTexture' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE

//-----------------------------------------------------------------------------
// ObjC API
//-----------------------------------------------------------------------------

#ifdef __OBJC__

@class MTLRenderPassDescriptor;
@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;

// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
id<MTLCommandBuffer> commandBuffer,
id<MTLRenderCommandEncoder> commandEncoder);

// Called by Init/NewFrame/Shutdown
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device);
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();

// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);

#endif

//-----------------------------------------------------------------------------
// C++ API
//-----------------------------------------------------------------------------

// Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
// More info about using Metal from C++: https://developer.apple.com/metal/cpp/

#ifdef IMGUI_IMPL_METAL_CPP
#include <Metal/Metal.hpp>
#ifndef __OBJC__

// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
MTL::CommandBuffer* commandBuffer,
MTL::RenderCommandEncoder* commandEncoder);

// Called by Init/NewFrame/Shutdown
IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();

// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);

#endif
#endif

//-----------------------------------------------------------------------------

#endif // #ifndef IMGUI_DISABLE
Loading
Loading