Split library into vulkan and opengl parts.

This has caused a lot of issues because when preloaded the vulkan hooks
will still initialize even tho it's an OpenGL application.
This will subsequently crash the application.
The solution is to split the vulkan and opengl parts into two separate
shared libraries.
pull/1077/head
FlightlessMango 9 months ago
parent 1182bcfbec
commit 602ba78ea3

@ -226,9 +226,11 @@ install() {
echo DEFAULTLIB: $DEFAULTLIB
/usr/bin/install -Dvm644 ./build/release/usr/lib/mangohud/lib64/libMangoHud.so /usr/lib/mangohud/lib64/libMangoHud.so
/usr/bin/install -Dvm644 ./build/release/usr/lib/mangohud/lib64/libMangoHud_dlsym.so /usr/lib/mangohud/lib64/libMangoHud_dlsym.so
/usr/bin/install -Dvm644 ./build/release/usr/lib/mangohud/lib64/libMangoHud_opengl.so /usr/lib/mangohud/lib64/libMangoHud_opengl.so
if [ "$MACHINE" = "x86_64" ]; then
/usr/bin/install -Dvm644 ./build/release/usr/lib/mangohud/lib32/libMangoHud.so /usr/lib/mangohud/lib32/libMangoHud.so
/usr/bin/install -Dvm644 ./build/release/usr/lib/mangohud/lib32/libMangoHud_dlsym.so /usr/lib/mangohud/lib32/libMangoHud_dlsym.so
/usr/bin/install -Dvm644 ./build/release/usr/lib/mangohud/lib32/libMangoHud_opengl.so /usr/lib/mangohud/lib32/libMangoHud_opengl.so
fi
/usr/bin/install -Dvm644 ./build/release/usr/share/vulkan/implicit_layer.d/MangoHud.x86_64.json /usr/share/vulkan/implicit_layer.d/MangoHud.x86_64.json

@ -109,21 +109,20 @@ void imgui_create(void *ctx, const gl_wsi plat)
imgui_shutdown();
imgui_init();
inited = true;
// if using vulkan skip OpenGL impl, fixes issues with ZINK and multiple games using DXVK
if (lib_loaded("libvulkan.so") && (sw_stats.engine == ZINK || sw_stats.engine == WINED3D)) {
SPDLOG_INFO("libvulkan is loaded, skipping OPENGL");
return;
}
if (!gladLoadGL())
spdlog::error("Failed to initialize OpenGL context, crash incoming");
deviceName = (char*)glGetString(GL_RENDERER);
// If we're running zink we want to rely on the vulkan loader for the hud instead.
if (deviceName.find("zink") != std::string::npos)
return;
GetOpenGLVersion(sw_stats.version_gl.major,
sw_stats.version_gl.minor,
sw_stats.version_gl.is_gles);
std::string vendor = (char*)glGetString(GL_VENDOR);
deviceName = (char*)glGetString(GL_RENDERER);
SPDLOG_DEBUG("vendor: {}, deviceName: {}", vendor, deviceName);
sw_stats.deviceName = deviceName;
if (vendor.find("AMD") != std::string::npos
@ -137,8 +136,6 @@ void imgui_create(void *ctx, const gl_wsi plat)
} else {
vendorID = 0x10de;
}
if (deviceName.find("zink") != std::string::npos)
sw_stats.engine = EngineTypes::ZINK;
uint32_t device_id = 0;
if (plat == gl_wsi::GL_WSI_GLX)

@ -41,7 +41,6 @@ vklayer_files = files(
'logging.cpp',
'config.cpp',
'gpu.cpp',
'vulkan.cpp',
'blacklist.cpp',
'file_utils.cpp',
'intel.cpp'
@ -148,10 +147,10 @@ link_args += '-Wl,--version-script,@0@'.format(join_paths(meson.current_source_d
mangohud_static_lib = static_library(
'MangoHud',
mangohud_version,
files('vulkan.cpp'),
util_files,
vk_enum_to_str,
vklayer_files,
opengl_files,
overlay_spv,
c_args : [
pre_args,
@ -189,6 +188,38 @@ mangohud_shared_lib = shared_library(
install: true
)
mangohud_opengl_shared_lib = shared_library(
'MangoHud_opengl',
mangohud_version,
opengl_files,
vklayer_files,
util_files,
c_args : [
pre_args,
vulkan_wsi_args
],
cpp_args : [
pre_args,
vulkan_wsi_args
],
dependencies : [
mangohud_version_dep,
vulkan_wsi_deps,
dearimgui_dep,
spdlog_dep,
dbus_dep,
dep_dl,
dep_rt,
dep_pthread,
dep_vulkan,
windows_deps,
json_dep],
include_directories : [inc_common],
link_args : link_args,
install_dir : libdir_mangohud,
install: true
)
if is_unixy
mangohud_dlsym = shared_library(
'MangoHud_dlsym',

@ -1859,9 +1859,6 @@ static VkResult overlay_CreateInstance(
else if(engineName == "mesa zink") {
engine = ZINK;
#if !defined(_WIN32)
MangoHud::GL::sw_stats.engine = ZINK;
#endif
}
else if (engineName == "Damavand")

Loading…
Cancel
Save