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:
Erik 2026-07-19 06:29:30 +02:00
parent 47d7086a74
commit 3718e341be
17 changed files with 1103 additions and 225 deletions

View file

@ -91,6 +91,62 @@ public sealed class FramePacingControllerTests
Assert.Equal([25L], waiter.Durations);
}
[Theory]
[InlineData(1L, 10_000_000L, 1L)]
[InlineData(1L, 3L, 3_333_334L)]
[InlineData(6_000L, 1_000_000L, 60_000L)]
[InlineData(1_000L, 1_000L, 10_000_000L)]
public void High_resolution_timer_conversion_rounds_up_without_losing_time(
long durationTicks,
long frequency,
long expectedHundredNanoseconds)
{
Assert.Equal(
expectedHundredNanoseconds,
WindowsHighResolutionFramePacingWaiter.ConvertTicksToHundredNanoseconds(
durationTicks,
frequency));
}
[Fact]
public void High_resolution_timer_conversion_saturates_instead_of_overflowing()
{
Assert.Equal(
long.MaxValue,
WindowsHighResolutionFramePacingWaiter.ConvertTicksToHundredNanoseconds(
long.MaxValue,
clockFrequency: 1));
}
[Fact]
public void Windows_high_resolution_timer_arms_and_disposes_its_handle()
{
if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 17134))
return;
using var timer = WindowsHighResolutionFramePacingWaiter.Create();
timer.Wait(1, System.Diagnostics.Stopwatch.Frequency);
timer.Dispose();
timer.Dispose();
Assert.Throws<ObjectDisposedException>(() => timer.Wait(1, 1));
}
[Fact]
public void Controller_disposes_owned_waiter_exactly_once()
{
var waiter = new DisposableWaiter();
var controller = new FramePacingController(
new FakeClock(frequency: 1_000),
waiter,
ownsWaiter: true);
controller.Dispose();
controller.Dispose();
Assert.Equal(1, waiter.DisposeCount);
}
private sealed class FakeClock(long frequency) : IFramePacingClock
{
public long Frequency { get; } = frequency;
@ -113,4 +169,15 @@ public sealed class FramePacingControllerTests
clock.Timestamp += durationTicks + OvershootTicks;
}
}
private sealed class DisposableWaiter : IFramePacingWaiter, IDisposable
{
public int DisposeCount { get; private set; }
public void Wait(long durationTicks, long clockFrequency)
{
}
public void Dispose() => DisposeCount++;
}
}