-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid showing the incompatible driver error in some cases
For systems with hybrid graphics, it may be the case that an incompatible graphics driver is installed, but that it isn't used for the OpenGL context. We can avoid showing errors in this situation by checking the vendor string of the context immediately after creation. This is not the most robust check, but in practice, a single system should not have multiple graphics drivers installed from the same vendor, so checking the string should be relatively safe.
- Loading branch information
1 parent
57e1ccb
commit 58e837c
Showing
10 changed files
with
163 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...nds/java/net/caffeinemc/mods/sodium/client/compatibility/checks/GraphicsDriverChecks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package net.caffeinemc.mods.sodium.client.compatibility.checks; | ||
|
||
import net.caffeinemc.mods.sodium.client.compatibility.environment.GlContextInfo; | ||
import net.caffeinemc.mods.sodium.client.compatibility.environment.probe.GraphicsAdapterVendor; | ||
import net.caffeinemc.mods.sodium.client.compatibility.workarounds.intel.IntelWorkarounds; | ||
import net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaDriverVersion; | ||
import net.caffeinemc.mods.sodium.client.compatibility.workarounds.nvidia.NvidiaWorkarounds; | ||
import net.caffeinemc.mods.sodium.client.platform.NativeWindowHandle; | ||
import net.caffeinemc.mods.sodium.client.platform.PlatformHelper; | ||
|
||
class GraphicsDriverChecks { | ||
static void postContextInit(NativeWindowHandle window, GlContextInfo context) { | ||
var vendor = GraphicsAdapterVendor.fromContext(context); | ||
|
||
if (vendor == GraphicsAdapterVendor.UNKNOWN) { | ||
return; | ||
} | ||
|
||
if (vendor == GraphicsAdapterVendor.INTEL && BugChecks.ISSUE_899) { | ||
var installedVersion = IntelWorkarounds.findIntelDriverMatchingBug899(); | ||
|
||
if (installedVersion != null) { | ||
var installedVersionString = installedVersion.toString(); | ||
|
||
PlatformHelper.showCriticalErrorAndClose(window, | ||
"Sodium Renderer - Unsupported Driver", | ||
""" | ||
The game failed to start because the currently installed Intel Graphics Driver is not \ | ||
compatible. | ||
Installed version: ###CURRENT_DRIVER### | ||
Required version: 10.18.10.5161 (or newer) | ||
You must update your graphics card driver in order to continue.""" | ||
.replace("###CURRENT_DRIVER###", installedVersionString), | ||
"https://github.com/CaffeineMC/sodium/wiki/Driver-Compatibility#windows-intel-gen7"); | ||
} | ||
} | ||
|
||
if (vendor == GraphicsAdapterVendor.NVIDIA && BugChecks.ISSUE_1486) { | ||
var installedVersion = NvidiaWorkarounds.findNvidiaDriverMatchingBug1486(); | ||
|
||
if (installedVersion != null) { | ||
var installedVersionString = NvidiaDriverVersion.parse(installedVersion) | ||
.toString(); | ||
|
||
PlatformHelper.showCriticalErrorAndClose(window, | ||
"Sodium Renderer - Unsupported Driver", | ||
""" | ||
The game failed to start because the currently installed NVIDIA Graphics Driver is not \ | ||
compatible. | ||
Installed version: ###CURRENT_DRIVER### | ||
Required version: 536.23 (or newer) | ||
You must update your graphics card driver in order to continue.""" | ||
.replace("###CURRENT_DRIVER###", installedVersionString), | ||
"https://github.com/CaffeineMC/sodium/wiki/Driver-Compatibility#nvidia-gpus"); | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
common/src/workarounds/java/net/caffeinemc/mods/sodium/client/platform/PlatformHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.caffeinemc.mods.sodium.client.platform; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class PlatformHelper { | ||
private static final Logger LOGGER = LoggerFactory.getLogger("Sodium-EarlyDriverScanner"); | ||
|
||
public static void showCriticalErrorAndClose( | ||
@Nullable NativeWindowHandle window, | ||
@NotNull String messageTitle, | ||
@NotNull String messageBody, | ||
@NotNull String helpUrl) | ||
{ | ||
// Always print the information to the log file first, just in case we can't show the message box. | ||
LOGGER.error(""" | ||
###ERROR_DESCRIPTION### | ||
For more information, please see: ###HELP_URL###""" | ||
.replace("###ERROR_DESCRIPTION###", messageBody) | ||
.replace("###HELP_URL###", helpUrl)); | ||
|
||
// Try to show a graphical message box (if the platform supports it) and shut down the game. | ||
MessageBox.showMessageBox(window, MessageBox.IconType.ERROR, messageTitle, messageBody, helpUrl); | ||
System.exit(1 /* failure code */); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.