From d71eb2bf365d520cfa95d392c21bfa2411dd0f2b Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Thu, 29 Jul 2021 00:10:13 -0400 Subject: [PATCH] Disable X11_XCB dependencies for Linux and macOS --- neo/CMakeLists.txt | 24 ++++++++++++------------ neo/renderer/Vulkan/RenderBackend_VK.cpp | 6 +++--- neo/sys/posix/posix_public.h | 7 ++++--- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 4d23fee6..117a765d 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -424,18 +424,18 @@ if(USE_VULKAN) # Eric: For use with SDL2/Vulkan if(UNIX) - find_package(X11_XCB) - if(X11_XCB_FOUND) - add_definitions(-DHAVE_X11_XCB) - list(APPEND SUBSYSTEMS [X11]) - # SRS - Added PKG_ preface to X11_XCB_INCLUDE_DIRS for OSX, not sure about UNIX - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - include_directories(${PKG_X11_XCB_INCLUDE_DIRS}) - else() - include_directories(${X11_XCB_INCLUDE_DIRS}) - endif() - endif() - add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + # SRS - Do nothing here for Linux and OSX since SDL2 is used in place of platform-specific Vulkan + else() + find_package(X11_XCB) + if(X11_XCB_FOUND) + list(APPEND SUBSYSTEMS [X11]) + include_directories(${X11_XCB_INCLUDE_DIR}) + add_definitions(-DVK_USE_PLATFORM_XCB_KHR) + else() + message(FATAL_ERROR "Could not find XCB library!") + endif() + endif() elseif(WIN32) add_definitions(-DVK_USE_PLATFORM_WIN32_KHR) endif() diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index a95c710f..c377b6d4 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -435,7 +435,7 @@ CreateSurface static void CreateSurface() { -#ifdef _WIN32 +#if defined(VK_USE_PLATFORM_WIN32_KHR) // _WIN32 VkWin32SurfaceCreateInfoKHR createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; createInfo.hinstance = win32.hInstance; @@ -459,7 +459,7 @@ static void CreateSurface() { idLib::FatalError( "Error while creating Vulkan surface: %s", SDL_GetError() ); } -#else +#else // defined(VK_USE_PLATFORM_XCB_KHR) VkXcbSurfaceCreateInfoKHR createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; createInfo.pNext = NULL; @@ -468,7 +468,7 @@ static void CreateSurface() createInfo.window = info.window; ID_VK_CHECK( vkCreateXcbSurfaceKHR( vkcontext.instance, &createInfo, NULL, &vkcontext.surface ) ); -#endif // __linux__ +#endif // UNIX-style platforms #endif // _WIN32 diff --git a/neo/sys/posix/posix_public.h b/neo/sys/posix/posix_public.h index 7c7ba169..ce90c3a2 100644 --- a/neo/sys/posix/posix_public.h +++ b/neo/sys/posix/posix_public.h @@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms #include -#ifdef USE_VULKAN +// SRS - Not used on Linux/macOS since using SDL2 +#if defined(USE_VULKAN) && defined(VK_USE_PLATFORM_XCB_KHR) #include #endif @@ -74,8 +75,8 @@ enum /*clk_id_t*/ clockid_t { CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_R int clock_gettime( /*clk_id_t*/ clockid_t clock, struct timespec* tp ); // SRS - use APPLE clockid_t #endif -// Eric: Not used on Linux since using SDL2 -#if 0 //defined(USE_VULKAN) +// Eric: Not used on Linux/macOS since using SDL2 +#if defined(USE_VULKAN) && defined(VK_USE_PLATFORM_XCB_KHR) /* Struct that holds global xcb state for vulkan */ typedef struct _posixInfo {