public NvidiaGroup() { if (!NVAPI.IsAvailable) { return; } NvPhysicalGpuHandle[] handles = new NvPhysicalGpuHandle[NVAPI.MAX_PHYSICAL_GPUS]; int count; if (NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count) != NvStatus.OK) { return; } for (int i = 0; i < count; i++) { string gpuName; NVAPI.NvAPI_GPU_GetFullName(handles[i], out gpuName); if (gpuName != null && gpuName.Trim() != "") { hardware.Add(new NvidiaGPU(i, handles[i])); } } }
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle) { try { string gpuName; if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) { this.name = "NVIDIA " + gpuName.Trim(); } else { this.name = "NVIDIA"; } this.icon = Utilities.EmbeddedResources.GetImage("nvidia.png"); this.adapterIndex = adapterIndex; this.handle = handle; NvGPUThermalSettings settings = GetThermalSettings(); temperatures = new Sensor[settings.Count]; for (int i = 0; i < temperatures.Length; i++) { NvSensor sensor = settings.Sensor[i]; string name; switch (sensor.Target) { case NvThermalTarget.BOARD: name = "GPU Board"; break; case NvThermalTarget.GPU: name = "GPU Core"; break; case NvThermalTarget.MEMORY: name = "GPU Memory"; break; case NvThermalTarget.POWER_SUPPLY: name = "GPU Power Supply"; break; case NvThermalTarget.UNKNOWN: name = "GPU Unknown"; break; default: name = "GPU"; break; } temperatures[i] = new Sensor(name, i, sensor.DefaultMaxTemp, SensorType.Temperature, this); ActivateSensor(temperatures[i]); } int value; if (NVAPI.NvAPI_GPU_GetTachReading != null && NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK) { if (value > 0) { fan = new Sensor("GPU", 0, SensorType.Fan, this); ActivateSensor(fan); } } available = temperatures.Length > 0 || fan != null; } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message + "\n" + e.StackTrace); } }
private static string GetName(NvPhysicalGpuHandle handle) { string gpuName; if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) { return("NVIDIA " + gpuName.Trim()); } return("NVIDIA"); }
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle, NvDisplayHandle?displayHandle, ISettings settings) { string gpuName; if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) { this.name = "NVIDIA " + gpuName.Trim(); } else { this.name = "NVIDIA"; } this.adapterIndex = adapterIndex; this.handle = handle; this.displayHandle = displayHandle; NvGPUThermalSettings thermalSettings = GetThermalSettings(); temperatures = new Sensor[thermalSettings.Count]; for (int i = 0; i < temperatures.Length; i++) { NvSensor sensor = thermalSettings.Sensor[i]; string name; switch (sensor.Target) { case NvThermalTarget.BOARD: name = "GPU Board"; break; case NvThermalTarget.GPU: name = "GPU Core"; break; case NvThermalTarget.MEMORY: name = "GPU Memory"; break; case NvThermalTarget.POWER_SUPPLY: name = "GPU Power Supply"; break; case NvThermalTarget.UNKNOWN: name = "GPU Unknown"; break; default: name = "GPU"; break; } temperatures[i] = new Sensor(name, i, SensorType.Temperature, this, new ParameterDescription[0], settings); ActivateSensor(temperatures[i]); } int value; if (NVAPI.NvAPI_GPU_GetTachReading != null && NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK) { if (value > 0) { fan = new Sensor("GPU", 0, SensorType.Fan, this, settings); ActivateSensor(fan); } } clocks = new Sensor[3]; clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this, settings); clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings); clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this, settings); for (int i = 0; i < clocks.Length; i++) { ActivateSensor(clocks[i]); } loads = new Sensor[3]; loads[0] = new Sensor("GPU Core", 0, SensorType.Load, this, settings); loads[1] = new Sensor("GPU Memory Controller", 1, SensorType.Load, this, settings); loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this, settings); memoryLoad = new Sensor("GPU Memory", 3, SensorType.Load, this, settings); control = new Sensor("GPU Fan", 0, SensorType.Control, this, settings); }