Archived
1
Fork 0

Enable Metal by default on SDL backend

This commit is contained in:
Joshua Goins 2022-02-15 11:29:56 -05:00
parent aa33bb6bf9
commit 93c2639539
2 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,11 @@
include(../../cmake/AddPlatformExecutable.cmake) include(../../cmake/AddPlatformExecutable.cmake)
if(ENABLE_MACOS)
find_library(METAL Metal)
set(EXTRA_LIBRARIES ${METAL})
endif()
add_platform( add_platform(
SRC ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp SRC ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
MAIN_FILE MAIN_FILE
@ -12,6 +18,7 @@ add_platform(
Core Core
GFXVulkan GFXVulkan
GFXMetal GFXMetal
${EXTRA_LIBRARIES}
) )
function(add_platform_commands target) function(add_platform_commands target)

View file

@ -87,7 +87,11 @@ bool platform::supports_feature(const PlatformFeature feature) {
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) { platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
auto& win = windows.emplace_back(); auto& win = windows.emplace_back();
int sdl_flags = SDL_WINDOW_VULKAN | SDL_WINDOW_ALLOW_HIGHDPI; int sdl_flags = SDL_WINDOW_ALLOW_HIGHDPI;
#ifndef ENABLE_METAL
sdl_flags |= SDL_WINDOW_VULKAN;
#endif
if(flags & WindowFlags::Borderless) if(flags & WindowFlags::Borderless)
sdl_flags |= SDL_WINDOW_BORDERLESS; sdl_flags |= SDL_WINDOW_BORDERLESS;
@ -299,6 +303,10 @@ void platform::end_text_input() {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
#ifdef ENABLE_METAL
SDL_setenv("METAL_DEVICE_WRAPPER_TYPE", "1", 0);
#endif
engine = new prism::engine(argc, argv); engine = new prism::engine(argc, argv);
app = new @APP_CLASS@(); app = new @APP_CLASS@();
@ -306,7 +314,11 @@ int main(int argc, char* argv[]) {
GFXCreateInfo info = {}; GFXCreateInfo info = {};
#ifdef ENABLE_METAL
gfx_interface = new GFXMetal();
#else
gfx_interface = new GFXVulkan(); gfx_interface = new GFXVulkan();
#endif
if(gfx_interface->initialize(info)) { if(gfx_interface->initialize(info)) {
engine->set_gfx(gfx_interface); engine->set_gfx(gfx_interface);
} else { } else {