From 2429e8bda0913db1ed7acae9be17ff7a6ff02c4d Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Sun, 23 May 2021 12:00:01 -0400 Subject: [PATCH 1/4] Fix build on macOS for latest Vulkan SDK 1.2.176.1 --- neo/CMakeLists.txt | 21 +++++++++++++-------- neo/renderer/Vulkan/RenderBackend_VK.cpp | 15 +++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index b9fce3b8..98edc2b5 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -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) diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index f9b5ddc4..cd9538d5 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -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 - #if defined(USE_MoltenVK) - // optionally needed for runtime access to fullImageViewSwizzle (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1) - #include - #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 #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(); From ea8096d949c9af3e8cc6a9b437cc510de2f50f80 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 25 May 2021 01:04:23 -0400 Subject: [PATCH 2/4] Remove erroneous comment from CMakeLists --- neo/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 98edc2b5..8dbb10e9 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -399,7 +399,6 @@ if(USE_VULKAN) 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) From 2068e92d92c344c1111a8ba257be5a9ce5a29059 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 25 May 2021 13:33:28 -0400 Subject: [PATCH 3/4] Use default VULKAN_SDK location on macOS; disable broken ZERO_CHECK for Xcode Vulkan builds --- neo/CMakeLists.txt | 10 ++++++++++ neo/cmake-xcode-vulkan-debug.sh | 2 +- neo/cmake-xcode-vulkan-release.sh | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 8dbb10e9..5be74cd4 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -350,6 +350,16 @@ if(USE_VULKAN) # RB: moved this above the general Vulkan part so glslang does not include Vulkan SDK headers # which causes all kinds of weird segmentation faults because struct sizes don't match + + # SRS - Set default VULKAN_SDK location if environment variable not defined on OSX + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT DEFINED ENV{VULKAN_SDK}) + if(NOT USE_MoltenVK) + # SRS - Vulkan SDK installer copies standard vulkan headers and libs to /usr/local on OSX + set(ENV{VULKAN_SDK} /usr/local) + else() + message(FATAL_ERROR "Must define VULKAN_SDK location if USE_MoltenVK option enabled!") + endif() + endif() if(SPIRV_SHADERC) add_definitions(-DSPIRV_SHADERC) diff --git a/neo/cmake-xcode-vulkan-debug.sh b/neo/cmake-xcode-vulkan-debug.sh index dc00933c..9ea2307b 100755 --- a/neo/cmake-xcode-vulkan-debug.sh +++ b/neo/cmake-xcode-vulkan-debug.sh @@ -2,4 +2,4 @@ cd .. rm -rf xcode-vulkan-debug mkdir xcode-vulkan-debug cd xcode-vulkan-debug -cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev +cmake -G Xcode -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-xcode-vulkan-release.sh b/neo/cmake-xcode-vulkan-release.sh index 907a6880..80937a7c 100755 --- a/neo/cmake-xcode-vulkan-release.sh +++ b/neo/cmake-xcode-vulkan-release.sh @@ -2,4 +2,4 @@ cd .. rm -rf xcode-vulkan-release mkdir xcode-vulkan-release cd xcode-vulkan-release -cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev +cmake -G Xcode -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev From baedc98b6dd2db024bbd9b128b0d5ccd2521366d Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Thu, 27 May 2021 23:41:05 -0400 Subject: [PATCH 4/4] Update cmake shell scripts for macOS with improved Xcode integration --- neo/cmake-macos-opengl-debug.sh | 2 +- neo/cmake-macos-opengl-release.sh | 2 +- neo/cmake-macos-opengl-retail.sh | 2 +- neo/cmake-xcode-opengl-debug.sh | 2 +- neo/cmake-xcode-opengl-release.sh | 2 +- neo/cmake-xcode-vulkan-debug.sh | 2 +- neo/cmake-xcode-vulkan-release.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/neo/cmake-macos-opengl-debug.sh b/neo/cmake-macos-opengl-debug.sh index 26bf73f1..4285d97f 100755 --- a/neo/cmake-macos-opengl-debug.sh +++ b/neo/cmake-macos-opengl-debug.sh @@ -2,4 +2,4 @@ cd .. rm -rf build mkdir build cd build -cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-macos-opengl-release.sh b/neo/cmake-macos-opengl-release.sh index 764ed5f7..fe681817 100755 --- a/neo/cmake-macos-opengl-release.sh +++ b/neo/cmake-macos-opengl-release.sh @@ -2,4 +2,4 @@ cd .. rm -rf build mkdir build cd build -cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-macos-opengl-retail.sh b/neo/cmake-macos-opengl-retail.sh index 7e52521e..31bfa269 100755 --- a/neo/cmake-macos-opengl-retail.sh +++ b/neo/cmake-macos-opengl-retail.sh @@ -2,4 +2,4 @@ cd .. rm -rf build mkdir build cd build -cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-xcode-opengl-debug.sh b/neo/cmake-xcode-opengl-debug.sh index 247a3d61..fa5e1453 100755 --- a/neo/cmake-xcode-opengl-debug.sh +++ b/neo/cmake-xcode-opengl-debug.sh @@ -2,4 +2,4 @@ cd .. rm -rf xcode-opengl-debug mkdir xcode-opengl-debug cd xcode-opengl-debug -cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo +cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-xcode-opengl-release.sh b/neo/cmake-xcode-opengl-release.sh index fa3fdc1f..c095d89f 100755 --- a/neo/cmake-xcode-opengl-release.sh +++ b/neo/cmake-xcode-opengl-release.sh @@ -2,4 +2,4 @@ cd .. rm -rf xcode-opengl-release mkdir xcode-opengl-release cd xcode-opengl-release -cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo +cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-xcode-vulkan-debug.sh b/neo/cmake-xcode-vulkan-debug.sh index 9ea2307b..93b7a847 100755 --- a/neo/cmake-xcode-vulkan-debug.sh +++ b/neo/cmake-xcode-vulkan-debug.sh @@ -2,4 +2,4 @@ cd .. rm -rf xcode-vulkan-debug mkdir xcode-vulkan-debug cd xcode-vulkan-debug -cmake -G Xcode -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev +cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENVIRONMENT="MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1" -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev diff --git a/neo/cmake-xcode-vulkan-release.sh b/neo/cmake-xcode-vulkan-release.sh index 80937a7c..b825d56d 100755 --- a/neo/cmake-xcode-vulkan-release.sh +++ b/neo/cmake-xcode-vulkan-release.sh @@ -2,4 +2,4 @@ cd .. rm -rf xcode-vulkan-release mkdir xcode-vulkan-release cd xcode-vulkan-release -cmake -G Xcode -DCMAKE_SUPPRESS_REGENERATION=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev +cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 -DSDL2=ON -DUSE_VULKAN=ON -DSPIRV_SHADERC=OFF -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev