1.1 --- a/Hardware/Nvidia/NvidiaGroup.cs Sat Jun 12 12:15:00 2010 +0000
1.2 +++ b/Hardware/Nvidia/NvidiaGroup.cs Sun Jun 27 10:24:27 2010 +0000
1.3 @@ -53,25 +53,68 @@
1.4 report.AppendLine("NVAPI");
1.5 report.AppendLine();
1.6
1.7 + string version;
1.8 + if (NVAPI.NvAPI_GetInterfaceVersionString(out version) == NvStatus.OK) {
1.9 + report.Append("Version: ");
1.10 + report.AppendLine(version);
1.11 + }
1.12 +
1.13 NvPhysicalGpuHandle[] handles =
1.14 new NvPhysicalGpuHandle[NVAPI.MAX_PHYSICAL_GPUS];
1.15 -
1.16 + int count;
1.17 if (NVAPI.NvAPI_EnumPhysicalGPUs == null) {
1.18 report.AppendLine("Error: NvAPI_EnumPhysicalGPUs not available");
1.19 report.AppendLine();
1.20 return;
1.21 + } else {
1.22 + NvStatus status = NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count);
1.23 + if (status != NvStatus.OK) {
1.24 + report.AppendLine("Status: " + status.ToString());
1.25 + report.AppendLine();
1.26 + return;
1.27 + }
1.28 }
1.29
1.30 - int count;
1.31 - if (NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count) != NvStatus.OK)
1.32 - return;
1.33 + IDictionary<NvPhysicalGpuHandle, NvDisplayHandle> displayHandles =
1.34 + new Dictionary<NvPhysicalGpuHandle, NvDisplayHandle>();
1.35 +
1.36 + if (NVAPI.NvAPI_EnumNvidiaDisplayHandle != null &&
1.37 + NVAPI.NvAPI_GetPhysicalGPUsFromDisplay != null)
1.38 + {
1.39 + NvStatus status = NvStatus.OK;
1.40 + int i = 0;
1.41 + while (status == NvStatus.OK) {
1.42 + NvDisplayHandle displayHandle = new NvDisplayHandle();
1.43 + status = NVAPI.NvAPI_EnumNvidiaDisplayHandle(i, ref displayHandle);
1.44 + i++;
1.45 +
1.46 + if (status == NvStatus.OK) {
1.47 + NvPhysicalGpuHandle[] handlesFromDisplay =
1.48 + new NvPhysicalGpuHandle[NVAPI.MAX_PHYSICAL_GPUS];
1.49 + uint countFromDisplay;
1.50 + if (NVAPI.NvAPI_GetPhysicalGPUsFromDisplay(displayHandle,
1.51 + handlesFromDisplay, out countFromDisplay) == NvStatus.OK) {
1.52 + for (int j = 0; j < countFromDisplay; j++) {
1.53 + if (!displayHandles.ContainsKey(handlesFromDisplay[j]))
1.54 + displayHandles.Add(handlesFromDisplay[j], displayHandle);
1.55 + }
1.56 + }
1.57 + }
1.58 + }
1.59 + }
1.60
1.61 report.Append("Number of GPUs: ");
1.62 - report.AppendLine(count.ToString());
1.63 + report.AppendLine(count.ToString());
1.64 +
1.65 + for (int i = 0; i < count; i++) {
1.66 + NvDisplayHandle displayHandle;
1.67 + if (displayHandles.TryGetValue(handles[i], out displayHandle))
1.68 + hardware.Add(new NvidiaGPU(i, handles[i], displayHandle));
1.69 + else
1.70 + hardware.Add(new NvidiaGPU(i, handles[i], null));
1.71 + }
1.72 +
1.73 report.AppendLine();
1.74 -
1.75 - for (int i = 0; i < count; i++)
1.76 - hardware.Add(new NvidiaGPU(i, handles[i]));
1.77 }
1.78
1.79 public IHardware[] Hardware {
1.80 @@ -84,7 +127,6 @@
1.81 return report.ToString();
1.82 }
1.83
1.84 - public void Close() {
1.85 - }
1.86 + public void Close() { }
1.87 }
1.88 }