using System; namespace UnityEngine.AdaptivePerformance { /// /// Event arguments for performance bottleneck changes. These are used in the . /// public struct PerformanceBottleneckChangeEventArgs { /// /// The performance bottleneck reported in the event. /// public PerformanceBottleneck PerformanceBottleneck { get; set; } } /// /// You can subscribe to the bottleneck event delegate which sends the when the bottleneck changes. /// /// The that describes the performance bottleneck state. public delegate void PerformanceBottleneckChangeHandler(PerformanceBottleneckChangeEventArgs bottleneckEventArgs); /// /// Event arguments for boost changes. These are used in the . /// public struct PerformanceBoostChangeEventArgs { /// /// Is the CPU boosted. /// public bool CpuBoost { get; set; } /// /// Is the GPU boosted /// public bool GpuBoost { get; set; } } /// /// You can subscribe to the boost event delegate which sends the when a boost changes. /// /// The that describes the boost event. public delegate void PerformanceBoostChangeHandler(PerformanceBoostChangeEventArgs boostEventArgs); /// /// Arguments for the performance level change event. These are used in the . /// public struct PerformanceLevelChangeEventArgs { /// /// The new CPU level. /// public int CpuLevel { get; set; } /// /// The difference in CPU levels /// 0 if the previous or new level equals . /// public int CpuLevelDelta { get; set; } /// /// The new GPU level. /// public int GpuLevel { get; set; } /// /// The difference in GPU levels. /// 0 if either the previous or the new level equals . /// public int GpuLevelDelta { get; set; } /// /// The current PerformanceControlMode. See . /// public PerformanceControlMode PerformanceControlMode { get; set; } /// /// True if the change was caused by manual adjustments to or during automatic mode, false otherwise. /// public bool ManualOverride { get; set; } } /// /// You can subscribe to the performance level event delegate which sends the when the performance level changes. /// /// The performance level change event is sent to the delegate via the level change event argument. public delegate void PerformanceLevelChangeHandler(PerformanceLevelChangeEventArgs levelChangeEventArgs); /// /// You can use the performance status interface to obtain performance metrics, frame timing, and subscribe to bottleneck and performance event changes. /// public interface IPerformanceStatus { /// /// Allows you to query the latest performance metrics. /// PerformanceMetrics PerformanceMetrics { get; } /// /// Allows you to query the latest frame timing measurements. /// FrameTiming FrameTiming { get; } /// /// Subscribe to performance events and get updates when the bottleneck changes. /// event PerformanceBottleneckChangeHandler PerformanceBottleneckChangeEvent; /// /// Subscribe to events and get updates when the the current CPU or GPU level changes. /// event PerformanceLevelChangeHandler PerformanceLevelChangeEvent; /// /// Subscribe to events and get updates when the the current CPU or GPU is boosted. /// event PerformanceBoostChangeHandler PerformanceBoostChangeEvent; } /// /// PerformanceMetrics store the current bottleneck, CPU, and GPU levels /// public struct PerformanceMetrics { /// /// Current CPU performance level. /// This value updates once per frame when changes are applied to . /// Value in the range [, ] or . /// /// Current CPU performance level public int CurrentCpuLevel { get; set; } /// /// Current GPU performance level. /// This value updates once per frame when changes are applied to . /// Value in the range [, ] or . /// /// Current GPU performance level public int CurrentGpuLevel { get; set; } /// /// Current performance bottleneck which describes if the program is CPU, GPU, or `Application.targetFrameRate` bound. /// public PerformanceBottleneck PerformanceBottleneck { get; set; } /// /// CPU boosted. /// /// CPU boosted public bool CpuPerformanceBoost { get; set; } /// /// GPU boosted. /// /// GPU boosted public bool GpuPerformanceBoost { get; set; } /// /// Current CPU cluster information information. Updated at application startup. /// /// CPU cluster information public ClusterInfo ClusterInfo { get; set; } } /// /// FrameTiming stores timing information about CPU, GPU, and the overall frame time. /// public struct FrameTiming { /// /// The overall frame time in seconds. /// Returns `-1.0f` if no timing information is available (for example, in the first frame or directly after resume). /// /// Frame time in seconds public float CurrentFrameTime { get; set; } /// /// The overall frame time as an average over the past 100 frames (in seconds). /// Returns -1.0f if no timing information is available (for example, in the first frame or directly after resume). /// /// Frame time in seconds public float AverageFrameTime { get; set; } /// /// Returns the GPU time of the last completely rendered frame (in seconds). /// Returns `-1.0f` if no timing information is available. /// The GPU time only includes the time the GPU spent on rendering a frame (for example, in the first frame or directly after resume). /// /// Frame time in seconds public float CurrentGpuFrameTime { get; set; } /// /// Returns the overall frame time as an average over the past 100 frames (in seconds). /// Returns `-1.0f` if no timing information is available. /// The GPU time only includes the time the GPU spent on rendering a frame (for example, in the first frame or directly after resume). /// /// Frame time value in seconds public float AverageGpuFrameTime { get; set; } /// /// Returns the main thread CPU time of the last frame (in seconds). /// The CPU time includes only time the CPU spent executing Unity's main and/or render threads. /// Returns `-1.0f` if no timing information is available (for example, in the first frame or directly after resume). /// /// Frame time value in seconds public float CurrentCpuFrameTime { get; set; } /// /// Returns the main thread CPU time as an average over the past 100 frames (in seconds). /// Returns `-1.0f` if this is not available (for example, in the first frame or directly after resume). /// The CPU time includes only the time the CPU spent executing Unity's main and/or render threads. /// /// Frame time in seconds public float AverageCpuFrameTime { get; set; } } /// /// The performance bottleneck enum describes what is currently limiting the system. /// public enum PerformanceBottleneck { /// /// Framerate bottleneck is unknown. /// Unknown, /// /// Framerate is limited by CPU processing. /// CPU, /// /// Framerate is limited by GPU processing. /// GPU, /// /// Framerate is limited by `Application.targetFrameRate`. /// In this case, you should consider lowering the application's performance requirements (see ). /// TargetFrameRate } /// /// The cluster info describes the CPU Cluster setup. /// public struct ClusterInfo { /// /// Number of big cores supported by the CPU. /// public int BigCore { get; set; } /// /// Number of medium cores supported by the CPU. /// public int MediumCore { get; set; } /// /// Number of little cores supported by the CPU. /// public int LittleCore { get; set; } } }