mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added NVidia GPU usage
This commit is contained in:
@@ -77,14 +77,14 @@ public class AmdGpuTemperatureProvider : IGpuTemperatureProvider {
|
|||||||
public int? GetGpuUse()
|
public int? GetGpuUse()
|
||||||
{
|
{
|
||||||
if (!IsValid)
|
if (!IsValid)
|
||||||
return -1;
|
return null;
|
||||||
|
|
||||||
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
|
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
|
||||||
return -1;
|
return null;
|
||||||
|
|
||||||
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX];
|
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX];
|
||||||
if (gpuUsage.Supported == 0)
|
if (gpuUsage.Supported == 0)
|
||||||
return -1;
|
return null;
|
||||||
|
|
||||||
return gpuUsage.Value;
|
return gpuUsage.Value;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,19 @@ public class NvidiaGpuTemperatureProvider : IGpuTemperatureProvider
|
|||||||
|
|
||||||
public int? GetGpuUse()
|
public int? GetGpuUse()
|
||||||
{
|
{
|
||||||
return -1;
|
if (!IsValid)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
PhysicalGPU internalGpu = _internalGpu!;
|
||||||
|
|
||||||
|
IUtilizationDomainInfo? gpuUsage = GPUApi.GetUsages(internalGpu.Handle).GPU;
|
||||||
|
|
||||||
|
if (gpuUsage == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return
|
||||||
|
(int)gpuUsage?.Percentage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public static class HardwareMonitor
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user