Skip to content
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

Show VRAM usage in monitor #98

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All notable changes to this project will be documented in this file.
- Move method to YatWindow to move window (e.q. top left, bottom right).
- Monitor scene.
- IMonitorComponent interface.
- FPS, OS, CPU, RAM, Engine, LookingAt components for Monitor.
- FPS, OS, CPU, memory, Engine, LookingAt components for Monitor.
- Stats command.

### Changed
Expand Down
6 changes: 3 additions & 3 deletions addons/yat/src/commands/builtin/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace YAT.Commands
[Option("-fps", null, "Shows the FPS in the game monitor.", false)]
[Option("-os", null, "Shows the OS information in the game monitor.", false)]
[Option("-cpu", null, "Shows the CPU information in the game monitor.", false)]
[Option("-ram", null, "Shows the RAM information in the game monitor.", false)]
[Option("-mem", null, "Shows memory information in the game monitor.", false)]
[Option("-engine", null, "Shows the engine information in the game monitor.", false)]
[Option("-lookingat", null, "Shows the info about node the player is looking at. Only in 3D.", false)]
public sealed class Stats : ICommand
Expand All @@ -40,7 +40,7 @@ private CommandResult Open(Dictionary<string, object> cArgs)
bool fps = (bool)cArgs["-fps"];
bool os = (bool)cArgs["-os"];
bool cpu = (bool)cArgs["-cpu"];
bool ram = (bool)cArgs["-ram"];
bool mem = (bool)cArgs["-mem"];
bool engine = (bool)cArgs["-engine"];
bool lookingAt = (bool)cArgs["-lookingat"];

Expand All @@ -54,7 +54,7 @@ private CommandResult Open(Dictionary<string, object> cArgs)
}

if (fps) components.Add(GD.Load<PackedScene>(_componentsPath + "fps/Fps.tscn").Instantiate<Fps>());
if (ram) components.Add(GD.Load<PackedScene>(_componentsPath + "memory_info/MemoryInfo.tscn").Instantiate<MemoryInfo>());
if (mem) components.Add(GD.Load<PackedScene>(_componentsPath + "memory_info/MemoryInfo.tscn").Instantiate<MemoryInfo>());
if (os) components.Add(GD.Load<PackedScene>(_componentsPath + "os/Os.tscn").Instantiate<Os>());
if (cpu) components.Add(GD.Load<PackedScene>(_componentsPath + "cpu_info/CpuInfo.tscn").Instantiate<CpuInfo>());
if (engine) components.Add(GD.Load<PackedScene>(_componentsPath + "engine_info/EngineInfo.tscn").Instantiate<EngineInfo>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ public void Update()
var physical = mem["physical"];
var free = mem["free"];
var stack = mem["stack"];
var vram = Performance.GetMonitor(Performance.Monitor.RenderVideoMemUsed);

var freePercent = (float)free / (float)physical * 100f;

_label.Clear();
_label.AppendText(
$"Memory: {NumericHelper.SizeToString(physical.AsInt64(), 3)}\n" +
$"RAM: {NumericHelper.SizeToString(physical.AsInt64(), 3)}\n" +
$"Free: {(
freePercent < 15
freePercent < 15 && UseColors
? $"[color={_yat.Options.ErrorColor}]{NumericHelper.SizeToString(free.AsInt64(), 3)}[/color]"
: NumericHelper.SizeToString(free.AsInt64(), 3))}\n" +
$"Stack: {NumericHelper.SizeToString(stack.AsInt64(), 1)}"
$"Stack: {NumericHelper.SizeToString(stack.AsInt64(), 1)}\n" +
$"VRAM: {NumericHelper.SizeToString((long)vram, 2)}"
);
}
}
Expand Down