Skip to content

Commit

Permalink
GS:MTL: Add option to disable Metal renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
TellowKrinkle committed Mar 2, 2022
1 parent e4aaef0 commit a4878b1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
9 changes: 9 additions & 0 deletions cmake/BuildParameters.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ option(USE_VTUNE "Plug VTUNE to profile GS JIT.")
#-------------------------------------------------------------------------------
option(BUILD_REPLAY_LOADERS "Build GS replayer to ease testing (developer option)")
option(USE_VULKAN "Enable Vulkan GS renderer" ON)
if (APPLE)
option(USE_METAL "Enable Metal GS renderer" ON)
else()
option(USE_METAL "Enable Metal GS renderer" OFF)
endif()

#-------------------------------------------------------------------------------
# Path and lib option
Expand Down Expand Up @@ -242,6 +247,10 @@ if(USE_VULKAN)
list(APPEND PCSX2_DEFS ENABLE_VULKAN)
endif()

if (USE_METAL)
list(APPEND PCSX2_DEFS ENABLE_METAL)
endif()

if(X11_API)
list(APPEND PCSX2_DEFS X11_API)
endif()
Expand Down
4 changes: 3 additions & 1 deletion pcsx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ if(WIN32)
list(APPEND pcsx2FrontendHeaders
Frontend/D3D11HostDisplay.h
)
elseif(APPLE)
elseif(USE_METAL)
list(APPEND pcsx2GSSources
GS/Renderers/Metal/GSDeviceMTL.mm
GS/Renderers/Metal/GSMTLDeviceInfo.mm
Expand Down Expand Up @@ -1708,6 +1708,7 @@ if(GETTEXT_FOUND AND NOT NO_TRANSLATION AND NOT PCSX2_CORE)
endif()

if (APPLE)
if(USE_METAL)
find_library(METAL_LIBRARY Metal)
target_link_libraries(PCSX2 PRIVATE ${METAL_LIBRARY})

Expand Down Expand Up @@ -1750,6 +1751,7 @@ if (APPLE)
generateMetallib(macos-metal2.2 air64-apple-macos10.15 Metal22)
generateMetallib(macos-metal2.3 air64-apple-macos11.0 Metal23)
endif()
endif(USE_METAL)

# MacOS defaults to having a maximum protection of the __DATA segment of rw (non-executable)
# We have a bunch of page-sized arrays in bss that we use for jit
Expand Down
6 changes: 3 additions & 3 deletions pcsx2/GS/GS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static HostDisplay::RenderAPI GetAPIForRenderer(GSRendererType renderer)
case GSRendererType::VK:
return HostDisplay::RenderAPI::Vulkan;

#ifdef __APPLE__
#ifdef ENABLE_METAL
case GSRendererType::Metal:
return HostDisplay::RenderAPI::Metal;
#endif
Expand All @@ -191,7 +191,7 @@ static bool DoGSOpen(GSRendererType renderer, u8* basemem)
g_gs_device = std::make_unique<GSDevice11>();
break;
#endif
#ifdef __APPLE__
#ifdef ENABLE_METAL
case HostDisplay::RenderAPI::Metal:
g_gs_device = std::unique_ptr<GSDevice>(MakeGSDeviceMTL());
break;
Expand Down Expand Up @@ -1199,7 +1199,7 @@ void GSApp::Init()
#ifdef _WIN32
m_gs_renderers.push_back(GSSetting(static_cast<u32>(GSRendererType::DX11), "Direct3D 11", ""));
#endif
#ifdef __APPLE__
#ifdef ENABLE_METAL
m_gs_renderers.push_back(GSSetting(static_cast<u32>(GSRendererType::Metal), "Metal", ""));
#endif
m_gs_renderers.push_back(GSSetting(static_cast<u32>(GSRendererType::OGL), "OpenGL", ""));
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/GS/Renderers/Metal/GSMetalCPPAccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#pragma once
// Header with all metal stuff available for use with C++ (rather than Objective-C++)

#ifdef __APPLE__
#ifdef ENABLE_METAL

#include "HostDisplay.h"

Expand Down
4 changes: 2 additions & 2 deletions pcsx2/GS/Window/GSwxDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace
, inner(new wxBoxSizer(orientation))
{
wxSizerFlags flags = wxSizerFlags().Expand();
#ifdef __APPLE__
#ifdef ENABLE_METAL
if (!std::is_same<OuterSizer, wxStaticBoxSizer>::value) // wxMac already adds padding to static box sizers
#endif
flags.Border();
Expand Down Expand Up @@ -700,7 +700,7 @@ void Dialog::RendererChange()
list = VulkanHostDisplay::StaticGetAdapterAndModeList(nullptr);
break;
#endif
#ifdef __APPLE__
#ifdef ENABLE_METAL
case GSRendererType::Metal:
list = GetMetalAdapterAndModeList();
break;
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/HostDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ std::unique_ptr<HostDisplay> HostDisplay::CreateDisplayForAPI(RenderAPI api)
case RenderAPI::D3D11:
return std::make_unique<D3D11HostDisplay>();
#endif
#ifdef __APPLE__
#ifdef ENABLE_METAL
case HostDisplay::RenderAPI::Metal:
return std::unique_ptr<HostDisplay>(MakeMetalHostDisplay());
#endif
Expand Down

0 comments on commit a4878b1

Please sign in to comment.