internal GPUPerformanceStatesInformation( IPerformanceStates20Info states20Info, PerformanceStateId currentPerformanceStateId, PrivatePCIeInfoV2?pciInformation) { IsReadOnly = !states20Info.IsEditable; GlobalVoltages = states20Info.GeneralVoltages .Select(entry => new GPUPerformanceStateVoltage(entry)) .ToArray(); var clocks = states20Info.Clocks; var baseVoltages = states20Info.Voltages; PerformanceStates = states20Info.PerformanceStates.Select((state20, i) => { PCIeInformation statePCIeInfo = null; if (pciInformation != null && pciInformation.Value.PCIePerformanceStateInfos.Length > i) { statePCIeInfo = new PCIeInformation(pciInformation.Value.PCIePerformanceStateInfos[i]); } return(new GPUPerformanceState( i, state20, clocks[state20.StateId], baseVoltages[state20.StateId], statePCIeInfo )); }).ToArray(); CurrentPerformanceState = PerformanceStates.FirstOrDefault(performanceState => performanceState.StateId == currentPerformanceStateId); }
/// <summary> /// Creates a new instance of <see cref="PerformanceState20" />. /// </summary> /// <param name="stateId">The performance identification number.</param> /// <param name="clocks">The list of clock entries.</param> /// <param name="baseVoltages">The list of base voltages.</param> public PerformanceState20( PerformanceStateId stateId, PerformanceStates20ClockEntryV1[] clocks, PerformanceStates20BaseVoltageEntryV1[] baseVoltages) { if (clocks?.Length > MaxPerformanceStatesClocks) { throw new ArgumentException( $"Maximum of {MaxPerformanceStatesClocks} clocks are configurable.", nameof(clocks) ); } if (clocks == null) { throw new ArgumentNullException(nameof(clocks)); } if (baseVoltages?.Length > MaxPerformanceStatesBaseVoltages) { throw new ArgumentException( $"Maximum of {MaxPerformanceStatesBaseVoltages} base voltages are configurable.", nameof(baseVoltages) ); } if (baseVoltages == null) { throw new ArgumentNullException(nameof(baseVoltages)); } this = typeof(PerformanceState20).Instantiate <PerformanceState20>(); _Id = stateId; Array.Copy(clocks, 0, _Clocks, 0, clocks.Length); Array.Copy(baseVoltages, 0, _BaseVoltages, 0, baseVoltages.Length); }