public void Start() { APLog.enabled = StartupSettings.Logging; LoggingFrequencyInFrames = StartupSettings.StatsLoggingFrequencyInFrames; if (!StartupSettings.Enable) { AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); return; } if (InitializeSubsystem(StartupSettings.PreferredSubsystem)) { m_Subsystem = StartupSettings.PreferredSubsystem; } else { System.Collections.Generic.List <Provider.AdaptivePerformanceSubsystemDescriptor> perfDescriptors = Provider.AdaptivePerformanceSubsystemRegistry.GetRegisteredDescriptors(); if (perfDescriptors.Count == 0) { APLog.Debug("No Subsystems found and initialized."); } foreach (var perfDesc in perfDescriptors) { var subsystem = perfDesc.Create(); if (InitializeSubsystem(subsystem)) { m_Subsystem = subsystem; break; } } } if (m_Subsystem != null) { m_UseProviderOverallFrameTime = m_Subsystem.Capabilities.HasFlag(Provider.Feature.OverallFrameTime); m_DevicePerfControl = new DevicePerformanceControlImpl(m_Subsystem.PerformanceLevelControl); m_AutoPerformanceLevelController = new AutoPerformanceLevelController(m_DevicePerfControl, PerformanceStatus, ThermalStatus); m_AppLifecycle = m_Subsystem.ApplicationLifecycle; if (!m_Subsystem.Capabilities.HasFlag(Provider.Feature.CpuFrameTime)) { m_CpuFrameTimeProvider = new CpuTimeProvider(); StartCoroutine(InvokeEndOfFrame()); } if (!m_Subsystem.Capabilities.HasFlag(Provider.Feature.GpuFrameTime)) { m_GpuFrameTimeProvider = new GpuTimeProvider(); } m_TemperatureTrend = new TemperatureTrend(m_Subsystem.Capabilities.HasFlag(Provider.Feature.TemperatureTrend)); // Request maximum performance by default if (m_RequestedCpuLevel == Constants.UnknownPerformanceLevel) { m_RequestedCpuLevel = m_DevicePerfControl.MaxCpuPerformanceLevel; } if (m_RequestedGpuLevel == Constants.UnknownPerformanceLevel) { m_RequestedGpuLevel = m_DevicePerfControl.MaxGpuPerformanceLevel; } // Override to get maximum performance by default in 'auto' mode m_NewUserPerformanceLevelRequest = true; if (m_Subsystem.PerformanceLevelControl == null) { m_DevicePerfControl.PerformanceControlMode = PerformanceControlMode.System; } else if (AutomaticPerformanceControl) { m_DevicePerfControl.PerformanceControlMode = PerformanceControlMode.Automatic; } else { m_DevicePerfControl.PerformanceControlMode = PerformanceControlMode.Manual; } ThermalEvent += (ThermalMetrics thermalMetrics) => LogThermalEvent(thermalMetrics); PerformanceBottleneckChangeEvent += (PerformanceBottleneckChangeEventArgs ev) => LogBottleneckEvent(ev); PerformanceLevelChangeEvent += (PerformanceLevelChangeEventArgs ev) => LogPerformanceLevelEvent(ev); UpdateSubsystem(); } AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); }
public void Awake() { APLog.enabled = true; if (AdaptivePerformanceGeneralSettings.Instance == null) { APLog.Debug("No Provider was configured for use. Make sure you added at least one Provider in the Adaptive Performance Settings."); AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); return; } if (!AdaptivePerformanceGeneralSettings.Instance.InitManagerOnStart) { APLog.Debug("Adaptive Performance is disabled via Settings."); AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); return; } var activeLoader = AdaptivePerformanceGeneralSettings.Instance.Manager.ActiveLoaderAs <AdaptivePerformanceLoader>(); if (activeLoader == null) { APLog.Debug("No Active Loader was found. Make sure to select your loader in the Adaptive Performance Settings for this platform."); AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); return; } m_Settings = activeLoader.GetSettings(); if (m_Settings == null) { APLog.Debug("No Settings available. Did the Post Process Buildstep fail?"); AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); return; } AutomaticPerformanceControl = m_Settings.automaticPerformanceMode; LoggingFrequencyInFrames = m_Settings.statsLoggingFrequencyInFrames; APLog.enabled = m_Settings.logging; if (m_Subsystem == null) { var subsystem = (Provider.AdaptivePerformanceSubsystem)activeLoader.GetDefaultSubsystem(); if (subsystem != null) { if (subsystem.initialized) { m_Subsystem = subsystem; APLog.Debug("Subsystem version={0}", m_Subsystem.Version); } else { subsystem.Destroy(); APLog.Debug("Subsystem not initialized."); AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); return; } } } if (m_Subsystem != null) { m_UseProviderOverallFrameTime = m_Subsystem.Capabilities.HasFlag(Provider.Feature.OverallFrameTime); m_DevicePerfControl = new DevicePerformanceControlImpl(m_Subsystem.PerformanceLevelControl); m_AutoPerformanceLevelController = new AutoPerformanceLevelController(m_DevicePerfControl, PerformanceStatus, ThermalStatus); m_AppLifecycle = m_Subsystem.ApplicationLifecycle; if (!m_Subsystem.Capabilities.HasFlag(Provider.Feature.CpuFrameTime)) { m_CpuFrameTimeProvider = new CpuTimeProvider(); StartCoroutine(InvokeEndOfFrame()); } if (!m_Subsystem.Capabilities.HasFlag(Provider.Feature.GpuFrameTime)) { m_GpuFrameTimeProvider = new GpuTimeProvider(); } m_TemperatureTrend = new TemperatureTrend(m_Subsystem.Capabilities.HasFlag(Provider.Feature.TemperatureTrend)); // Request maximum performance by default if (m_RequestedCpuLevel == Constants.UnknownPerformanceLevel) { m_RequestedCpuLevel = m_DevicePerfControl.MaxCpuPerformanceLevel; } if (m_RequestedGpuLevel == Constants.UnknownPerformanceLevel) { m_RequestedGpuLevel = m_DevicePerfControl.MaxGpuPerformanceLevel; } // Override to get maximum performance by default in 'auto' mode m_NewUserPerformanceLevelRequest = true; if (m_Subsystem.PerformanceLevelControl == null) { m_DevicePerfControl.PerformanceControlMode = PerformanceControlMode.System; } else if (AutomaticPerformanceControl) { m_DevicePerfControl.PerformanceControlMode = PerformanceControlMode.Automatic; } else { m_DevicePerfControl.PerformanceControlMode = PerformanceControlMode.Manual; } ThermalEvent += (ThermalMetrics thermalMetrics) => LogThermalEvent(thermalMetrics); PerformanceBottleneckChangeEvent += (PerformanceBottleneckChangeEventArgs ev) => LogBottleneckEvent(ev); PerformanceLevelChangeEvent += (PerformanceLevelChangeEventArgs ev) => LogPerformanceLevelEvent(ev); if (m_Subsystem.Capabilities.HasFlag(Provider.Feature.CpuPerformanceBoost)) { PerformanceBoostChangeEvent += (PerformanceBoostChangeEventArgs ev) => LogBoostEvent(ev); } Indexer = new AdaptivePerformanceIndexer(ref m_Settings); UpdateSubsystem(); } AdaptivePerformanceAnalytics.SendAdaptiveStartupEvent(m_Subsystem); }