-
Notifications
You must be signed in to change notification settings - Fork 922
支持在 Linux 双显卡平台上优先使用 NVIDIA 显卡 #6670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -681,6 +683,28 @@ else if (driver instanceof Renderer.Vulkan vulkanDriver) { | |
| } | ||
| } | ||
|
|
||
| if (options.getRenderer() == Renderer.DEFAULT) { | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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. 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"); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.