using System; using System.Linq; using System.Runtime.InteropServices; using NvAPIWrapper.Native.Attributes; using NvAPIWrapper.Native.General.Structures; using NvAPIWrapper.Native.Helpers; using NvAPIWrapper.Native.Interfaces; namespace NvAPIWrapper.Native.GPU.Structures { /// /// Contains information regarding GPU cooler policy table /// [StructLayout(LayoutKind.Sequential, Pack = 8)] [StructureVersion(1)] public struct PrivateCoolerPolicyTableV1 : IInitializable { internal const int MaxNumberOfPolicyLevels = 24; internal StructureVersion _Version; internal CoolerPolicy _Policy; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfPolicyLevels)] internal readonly CoolerPolicyTableEntry[] _TableEntries; /// /// Gets an array of policy table entries /// /// The number of table entries. /// An array of instances. public CoolerPolicyTableEntry[] TableEntries(int count) { return _TableEntries.Take(count).ToArray(); } /// /// Gets the table cooler policy /// public CoolerPolicy Policy { get => _Policy; } /// /// Creates a new instance of /// /// The table cooler policy. /// An array of table entries. public PrivateCoolerPolicyTableV1(CoolerPolicy policy, CoolerPolicyTableEntry[] policyTableEntries) { if (policyTableEntries?.Length > MaxNumberOfPolicyLevels) { throw new ArgumentException($"Maximum of {MaxNumberOfPolicyLevels} policy levels are configurable.", nameof(policyTableEntries)); } if (policyTableEntries == null || policyTableEntries.Length == 0) { throw new ArgumentException("Array is null or empty.", nameof(policyTableEntries)); } this = typeof(PrivateCoolerPolicyTableV1).Instantiate(); _Policy = policy; Array.Copy(policyTableEntries, 0, _TableEntries, 0, policyTableEntries.Length); } /// /// Contains information regarding a clock boost mask /// [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct CoolerPolicyTableEntry { internal uint _EntryId; internal uint _CurrentLevel; internal uint _DefaultLevel; /// /// Gets the entry identification number /// public uint EntryId { get => _EntryId; } /// /// Gets the current level in percentage /// public uint CurrentLevel { get => _CurrentLevel; } /// /// Gets the default level in percentage /// public uint DefaultLevel { get => _DefaultLevel; } /// /// Creates a new instance of . /// /// The entry identification number. /// The current level in percentage. /// The default level in percentage. public CoolerPolicyTableEntry(uint entryId, uint currentLevel, uint defaultLevel) { _EntryId = entryId; _CurrentLevel = currentLevel; _DefaultLevel = defaultLevel; } } } }