Add RTD_GFX_VERIFY_OUT live Vulkan verification suite for Settings -> Graphics

This commit is contained in:
Meta Vens 2026-12-06 00:57:18 +01:00
commit a3f5ae94cf

View file

@ -64,6 +64,7 @@ public partial class Main : Node3D
private int _menuPreviewTargetFrames;
private int _menuPreviewFrames;
private string? _menuPreviewOut;
private string? _gfxVerifyOut;
private readonly WalkerFootstepTracker _footsteps = new();
private readonly CameraJuiceState _camJuice = new();
private readonly List<ISimEvent> _frameEvents = new(128);
@ -349,6 +350,7 @@ public partial class Main : Node3D
_menuPreviewTargetFrames = menuExitFrames;
}
_menuPreviewOut = System.Environment.GetEnvironmentVariable("RTD_MENU_PREVIEW_OUT");
_gfxVerifyOut = System.Environment.GetEnvironmentVariable("RTD_GFX_VERIFY_OUT");
_hasWindowOverride = GetCliArg("--windowed", allowBareFlag: true) is not null
|| GetCliArg("--resolution", allowBareFlag: true) is not null
@ -1595,6 +1597,10 @@ public partial class Main : Node3D
}
_perfFrameCount++;
if (!string.IsNullOrWhiteSpace(_gfxVerifyOut))
{
StepGfxVerifySuite(_perfFrameCount);
}
if (_perfFrameCount >= _perfTargetFrames)
{
PrintPerfSummaryAndQuit();
@ -1833,9 +1839,70 @@ public partial class Main : Node3D
GD.Print($"PERF PREVIEW SAVED: {previewOut} ({img.GetWidth()}x{img.GetHeight()}, err={err})");
}
}
if (!string.IsNullOrWhiteSpace(_gfxVerifyOut))
{
VerifyPersistenceRoundTrip();
_graphicsSettings.Apply(VfxResolutionScale.Half, VolumetricSamples.Medium, SdfgiQuality.Balanced, borderlessFullscreen: true, persist: false);
_menuPreviewOut = _gfxVerifyOut;
_menuPreviewTargetFrames = 12;
_menuPreviewFrames = 0;
_perfTargetFrames = 0;
EnterMainMenuBackdrop();
OpenSettingsFromCurrentScreen();
return;
}
GetTree().Quit(0);
}
private void StepGfxVerifySuite(int frameCount)
{
var volFx = _atmosphere.VolumetricEffect;
var env = _atmosphere.Environment;
if (frameCount == 33)
{
GD.Print($"GFX_VERIFY Phase0 (Half/Medium/Balanced): march={volFx?.LastMarchSize.X}x{volFx?.LastMarchSize.Y} steps={volFx?.CurrentMaxSteps} iter={volFx?.CurrentMaxIter} total={volFx?.LastTotalGpuMs:F3}ms marchMs={volFx?.LastMarchGpuMs:F3}ms compMs={volFx?.LastCompGpuMs:F3}ms sdfgi={env.SdfgiEnabled} cell={env.SdfgiMinCellSize:F1} casc={env.SdfgiCascades}");
_graphicsSettings.Apply(VfxResolutionScale.ThreeQuarter, VolumetricSamples.High, SdfgiQuality.High, borderlessFullscreen: true, persist: false);
}
else if (frameCount == 57)
{
GD.Print($"GFX_VERIFY Phase1 (ThreeQuarter/High/SdfgiHigh): march={volFx?.LastMarchSize.X}x{volFx?.LastMarchSize.Y} steps={volFx?.CurrentMaxSteps} iter={volFx?.CurrentMaxIter} total={volFx?.LastTotalGpuMs:F3}ms marchMs={volFx?.LastMarchGpuMs:F3}ms compMs={volFx?.LastCompGpuMs:F3}ms sdfgi={env.SdfgiEnabled} cell={env.SdfgiMinCellSize:F1} casc={env.SdfgiCascades}");
_graphicsSettings.Apply(VfxResolutionScale.Full, VolumetricSamples.Ultra, SdfgiQuality.Off, borderlessFullscreen: true, persist: false);
}
else if (frameCount == 81)
{
GD.Print($"GFX_VERIFY Phase2 (Full/Ultra/SdfgiOff): march={volFx?.LastMarchSize.X}x{volFx?.LastMarchSize.Y} steps={volFx?.CurrentMaxSteps} iter={volFx?.CurrentMaxIter} total={volFx?.LastTotalGpuMs:F3}ms marchMs={volFx?.LastMarchGpuMs:F3}ms compMs={volFx?.LastCompGpuMs:F3}ms sdfgi={env.SdfgiEnabled}");
_graphicsSettings.Apply(VfxResolutionScale.Half, VolumetricSamples.Low, SdfgiQuality.Balanced, borderlessFullscreen: true, persist: false);
}
else if (frameCount == 98)
{
GD.Print($"GFX_VERIFY Phase3 (Half/Low/Balanced): march={volFx?.LastMarchSize.X}x{volFx?.LastMarchSize.Y} steps={volFx?.CurrentMaxSteps} iter={volFx?.CurrentMaxIter} total={volFx?.LastTotalGpuMs:F3}ms marchMs={volFx?.LastMarchGpuMs:F3}ms compMs={volFx?.LastCompGpuMs:F3}ms sdfgi={env.SdfgiEnabled}");
}
}
private static void VerifyPersistenceRoundTrip()
{
string userPath = ResolveGraphicsSettingsPath() ?? string.Empty;
string verifyPath = ProjectSettings.GlobalizePath("user://graphics_settings_verify_rt.json");
try
{
var s1 = new GraphicsSettings(verifyPath);
s1.Apply(VfxResolutionScale.Full, VolumetricSamples.Ultra, SdfgiQuality.High, borderlessFullscreen: false, persist: true);
var s2 = GraphicsSettings.Load(verifyPath);
bool ok = s2.VfxResolution == VfxResolutionScale.Full
&& s2.VolumetricSamples == VolumetricSamples.Ultra
&& s2.SdfgiQuality == SdfgiQuality.High
&& !s2.BorderlessFullscreen;
GD.Print($"GFX_VERIFY PersistenceRoundTrip: ok={ok} userPath='{userPath}' verifyPath='{verifyPath}'");
}
finally
{
if (System.IO.File.Exists(verifyPath))
{
System.IO.File.Delete(verifyPath);
}
}
}
private static void CollectNodeNames(Node cur, List<string> outNames, int limit)
{
if (outNames.Count >= limit) return;