Different intel GPU check
This commit is contained in:
@@ -57,10 +57,13 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
Log.info("[GL] Max texture size: @", maxTextureSize);
|
||||
Log.info("[GL] Using @ API.", gl30 != null ? "OpenGL 3" : "OpenGL 2");
|
||||
|
||||
if(GpuDetect.gpus.size > 0) Log.info("[GL] Detected GPU: @", GpuDetect.gpus.toString(", "));
|
||||
if(GpuDetect.hasIntel && !graphics.isGL30Available()) Log.warn("[GL] Intel GPU detected. Due to memory corruption issues, OpenGL 3 support has been disabled for Intel GPUs. See issue #11041.");
|
||||
IntelGpuCheck.init(graphics.getGLVersion().vendorString);
|
||||
|
||||
if(gl30 == null && !GpuDetect.hasIntel) Log.warn("[GL] Your device or video drivers do not support OpenGL 3. This will cause performance issues.");
|
||||
boolean isIntel = IntelGpuCheck.wasIntel();
|
||||
|
||||
if(isIntel && !graphics.isGL30Available()) Log.warn("[GL] Intel GPU detected on previous launch. Due to memory corruption issues, OpenGL 3 support has been disabled for Intel GPUs. See issue #11041.");
|
||||
|
||||
if(gl30 == null && !isIntel) Log.warn("[GL] Your device or video drivers do not support OpenGL 3. This will cause performance issues.");
|
||||
|
||||
if(NvGpuInfo.hasMemoryInfo()) Log.info("[GL] Total available VRAM: @mb", NvGpuInfo.getMaxMemoryKB()/1024);
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/** GPU detection for Windows only. All fields will be false or empty on other platforms, even if #init() is called. */
|
||||
public class GpuDetect{
|
||||
public static String rawGpuString = "";
|
||||
public static Seq<String> gpus = new Seq<>();
|
||||
public static boolean hasIntel, hasNvidia, hasAMD;
|
||||
|
||||
public static void init(){
|
||||
if(OS.isWindows){
|
||||
try{
|
||||
rawGpuString = OS.exec("wmic", "path", "win32_VideoController", "get", "name");
|
||||
gpus = Seq.with(rawGpuString.split("\n")).map(s -> s.trim()).removeAll(s -> s.isEmpty() || s.equalsIgnoreCase("name"));
|
||||
|
||||
hasIntel = rawGpuString.toLowerCase(Locale.ROOT).contains("intel");
|
||||
hasNvidia = rawGpuString.toLowerCase(Locale.ROOT).contains("nvidia");
|
||||
hasAMD = rawGpuString.toLowerCase(Locale.ROOT).contains("amd") || rawGpuString.toLowerCase(Locale.ROOT).contains("radeon");
|
||||
}catch(Exception e){
|
||||
Log.err("Failed to detect GPU type. This is not a fatal error, but if you are using a Intel GPU, it may result in rare graphical issues.", Strings.getSimpleMessage(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
core/src/mindustry/graphics/IntelGpuCheck.java
Normal file
45
core/src/mindustry/graphics/IntelGpuCheck.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.files.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class IntelGpuCheck{
|
||||
private static boolean wasIntel, checkedLastLaunch;
|
||||
|
||||
/** initialize intel version check for the next application launch */
|
||||
public static void init(String vendor){
|
||||
if(!OS.isWindows) return;
|
||||
|
||||
boolean isIntel = vendor.toLowerCase(Locale.ROOT).contains("intel");
|
||||
try{
|
||||
Fi file = Vars.dataDirectory.child("was_intel_gpu");
|
||||
if(isIntel){
|
||||
file.writeString("1");
|
||||
}else if(file.exists()){
|
||||
file.delete();
|
||||
}
|
||||
}catch(Throwable e){
|
||||
Log.err(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** @return whether the last launch used an intel GPU on Windows */
|
||||
public static boolean wasIntel(){
|
||||
if(!OS.isWindows) return false;
|
||||
if(checkedLastLaunch) return wasIntel;
|
||||
checkedLastLaunch = true;
|
||||
|
||||
try{
|
||||
Fi file = new Fi(OS.getAppDataDirectoryString("Mindustry")).child("was_intel_gpu");
|
||||
if(file.exists() && file.readString().equals("1")){
|
||||
return wasIntel = true;
|
||||
}
|
||||
}catch(Throwable e){
|
||||
Log.err("Failed to check whether the last launch used an intel GPU.", e);
|
||||
}
|
||||
return wasIntel = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user