Fix build on macOS for latest Vulkan SDK 1.2.176.1

This commit is contained in:
Stephen Saunders 2021-05-23 12:00:01 -04:00
parent 447d11b1ee
commit 2429e8bda0
2 changed files with 18 additions and 18 deletions

View file

@ -396,18 +396,23 @@ if(USE_VULKAN)
if(NOT Vulkan_FOUND)
message(FATAL_ERROR "Could not find Vulkan library!")
else()
# SRS - Optionally use MoltenVK headers/library for runtime config functions on OSX
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND USE_MoltenVK)
add_definitions(-DUSE_MoltenVK)
include_directories($ENV{VULKAN_SDK}/../MoltenVK/include)
set(Vulkan_LIBRARY $ENV{VULKAN_SDK}/lib/libMoltenVK.dylib)
add_definitions(-DUSE_VULKAN)
include_directories($ENV{VULKAN_SDK}/include)
# SRS - Locate this after Vulkan SDK include path, otherwise issues with precompiled headers
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# SRS - Enable Beta extensions for VULKAN_SDK portability subset features on OSX
add_definitions(-DVK_ENABLE_BETA_EXTENSIONS)
# SRS - Optionally use MoltenVK headers/library for runtime config functions on OSX
if(USE_MoltenVK)
add_definitions(-DUSE_MoltenVK)
include_directories($ENV{VULKAN_SDK}/../MoltenVK/include)
set(Vulkan_LIBRARY $ENV{VULKAN_SDK}/lib/libMoltenVK.dylib)
endif()
endif()
message(STATUS "Using Vulkan: " ${Vulkan_LIBRARY})
endif()
add_definitions(-DUSE_VULKAN)
include_directories($ENV{VULKAN_SDK}/include)
# Eric: For use with SDL2/Vulkan
if(UNIX)
find_package(X11_XCB)

View file

@ -74,14 +74,9 @@ static const char* g_instanceExtensions[ g_numInstanceExtensions ] =
};
#endif
// SRS - needed for MoltenVK portability implementation on OSX
#if defined(__APPLE__)
// required for VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME visibility (as of SDK 1.2.170.0)
#include <vulkan/vulkan_beta.h>
#if defined(USE_MoltenVK)
// optionally needed for runtime access to fullImageViewSwizzle (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1)
#include <MoltenVK/vk_mvk_moltenvk.h>
#endif
// SRS - optionally needed for runtime access to fullImageViewSwizzle (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1)
#if defined(__APPLE__) && defined(USE_MoltenVK)
#include <MoltenVK/vk_mvk_moltenvk.h>
#endif
static const int g_numDebugInstanceExtensions = 1;
@ -1508,7 +1503,7 @@ void idRenderBackend::Init()
// DG: make sure SDL has setup video so getting supported modes in R_SetNewMode() works
// SRS - Add OSX case
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
#if defined(__linux__) || defined(__APPLE__)
VKimp_PreInit();
#else
GLimp_PreInit();
@ -1704,7 +1699,7 @@ void idRenderBackend::Shutdown()
// destroy main window
// SRS - Add OSX case
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
#if defined(__linux__) || defined(__APPLE__)
VKimp_Shutdown();
#else
GLimp_Shutdown();