Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ public LaunchOptions.Builder getLaunchOptions(GameInstanceID instanceId, JavaRun
GameSettings.Effective vs = getEffectiveGameSettings(instanceId);
boolean noJVMOptions = vs.getInheritable(GameSettings::noJVMOptionsProperty);
boolean autoMemory = vs.getInheritable(GameSettings::autoMemoryProperty);
boolean highPerformanceGPU = vs.getInheritable(GameSettings::highPerformanceProperty);
GameVersionNumber gameVersionNumber = GameVersionNumber.asGameVersion(getGameVersion(instanceId));

@Nullable Integer maxMemory;
Expand Down Expand Up @@ -793,6 +794,7 @@ public LaunchOptions.Builder getLaunchOptions(GameInstanceID instanceId, JavaRun
.setDisableAutoGameOptions(vs.getInheritable(GameSettings::disableAutoGameOptionsProperty))
.setUseNativeGLFW(vs.getInheritable(GameSettings::useNativeGLFWProperty))
.setUseNativeOpenAL(vs.getInheritable(GameSettings::useNativeOpenALProperty))
.setUseHighPerformanceGPU(vs.getInheritable(GameSettings::highPerformanceProperty))
.setDaemon(!makeLaunchScript && vs.getInheritable(GameSettings::launcherVisibilityProperty).isDaemon())
.setJavaAgents(javaAgents)
.setJavaArguments(javaArguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ public GameSettingsPage(Class<S> settingType) {
var highPerformancePane = createInheritableBooleanButton(GameSettings::highPerformanceProperty);
graphicsSettings.getContent().add(highPerformancePane);
highPerformancePane.setTitle(i18n("settings.advanced.renderer.gpu_preferences"));
highPerformancePane.setSubtitle(i18n("settings.advanced.windows_only"));

this.currentGameVersionNumber.addListener((o, oldValue, newValue) -> {
boolean showBackendChoose = isPresetSetting || newValue.compareTo("26.2-snapshot-2") >= 0;
Expand Down
10 changes: 10 additions & 0 deletions HMCLCore/src/main/java/org/jackhuang/hmcl/game/LaunchOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class LaunchOptions implements Serializable {
private Renderer renderer = Renderer.DEFAULT;
private boolean useNativeGLFW;
private boolean useNativeOpenAL;
private boolean useHighPerformanceGPU;
private boolean enableDebugLogOutput;
private boolean allowAutoAgent;
private boolean disableAutoGameOptions;
Expand Down Expand Up @@ -263,6 +264,10 @@ public boolean isUseNativeOpenAL() {
return useNativeOpenAL;
}

public boolean isUseHighPerformanceGPU() {
return useHighPerformanceGPU;
}

public boolean isEnableDebugLogOutput() {
return enableDebugLogOutput;
}
Expand Down Expand Up @@ -476,6 +481,11 @@ public Builder setUseNativeOpenAL(boolean useNativeOpenAL) {
return this;
}

public Builder setUseHighPerformanceGPU(boolean useHighPerformanceGPU) {
options.useHighPerformanceGPU = useHighPerformanceGPU;
return this;
}

public Builder setDaemon(boolean daemon) {
options.daemon = daemon;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.Unzipper;
import org.jackhuang.hmcl.util.platform.*;
import org.jackhuang.hmcl.util.platform.hardware.GraphicsCard;
import org.jackhuang.hmcl.util.platform.hardware.HardwareVendor;
import org.jackhuang.hmcl.util.platform.macos.HomebrewUtils;
import org.jackhuang.hmcl.util.versioning.GameVersionNumber;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -681,6 +683,28 @@ else if (driver instanceof Renderer.Vulkan vulkanDriver) {
}
}

if (options.getRenderer() == Renderer.DEFAULT) {
Comment thread
Glavo marked this conversation as resolved.
List<GraphicsCard> graphicsCards = SystemInfo.getGraphicsCards();
if (graphicsCards != null && graphicsCards.size() == 2) {
GraphicsCard card0 = graphicsCards.get(0);
GraphicsCard card1 = graphicsCards.get(1);

if (card0.getType() != null && card1.getType() != null
&& card0.getType() != card1.getType()) {
GraphicsCard discreteGraphicsCard = card0.getType() == GraphicsCard.Type.Discrete ? card0 : card1;
Comment on lines +692 to +694

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid requiring a missing NVIDIA card type

On the normal Linux sysfs detection path, the NVIDIA card generally has a null type, so this guard prevents the new offload variables from ever being set on the intended Intel/NVIDIA laptop configuration. LinuxGPUDetector.detectPCI constructs names such as NVIDIA GeForce ... (or NVIDIA Device ...) but only marks NVIDIA cards discrete when the name starts directly with GeForce, Quadro, or Tesla; because sysfs usually yields at least one card, the typed fastfetch fallback is not used. Determine the NVIDIA discrete adapter without requiring both existing type values, or correct the detector before applying this guard.

Useful? React with 👍 / 👎.


if (OperatingSystem.CURRENT_OS == OperatingSystem.LINUX) {
if (HardwareVendor.NVIDIA.equals(discreteGraphicsCard.getVendor())) {
// https://askubuntu.com/a/1350825
env.put("__NV_PRIME_RENDER_OFFLOAD", "1");
env.put("__GLX_VENDOR_LIBRARY_NAME", "nvidia");
env.put("__VK_LAYER_NV_optimus", "NVIDIA_only");
}
}
}
}
}

if (analyzer.has(LibraryAnalyzer.LibraryType.FORGE)) {
env.put("INST_FORGE", "1");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public String getName() {
return driverVersion;
}

public @Nullable Type getType() {
return type;
}

public List<Path> getVulkanDriverFiles() {
return vulkanDriverFiles;
}
Expand Down