Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,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
Expand Down
1 change: 1 addition & 0 deletions buildconfig/BuildConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Config {

QString GLFW_LIBRARY_NAME;
QString OPENAL_LIBRARY_NAME;
QString JEMALLOC_LIBRARY_NAME;

QString BUG_TRACKER_URL;
QString TRANSLATIONS_URL;
Expand Down
5 changes: 4 additions & 1 deletion launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,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);
Expand Down Expand Up @@ -1926,7 +1928,8 @@ void Application::detectLibraries()
#ifdef Q_OS_LINUX
m_detectedGLFWPath = LibraryUtils::find(BuildConfig.GLFW_LIBRARY_NAME);
m_detectedOpenALPath = LibraryUtils::find(BuildConfig.OPENAL_LIBRARY_NAME);
qDebug() << "Detected native libraries:" << m_detectedGLFWPath << m_detectedOpenALPath;
m_detectedJemallocPath = LibraryUtils::find(BuildConfig.JEMALLOC_LIBRARY_NAME);
qDebug() << "Detected native libraries:" << m_detectedGLFWPath << m_detectedOpenALPath << m_detectedJemallocPath;
#endif
}

Expand Down
1 change: 1 addition & 0 deletions launcher/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class Application : public QApplication {
public:
QString m_detectedGLFWPath;
QString m_detectedOpenALPath;
QString m_detectedJemallocPath;
QString m_instanceIdToLaunch;
QString m_serverToJoin;
QString m_worldToJoin;
Expand Down
20 changes: 19 additions & 1 deletion launcher/minecraft/MinecraftInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,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);
Expand Down Expand Up @@ -564,6 +566,7 @@ QStringList MinecraftInstance::extraArguments(AuthSessionPtr session)
{
QString openALPath;
QString glfwPath;
QString jemallocPath;

if (settings()->get("UseNativeOpenAL").toBool()) {
openALPath = APPLICATION->m_detectedOpenALPath;
Expand All @@ -587,6 +590,18 @@ QStringList MinecraftInstance::extraArguments(AuthSessionPtr session)
if (!glfwPath.isEmpty() && glfwInfo.exists())
list.append("-Dorg.lwjgl.glfw.libname=" + glfwInfo.absoluteFilePath());
}

if (settings()->get("UseNativeJemalloc").toBool()) {
jemallocPath = APPLICATION->m_detectedJemallocPath;
auto customPath = settings()->get("CustomJemallocPath").toString();
if (!customPath.isEmpty())
jemallocPath = customPath;

QFileInfo jemallocInfo(jemallocPath);

if (!jemallocPath.isEmpty() && jemallocInfo.exists())
list.append("-Dorg.lwjgl.system.jemalloc.libname=" + jemallocInfo.absoluteFilePath());
}
}

return list;
Expand Down Expand Up @@ -990,11 +1005,14 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
auto settings = this->settings();
bool nativeOpenAL = settings->get("UseNativeOpenAL").toBool();
bool nativeGLFW = settings->get("UseNativeGLFW").toBool();
if (nativeOpenAL || nativeGLFW) {
bool nativeJemalloc = settings->get("UseNativeJemalloc").toBool();
if (nativeOpenAL || nativeGLFW || nativeJemalloc) {
if (nativeOpenAL)
out << "Using system OpenAL.";
if (nativeGLFW)
out << "Using system GLFW.";
if (nativeJemalloc)
out << "Using system Jemalloc.";
out << emptyLine;
}

Expand Down
16 changes: 15 additions & 1 deletion launcher/ui/widgets/MinecraftSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(MinecraftInstance* instance, QW

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);


connect(m_ui->injectorImplCombo, &QComboBox::currentIndexChanged, this, [this] { resetInjectorVersion(); });

Expand Down Expand Up @@ -240,6 +242,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());
Expand Down Expand Up @@ -440,19 +449,24 @@ void MinecraftSettingsWidget::saveSettings()
// Workarounds
bool workarounds = m_instance == nullptr || m_ui->nativeWorkaroundsGroupBox->isChecked();

if (m_instance != nullptr)
if (m_instance != nullptr) {
settings->set("OverrideNativeWorkarounds", workarounds);
}

if (workarounds) {
settings->set("UseNativeGLFW", m_ui->useNativeGLFWCheck->isChecked());
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
Expand Down
42 changes: 42 additions & 0 deletions launcher/ui/widgets/MinecraftSettingsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,32 @@
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
<item row="10" 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">
Expand Down Expand Up @@ -886,6 +912,20 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="useNativeJemallocCheck">
<property name="text">
<string>Use system installation of Jemalloc</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="lineEditJemallocPath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1065,6 +1105,8 @@
<tabstop>lineEditGLFWPath</tabstop>
<tabstop>useNativeOpenALCheck</tabstop>
<tabstop>lineEditOpenALPath</tabstop>
<tabstop>useNativeJemallocCheck</tabstop>
<tabstop>lineEditJemallocPath</tabstop>
<tabstop>enableFeralGamemodeCheck</tabstop>
<tabstop>enableMangoHud</tabstop>
<tabstop>useDiscreteGpuCheck</tabstop>
Expand Down
Loading