Utility class for displaying VRAM information for Nvidia cards

This commit is contained in:
Anuken 2024-12-21 11:48:21 -05:00
parent eae43b7885
commit ef5e024954
3 changed files with 32 additions and 1 deletions

View File

@ -55,6 +55,9 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
Log.info("[GL] Version: @", graphics.getGLVersion());
Log.info("[GL] Max texture size: @", maxTextureSize);
Log.info("[GL] Using @ context.", gl30 != null ? "OpenGL 3" : "OpenGL 2");
if(NvGpuInfo.hasMemoryInfo()){
Log.info("[GL] Total available VRAM: @mb", NvGpuInfo.getMaxMemoryKB()/1024);
}
if(maxTextureSize < 4096) Log.warn("[GL] Your maximum texture size is below the recommended minimum of 4096. This will cause severe performance issues.");
Log.info("[JAVA] Version: @", OS.javaVersion);
if(Core.app.isAndroid()){

View File

@ -0,0 +1,28 @@
package mindustry.graphics;
import arc.*;
import arc.graphics.*;
/** Nvidia-specific utility class for querying GPU VRAM information. */
public class NvGpuInfo{
private static final int GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX = 0x9048;
private static final int GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX = 0x9049;
private static boolean supported, initialized;
public static int getMaxMemoryKB(){
return hasMemoryInfo() ? Gl.getInt(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX) : 0;
}
public static int getAvailableMemoryKB(){
return hasMemoryInfo() ? Gl.getInt(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX) : 0;
}
public static boolean hasMemoryInfo(){
if(!initialized){
supported = Core.graphics.supportsExtension("GL_NVX_gpu_memory_info");
initialized = true;
}
return supported;
}
}

View File

@ -34,7 +34,7 @@ public class CrashHandler{
+ ((OS.isAndroid || OS.isIos) && app != null ? "Android API level: " + Core.app.getVersion() + "\n" : "")
+ "Java Version: " + OS.javaVersion + "\n"
+ "Runtime Available Memory: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + "mb\n"
+ "Cores: " + Runtime.getRuntime().availableProcessors() + "\n"
+ "Cores: " + OS.cores + "\n"
+ (cause == null ? "" : "Likely Cause: " + cause.meta.displayName + " (" + cause.name + " v" + cause.meta.version + ")\n")
+ (mods == null ? "<no mod init>" : "Mods: " + (!mods.list().contains(LoadedMod::shouldBeEnabled) ? "none (vanilla)" : mods.list().select(LoadedMod::shouldBeEnabled).toString(", ", mod -> mod.name + ":" + mod.meta.version)))
+ "\n\n" + error;