extra portability adjustments

This commit is contained in:
lizzie
2026-08-30 06:56:15 +00:00
parent 65471f4661
commit 11af553756
6 changed files with 41 additions and 28 deletions
+1 -5
View File
@@ -24,17 +24,13 @@ include(CTest)
include(CPMUtil)
if (CXX_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0")
message(FATAL_ERROR "You must use gcc14 (or newer) feel free to fix clang yourself otherwise.")
message(FATAL_ERROR "GCC versions older than 14.0 are not supported. Update your system, or use clang/clang++ instead.")
endif()
if (OPENBSD)
# OpenBSD 7.8 broke libcxx when upgrading, so we must define the PSTL backend manually
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LIBCPP_PSTL_BACKEND_SERIAL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_PSTL_BACKEND_SERIAL=1")
elseif (NETBSD)
if (NOT CXX_GCC OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0")
message(FATAL_ERROR "You must use gcc14 (or newer) from pkgin; feel free to fix clang yourself otherwise.")
endif()
endif()
# NetBSD: Fun for the whole family!
+13
View File
@@ -411,3 +411,16 @@ if (APPLE)
set(MOLTENVK_LIBRARY "${moltenvk_SOURCE_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib" CACHE STRING "" FORCE)
endif()
endif()
# We are NOT adding this to cpmfile.json
# In BSD world, it is often the case that X11
# will be under /usr/X11R{5,6,7}/include/...
# ...
# FreeBSD was able to see with hindsight this was a bad idea.
# OpenBSD, OmniOS and NetBSD by default, aren't illuminated yet by this notion.
#
# Reliance on X11 Headers being available without explicitly
# linking or mentioning X11 is something to note.
if (NOT (WIN32 OR APPLE OR ANDROID OR HAIKU OR PS4))
find_package(X11 REQUIRED)
endif()
+3 -7
View File
@@ -63,13 +63,9 @@ if (USE_DISCORD_PRESENCE)
endif()
# Qt itself may use Vulkan stuffs so we'd need to account for that as well
# must match src/video_core/vulkan_common/vulkan.h logic
if (WIN32 OR APPLE OR ANDROID OR PLATFORM_HAIKU OR PLATFORM_PS4)
# ...
else()
find_package(X11 REQUIRED)
target_include_directories(video_core PUBLIC ${X11_INCLUDE_DIR})
target_link_libraries(video_core PUBLIC ${X11_LIBRARIES})
if (X11_FOUND)
target_include_directories(qt_common PUBLIC ${X11_INCLUDE_DIR})
target_link_libraries(qt_common PUBLIC ${X11_LIBRARIES})
endif()
# TODO(crueter)
+1 -5
View File
@@ -358,11 +358,7 @@ if (ENABLE_OPENGL)
)
endif()
# Must match src/video_core/vulkan_common/vulkan.h X11 logic
if (WIN32 OR APPLE OR ANDROID OR PLATFORM_HAIKU OR PLATFORM_PS4)
# ...
else()
find_package(X11 REQUIRED)
if (X11_FOUND)
target_include_directories(video_core PUBLIC ${X11_INCLUDE_DIR})
target_link_libraries(video_core PUBLIC ${X11_LIBRARIES})
endif()
@@ -43,26 +43,32 @@ namespace {
switch (window_type) {
case Core::Frontend::WindowSystemType::Headless:
break;
#ifdef _WIN32
#if defined(VK_USE_PLATFORM_WIN32_KHR)
case Core::Frontend::WindowSystemType::Windows:
extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
break;
#elif defined(__APPLE__)
#endif
#if defined(VK_USE_PLATFORM_METAL_EXT)
case Core::Frontend::WindowSystemType::Cocoa:
extensions.push_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME);
break;
#elif defined(__ANDROID__)
#endif
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
case Core::Frontend::WindowSystemType::Android:
extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
break;
#elif defined(__HAIKU__)
#endif
#if defined(VK_USE_PLATFORM_XCB_KHR)
case Core::Frontend::WindowSystemType::Xcb:
extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
break;
#else
#endif
#if defined(VK_USE_PLATFORM_XLIB_KHR)
case Core::Frontend::WindowSystemType::X11:
extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
break;
#endif
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
case Core::Frontend::WindowSystemType::Wayland:
extensions.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
break;
@@ -8,6 +8,7 @@
#include "core/frontend/emu_window.h"
#include "video_core/vulkan_common/vulkan_surface.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
#include "video_core/vulkan_common/vulkan.h"
namespace Vulkan {
@@ -17,7 +18,7 @@ vk::SurfaceKHR CreateSurface(
[[maybe_unused]] const vk::InstanceDispatch& dld = instance.Dispatch();
VkSurfaceKHR unsafe_surface = VkSurfaceKHR{};
#ifdef _WIN32
#if defined(VK_USE_PLATFORM_WIN32_KHR)
if (window_info.type == Core::Frontend::WindowSystemType::Windows) {
const HWND hWnd = static_cast<HWND>(window_info.render_surface);
const VkWin32SurfaceCreateInfoKHR win32_ci{VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
@@ -30,7 +31,8 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#elif defined(__APPLE__)
#endif
#if defined(VK_USE_PLATFORM_METAL_EXT)
if (window_info.type == Core::Frontend::WindowSystemType::Cocoa) {
const VkMetalSurfaceCreateInfoEXT metal_ci = {
.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT,
@@ -45,7 +47,8 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#elif defined(__ANDROID__)
#endif
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
if (window_info.type == Core::Frontend::WindowSystemType::Android) {
const VkAndroidSurfaceCreateInfoKHR android_ci{
VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, nullptr, 0,
@@ -59,7 +62,8 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#elif defined(__HAIKU__)
#endif
#if defined(VK_USE_PLATFORM_XCB_KHR)
if (window_info.type == Core::Frontend::WindowSystemType::Xcb) {
const VkXcbSurfaceCreateInfoKHR xcb_ci{
.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
@@ -76,7 +80,8 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#else
#endif
#if defined(VK_USE_PLATFORM_XLIB_KHR)
if (window_info.type == Core::Frontend::WindowSystemType::X11) {
const VkXlibSurfaceCreateInfoKHR xlib_ci{
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, nullptr, 0,
@@ -90,6 +95,8 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#endif
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
if (window_info.type == Core::Frontend::WindowSystemType::Wayland) {
const VkWaylandSurfaceCreateInfoKHR wayland_ci{
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, nullptr, 0,
@@ -105,7 +112,6 @@ vk::SurfaceKHR CreateSurface(
}
}
#endif
if (!unsafe_surface) {
LOG_ERROR(Render_Vulkan, "Presentation not supported on this platform");
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);