Better MacOS support

This commit is contained in:
David Gonzalez Martin 2024-12-04 20:59:12 -06:00 committed by David
parent 6fe7e382e9
commit b30a2d0c52
4 changed files with 26 additions and 11 deletions

View File

@ -49,7 +49,7 @@ add_compile_options(
-fdiagnostics-color=always -fdiagnostics-color=always
-fansi-escape-codes -fansi-escape-codes
-ferror-limit=1 -ferror-limit=1
-march=native # -march=native
${BB_IS_CI_C_FLAG} -DCOMPILER_NAME=\"${COMPILER_NAME}\" -DBUILD_DIR=\"${CMAKE_BINARY_DIR}\" -DBB_DIR=\"${BB_DIR}\" ${SHADER_COMPILATION_USE_SOURCE_C_FLAG} ${BB_IS_CI_C_FLAG} -DCOMPILER_NAME=\"${COMPILER_NAME}\" -DBUILD_DIR=\"${CMAKE_BINARY_DIR}\" -DBB_DIR=\"${BB_DIR}\" ${SHADER_COMPILATION_USE_SOURCE_C_FLAG}
) )
include_directories("bootstrap/include") include_directories("bootstrap/include")
@ -213,10 +213,19 @@ if (NOT BB_IS_CI)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XLIB_KHR) set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XLIB_KHR)
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_X11) target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_X11)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_MACOS_MVK) set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_METAL_EXT)
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_COCOA) target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_COCOA)
endif() endif()
if (APPLE)
execute_process(
COMMAND brew --prefix vulkan-headers
OUTPUT_VARIABLE VULKAN_HEADERS_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
include_directories("${VULKAN_HEADERS_PREFIX}/include")
endif()
add_subdirectory(dependencies/volk-1.3.301 volk) add_subdirectory(dependencies/volk-1.3.301 volk)
target_link_libraries(${COMPILER_NAME} PRIVATE volk) target_link_libraries(${COMPILER_NAME} PRIVATE volk)
target_sources(${COMPILER_NAME} PRIVATE target_sources(${COMPILER_NAME} PRIVATE

View File

@ -146,6 +146,8 @@ void run_app()
strlit("C:/Users/David/Downloads/Fira_Sans/FiraSans-Regular.ttf"); strlit("C:/Users/David/Downloads/Fira_Sans/FiraSans-Regular.ttf");
#elif defined(__linux__) #elif defined(__linux__)
strlit("/usr/share/fonts/TTF/FiraSans-Regular.ttf"); strlit("/usr/share/fonts/TTF/FiraSans-Regular.ttf");
#elif defined(__APPLE__)
strlit("/Users/david/Library/Fonts/FiraSans-Regular.ttf");
#else #else
strlit("WRONG_PATH"); strlit("WRONG_PATH");
#endif #endif

View File

@ -840,12 +840,12 @@ Renderer* renderer_initialize(Arena* arena)
#ifdef VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR
VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
#endif #endif
#ifdef VK_USE_PLATFORM_MACOS_MVK #ifdef VK_USE_PLATFORM_METAL_EXT
VK_KHR_COCOA_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME,
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME,
#endif #endif
}; };
#if BB_DEBUG #if BB_DEBUG
VkValidationFeatureEnableEXT enabled_validation_features[] = VkValidationFeatureEnableEXT enabled_validation_features[] =
{ {
@ -855,7 +855,6 @@ Renderer* renderer_initialize(Arena* arena)
VkDebugUtilsMessengerCreateInfoEXT msg_ci = { VkDebugUtilsMessengerCreateInfoEXT msg_ci = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
.pNext = 0, .pNext = 0,
.flags = 0,
.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT, .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT,
.pfnUserCallback = debug_callback, .pfnUserCallback = debug_callback,
@ -884,12 +883,17 @@ Renderer* renderer_initialize(Arena* arena)
}; };
VkInstanceCreateInfo ci = { VkInstanceCreateInfo ci = {
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.pNext = pNext,
#if __APPLE__
.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR,
#else
.flags = 0,
#endif
.pApplicationInfo = &app_info, .pApplicationInfo = &app_info,
.ppEnabledLayerNames = layers, .ppEnabledLayerNames = layers,
.enabledLayerCount = layer_count, .enabledLayerCount = layer_count,
.ppEnabledExtensionNames = extensions, .ppEnabledExtensionNames = extensions,
.enabledExtensionCount = array_length(extensions), .enabledExtensionCount = array_length(extensions),
.pNext = pNext,
}; };
vkok(vkCreateInstance(&ci, renderer->allocator, &renderer->instance)); vkok(vkCreateInstance(&ci, renderer->allocator, &renderer->instance));
@ -1080,6 +1084,7 @@ Renderer* renderer_initialize(Arena* arena)
strlit("bootstrap/shaders/font.vert"), strlit("bootstrap/shaders/font.vert"),
strlit("bootstrap/shaders/font.frag"), strlit("bootstrap/shaders/font.frag"),
}; };
PipelineLayoutCreate pipeline_layouts[] = { PipelineLayoutCreate pipeline_layouts[] = {
(PipelineLayoutCreate) { (PipelineLayoutCreate) {
.push_constant_ranges = array_to_slice(((PushConstantRange[]){ .push_constant_ranges = array_to_slice(((PushConstantRange[]){

View File

@ -23,10 +23,9 @@ if [[ -z "${BIRTH_OS-}" ]]; then
fi fi
if [[ "$BIRTH_OS" == "macos" ]]; then if [[ "$BIRTH_OS" == "macos" ]]; then
MY_HOMEBREW_PREFIX=$(brew --prefix llvm) VK_LOADER_PREFIX=$(brew --prefix vulkan-loader)
C_COMPILER_PATH=$MY_HOMEBREW_PREFIX/bin/clang VK_VALIDATION_PREFIX=$(brew --prefix vulkan-validationlayers)
CXX_COMPILER_PATH=$MY_HOMEBREW_PREFIX/bin/clang++ export DYLD_LIBRARY_PATH=$VK_LOADER_PREFIX/lib:$VK_VALIDATION_PREFIX/lib
ASM_COMPILER_PATH=$MY_HOMEBREW_PREFIX/bin/clang
fi fi
if [[ -z "${BIRTH_ARCH-}" ]]; then if [[ -z "${BIRTH_ARCH-}" ]]; then