15 private float _renderScale = 1f;
27 if (!
float.IsFinite(value) || value <= 0)
28 throw new ArgumentOutOfRangeException(nameof(value),
"RenderScale must be finite and positive.");
30 if (_renderScale == value)
33 var surfaces = RenderSurfaceHostRegistry.Snapshot();
36 foreach (var surface
in surfaces)
38 if (surface.RenderSurfaceAdapter is { } adapter)
47 foreach (var surface
in surfaces)
48 surface.RequestRenderScale(value);
57 get => _renderScalingFilter;
60 if (!Enum.IsDefined(value))
61 throw new ArgumentOutOfRangeException(nameof(value));
63 _renderScalingFilter = value;
65 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
66 surface.InvalidatePresentation();
70 private int _targetFPS = 60;
89 _targetFPS = value < 0 ? 0 : value;
92 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
95 gpuBb.TargetFps = _targetFPS;
100 private int _timerDrivenSimulationRate = 120;
109 get => _timerDrivenSimulationRate;
110 set => _timerDrivenSimulationRate = Math.Max(1, value);
113 private int _maxTimerDrivenSimulationSteps = 8;
123 get => _maxTimerDrivenSimulationSteps;
124 set => _maxTimerDrivenSimulationSteps = Math.Max(1, value);
127 private float _startInitializationWaitTimeout = 30f;
139 get => _startInitializationWaitTimeout;
140 set => _startInitializationWaitTimeout =
141 !
float.IsFinite(value) || value <= 0f
143 : Math.Min(value, (
float)TimeSpan.MaxValue.TotalSeconds);
146 private bool _vSync =
true;
179 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
182 gpuBb.VSync = _vSync;
187 private int _msaaSampleCount = 1;
218 get => _msaaSampleCount;
221 _msaaSampleCount = value < 1 ? 1 : value;
224 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
227 gpuBb.MsaaSampleCount = _msaaSampleCount;
232 private double _samplingTimeForCPS = 1.5;
243 "Legacy CPS/FPS sampling is deprecated. Use Engine.Profiler.Configure(...) for runtime telemetry.",
244 DiagnosticId =
"GOND0001")]
247 get => _samplingTimeForCPS;
248 set => _samplingTimeForCPS = value < 0 ? 0 : value;
259 "Legacy CPS/FPS sampling is deprecated. Use Engine.Profiler.Configure(...) for runtime telemetry.",
260 DiagnosticId =
"GOND0001")]
266 internal double LegacyCpsSamplingTime
268 get => _samplingTimeForCPS;
269 set => _samplingTimeForCPS = value < 0 ? 0 : value;
275 internal long LegacyCpsSamplingTicks =>
276 (long)(_samplingTimeForCPS * HighResTimer.TicksPerSecond);
285 private double _gamepadConnectionUpdateFrequencyHz = 0.2;
297 get => _gamepadConnectionUpdateFrequencyHz;
298 set => _gamepadConnectionUpdateFrequencyHz =
299 double.IsFinite(value) && value > 0d ? value : 0d;
302 private double _gamepadPollFrequencyHz = 60d;
313 get => _gamepadPollFrequencyHz;
314 set => _gamepadPollFrequencyHz =
315 double.IsFinite(value) && value > 0d ? value : 0d;
357 private int _loggingQueueCapacity = 8192;
370 get => _loggingQueueCapacity;
374 throw new ArgumentOutOfRangeException(nameof(value),
"Capacity must be > 0.");
376 _loggingQueueCapacity = value;
391 #region ConfigurationSections
451 ArgumentException.ThrowIfNullOrWhiteSpace(section);
455 values =
new Dictionary<string, string>();
471 ArgumentException.ThrowIfNullOrWhiteSpace(section);
485 ArgumentException.ThrowIfNullOrWhiteSpace(section);
502 ArgumentException.ThrowIfNullOrWhiteSpace(section);
503 ArgumentException.ThrowIfNullOrWhiteSpace(key);
506 && values.ContainsKey(key);
520 ArgumentException.ThrowIfNullOrWhiteSpace(section);
521 ArgumentException.ThrowIfNullOrWhiteSpace(key);
524 && values.TryGetValue(key, out var value)
537 ArgumentException.ThrowIfNullOrWhiteSpace(section);
538 ArgumentException.ThrowIfNullOrWhiteSpace(key);
539 ArgumentNullException.ThrowIfNull(value);
555 ArgumentException.ThrowIfNullOrWhiteSpace(section);
556 ArgumentException.ThrowIfNullOrWhiteSpace(key);
559 && values.Remove(key);
571 ArgumentException.ThrowIfNullOrWhiteSpace(section);
599 public Dictionary<string, string>?
this[
string section]
603 ArgumentException.ThrowIfNullOrWhiteSpace(section);
611 ArgumentException.ThrowIfNullOrWhiteSpace(section);
636 public string?
this[
string section,
string key]
640 ArgumentException.ThrowIfNullOrWhiteSpace(section);
641 ArgumentException.ThrowIfNullOrWhiteSpace(key);
644 && values.TryGetValue(key, out var value)
650 ArgumentException.ThrowIfNullOrWhiteSpace(section);
651 ArgumentException.ThrowIfNullOrWhiteSpace(key);
665 sectionValues =
new Dictionary<string, string>();
669 sectionValues[key] = value;
673 #endregion ConfigurationSections
Settings used by the engine when cycling.
int LoggingQueueCapacity
Maximum number of queued log events when LoggingMode is EngineLoggingMode.Asynchronous....
bool RemoveConfigurationValue(string section, string key)
Removes a configuration value from the specified section.
RenderScalingFilter RenderScalingFilter
Filtering for the finished Backbuffer image; independent of View.Zoom and tile filtering.
long SamplingTimeForCPSTicks
Total number of system ticks between each legacy CPS sampling.
int TimerDrivenSimulationRate
Gets or sets the number of fixed simulation updates performed per second in timer-driven mode....
bool RemoveConfigurationSection(string section)
Removes the specified configuration section and all key/value pairs contained within it.
double TimeBetweenMouseEvents
Minimum time (in seconds) allowed between Mouse events. Use this to prevent flooding the system with ...
void ClearConfigurationSections()
Removes all configuration sections and all contained key/value pairs.
double TimeBetweenGamepadEvents
Minimum time (in seconds) allowed between Gamepad events. Use this to prevent flooding the system wit...
IReadOnlyDictionary< string, string >? GetConfigurationSection(string section)
Gets a read-only view of all key/value pairs in the specified configuration section.
double GamepadPollFrequencyHz
Gets or sets how often the engine refreshes the state of already-connected gamepads.
float RenderScale
Establishes logical Backbuffer dimensions from current adapter dimensions. Default is one; values abo...
string? GetConfigurationValue(string section, string key, string? defaultValue=null)
Gets a configuration value from the specified section.
float StartInitializationWaitTimeout
Gets or sets how long Engine.Start(SynchronizationContext) waits when another thread is already runni...
List< StateFileMount >? StateFiles
Optional collection of serialized EngineStates to mount at initialization.
void SetConfigurationValue(string section, string key, string value)
Sets a configuration value in the specified section, creating the section if necessary.
Dictionary< string, string > CreateConfigurationSection(string section)
Creates a configuration section if it does not already exist.
EngineLoggingMode LoggingMode
Controls whether engine logging operations are performed synchronously or asynchronously.
double GamepadConnectionUpdateFrequencyHz
Gets or sets how often the engine checks for gamepad connection and disconnection changes.
int MsaaSampleCount
Gets or sets the number of MSAA (multisample anti-aliasing) samples used when creating GPU render-tar...
bool VSync
Gets or sets a value indicating whether vertical synchronisation (vsync) is enabled.
double TimeBetweenKeyboardEvents
Minimum time (in seconds) allowed between Keyboard events. Use this to prevent flooding the system wi...
double SamplingTimeForCPS
Total number of seconds between legacy Cycles Per Second (CPS) calculations. Default is 1....
bool ClearConfigurationSection(string section)
Clears all key/value pairs from the specified configuration section without removing the section itse...
bool FlushAsyncLogsOnShutdown
If true, the engine will attempt to flush queued async log events during shutdown....
bool HasConfigurationSection(string section)
Determines whether the specified configuration section exists.
int TargetFPS
Target screen refresh rate for the Engine. Setting the number lower allows more time for the processo...
int MaxTimerDrivenSimulationSteps
Gets or sets the maximum number of fixed simulation updates that one externally driven Tick() call ma...
Dictionary< string, Dictionary< string, string > > ConfigurationSections
Gets or sets a collection of structured configuration values organized into named sections.
bool HasConfigurationValue(string section, string key)
Determines whether a configuration value exists in the specified section.
double TimeBetweenTouchEvents
Minimum time (in seconds) allowed between Touch events. Use this to prevent flooding the system with ...
Provides a fully GPU-rendered backbuffer implementation using SkiaSharp and OpenGL.
EngineLoggingMode
Specifies the logging mode for the engine.
readonly record struct PresentationTransform(float Scale, SKRect DestinationRect)
Aspect-preserving mapping between logical Backbuffer ScreenPx and adapter pixels.
RenderScalingFilter
Filtering used only when presenting the finished Backbuffer.