fix #225: stabilize render pacing and frame CPU
Replace scheduler-quantized software sleeps with a reusable Windows high-resolution deadline timer, expose pacing in the frame profiler, and make shutdown wake every persistent mesh worker without losing the shared signal. Preserve retail alpha order while using a stable radix, skip duplicate deferred-alpha SSBO packing, pack light sets, cache static selection descriptors, and retire historical material groups at the whole-frame boundary. The fixed dense-Caul sample improved from roughly 9-12 ms CPU to 5.3-6.2 ms without reducing visual quality. Release build succeeds with zero warnings and all 6,300 tests pass with five intentional skips. Three independent retail, architecture, and adversarial reviews are clean; the post-review connected route remains pending because local ACE is offline. Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
parent
47d7086a74
commit
3718e341be
17 changed files with 1103 additions and 225 deletions
|
|
@ -94,6 +94,91 @@ public sealed class RetailAlphaQueueTests
|
|||
Assert.Equal(new[] { 1 }, particles.BatchSizes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Flush_LargeInputMatchesStableDescendingRetailOrder()
|
||||
{
|
||||
var log = new List<string>();
|
||||
var source = new RecordingSource("alpha", log);
|
||||
var queue = new RetailAlphaQueue();
|
||||
var random = new Random(0xAC2013);
|
||||
float[] distances = new float[4_096];
|
||||
|
||||
queue.BeginFrame();
|
||||
for (int i = 0; i < distances.Length; i++)
|
||||
{
|
||||
distances[i] = i % 127 switch
|
||||
{
|
||||
0 => float.NaN,
|
||||
1 => float.PositiveInfinity,
|
||||
2 => -0f,
|
||||
3 => -1f,
|
||||
_ => random.Next(0, 64),
|
||||
};
|
||||
queue.Submit(source, i, distances[i]);
|
||||
}
|
||||
queue.EndFrame();
|
||||
|
||||
int[] expected = Enumerable.Range(0, distances.Length)
|
||||
.OrderByDescending(i => NormalizeForReference(distances[i]))
|
||||
.ToArray();
|
||||
Assert.Equal(expected, source.PreparedTokens);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Flush_ExtremeFloatKeysMatchNormalizedRetailOrder()
|
||||
{
|
||||
var log = new List<string>();
|
||||
var source = new RecordingSource("alpha", log);
|
||||
var queue = new RetailAlphaQueue();
|
||||
float[] distances =
|
||||
[
|
||||
1f,
|
||||
float.BitIncrement(1f),
|
||||
float.BitDecrement(1f),
|
||||
float.Epsilon,
|
||||
float.MaxValue,
|
||||
0f,
|
||||
-0f,
|
||||
float.NaN,
|
||||
float.PositiveInfinity,
|
||||
float.NegativeInfinity,
|
||||
-float.Epsilon,
|
||||
1f,
|
||||
];
|
||||
|
||||
queue.BeginFrame();
|
||||
for (int i = 0; i < distances.Length; i++)
|
||||
queue.Submit(source, i, distances[i]);
|
||||
queue.EndFrame();
|
||||
|
||||
int[] expected = Enumerable.Range(0, distances.Length)
|
||||
.OrderByDescending(i => NormalizeForReference(distances[i]))
|
||||
.ToArray();
|
||||
Assert.Equal(expected, source.PreparedTokens);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Flush_EqualDistanceOrderStartsFreshInEachFrameScope()
|
||||
{
|
||||
var log = new List<string>();
|
||||
var source = new RecordingSource("alpha", log);
|
||||
var queue = new RetailAlphaQueue();
|
||||
|
||||
queue.BeginFrame();
|
||||
queue.Submit(source, 1, 12f);
|
||||
queue.Submit(source, 2, 12f);
|
||||
queue.EndFrame();
|
||||
|
||||
queue.BeginFrame();
|
||||
queue.Submit(source, 9, 12f);
|
||||
queue.Submit(source, 8, 12f);
|
||||
queue.EndFrame();
|
||||
|
||||
Assert.Equal(
|
||||
["alpha:1", "alpha:2", "alpha:9", "alpha:8"],
|
||||
log);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeViewerDistance_UsesTransformedGfxSortCenter()
|
||||
{
|
||||
|
|
@ -113,11 +198,15 @@ public sealed class RetailAlphaQueueTests
|
|||
Assert.Equal(2f, cypt, precision: 5);
|
||||
}
|
||||
|
||||
private static float NormalizeForReference(float value)
|
||||
=> float.IsFinite(value) && value > 0f ? value : 0f;
|
||||
|
||||
private sealed class RecordingSource(string name, List<string> log) : IRetailAlphaDrawSource
|
||||
{
|
||||
public List<int> BatchSizes { get; } = new();
|
||||
public int ResetCount { get; private set; }
|
||||
public int PrepareCount { get; private set; }
|
||||
public IReadOnlyList<int> PreparedTokens => _prepared;
|
||||
private int[] _prepared = [];
|
||||
|
||||
public void PrepareAlphaDraws(ReadOnlySpan<int> tokens)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue