[compat] HaikuOS port (#2805)

Still had the issues with libusb, but that should get solved with the other PRs anyways
Signed-off-by: lizzie <lizzie@eden-emu.dev>

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2805
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-10-22 04:53:40 +02:00 committed by crueter
parent 992bae4e2a
commit 87cacbeed4
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
28 changed files with 250 additions and 129 deletions

View file

@ -86,7 +86,15 @@ set(SHADER_FILES
dynamic_resolution_scale.comp
)
find_program(GLSLANGVALIDATOR "glslangValidator")
if (PLATFORM_HAIKU)
# glslangValidator WILL crash, glslang will not - why? Who the fuck knows
#/boot/home/glslang/build/StandAlone/glslangValidator
set(GLSLANGVALIDATOR "glslang")
else()
# Normal sane platform who doesn't have a CRASHING glslangValidator
find_program(GLSLANGVALIDATOR "glslangValidator")
endif()
if ("${GLSLANGVALIDATOR}" STREQUAL "GLSLANGVALIDATOR-NOTFOUND")
message(FATAL_ERROR "Required program `glslangValidator` not found.")
endif()

View file

@ -50,20 +50,24 @@ bool TestProgram(const GLchar* glsl) {
return link_status == GL_TRUE;
}
std::vector<std::string_view> GetExtensions() {
/// @brief Query OpenGL extensions
/// DO NOT use string_view, the driver can immediately free up the extension name and such
/// do NOT under ANY circumstances use string_view, make a copy, it's required
std::vector<std::string> GetExtensions() {
GLint num_extensions;
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
std::vector<std::string_view> extensions;
extensions.reserve(num_extensions);
std::vector<std::string> extensions;
for (GLint index = 0; index < num_extensions; ++index) {
extensions.push_back(
reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, static_cast<GLuint>(index))));
auto const* p = reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, GLuint(index)));
if (p != nullptr) // Fuck you? - sincerely, buggy mesa drivers
extensions.push_back(std::string{p});
}
return extensions;
}
bool HasExtension(std::span<const std::string_view> extensions, std::string_view extension) {
return std::ranges::find(extensions, extension) != extensions.end();
/// @brief Find extension in set of extensions (string)
bool HasExtension(std::span<const std::string> extensions, std::string_view extension) {
return std::ranges::find(extensions, std::string{extension}) != extensions.end();
}
std::array<u32, Shader::MaxStageTypes> BuildMaxUniformBuffers() noexcept {
@ -148,7 +152,7 @@ static bool HasSlowSoftwareAstc(std::string_view vendor_name, std::string_view r
return false;
}
[[nodiscard]] bool IsDebugToolAttached(std::span<const std::string_view> extensions) {
[[nodiscard]] bool IsDebugToolAttached(std::span<const std::string> extensions) {
const bool nsight = std::getenv("NVTX_INJECTION64_PATH") || std::getenv("NSIGHT_LAUNCHED");
return nsight || HasExtension(extensions, "GL_EXT_debug_tool") ||
Settings::values.renderer_debug.GetValue();
@ -160,10 +164,17 @@ Device::Device(Core::Frontend::EmuWindow& emu_window) {
LOG_ERROR(Render_OpenGL, "OpenGL 4.6 is not available");
throw std::runtime_error{"Insufficient version"};
}
#ifdef __HAIKU__
if (glad_glCreateProgramPipelines == nullptr) {
LOG_ERROR(Render_OpenGL, "You must compile Mesa +22 manually or use a different libGL.so (GLES is not supported)");
throw std::runtime_error{"Outdated mesa"};
}
#endif
vendor_name = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
const std::string_view version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
const std::string_view renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
const std::vector extensions = GetExtensions();
const std::string version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
const std::string renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
const std::vector<std::string> extensions = GetExtensions();
const bool is_nvidia = vendor_name == "NVIDIA Corporation";
const bool is_amd = vendor_name == "ATI Technologies Inc.";

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -10,6 +13,8 @@
#define VK_USE_PLATFORM_METAL_EXT
#elif defined(__ANDROID__)
#define VK_USE_PLATFORM_ANDROID_KHR
#elif defined(__HAIKU__)
#define VK_USE_PLATFORM_XCB_KHR
#else
#define VK_USE_PLATFORM_XLIB_KHR
#define VK_USE_PLATFORM_WAYLAND_KHR

View file

@ -59,6 +59,10 @@ namespace {
case Core::Frontend::WindowSystemType::Android:
extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
break;
#elif defined(__HAIKU__)
case Core::Frontend::WindowSystemType::Xcb:
extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
break;
#else
case Core::Frontend::WindowSystemType::X11:
extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -54,6 +57,23 @@ vk::SurfaceKHR CreateSurface(
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#elif defined(__HAIKU__)
if (window_info.type == Core::Frontend::WindowSystemType::Xcb) {
const VkXcbSurfaceCreateInfoKHR xcb_ci{
.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
.pNext = nullptr,
.flags = 0,
.connection = static_cast<xcb_connection_t*>(window_info.display_connection),
.window = xcb_window_t(uintptr_t(window_info.render_surface))
};
const auto vkCreateXcbSurfaceKHR = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>(
dld.vkGetInstanceProcAddr(*instance, "vkCreateXcbSurfaceKHR"));
if (!vkCreateXcbSurfaceKHR ||
vkCreateXcbSurfaceKHR(*instance, &xcb_ci, nullptr, &unsafe_surface) != VK_SUCCESS) {
LOG_ERROR(Render_Vulkan, "Failed to initialize Xcb surface");
throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED);
}
}
#else
if (window_info.type == Core::Frontend::WindowSystemType::X11) {
const VkXlibSurfaceCreateInfoKHR xlib_ci{