Soul Pass #1 fixes: stepScale raymarch traversal, remove verify harness, forcePersist ResetToDefaults, windowed UI/hotkey sync
This commit is contained in:
parent
a3f5ae94cf
commit
5820817879
4 changed files with 36 additions and 79 deletions
|
|
@ -181,7 +181,8 @@ public sealed class GraphicsSettings
|
||||||
VolumetricSamples volumetricSamples,
|
VolumetricSamples volumetricSamples,
|
||||||
SdfgiQuality sdfgiQuality,
|
SdfgiQuality sdfgiQuality,
|
||||||
bool borderlessFullscreen,
|
bool borderlessFullscreen,
|
||||||
bool persist = true)
|
bool persist = true,
|
||||||
|
bool forcePersist = false)
|
||||||
{
|
{
|
||||||
VfxResolutionScale safeRes = Enum.IsDefined(vfxResolution) ? vfxResolution : VfxResolutionScale.Half;
|
VfxResolutionScale safeRes = Enum.IsDefined(vfxResolution) ? vfxResolution : VfxResolutionScale.Half;
|
||||||
VolumetricSamples safeSamples = Enum.IsDefined(volumetricSamples) ? volumetricSamples : VolumetricSamples.Medium;
|
VolumetricSamples safeSamples = Enum.IsDefined(volumetricSamples) ? volumetricSamples : VolumetricSamples.Medium;
|
||||||
|
|
@ -194,6 +195,10 @@ public sealed class GraphicsSettings
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
|
if (persist && forcePersist)
|
||||||
|
{
|
||||||
|
Save();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,7 +232,8 @@ public sealed class GraphicsSettings
|
||||||
VolumetricSamples.Medium,
|
VolumetricSamples.Medium,
|
||||||
SdfgiQuality.Balanced,
|
SdfgiQuality.Balanced,
|
||||||
borderlessFullscreen: true,
|
borderlessFullscreen: true,
|
||||||
persist: persist);
|
persist: persist,
|
||||||
|
forcePersist: persist);
|
||||||
|
|
||||||
public static float GetResolutionScaleFactor(VfxResolutionScale scale) => scale switch
|
public static float GetResolutionScaleFactor(VfxResolutionScale scale) => scale switch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ public partial class Main : Node3D
|
||||||
private int _menuPreviewTargetFrames;
|
private int _menuPreviewTargetFrames;
|
||||||
private int _menuPreviewFrames;
|
private int _menuPreviewFrames;
|
||||||
private string? _menuPreviewOut;
|
private string? _menuPreviewOut;
|
||||||
private string? _gfxVerifyOut;
|
|
||||||
private readonly WalkerFootstepTracker _footsteps = new();
|
private readonly WalkerFootstepTracker _footsteps = new();
|
||||||
private readonly CameraJuiceState _camJuice = new();
|
private readonly CameraJuiceState _camJuice = new();
|
||||||
private readonly List<ISimEvent> _frameEvents = new(128);
|
private readonly List<ISimEvent> _frameEvents = new(128);
|
||||||
|
|
@ -350,7 +349,6 @@ public partial class Main : Node3D
|
||||||
_menuPreviewTargetFrames = menuExitFrames;
|
_menuPreviewTargetFrames = menuExitFrames;
|
||||||
}
|
}
|
||||||
_menuPreviewOut = System.Environment.GetEnvironmentVariable("RTD_MENU_PREVIEW_OUT");
|
_menuPreviewOut = System.Environment.GetEnvironmentVariable("RTD_MENU_PREVIEW_OUT");
|
||||||
_gfxVerifyOut = System.Environment.GetEnvironmentVariable("RTD_GFX_VERIFY_OUT");
|
|
||||||
|
|
||||||
_hasWindowOverride = GetCliArg("--windowed", allowBareFlag: true) is not null
|
_hasWindowOverride = GetCliArg("--windowed", allowBareFlag: true) is not null
|
||||||
|| GetCliArg("--resolution", allowBareFlag: true) is not null
|
|| GetCliArg("--resolution", allowBareFlag: true) is not null
|
||||||
|
|
@ -359,9 +357,19 @@ public partial class Main : Node3D
|
||||||
{
|
{
|
||||||
ApplyWindowMode(_graphicsSettings.BorderlessFullscreen);
|
ApplyWindowMode(_graphicsSettings.BorderlessFullscreen);
|
||||||
}
|
}
|
||||||
else if (IsAutomatedRun && DisplayServer.GetName() != "headless")
|
else
|
||||||
{
|
{
|
||||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.NoFocus, true);
|
if (IsAutomatedRun && DisplayServer.GetName() != "headless")
|
||||||
|
{
|
||||||
|
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.NoFocus, true);
|
||||||
|
}
|
||||||
|
if (_hasWindowOverride && DisplayServer.GetName() != "headless")
|
||||||
|
{
|
||||||
|
var winMode = DisplayServer.WindowGetMode();
|
||||||
|
bool actualFullscreen = winMode == DisplayServer.WindowMode.Fullscreen
|
||||||
|
|| winMode == DisplayServer.WindowMode.ExclusiveFullscreen;
|
||||||
|
_graphicsSettings.SetBorderlessFullscreen(actualFullscreen, persist: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool perfCombat = _perfTargetFrames > 0 && System.Environment.GetEnvironmentVariable("RTD_PERF_COMBAT") == "1";
|
bool perfCombat = _perfTargetFrames > 0 && System.Environment.GetEnvironmentVariable("RTD_PERF_COMBAT") == "1";
|
||||||
|
|
@ -396,10 +404,6 @@ public partial class Main : Node3D
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EnterMainMenuBackdrop();
|
EnterMainMenuBackdrop();
|
||||||
if (System.Environment.GetEnvironmentVariable("RTD_OPEN_SETTINGS") == "1")
|
|
||||||
{
|
|
||||||
OpenSettingsFromCurrentScreen();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (perfCombat && _session is not null)
|
if (perfCombat && _session is not null)
|
||||||
|
|
@ -1122,7 +1126,7 @@ public partial class Main : Node3D
|
||||||
|
|
||||||
private void ToggleBorderlessFullscreen()
|
private void ToggleBorderlessFullscreen()
|
||||||
{
|
{
|
||||||
if (DisplayServer.GetName() == "headless")
|
if (IsAutomatedRun || DisplayServer.GetName() == "headless")
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1597,10 +1601,6 @@ public partial class Main : Node3D
|
||||||
}
|
}
|
||||||
|
|
||||||
_perfFrameCount++;
|
_perfFrameCount++;
|
||||||
if (!string.IsNullOrWhiteSpace(_gfxVerifyOut))
|
|
||||||
{
|
|
||||||
StepGfxVerifySuite(_perfFrameCount);
|
|
||||||
}
|
|
||||||
if (_perfFrameCount >= _perfTargetFrames)
|
if (_perfFrameCount >= _perfTargetFrames)
|
||||||
{
|
{
|
||||||
PrintPerfSummaryAndQuit();
|
PrintPerfSummaryAndQuit();
|
||||||
|
|
@ -1839,70 +1839,9 @@ public partial class Main : Node3D
|
||||||
GD.Print($"PERF PREVIEW SAVED: {previewOut} ({img.GetWidth()}x{img.GetHeight()}, err={err})");
|
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);
|
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)
|
private static void CollectNodeNames(Node cur, List<string> outNames, int limit)
|
||||||
{
|
{
|
||||||
if (outNames.Count >= limit) return;
|
if (outNames.Count >= limit) return;
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,8 @@ void main() {
|
||||||
int steps = 0;
|
int steps = 0;
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
int maxSteps = clamp(int(u_frame.qualityParams.x), 1, 64);
|
int maxSteps = clamp(int(u_frame.qualityParams.x), 1, 64);
|
||||||
int maxIter = clamp(int(u_frame.qualityParams.y), 1, 96);
|
int maxIter = clamp(max(int(u_frame.qualityParams.y), maxSteps * 2), 1, 96);
|
||||||
|
float stepScale = 10.0 / max(float(maxSteps), 1.0);
|
||||||
|
|
||||||
while ((nextIdx < hitCount || activeMask != 0u) && t < tEndMax && T >= 0.03 && steps < maxSteps && iter < maxIter) {
|
while ((nextIdx < hitCount || activeMask != 0u) && t < tEndMax && T >= 0.03 && steps < maxSteps && iter < maxIter) {
|
||||||
// Empty-space jump directly to nextIdx's t0 whenever no emitter is currently active
|
// Empty-space jump directly to nextIdx's t0 whenever no emitter is currently active
|
||||||
|
|
@ -330,7 +331,7 @@ void main() {
|
||||||
float minNext = uintBitsToFloat(hitPack[nextIdx] & 0xFFFFFFE0u);
|
float minNext = uintBitsToFloat(hitPack[nextIdx] & 0xFFFFFFE0u);
|
||||||
float nextT1 = hitT1[nextIdx];
|
float nextT1 = hitT1[nextIdx];
|
||||||
float chord = max(0.0, nextT1 - minNext);
|
float chord = max(0.0, nextT1 - minNext);
|
||||||
float dsLeap = max(0.42, 0.32 + 0.014 * minNext);
|
float dsLeap = max(0.16, max(0.42, 0.32 + 0.014 * minNext) * stepScale);
|
||||||
float jitter = ign * min(dsLeap, max(0.05, chord * 0.45));
|
float jitter = ign * min(dsLeap, max(0.05, chord * 0.45));
|
||||||
t = min(max(t, minNext) + jitter, tEndMax - 1e-4);
|
t = min(max(t, minNext) + jitter, tEndMax - 1e-4);
|
||||||
if (t >= tEndMax) {
|
if (t >= tEndMax) {
|
||||||
|
|
@ -338,7 +339,7 @@ void main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float ds = max(0.42, 0.32 + 0.014 * t);
|
float ds = max(0.16, max(0.42, 0.32 + 0.014 * t) * stepScale);
|
||||||
float tLo = t - 0.5 * ds;
|
float tLo = t - 0.5 * ds;
|
||||||
float tHi = t + 0.5 * ds;
|
float tHi = t + 0.5 * ds;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,17 @@ public sealed class GraphicsSettingsTests
|
||||||
Assert.Equal(SdfgiQuality.Balanced, corruptLoaded.SdfgiQuality);
|
Assert.Equal(SdfgiQuality.Balanced, corruptLoaded.SdfgiQuality);
|
||||||
Assert.True(corruptLoaded.BorderlessFullscreen);
|
Assert.True(corruptLoaded.BorderlessFullscreen);
|
||||||
|
|
||||||
|
// ResetToDefaults(persist: true) must unconditionally rewrite a corrupt file even when memory equals defaults
|
||||||
|
corruptLoaded.ResetToDefaults(persist: true);
|
||||||
|
string repairedJson = File.ReadAllText(corruptPath);
|
||||||
|
Assert.DoesNotContain("not valid json", repairedJson, StringComparison.Ordinal);
|
||||||
|
var repaired = new GraphicsSettings();
|
||||||
|
Assert.True(repaired.LoadFromJson(repairedJson));
|
||||||
|
Assert.Equal(VfxResolutionScale.Half, repaired.VfxResolution);
|
||||||
|
Assert.Equal(VolumetricSamples.Medium, repaired.VolumetricSamples);
|
||||||
|
Assert.Equal(SdfgiQuality.Balanced, repaired.SdfgiQuality);
|
||||||
|
Assert.True(repaired.BorderlessFullscreen);
|
||||||
|
|
||||||
var outOfRange = new GraphicsSettings();
|
var outOfRange = new GraphicsSettings();
|
||||||
Assert.True(outOfRange.LoadFromJson("""{"vfxResolutionScale":99,"volumetricSamples":42,"sdfgiQuality":77,"borderlessFullscreen":false}"""));
|
Assert.True(outOfRange.LoadFromJson("""{"vfxResolutionScale":99,"volumetricSamples":42,"sdfgiQuality":77,"borderlessFullscreen":false}"""));
|
||||||
Assert.Equal(VfxResolutionScale.Half, outOfRange.VfxResolution);
|
Assert.Equal(VfxResolutionScale.Half, outOfRange.VfxResolution);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue