Fix up macOS build
This commit is contained in:
parent
54c95b9ddd
commit
9b507aa79a
7 changed files with 37 additions and 20 deletions
|
@ -100,6 +100,10 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
||||||
set(REQUIRED_SHADER_LANGUAGE "wgsl")
|
set(REQUIRED_SHADER_LANGUAGE "wgsl")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_VULKAN)
|
||||||
|
find_package(Vulkan REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NEEDS_HOSTED_SHADER_COMPILER AND (NOT DEFINED SHADER_COMPILER_LOCATION))
|
if(NEEDS_HOSTED_SHADER_COMPILER AND (NOT DEFINED SHADER_COMPILER_LOCATION))
|
||||||
message(FATAL_ERROR "You are building for a platform that needs a hosted shader compiler. Please specify the path in SHADER_COMPILER_LOCATION!")
|
message(FATAL_ERROR "You are building for a platform that needs a hosted shader compiler. Please specify the path in SHADER_COMPILER_LOCATION!")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -172,7 +172,11 @@ void GFXMetal::initialize_view(void* native_handle, const platform::window_ptr i
|
||||||
auto native = new NativeMTLView();
|
auto native = new NativeMTLView();
|
||||||
native->identifier = identifier;
|
native->identifier = identifier;
|
||||||
|
|
||||||
native->format = (MTL::PixelFormat)platform::initialize_metal_layer(identifier, device);
|
auto surface_creation_info = new metal_surface_creation_info();
|
||||||
|
surface_creation_info->device = device;
|
||||||
|
|
||||||
|
auto mtl_surface = (metal_surface*)platform::create_surface(identifier, surface_creation_info);
|
||||||
|
native->format = mtl_surface->format;
|
||||||
|
|
||||||
nativeViews.push_back(native);
|
nativeViews.push_back(native);
|
||||||
}
|
}
|
||||||
|
@ -715,8 +719,10 @@ void GFXMetal::submit(GFXCommandBuffer* command_buffer, const platform::window_p
|
||||||
NativeMTLView* native = getNativeView(window);
|
NativeMTLView* native = getNativeView(window);
|
||||||
|
|
||||||
CA::MetalDrawable* drawable = nullptr;
|
CA::MetalDrawable* drawable = nullptr;
|
||||||
if(native != nullptr)
|
if(native != nullptr) {
|
||||||
drawable = ((CA::MetalDrawable*)platform::get_next_drawable(window));
|
auto next_drawable = (metal_next_image*)platform::get_next_image(window);
|
||||||
|
drawable = next_drawable->next_drawable;
|
||||||
|
}
|
||||||
|
|
||||||
MTL::CommandBuffer* commandBuffer = command_queue->commandBuffer();
|
MTL::CommandBuffer* commandBuffer = command_queue->commandBuffer();
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ set(HEADERS
|
||||||
src/gfx_vulkan_renderpass.hpp
|
src/gfx_vulkan_renderpass.hpp
|
||||||
src/gfx_vulkan_commandbuffer.hpp)
|
src/gfx_vulkan_commandbuffer.hpp)
|
||||||
|
|
||||||
find_package(Vulkan REQUIRED)
|
|
||||||
|
|
||||||
add_library(GFXVulkan STATIC
|
add_library(GFXVulkan STATIC
|
||||||
src/gfx_vulkan.cpp
|
src/gfx_vulkan.cpp
|
||||||
${HEADERS})
|
${HEADERS})
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
if(ENABLE_VULKAN)
|
||||||
|
set(EXTRA_LIBRARIES Vulkan::Vulkan ${EXTRA_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_METAL)
|
||||||
|
set(EXTRA_LIBRARIES metal-cpp ${EXTRA_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(Platform INTERFACE)
|
add_library(Platform INTERFACE)
|
||||||
target_include_directories(Platform INTERFACE include)
|
target_include_directories(Platform INTERFACE include)
|
||||||
target_link_libraries(Platform INTERFACE Utility Log)
|
target_link_libraries(Platform INTERFACE Utility Log ${EXTRA_LIBRARIES})
|
|
@ -78,6 +78,7 @@ enum class PlatformTheme {
|
||||||
// this only determines it at build-time, not at runtime.
|
// this only determines it at build-time, not at runtime.
|
||||||
#ifdef ENABLE_VULKAN
|
#ifdef ENABLE_VULKAN
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct vulkan_information {
|
struct vulkan_information {
|
||||||
std::vector<const char*> surface_extensions;
|
std::vector<const char*> surface_extensions;
|
||||||
|
@ -99,10 +100,11 @@ struct directx_surface_creation_info {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_METAL
|
#ifdef ENABLE_METAL
|
||||||
#import <Metal/Metal.hpp>
|
#include <Metal/Metal.hpp>
|
||||||
|
#include <QuartzCore/CAMetalDrawable.hpp>
|
||||||
|
|
||||||
struct metal_surface_creation_info {
|
struct metal_surface_creation_info {
|
||||||
MTLDevice device;
|
MTL::Device* device;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct metal_surface {
|
struct metal_surface {
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
include(../../cmake/AddPlatformExecutable.cmake)
|
include(../../cmake/AddPlatformExecutable.cmake)
|
||||||
|
|
||||||
if(ENABLE_MACOS)
|
if(ENABLE_METAL)
|
||||||
find_library(METAL Metal)
|
find_library(METAL Metal)
|
||||||
|
|
||||||
set(EXTRA_LIBRARIES GFXMetal ${METAL})
|
set(EXTRA_LIBRARIES GFXMetal ${METAL} ${EXTRA_LIBRARIES})
|
||||||
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_metal.mm)
|
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_metal.mm ${EXTRA_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_VULKAN)
|
if(ENABLE_VULKAN)
|
||||||
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_vulkan.cpp)
|
set(EXTRA_LIBRARIES GFXVulkan ${EXTRA_LIBRARIES})
|
||||||
|
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_vulkan.cpp ${EXTRA_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET SDL2::SDL2)
|
if(TARGET SDL2::SDL2)
|
||||||
set(EXTRA_LIBRARIES SDL2::SDL2)
|
set(EXTRA_LIBRARIES SDL2::SDL2 ${EXTRA_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET SDL2::Main)
|
if(TARGET SDL2::Main)
|
||||||
set(EXTRA_LIBRARIES SDL2::Main)
|
set(EXTRA_LIBRARIES SDL2::Main ${EXTRA_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET SDL2::SDL2main)
|
if(TARGET SDL2::SDL2main)
|
||||||
set(EXTRA_LIBRARIES SDL2::SDL2main)
|
set(EXTRA_LIBRARIES SDL2::SDL2main ${EXTRA_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_platform(
|
add_platform(
|
||||||
|
@ -34,7 +35,6 @@ add_platform(
|
||||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
|
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
Core
|
Core
|
||||||
GFXVulkan
|
|
||||||
${EXTRA_LIBRARIES}
|
${EXTRA_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,16 @@ CAMetalLayer* get_layer(platform::window_ptr index) {
|
||||||
return (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderers[get_window(index)]);
|
return (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderers[get_window(index)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
metal_surface* create_metal_surface(platform::window_ptr window, void* surface_creation_info) {
|
void* create_metal_surface(platform::window_ptr window, void* surface_creation_info) {
|
||||||
auto layer = get_layer(index);
|
auto layer = get_layer(window);
|
||||||
|
|
||||||
auto layer = (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderers[get_window(window)]);
|
|
||||||
auto metal_surface_info = (metal_surface_creation_info*)surface_creation_info;
|
auto metal_surface_info = (metal_surface_creation_info*)surface_creation_info;
|
||||||
|
|
||||||
layer.device = (__bridge id<MTLDevice>)metal_surface_info->device;
|
layer.device = (__bridge id<MTLDevice>)metal_surface_info->device;
|
||||||
layer.allowsNextDrawableTimeout = true;
|
layer.allowsNextDrawableTimeout = true;
|
||||||
|
|
||||||
auto return_surface = new metal_surface();
|
auto return_surface = new metal_surface();
|
||||||
return_surface->format = layer.pixelFormat;
|
return_surface->format = static_cast<MTL::PixelFormat>(layer.pixelFormat);
|
||||||
|
|
||||||
return return_surface;
|
return return_surface;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue