Skip to content

Commit ef5e024

Browse files
committed
Utility class for displaying VRAM information for Nvidia cards
1 parent eae43b7 commit ef5e024

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

core/src/mindustry/ClientLauncher.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public void setup(){
5555
Log.info("[GL] Version: @", graphics.getGLVersion());
5656
Log.info("[GL] Max texture size: @", maxTextureSize);
5757
Log.info("[GL] Using @ context.", gl30 != null ? "OpenGL 3" : "OpenGL 2");
58+
if(NvGpuInfo.hasMemoryInfo()){
59+
Log.info("[GL] Total available VRAM: @mb", NvGpuInfo.getMaxMemoryKB()/1024);
60+
}
5861
if(maxTextureSize < 4096) Log.warn("[GL] Your maximum texture size is below the recommended minimum of 4096. This will cause severe performance issues.");
5962
Log.info("[JAVA] Version: @", OS.javaVersion);
6063
if(Core.app.isAndroid()){
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package mindustry.graphics;
2+
3+
import arc.*;
4+
import arc.graphics.*;
5+
6+
/** Nvidia-specific utility class for querying GPU VRAM information. */
7+
public class NvGpuInfo{
8+
private static final int GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX = 0x9048;
9+
private static final int GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX = 0x9049;
10+
11+
private static boolean supported, initialized;
12+
13+
public static int getMaxMemoryKB(){
14+
return hasMemoryInfo() ? Gl.getInt(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX) : 0;
15+
}
16+
17+
public static int getAvailableMemoryKB(){
18+
return hasMemoryInfo() ? Gl.getInt(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX) : 0;
19+
}
20+
21+
public static boolean hasMemoryInfo(){
22+
if(!initialized){
23+
supported = Core.graphics.supportsExtension("GL_NVX_gpu_memory_info");
24+
initialized = true;
25+
}
26+
return supported;
27+
}
28+
}

core/src/mindustry/net/CrashHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static String createReport(Throwable exception){
3434
+ ((OS.isAndroid || OS.isIos) && app != null ? "Android API level: " + Core.app.getVersion() + "\n" : "")
3535
+ "Java Version: " + OS.javaVersion + "\n"
3636
+ "Runtime Available Memory: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + "mb\n"
37-
+ "Cores: " + Runtime.getRuntime().availableProcessors() + "\n"
37+
+ "Cores: " + OS.cores + "\n"
3838
+ (cause == null ? "" : "Likely Cause: " + cause.meta.displayName + " (" + cause.name + " v" + cause.meta.version + ")\n")
3939
+ (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)))
4040
+ "\n\n" + error;

0 commit comments

Comments
 (0)