Triforce v0.7.0 "Sage Of Courage"

The 0.6 crashes after warps and area changes fixed (no write-back into memory the capture leaves out), invisible objects fixed (occlusion gate), DLSS frame generation flicker fixed, achievements, the renderer built with a play profile, faster translated game code, helper threads judged on settled scenes, memory, shader preparation, audio effects, launcher, controls and Linux fixes.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-22 11:59:06 -06:00
parent 70c210cee1
commit e6f2f248f2
529 changed files with 55958 additions and 1898 deletions

View File

@@ -111,7 +111,7 @@ public static class BuildProtocol
}
/// <summary>The build's state as its lines come (old Shell.cs Line/Ended; the Tk builder's parser): the stage it is in, that
/// stage's progress, when each stage began, the plan, the time left the compile said, the folder @@done named, the last
/// stage's progress (and how it moved), when each stage began, the plan, the time left the compile said, the folder @@done named, the last
/// @@error. Fed line by line by BuildRunner, or by a test from a transcript.</summary>
public sealed class BuildTracker
{
@@ -149,10 +149,20 @@ public sealed class BuildTracker
Stage = s.Id;
StageStarted = t;
StageProgress = 0;
lock (Gate) { recent.Clear(); recent.Add((t, 0)); }
if (s.Id != "compile") EtaSeconds = null;
StageChanged?.Invoke(was, s.Id);
break;
case BuildEvent.Progress p: StageProgress = p.Fraction; break;
case BuildEvent.Progress p:
StageProgress = p.Fraction;
lock (Gate)
{
if (recent.Count == 0) recent.Add((StageStarted, 0));
if (p.Fraction < recent[^1].Progress) { recent.Clear(); recent.Add((now(), p.Fraction)); } // (it went back: start over)
else if (p.Fraction > recent[^1].Progress) recent.Add((now(), p.Fraction));
if (recent.Count > KeepSamples) recent.RemoveRange(0, recent.Count - KeepSamples / 2);
}
break;
case BuildEvent.Plan p: Plan = (p.Changed, p.Total); break;
case BuildEvent.FileBuilt f when f.How is "new" or "again": FilesBuilt++; break;
case BuildEvent.Eta x: EtaSeconds = x.Seconds; break;
@@ -177,4 +187,15 @@ public sealed class BuildTracker
public TimeSpan Elapsed => now() - Started;
public TimeSpan InStage => Stage == null ? TimeSpan.Zero : now() - StageStarted;
public DateTime Now => now();
/// <summary>This stage's progress as it moved: (when, how far), from (the stage's start, 0), a sample each time it went up (the
/// last 2000), for BuildClock's rate over the last minutes.</summary>
public IReadOnlyList<(DateTime At, double Progress)> Recent { get { lock (Gate) return recent.ToArray(); } }
const int KeepSamples = 2000;
readonly List<(DateTime At, double Progress)> recent = new();
/// <summary>The time left last shown and when (BuildClock.Remaining's smoothing), under Gate: the App asks from more than one thread.</summary>
internal (double Seconds, DateTime At)? Shown;
internal readonly object Gate = new();
}

View File

@@ -1,5 +1,6 @@
// nx2/make_game.py as a child process (old Setup.cs Runner, Shell.cs Run/Line/Ended; hookshot_builder.py start_make/on_exit):
// <python> -I <tools>\nx2\make_game.py <args> cwd <tools>, stdout+stderr UTF-8, below-normal priority (Windows)
// <python> -I <tools>\nx2\make_game.py <args> cwd <tools>, stdout+stderr UTF-8, normal priority (below normal on
// Windows only with HOOKSHOT_LOW_PRIORITY=1)
// env: PYTHONIOENCODING=utf-8, HOOKSHOT_BUILDER_EXE (written into the game folder's builder= line), HOOKSHOT_NGX_SDK when
// DLSS is on, EMSDK / RX_CPM / WGPU_NATIVE / HOOKSHOT_MINGW for tool folders that exist (Windows); Linux: DLSS on drops
// HOOKSHOT_VK_PREBUILT (the Vulkan back end is compiled with NGX), DLSS off drops HOOKSHOT_NGX_SDK
@@ -195,7 +196,12 @@ public sealed class BuildRunner
var si = StartInfo(ctx, tools, args, ctx.NgxSdkFolder, dlss);
using var p = ctx.Platform.StartTree(si);
process = p;
try { if (ctx.IsWindows) p.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception) { }
// (Triforce, 11-22, the performance audit's OS-57, after Source A's) The build tools run at normal priority;
// below normal, as every build was before, only with HOOKSHOT_LOW_PRIORITY=1. Source A's reason, a report it
// did not measure: below normal, Windows kept the steps that are one process (the read, the lift) on a hybrid
// Intel CPU's efficiency cores while the performance cores idled.
if (Environment.GetEnvironmentVariable("HOOKSHOT_LOW_PRIORITY") == "1")
try { if (ctx.IsWindows) p.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception) { }
try { p.StandardInput.Close(); } catch (Exception) { }
p.ErrorDataReceived += (_, e) => { if (e.Data != null) Take(e.Data); };
p.BeginErrorReadLine();

View File

@@ -115,6 +115,10 @@ public static class BuildEstimator
{
GpuVendor.Nvidia => (TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(20)),
GpuVendor.Amd => (TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(120)),
// ((Triforce, 11-22) Intel's Arc cards: an A750's preparation took 4.3 h on v0.6.0 (#bug-tracker "Intel Arc A750 current
// state", 12 threads), an A770's 11 h; with the compute warm cut to the listed programs (RX_VK_WARM_COMPUTES) a
// re-preparation is over an hour shorter. The 10 to 40 minutes before had the time left show minutes for hours)
GpuVendor.Intel => (TimeSpan.FromMinutes(60), TimeSpan.FromMinutes(240)),
_ => (TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(40)),
};
@@ -136,6 +140,13 @@ public static class BuildEstimator
{
if (!shaders) continue;
if (stages != null && stages.Seconds.TryGetValue("shaders", out var ss) && ss > 0) { list.Add(Exact(st.Id, ss)); continue; }
// ((Triforce, 11-22) an update with no update of its own on record: the shader step this PC measured in its
// last build of any kind, before the stated range (an update after a full build prepares the same shaders)
if (history.Stages.LastOrDefault(r => r.Seconds.TryGetValue("shaders", out var any) && any > 0) is { } anyRec)
{
list.Add(Exact(st.Id, anyRec.Seconds["shaders"]));
continue;
}
var (sl, sh) = ShaderRange(gpu);
list.Add(new StageEstimate(st.Id, sl, sh, false));
continue;
@@ -171,9 +182,34 @@ public static class BuildClock
return Unit(low) == Unit(high) ? M(low) + " to " + M(high) + " " + Unit(high) : M(low) + " " + Unit(low) + " to " + M(high) + " " + Unit(high);
}
/// <summary>The time left: the stages after this one by the estimate, and this one by @@eta (compile), else by its progress so
/// far (from 5 %), else its estimate less what it has run. Never below zero; "Almost done" is the App's words under a minute.</summary>
/// <summary>The time left as shown: Estimated, smoothed. Each call counts the shown time down by the time since the last one and
/// moves it toward the new estimate: down within seconds (FallSeconds), up slowly (RiseSeconds) and never faster than half a
/// second a second, so one odd moment never makes it jump. The first call of a build shows the estimate itself. Never below
/// zero; "Almost done" is the App's words under a minute.</summary>
public static TimeSpan Remaining(BuildEstimate estimate, BuildTracker tracker)
{
var raw = Estimated(estimate, tracker).TotalSeconds;
lock (tracker.Gate)
{
var now = tracker.Now;
var shown = raw;
if (tracker.Shown is { } was)
{
var dt = Math.Max(0, (now - was.At).TotalSeconds);
var counted = Math.Max(0, was.Seconds - dt);
shown = raw < counted ? counted + (raw - counted) * (1 - Math.Exp(-dt / FallSeconds))
: Math.Min(counted + (raw - counted) * (1 - Math.Exp(-dt / RiseSeconds)), was.Seconds + MaxRise * dt);
}
tracker.Shown = (shown, now);
return TimeSpan.FromSeconds(Math.Max(0, shown));
}
}
const double FallSeconds = 15, RiseSeconds = 30, MaxRise = 0.5;
/// <summary>The time left now, unsmoothed: the stages after this one by the estimate, and this one by @@eta (compile), else by
/// StageLeft. Never below zero.</summary>
public static TimeSpan Estimated(BuildEstimate estimate, BuildTracker tracker)
{
var at = tracker.Stage is { } s ? BuildStages.IndexOf(s) : -1;
var left = TimeSpan.Zero;
@@ -181,15 +217,63 @@ public static class BuildClock
if (BuildStages.IndexOf(st.Stage) > at) left += st.Mid;
if (at >= 0 && estimate.Of(tracker.Stage!) is { } cur)
{
TimeSpan here;
if (tracker.Stage == "compile" && tracker.EtaSeconds is { } eta) here = TimeSpan.FromSeconds(eta);
else if (tracker.StageProgress >= 0.05) here = tracker.InStage * ((1 - tracker.StageProgress) / tracker.StageProgress);
else here = cur.Mid - tracker.InStage;
var here = tracker.Stage == "compile" && tracker.EtaSeconds is { } eta ? TimeSpan.FromSeconds(eta)
: StageLeft(cur.Mid, tracker.Recent, tracker.StageStarted, tracker.Now);
left += here < TimeSpan.Zero ? TimeSpan.Zero : here;
}
return left;
}
/// <summary>A stage's time left by its progress. The work per step is uneven (the shader step: on AMD and Intel cards the first
/// part, the compute pipelines, can be most of its time, an Arc A750 spent 5175 s of 5858 s on them; one slow shader holds it
/// for minutes), so the rate since the stage began says hours where there is an hour. Instead:
/// the rate of the last WindowSeconds of progress, each wait between two steps counted as at most 4 times the usual one (and
/// at least half a minute), so one slow item is one step late, not a new pace;
/// blended with the estimate's own pace (what it leaves of the stage, at least a tenth of it, and past it a quarter of the
/// time over too), trusting the measured rate more as the stage goes (all of it from TrustFrom of the way);
/// reckoned at the last step: between steps it counts down for one usual wait, then holds, and after a long stall (2
/// minutes, or 4 waits) rises by a quarter of the time.
/// No progress yet: the estimate less the time run (the same floor).</summary>
public static TimeSpan StageLeft(TimeSpan expected, IReadOnlyList<(DateTime At, double Progress)> samples, DateTime began, DateTime now)
{
var e = expected.TotalSeconds;
static double Prior(double e, double run) => Math.Max(e - run, 0.1 * e + 0.25 * Math.Max(0, run - e));
if (samples.Count < 2 || samples[^1].Progress <= 0) return TimeSpan.FromSeconds(Prior(e, Math.Max(0, (now - began).TotalSeconds)));
var (last, p) = samples[^1];
if (p >= 1) return TimeSpan.Zero;
var run = Math.Max(0, (last - began).TotalSeconds);
var rateHere = (1 - p) / Math.Max(1, Prior(e, run));
var recent = RecentRate(samples);
var w = recent == null ? 0 : Math.Clamp(p / TrustFrom, 0, 1);
var rate = w * (recent?.Rate ?? 0) + (1 - w) * rateHere;
var atStep = (1 - p) / rate;
var wait = recent?.Wait ?? 0;
var stall = Math.Max(0, (now - last).TotalSeconds);
var left = atStep - Math.Min(stall, wait) + 0.25 * Math.Max(0, stall - Math.Max(120, 4 * wait));
return TimeSpan.FromSeconds(Math.Max(0, left));
}
const double WindowSeconds = 180, TrustFrom = 0.3;
/// <summary>Progress a second over the last WindowSeconds (each wait capped), and the usual wait between steps (the median of
/// the last 64); null with no step yet.</summary>
static (double Rate, double Wait)? RecentRate(IReadOnlyList<(DateTime At, double Progress)> s)
{
if (s.Count < 2) return null;
var waits = new List<double>();
for (var i = s.Count - 1; i >= 1 && waits.Count < 64; i--) waits.Add((s[i].At - s[i - 1].At).TotalSeconds);
waits.Sort();
var usual = waits[waits.Count / 2];
var cap = Math.Max(30, 4 * usual);
double span = 0, moved = 0;
for (var i = s.Count - 1; i >= 1 && span < WindowSeconds; i--)
{
span += Math.Min(cap, (s[i].At - s[i - 1].At).TotalSeconds);
moved += s[i].Progress - s[i - 1].Progress;
}
return span <= 0 || moved <= 0 ? null : (moved / span, usual);
}
/// <summary>"About 31 minutes left"; "Almost done" under a minute (DESIGN 6 Build).</summary>
public static string LeftText(TimeSpan left) =>
left.TotalSeconds < 60 ? "Almost done" : left.TotalMinutes < 90 ? "About " + (int)Math.Round(left.TotalMinutes) + " minutes left" : "About " + (int)left.TotalHours + " h " + left.Minutes + " min left";