Merge 1a719e9d23593daaa56f112e97f522f7150ff9ec into 6aa728b12a8f6750ac2115635fd070621137d675

This commit is contained in:
Tristan Ross 2025-09-22 09:54:01 +02:00 committed by GitHub
commit 9db27dd67b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 63 additions and 1 deletions

View File

@ -264,12 +264,15 @@ option(Launcher_ENABLE_JAVA_DOWNLOADER "Build the java downloader feature" ${Lau
if(UNIX AND APPLE)
set(Launcher_GLFW_LIBRARY_NAME "libglfw.dylib" CACHE STRING "Name of native glfw library")
set(Launcher_OPENAL_LIBRARY_NAME "libopenal.dylib" CACHE STRING "Name of native openal library")
set(Launcher_JEMALLOC_LIBRARY_NAME "libjemalloc.dylib" CACHE STRING "Name of native jemalloc library")
elseif(UNIX)
set(Launcher_GLFW_LIBRARY_NAME "libglfw.so" CACHE STRING "Name of native glfw library")
set(Launcher_OPENAL_LIBRARY_NAME "libopenal.so" CACHE STRING "Name of native openal library")
set(Launcher_JEMALLOC_LIBRARY_NAME "libjemalloc.so" CACHE STRING "Name of native jemalloc library")
elseif(WIN32)
set(Launcher_GLFW_LIBRARY_NAME "glfw.dll" CACHE STRING "Name of native glfw library")
set(Launcher_OPENAL_LIBRARY_NAME "OpenAL.dll" CACHE STRING "Name of native openal library")
set(Launcher_JEMALLOC_LIBRARY_NAME "jemalloc.dll" CACHE STRING "Name of native jemalloc library")
endif()
# API Keys

View File

@ -116,6 +116,7 @@ Config::Config()
GLFW_LIBRARY_NAME = "@Launcher_GLFW_LIBRARY_NAME@";
OPENAL_LIBRARY_NAME = "@Launcher_OPENAL_LIBRARY_NAME@";
JEMALLOC_LIBRARY_NAME = "@Launcher_JEMALLOC_LIBRARY_NAME@";
BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@";
TRANSLATIONS_URL = "@Launcher_TRANSLATIONS_URL@";

View File

@ -159,6 +159,7 @@ class Config {
QString GLFW_LIBRARY_NAME;
QString OPENAL_LIBRARY_NAME;
QString JEMALLOC_LIBRARY_NAME;
QString BUG_TRACKER_URL;
QString TRANSLATIONS_URL;

View File

@ -763,6 +763,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_settings->registerSetting("CustomOpenALPath", "");
m_settings->registerSetting("UseNativeGLFW", false);
m_settings->registerSetting("CustomGLFWPath", "");
m_settings->registerSetting("UseNativeJemalloc", false);
m_settings->registerSetting("CustomJemallocPath", "");
// Performance related options
m_settings->registerSetting("EnableFeralGamemode", false);
@ -1863,7 +1865,8 @@ void Application::detectLibraries()
#ifdef Q_OS_LINUX
m_detectedGLFWPath = MangoHud::findLibrary(BuildConfig.GLFW_LIBRARY_NAME);
m_detectedOpenALPath = MangoHud::findLibrary(BuildConfig.OPENAL_LIBRARY_NAME);
qDebug() << "Detected native libraries:" << m_detectedGLFWPath << m_detectedOpenALPath;
m_detectedJemallocPath = MangoHud::findLibrary(BuildConfig.JEMALLOC_LIBRARY_NAME);
qDebug() << "Detected native libraries:" << m_detectedGLFWPath << m_detectedOpenALPath << m_detectedJemallocPath;
#endif
}

View File

@ -303,6 +303,7 @@ class Application : public QApplication {
public:
QString m_detectedGLFWPath;
QString m_detectedOpenALPath;
QString m_detectedJemallocPath;
QString m_instanceIdToLaunch;
QString m_serverToJoin;
QString m_worldToJoin;

View File

@ -210,6 +210,8 @@ void MinecraftInstance::loadSpecificSettings()
m_settings->registerOverride(global_settings->getSetting("CustomOpenALPath"), nativeLibraryWorkaroundsOverride);
m_settings->registerOverride(global_settings->getSetting("UseNativeGLFW"), nativeLibraryWorkaroundsOverride);
m_settings->registerOverride(global_settings->getSetting("CustomGLFWPath"), nativeLibraryWorkaroundsOverride);
m_settings->registerOverride(global_settings->getSetting("UseNativeJemalloc"), nativeLibraryWorkaroundsOverride);
m_settings->registerOverride(global_settings->getSetting("CustomJemallocPath"), nativeLibraryWorkaroundsOverride);
// Performance related options
auto performanceOverride = m_settings->registerSetting("OverridePerformance", false);
@ -507,6 +509,7 @@ QStringList MinecraftInstance::extraArguments()
{
QString openALPath;
QString glfwPath;
QString jemallocPath;
if (settings()->get("UseNativeOpenAL").toBool()) {
openALPath = APPLICATION->m_detectedOpenALPath;
@ -520,14 +523,23 @@ QStringList MinecraftInstance::extraArguments()
if (!customPath.isEmpty())
glfwPath = customPath;
}
if (settings()->get("UseNativeJemalloc").toBool()) {
jemallocPath = APPLICATION->m_detectedJemallocPath;
auto customPath = settings()->get("CustomJemallocPath").toString();
if (!customPath.isEmpty())
jemallocPath = customPath;
}
QFileInfo openALInfo(openALPath);
QFileInfo glfwInfo(glfwPath);
QFileInfo jemallocInfo(jemallocPath);
if (!openALPath.isEmpty() && openALInfo.exists())
list.append("-Dorg.lwjgl.openal.libname=" + openALInfo.absoluteFilePath());
if (!glfwPath.isEmpty() && glfwInfo.exists())
list.append("-Dorg.lwjgl.glfw.libname=" + glfwInfo.absoluteFilePath());
if (!jemallocPath.isEmpty() && jemallocInfo.exists())
list.append("-Dorg.lwjgl.jemalloc.libname=" + jemallocInfo.absoluteFilePath());
}
return list;
@ -903,11 +915,14 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
auto settings = this->settings();
bool nativeOpenAL = settings->get("UseNativeOpenAL").toBool();
bool nativeGLFW = settings->get("UseNativeGLFW").toBool();
bool nativeJemalloc = settings->get("UseNativeJemalloc").toBool();
if (nativeOpenAL || nativeGLFW) {
if (nativeOpenAL)
out << "Using system OpenAL.";
if (nativeGLFW)
out << "Using system GLFW.";
if (nativeJemalloc)
out << "Using system Jemalloc.";
out << "";
}

View File

@ -143,6 +143,7 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(MinecraftInstancePtr instance,
connect(m_ui->useNativeOpenALCheck, &QAbstractButton::toggled, m_ui->lineEditOpenALPath, &QWidget::setEnabled);
connect(m_ui->useNativeGLFWCheck, &QAbstractButton::toggled, m_ui->lineEditGLFWPath, &QWidget::setEnabled);
connect(m_ui->useNativeJemallocCheck, &QAbstractButton::toggled, m_ui->lineEditJemallocPath, &QWidget::setEnabled);
loadSettings();
}
@ -215,6 +216,13 @@ void MinecraftSettingsWidget::loadSettings()
#else
m_ui->lineEditOpenALPath->setPlaceholderText(tr("Path to %1 library file").arg(BuildConfig.OPENAL_LIBRARY_NAME));
#endif
m_ui->useNativeJemallocCheck->setChecked(settings->get("UseNativeJemalloc").toBool());
m_ui->lineEditJemallocPath->setText(settings->get("CustomJemallocPath").toString());
#ifdef Q_OS_LINUX
m_ui->lineEditJemallocPath->setPlaceholderText(APPLICATION->m_detectedJemallocPath);
#else
m_ui->lineEditJemallocPath->setPlaceholderText(tr("Path to %1 library file").arg(BuildConfig.JEMALLOC_LIBRARY_NAME));
#endif
// Performance
m_ui->perfomanceGroupBox->setChecked(m_instance == nullptr || settings->get("OverridePerformance").toBool());
@ -383,11 +391,15 @@ void MinecraftSettingsWidget::saveSettings()
settings->set("CustomGLFWPath", m_ui->lineEditGLFWPath->text());
settings->set("UseNativeOpenAL", m_ui->useNativeOpenALCheck->isChecked());
settings->set("CustomOpenALPath", m_ui->lineEditOpenALPath->text());
settings->set("UseNativeJemalloc", m_ui->useNativeJemallocCheck->isChecked());
settings->set("CustomJemallocPath", m_ui->lineEditJemallocPath->text());
} else {
settings->reset("UseNativeGLFW");
settings->reset("CustomGLFWPath");
settings->reset("UseNativeOpenAL");
settings->reset("CustomOpenALPath");
settings->reset("UseNativeJemalloc");
settings->reset("CustomJemallocPath");
}
// Performance

View File

@ -661,6 +661,16 @@ It is most likely you will need to change the path - please refer to the mod's w
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelJemallocPath">
<property name="text">
<string>&amp;Jemalloc library path:</string>
</property>
<property name="buddy">
<cstring>lineEditJemallocPath</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditGLFWPath">
<property name="enabled">
@ -689,6 +699,20 @@ It is most likely you will need to change the path - please refer to the mod's w
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="useNativeJemallocCheck">
<property name="text">
<string>Use system installation of Jemalloc</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditJemallocPath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -28,6 +28,7 @@
udev,
vulkan-loader,
xrandr,
jemalloc,
additionalLibs ? [ ],
additionalPrograms ? [ ],
@ -80,6 +81,7 @@ symlinkJoin {
## native versions
glfw3-minecraft
openal
jemalloc
## openal
alsa-lib