using System.Runtime.InteropServices; using NvAPIWrapper.Native.Helpers; using NvAPIWrapper.Native.Interfaces.GPU; namespace NvAPIWrapper.Native.GPU.Structures { /// [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct PerformanceStates20ClockEntryV1 : IPerformanceStates20ClockEntry { internal PublicClockDomain _DomainId; internal PerformanceStates20ClockType _ClockType; internal uint _Flags; internal PerformanceStates20ParameterDelta _FrequencyDeltaInkHz; internal PerformanceStates20ClockDependentInfo _ClockDependentInfo; /// /// Creates a new instance of /// /// The public clock domain. /// The base value delta. public PerformanceStates20ClockEntryV1( PublicClockDomain domain, PerformanceStates20ParameterDelta valueDelta) : this() { _DomainId = domain; _FrequencyDeltaInkHz = valueDelta; } /// /// Creates a new instance of /// /// The public clock domain. /// The type of the clock frequency. /// The base value delta. public PerformanceStates20ClockEntryV1( PublicClockDomain domain, PerformanceStates20ClockType clockType, PerformanceStates20ParameterDelta valueDelta) : this(domain, valueDelta) { _ClockType = clockType; } /// /// Creates a new instance of /// /// The public clock domain. /// The base value delta. /// The clock frequency value. // ReSharper disable once TooManyDependencies public PerformanceStates20ClockEntryV1( PublicClockDomain domain, PerformanceStates20ParameterDelta valueDelta, PerformanceStates20ClockDependentSingleFrequency singleFrequency) : this(domain, PerformanceStates20ClockType.Single, valueDelta) { _ClockDependentInfo = new PerformanceStates20ClockDependentInfo(singleFrequency); } /// /// Creates a new instance of /// /// The public clock domain. /// The base value delta. /// The clock frequency range value. // ReSharper disable once TooManyDependencies public PerformanceStates20ClockEntryV1( PublicClockDomain domain, PerformanceStates20ParameterDelta valueDelta, PerformanceStates20ClockDependentFrequencyRange frequencyRange) : this(domain, PerformanceStates20ClockType.Range, valueDelta) { _ClockDependentInfo = new PerformanceStates20ClockDependentInfo(frequencyRange); } /// public PublicClockDomain DomainId { get => _DomainId; } /// public PerformanceStates20ClockType ClockType { get => _ClockType; } /// public bool IsEditable { get => _Flags.GetBit(0); } /// public PerformanceStates20ParameterDelta FrequencyDeltaInkHz { get => _FrequencyDeltaInkHz; set => _FrequencyDeltaInkHz = value; } /// IPerformanceStates20ClockDependentSingleFrequency IPerformanceStates20ClockEntry.SingleFrequency { get => _ClockDependentInfo._Single; } /// IPerformanceStates20ClockDependentFrequencyRange IPerformanceStates20ClockEntry.FrequencyRange { get => _ClockDependentInfo._Range; } /// /// Gets the range of clock frequency and related voltage information if present /// public PerformanceStates20ClockDependentSingleFrequency SingleFrequency { get => _ClockDependentInfo._Single; } /// /// Gets the fixed frequency of the clock /// public PerformanceStates20ClockDependentFrequencyRange FrequencyRange { get => _ClockDependentInfo._Range; } /// [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct PerformanceStates20ClockDependentSingleFrequency : IPerformanceStates20ClockDependentSingleFrequency { internal uint _FrequencyInkHz; /// public uint FrequencyInkHz { get => _FrequencyInkHz; } /// /// Creates a new instance of . /// /// The fixed frequency in kHz. public PerformanceStates20ClockDependentSingleFrequency(uint frequencyInkHz) { _FrequencyInkHz = frequencyInkHz; } } /// [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct PerformanceStates20ClockDependentFrequencyRange : IPerformanceStates20ClockDependentFrequencyRange { internal uint _MinimumFrequency; internal uint _MaximumFrequency; internal PerformanceVoltageDomain _VoltageDomainId; internal uint _MinimumVoltage; internal uint _MaximumVoltage; /// /// Creates a new instance of . /// /// The minimum frequency in kHz. /// The maximum frequency in kHz. /// The corresponding voltage domain identification number. /// The minimum voltage in uV. /// The maximum voltage in uV. // ReSharper disable once TooManyDependencies public PerformanceStates20ClockDependentFrequencyRange( uint minimumFrequency, uint maximumFrequency, PerformanceVoltageDomain voltageDomainId, uint minimumVoltage, uint maximumVoltage) : this() { _MinimumFrequency = minimumFrequency; _MaximumFrequency = maximumFrequency; _VoltageDomainId = voltageDomainId; _MinimumVoltage = minimumVoltage; _MaximumVoltage = maximumVoltage; } /// public uint MinimumFrequencyInkHz { get => _MinimumFrequency; } /// public uint MaximumFrequencyInkHz { get => _MaximumFrequency; } /// public PerformanceVoltageDomain VoltageDomainId { get => _VoltageDomainId; } /// public uint MinimumVoltageInMicroVolt { get => _MinimumVoltage; } /// public uint MaximumVoltageInMicroVolt { get => _MaximumVoltage; } } [StructLayout(LayoutKind.Explicit, Pack = 8)] internal struct PerformanceStates20ClockDependentInfo { [FieldOffset(0)] internal PerformanceStates20ClockDependentSingleFrequency _Single; [FieldOffset(0)] internal PerformanceStates20ClockDependentFrequencyRange _Range; public PerformanceStates20ClockDependentInfo( PerformanceStates20ClockDependentSingleFrequency singleFrequency ) : this() { _Single = singleFrequency; } public PerformanceStates20ClockDependentInfo( PerformanceStates20ClockDependentFrequencyRange frequencyRange ) : this() { _Range = frequencyRange; } } } }