private bool GetCoolerSettings(int busId, out NvCoolerSettings info) { info = new NvCoolerSettings(); if (NvapiNativeMethods.NvGetCoolerSettings == null) { return(false); } if (_nvGetCoolerSettingsNotSupporteds.Contains(busId)) { return(false); } info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings)))); try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL; var r = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info); if (r != NvStatus.NVAPI_OK) { if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED) { _nvGetCoolerSettingsNotSupporteds.Add(busId); } Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}"); return(false); } return(true); } catch { } return(false); }
private bool NvPowerPoliciesSetStatus(int busId, ref NvGpuPowerStatus info) { if (NvapiNativeMethods.NvPowerPoliciesSetStatus == null) { return(false); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPowerStatus)))); var r = NvapiNativeMethods.NvPowerPoliciesSetStatus(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvPowerPoliciesSetStatus)} {r}"); } if (r == NvStatus.NVAPI_OK) { return(true); } } catch { } return(false); }
private bool NvThermalPoliciesSetLimit(int busId, ref NvGpuThermalLimit info) { if (NvapiNativeMethods.NvThermalPoliciesSetLimit == null) { return(false); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuThermalLimit)))); var r = NvapiNativeMethods.NvThermalPoliciesSetLimit(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvThermalPoliciesSetLimit)} {r.ToString()}"); } if (r == NvStatus.NVAPI_OK) { return(true); } } catch { } return(false); }
public bool GetMemoryClock(int gpuIndex, out int memoryClock, out int iVddc) { memoryClock = 0; iVddc = 0; try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(false); } ADLODNPerformanceLevelsX2 info = ADLODNPerformanceLevelsX2.Create(); var r = AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_MemoryClocksX2_Get)} {r.ToString()}"); return(false); } int index = 0; for (int i = 0; i < info.aLevels.Length; i++) { if (info.aLevels[i].iEnabled != 0) { index = i; } Write.DevWarn("GetMemoryClock " + info.aLevels[i].ToString()); } memoryClock = info.aLevels[index].iClock * 10; iVddc = info.aLevels[index].iVddc; return(true); } catch { return(false); } }
public void GetVersion(out Version driverVersion, out string nvmlVersion) { driverVersion = new Version(); nvmlVersion = "0.0"; if (!NvmlInit()) { return; } try { var r = NvmlNativeMethods.nvmlSystemGetDriverVersion(out string version); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlSystemGetDriverVersion)} {r.ToString()}"); } r = NvmlNativeMethods.nvmlSystemGetNVMLVersion(out nvmlVersion); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlSystemGetNVMLVersion)} {r.ToString()}"); } if (!string.IsNullOrEmpty(version) && Version.TryParse(version, out Version v)) { driverVersion = v; } if (string.IsNullOrEmpty(nvmlVersion)) { nvmlVersion = "0.0"; } } catch { } }
private bool NvPowerPoliciesGetInfo(int busId, out NvGpuPowerInfo info) { info = new NvGpuPowerInfo(); if (NvapiNativeMethods.NvPowerPoliciesGetInfo == null) { return(false); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPowerInfo)))); var r = NvapiNativeMethods.NvPowerPoliciesGetInfo(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvPowerPoliciesGetInfo)} {r.ToString()}"); return(false); } return(true); } catch { return(false); } }
private bool NvFanCoolersGetControl(int busId, out PrivateFanCoolersControlV1 info) { info = new PrivateFanCoolersControlV1(); if (NvapiNativeMethods.NvFanCoolersGetControl == null) { return(false); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(PrivateFanCoolersControlV1)))); var r = NvapiNativeMethods.NvFanCoolersGetControl(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersGetControl)} {r.ToString()}"); return(false); } return(true); } catch { } return(false); }
private NvGpuClockFrequenciesV2 NvGetAllClockFrequenciesV2(int busId, uint type) { NvGpuClockFrequenciesV2 info = new NvGpuClockFrequenciesV2(); if (NvapiNativeMethods.NvGetAllClockFrequenciesV2 == null) { return(info); } try { info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuClockFrequenciesV2)))); info.ClockType = type; var r = NvapiNativeMethods.NvGetAllClockFrequenciesV2(HandlesByBusId[busId], ref info); if (r != NvStatus.OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvGetAllClockFrequenciesV2)} {r}"); } if (r == NvStatus.OK) { return(info); } } catch { } return(info); }
public bool SetPowerLimit(int gpuIndex, int value) { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(false); } ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting(); try { var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}"); return(false); } #if DEBUG Write.DevWarn($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} result={r.ToString()},iMode={info.iMode.ToString()},iTDPLimit={info.iTDPLimit.ToString()},iMaxOperatingTemperature={info.iMaxOperatingTemperature.ToString()}"); #endif info.iMode = AdlConst.ODNControlType_Manual; info.iTDPLimit = value - 100; r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set)} {r.ToString()}"); return(false); } return(true); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } }
public uint GetPowerUsage(int gpuIndex) { if (!NvmlInit() || !TryGetNvmlDevice(gpuIndex, out nvmlDevice nvmlDevice)) { return(0); } if (_nvmlDeviceGetPowerUsageNotSupporteds.Contains(gpuIndex)) { return(0); } uint power = 0; try { var r = NvmlNativeMethods.nvmlDeviceGetPowerUsage(nvmlDevice, ref power); power = (uint)(power / 1000.0); if (r != nvmlReturn.Success) { if (r == nvmlReturn.NotSupported) { _nvmlDeviceGetPowerUsageNotSupporteds.Add(gpuIndex); } Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetPowerUsage)} {r.ToString()}"); } } catch { } return(power); }
public bool SetMemoryClock(int busId, int mHz, int voltage) { int kHz = mHz * 1000; try { if (NvGetPStateV2(busId, out NvGpuPerfPStates20InfoV2 info)) { info.numPStates = 1; info.numClocks = 1; info.numBaseVoltages = 0; info.pstates[0].clocks[0].domainId = NvGpuPublicClockId.NVAPI_GPU_PUBLIC_CLOCK_MEMORY; info.pstates[0].clocks[0].typeId = NvGpuPerfPState20ClockTypeId.NVAPI_GPU_PERF_PSTATE20_CLOCK_TYPE_SINGLE; info.pstates[0].clocks[0].freqDelta_kHz.value = kHz; var r = NvSetPStateV2(busId, ref info); if (!r) { Write.DevError($"{nameof(SetMemoryClock)} {r}"); } } return(false); } catch { } return(false); }
private bool GetFanCoolersGetStatus(int busId, out PrivateFanCoolersStatusV1 info) { info = new PrivateFanCoolersStatusV1(); if (NvapiNativeMethods.NvFanCoolersGetStatus == null) { return(false); } if (_nvFanCoolersGetStatusNotSupporteds.Contains(busId)) { return(false); } info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(PrivateFanCoolersStatusV1)))); try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } var r = NvapiNativeMethods.NvFanCoolersGetStatus(handle, ref info); if (r != NvStatus.NVAPI_OK) { if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED) { _nvFanCoolersGetStatusNotSupporteds.Add(busId); } Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersGetStatus)} {r.ToString()}"); return(false); } return(true); } catch { } return(false); }
public bool SetTempLimit(int gpuIndex, int value) { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(false); } ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting(); try { var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}"); return(false); } bool isAutoModel = value == 0; info.iMode = isAutoModel ? AdlConst.ODNControlType_Auto : AdlConst.ODNControlType_Manual; info.iMaxOperatingTemperature = isAutoModel ? -1 : value; r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Set)} {r.ToString()}"); return(false); } return(true); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } }
private NvGpuClockFrequenciesV2 NvGetAllClockFrequenciesV2(int busId, uint type) { NvGpuClockFrequenciesV2 info = new NvGpuClockFrequenciesV2(); if (NvapiNativeMethods.NvGetAllClockFrequenciesV2 == null) { return(info); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(info); } info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuClockFrequenciesV2)))); info.ClockType = type; var r = NvapiNativeMethods.NvGetAllClockFrequenciesV2(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvGetAllClockFrequenciesV2)} {r.ToString()}"); } if (r == NvStatus.NVAPI_OK) { return(info); } } catch { } return(info); }
public uint GetFanSpeed(int gpuIndex) { if (!NvmlInit() || !TryGetNvmlDevice(gpuIndex, out nvmlDevice nvmlDevice)) { return(0); } if (_nvmlDeviceGetFanSpeedNotSupporteds.Contains(gpuIndex)) { return(0); } uint fanSpeed = 0; try { var r = NvmlNativeMethods.nvmlDeviceGetFanSpeed(nvmlDevice, ref fanSpeed); if (r != nvmlReturn.Success) { if (r == nvmlReturn.NotSupported) { _nvmlDeviceGetFanSpeedNotSupporteds.Add(gpuIndex); } Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetFanSpeed)} {r.ToString()}"); } } catch { } return(fanSpeed); }
private bool NvSetPStateV1(int busId, ref NvGpuPerfPStates20InfoV1 info) { if (NvapiNativeMethods.NvSetPStateV1 == null) { return(false); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } int len = Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV1)); info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV1)))); var r = NvapiNativeMethods.NvSetPStateV1(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvSetPStateV1)} {r.ToString()}"); } if (r == NvStatus.NVAPI_OK) { return(true); } } catch { } return(false); }
private bool NvGetPStateV2(int busId, out NvGpuPerfPStates20InfoV2 info) { info = new NvGpuPerfPStates20InfoV2(); if (NvapiNativeMethods.NvGetPStateV2 == null) { return(false); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(false); } info.version = (uint)(VERSION2 | (Marshal.SizeOf(typeof(NvGpuPerfPStates20InfoV2)))); var r = NvapiNativeMethods.NvGetPStateV2(handle, ref info); if (r != NvStatus.NVAPI_OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvGetPStateV2)} {r.ToString()}"); return(false); } return(true); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } }
public OverClockRange GetClockRange(int gpuIndex) { OverClockRange result = new OverClockRange(gpuIndex); try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(result); } ADLODNCapabilitiesX2 info = new ADLODNCapabilitiesX2(); var r = AdlNativeMethods.ADL2_OverdriveN_CapabilitiesX2_Get(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_CapabilitiesX2_Get)} {r}"); return(result); } result.PowerCurr = GetPowerLimit(gpuIndex); result.TempCurr = GetTempLimit(gpuIndex); if (GetMemoryClock(gpuIndex, out int memoryClock, out int iVddc)) { result.MemoryClockDelta = memoryClock; result.MemoryVoltage = iVddc; } if (GetCoreClock(gpuIndex, out int coreClock, out iVddc)) { result.CoreClockDelta = coreClock; result.CoreVoltage = iVddc; } result.CoreClockMin = info.sEngineClockRange.iMin * 10; result.CoreClockMax = info.sEngineClockRange.iMax * 10; result.MemoryClockMin = info.sMemoryClockRange.iMin * 10; result.MemoryClockMax = info.sMemoryClockRange.iMax * 10; result.PowerMin = info.power.iMin + 100; result.PowerMax = info.power.iMax + 100; result.PowerDefault = info.power.iDefault + 100; result.TempLimitMin = info.powerTuneTemperature.iMin; result.TempLimitMax = info.powerTuneTemperature.iMax; result.TempLimitDefault = info.powerTuneTemperature.iDefault; result.VoltMin = info.svddcRange.iMin; result.VoltMax = info.svddcRange.iMax; result.VoltDefault = info.svddcRange.iDefault; if (info.fanSpeed.iMax == 0) { result.FanSpeedMin = 0; } else { result.FanSpeedMin = info.fanSpeed.iMin * 100 / info.fanSpeed.iMax; } result.FanSpeedMax = 100; result.FanSpeedDefault = info.fanSpeed.iDefault; #if DEBUG Write.DevWarn($"GetClockRange {result.ToString()}"); #endif } catch (Exception e) { Logger.ErrorDebugLine(e); } return(result); }
private bool SetCooler(int busId, uint value, bool isAutoMode) { #region GTX if (NvapiNativeMethods.NvSetCoolerLevels != null) { try { NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL; NvCoolerLevel info = new NvCoolerLevel() { version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerLevel)))), coolers = new NvCoolerLevelItem[NvapiConst.NVAPI_MAX_COOLERS_PER_GPU] }; info.coolers[0].currentLevel = isAutoMode ? 0 : value; info.coolers[0].currentPolicy = isAutoMode ? NvCoolerPolicy.NVAPI_COOLER_POLICY_AUTO : NvCoolerPolicy.NVAPI_COOLER_POLICY_MANUAL; var r = NvapiNativeMethods.NvSetCoolerLevels(HandlesByBusId[busId], coolerIndex, ref info); if (r != NvStatus.OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvSetCoolerLevels)} {r}"); } else { return(true); } } catch { } } #endregion #region RTX if (NvapiNativeMethods.NvFanCoolersSetControl == null) { return(false); } try { if (NvFanCoolersGetControl(busId, out PrivateFanCoolersControlV1 info)) { for (int i = 0; i < info.FanCoolersControlCount; i++) { info.FanCoolersControlEntries[i].ControlMode = isAutoMode ? FanCoolersControlMode.Auto : FanCoolersControlMode.Manual; info.FanCoolersControlEntries[i].Level = isAutoMode ? 0u : (uint)value; } var r = NvapiNativeMethods.NvFanCoolersSetControl(HandlesByBusId[busId], ref info); if (r != NvStatus.OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersSetControl)} {r}"); return(false); } return(true); } return(false); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } #endregion }
public string GetDriverVersion() { ADLVersionsInfoX2 info = new ADLVersionsInfoX2(); try { var r = AdlNativeMethods.ADL2_Graphics_VersionsX2_Get(context, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Graphics_VersionsX2_Get)} {r}"); } return(info.strCrimsonVersion); } catch { return("0.0"); } }
private bool NvFanCoolersGetControl(int busId, out PrivateFanCoolersControlV1 info) { info = new PrivateFanCoolersControlV1(); if (NvapiNativeMethods.NvFanCoolersGetControl == null) { return(false); } info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(PrivateFanCoolersControlV1)))); var r = NvapiNativeMethods.NvFanCoolersGetControl(HandlesByBusId[busId], ref info); if (r != NvStatus.OK) { Write.DevError($"{nameof(NvapiNativeMethods.NvFanCoolersGetControl)} {r}"); return(false); } return(true); }
public bool SetFanSpeed(int gpuIndex, int value, bool isAutoMode) { try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(false); } AdlStatus r; if (isAutoMode) { r = AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set(context, adapterIndex, 0); if (r != AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive5_FanSpeedToDefault_Set)} {r.ToString()}"); r = AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset(context, adapterIndex); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive6_FanSpeed_Reset)} {r.ToString()}"); } } return(true); } ADLFanSpeedValue info = new ADLFanSpeedValue { SpeedType = AdlConst.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT }; r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Get)} {r.ToString()}"); return(false); } info.FanSpeed = value; r = AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_FanSpeed_Set)} {r.ToString()}"); return(false); } return(true); } catch (Exception e) { Logger.ErrorDebugLine(e); return(false); } }
public uint GetTemperature(int gpuIndex) { if (!NvmlInit() || !TryGetNvmlDevice(gpuIndex, out nvmlDevice nvmlDevice)) { return(0); } uint temp = 0; try { var r = NvmlNativeMethods.nvmlDeviceGetTemperature(nvmlDevice, nvmlTemperatureSensors.Gpu, ref temp); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetTemperature)} {r.ToString()}"); } } catch { } return(temp); }
public uint GetFanSpeed(int gpuIndex) { if (!NvmlInit() || !TryGetNvmlDevice(gpuIndex, out nvmlDevice nvmlDevice)) { return(0); } uint fanSpeed = 0; try { var r = NvmlNativeMethods.nvmlDeviceGetFanSpeed(nvmlDevice, ref fanSpeed); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetFanSpeed)} {r}"); } } catch { } return(fanSpeed); }
public uint GetPowerUsage(int gpuIndex) { if (!NvmlInit() || !TryGetNvmlDevice(gpuIndex, out nvmlDevice nvmlDevice)) { return(0); } uint power = 0; try { var r = NvmlNativeMethods.nvmlDeviceGetPowerUsage(nvmlDevice, ref power); power = (uint)(power / 1000.0); if (r != nvmlReturn.Success) { Write.DevError($"{nameof(NvmlNativeMethods.nvmlDeviceGetPowerUsage)} {r}"); } } catch { } return(power); }
public Version GetDriverVersion() { ADLVersionsInfoX2 info = new ADLVersionsInfoX2(); try { var r = AdlNativeMethods.ADL2_Graphics_VersionsX2_Get(context, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Graphics_VersionsX2_Get)} {r.ToString()}"); } if (string.IsNullOrEmpty(info.strCrimsonVersion) || !Version.TryParse(info.strCrimsonVersion, out Version v)) { return(new Version()); } return(v); } catch { return(new Version()); } }
public ulong GetTotalMemory(int gpuIndex) { try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(0); } ADLMemoryInfo info = new ADLMemoryInfo(); var r = AdlNativeMethods.ADL_Adapter_MemoryInfo_Get(adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Adapter_MemoryInfo_Get)} {r.ToString()}"); return(0); } return(info.MemorySize); } catch { return(0); } }
public int GetTemperature(int gpuIndex) { try { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(0); } ADLTemperature info = new ADLTemperature(); var r = AdlNativeMethods.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL_Overdrive5_Temperature_Get)} {r.ToString()}"); return(0); } return((int)(0.001f * info.Temperature)); } catch { return(0); } }
public uint GetPowerUsage(int gpuIndex) { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(0); } int power = 0; try { var r = AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get(context, adapterIndex, 0, ref power); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_Overdrive6_CurrentPower_Get)} {r.ToString()}"); return(0); } return((uint)(power / 256.0)); } catch { } return(0); }
public int GetTempLimit(int gpuIndex) { if (!TryGpuAdapterIndex(gpuIndex, out int adapterIndex)) { return(0); } ADLODNPowerLimitSetting info = new ADLODNPowerLimitSetting(); try { var r = AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get(context, adapterIndex, ref info); if (r < AdlStatus.ADL_OK) { Write.DevError($"{nameof(AdlNativeMethods.ADL2_OverdriveN_PowerLimit_Get)} {r.ToString()}"); return(0); } return(info.iMaxOperatingTemperature); } catch { return(0); } }