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
-fansi-escape-codes
-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}
)
include_directories("bootstrap/include")
@ -213,10 +213,19 @@ if (NOT BB_IS_CI)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XLIB_KHR)
target_compile_definitions(${COMPILER_NAME} PRIVATE GLFW_EXPOSE_NATIVE_X11)
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)
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)
target_link_libraries(${COMPILER_NAME} PRIVATE volk)
target_sources(${COMPILER_NAME} PRIVATE

View File

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

View File

@ -840,12 +840,12 @@ Renderer* renderer_initialize(Arena* arena)
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
VK_KHR_COCOA_SURFACE_EXTENSION_NAME,
#ifdef VK_USE_PLATFORM_METAL_EXT
VK_EXT_METAL_SURFACE_EXTENSION_NAME,
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME,
#endif
};
#if BB_DEBUG
VkValidationFeatureEnableEXT enabled_validation_features[] =
{
@ -855,7 +855,6 @@ Renderer* renderer_initialize(Arena* arena)
VkDebugUtilsMessengerCreateInfoEXT msg_ci = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
.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,
.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,
@ -884,12 +883,17 @@ Renderer* renderer_initialize(Arena* arena)
};
VkInstanceCreateInfo ci = {
.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,
.ppEnabledLayerNames = layers,
.enabledLayerCount = layer_count,
.ppEnabledExtensionNames = extensions,
.enabledExtensionCount = array_length(extensions),
.pNext = pNext,
};
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.frag"),
};
PipelineLayoutCreate pipeline_layouts[] = {
(PipelineLayoutCreate) {
.push_constant_ranges = array_to_slice(((PushConstantRange[]){

View File

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