15 private float _renderScale = 1f;
27 if (!
float.IsFinite(value) || value <= 0)
28 throw new ArgumentOutOfRangeException(nameof(value),
"RenderScale must be finite and positive.");
29 if (_renderScale == value)
return;
30 var surfaces = RenderSurfaceHostRegistry.Snapshot();
32 foreach (var surface
in surfaces)
34 if (surface.RenderSurfaceAdapter is { } adapter)
41 foreach (var surface
in surfaces)
42 surface.RequestRenderScale(value);
51 get => _renderScalingFilter;
54 if (!Enum.IsDefined(value))
throw new ArgumentOutOfRangeException(nameof(value));
55 _renderScalingFilter = value;
56 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
57 surface.InvalidatePresentation();
61 private int _targetFPS = 60;
80 _targetFPS = value < 0 ? 0 : value;
83 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
86 gpuBb.TargetFps = _targetFPS;
91 private int _timerDrivenSimulationRate = 120;
100 get => _timerDrivenSimulationRate;
101 set => _timerDrivenSimulationRate = Math.Max(1, value);
104 private int _maxTimerDrivenSimulationSteps = 8;
114 get => _maxTimerDrivenSimulationSteps;
115 set => _maxTimerDrivenSimulationSteps = Math.Max(1, value);
118 private float _startInitializationWaitTimeout = 30f;
130 get => _startInitializationWaitTimeout;
131 set => _startInitializationWaitTimeout =
132 !
float.IsFinite(value) || value <= 0f
134 : Math.Min(value, (
float)TimeSpan.MaxValue.TotalSeconds);
137 private bool _vSync =
true;
170 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
173 gpuBb.VSync = _vSync;
178 private int _msaaSampleCount = 1;
209 get => _msaaSampleCount;
212 _msaaSampleCount = value < 1 ? 1 : value;
215 foreach (var surface
in RenderSurfaceHostRegistry.Snapshot())
218 gpuBb.MsaaSampleCount = _msaaSampleCount;
223 private double _samplingTimeForCPS = 1.5;
234 "Legacy CPS/FPS sampling is deprecated. Use Engine.Profiler.Configure(...) for runtime telemetry.",
235 DiagnosticId =
"GOND0001")]
238 get => _samplingTimeForCPS;
239 set => _samplingTimeForCPS = value < 0 ? 0 : value;
250 "Legacy CPS/FPS sampling is deprecated. Use Engine.Profiler.Configure(...) for runtime telemetry.",
251 DiagnosticId =
"GOND0001")]
257 internal double LegacyCpsSamplingTime
259 get => _samplingTimeForCPS;
260 set => _samplingTimeForCPS = value < 0 ? 0 : value;
266 internal long LegacyCpsSamplingTicks =>
267 (long)(_samplingTimeForCPS * HighResTimer.TicksPerSecond);
276 private double _gamepadConnectionUpdateFrequencyHz = 0.2;
288 get => _gamepadConnectionUpdateFrequencyHz;
289 set => _gamepadConnectionUpdateFrequencyHz =
290 double.IsFinite(value) && value > 0d ? value : 0d;
293 private double _gamepadPollFrequencyHz = 60d;
304 get => _gamepadPollFrequencyHz;
305 set => _gamepadPollFrequencyHz =
306 double.IsFinite(value) && value > 0d ? value : 0d;
348 private int _loggingQueueCapacity = 8192;
361 get => _loggingQueueCapacity;
365 throw new ArgumentOutOfRangeException(nameof(value),
"Capacity must be > 0.");
366 _loggingQueueCapacity = value;
381 #region ConfigurationSections
441 ArgumentException.ThrowIfNullOrWhiteSpace(section);
445 values =
new Dictionary<string, string>();
461 ArgumentException.ThrowIfNullOrWhiteSpace(section);
475 ArgumentException.ThrowIfNullOrWhiteSpace(section);
492 ArgumentException.ThrowIfNullOrWhiteSpace(section);
493 ArgumentException.ThrowIfNullOrWhiteSpace(key);
496 && values.ContainsKey(key);
510 ArgumentException.ThrowIfNullOrWhiteSpace(section);
511 ArgumentException.ThrowIfNullOrWhiteSpace(key);
514 && values.TryGetValue(key, out var value)
527 ArgumentException.ThrowIfNullOrWhiteSpace(section);
528 ArgumentException.ThrowIfNullOrWhiteSpace(key);
529 ArgumentNullException.ThrowIfNull(value);
545 ArgumentException.ThrowIfNullOrWhiteSpace(section);
546 ArgumentException.ThrowIfNullOrWhiteSpace(key);
549 && values.Remove(key);
561 ArgumentException.ThrowIfNullOrWhiteSpace(section);
589 public Dictionary<string, string>?
this[
string section]
593 ArgumentException.ThrowIfNullOrWhiteSpace(section);
601 ArgumentException.ThrowIfNullOrWhiteSpace(section);
626 public string?
this[
string section,
string key]
630 ArgumentException.ThrowIfNullOrWhiteSpace(section);
631 ArgumentException.ThrowIfNullOrWhiteSpace(key);
634 && values.TryGetValue(key, out var value)
640 ArgumentException.ThrowIfNullOrWhiteSpace(section);
641 ArgumentException.ThrowIfNullOrWhiteSpace(key);
654 sectionValues =
new Dictionary<string, string>();
658 sectionValues[key] = value;
662 #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.