acdream/src/AcDream.App/Rendering/FramePacingPolicy.cs
Erik 749e8ceeb1 fix(rendering): bound portal resource lifetime
Separate logical ownership, render publication, and GPU retirement across live entities, landblocks, particles, textures, mesh arenas, portal/UI teardown, and per-frame scratch storage. Add bounded DAT/texture caches, upload budgets, three-frame fence retirement, exact-incarnation appearance reconciliation, frame pacing, and extensive lifetime conformance coverage.\n\nThe seven-destination connected route now cuts peak working/private memory roughly in half, returns Caul to 125-153 FPS locally, and produces no WER or AMD reset.\n\nCo-authored-by: OpenAI Codex <codex@openai.com>
2026-07-18 21:35:16 +02:00

31 lines
1 KiB
C#

namespace AcDream.App.Rendering;
/// <summary>
/// Resolves the user's presentation preference into a bounded render policy.
/// A normal client is never uncapped: disabling VSync selects a software
/// ceiling at the active monitor's refresh rate. Only the explicit startup
/// diagnostic may disable both mechanisms.
/// </summary>
internal readonly record struct FramePacingPolicy(
bool UseVSync,
double? SoftwareLimitHz)
{
internal const double FallbackRefreshHz = 60d;
public static FramePacingPolicy Resolve(
bool requestedVSync,
bool uncappedRendering,
int? monitorRefreshHz)
{
if (uncappedRendering)
return new FramePacingPolicy(UseVSync: false, SoftwareLimitHz: null);
if (requestedVSync)
return new FramePacingPolicy(UseVSync: true, SoftwareLimitHz: null);
double refreshHz = monitorRefreshHz is > 0
? monitorRefreshHz.Value
: FallbackRefreshHz;
return new FramePacingPolicy(UseVSync: false, SoftwareLimitHz: refreshHz);
}
}