using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using NvAPIWrapper.Native.Attributes; using NvAPIWrapper.Native.General.Structures; using NvAPIWrapper.Native.Helpers; using NvAPIWrapper.Native.Interfaces; using NvAPIWrapper.Native.Interfaces.GPU; namespace NvAPIWrapper.Native.GPU.Structures { /// [StructLayout(LayoutKind.Sequential, Pack = 8)] [StructureVersion(3)] public struct PerformanceStatesInfoV3 : IInitializable, IPerformanceStatesInfo { internal const int MaxPerformanceStates = PerformanceStatesInfoV2.MaxPerformanceStates; internal const int MaxPerformanceStateClocks = PerformanceStatesInfoV2.MaxPerformanceStateClocks; internal const int MaxPerformanceStateVoltages = PerformanceStatesInfoV2.MaxPerformanceStateVoltages; internal StructureVersion _Version; internal uint _Flags; internal uint _NumberOfPerformanceStates; internal uint _NumberOfClocks; internal uint _NumberOfVoltages; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] internal PerformanceStatesInfoV2.PerformanceState[] _PerformanceStates; /// public bool IsPerformanceMonitorEnable { get => _Flags.GetBit(0); } /// public bool IsCapableOfDynamicPerformance { get => _Flags.GetBit(1); } /// public bool IsDynamicPerformanceEnable { get => _Flags.GetBit(2); } /// /// Gets an array of valid and available performance states information /// public PerformanceStatesInfoV2.PerformanceState[] PerformanceStates { get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); } /// IPerformanceState[] IPerformanceStatesInfo.PerformanceStates { get => PerformanceStates.Cast().ToArray(); } /// /// Gets a dictionary of valid and available performance states and their voltage information as an array /// public IReadOnlyDictionary PerformanceStatesVoltages { get { var voltages = (int) _NumberOfVoltages; return PerformanceStates.ToDictionary( state => state.StateId, state => state._Voltages.Take(voltages).ToArray() ); } } /// IReadOnlyDictionary IPerformanceStatesInfo. PerformanceStatesVoltages { get { return PerformanceStatesVoltages.ToDictionary( pair => pair.Key, pair => pair.Value.Cast().ToArray() ); } } /// /// Gets a dictionary of valid and available performance states and their clock information as an array /// public IReadOnlyDictionary PerformanceStatesClocks { get { var clocks = (int) _NumberOfClocks; return PerformanceStates.ToDictionary( state => state.StateId, state => state._Clocks.Take(clocks).ToArray() ); } } /// IReadOnlyDictionary IPerformanceStatesInfo. PerformanceStatesClocks { get { return PerformanceStatesClocks.ToDictionary( pair => pair.Key, pair => pair.Value.Cast().ToArray() ); } } } }