namespace AcDream.App.Rendering; /// /// 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. /// 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); } }