[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

@ -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.";