public AmdGpuGroup(ISettings settings) { try { _status = AtiAdlxx.ADL_Main_Control_Create(1); _report.AppendLine("AMD Display Library"); _report.AppendLine(); _report.Append("Status: "); _report.AppendLine(_status == AtiAdlxx.ADL_OK ? "OK" : _status.ToString(CultureInfo.InvariantCulture)); _report.AppendLine(); if (_status == AtiAdlxx.ADL_OK) { int numberOfAdapters = 0; AtiAdlxx.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters); _report.Append("Number of adapters: "); _report.AppendLine(numberOfAdapters.ToString(CultureInfo.InvariantCulture)); _report.AppendLine(); if (numberOfAdapters > 0) { AtiAdlxx.ADLAdapterInfo[] adapterInfo = new AtiAdlxx.ADLAdapterInfo[numberOfAdapters]; if (AtiAdlxx.ADL_Adapter_AdapterInfo_Get(adapterInfo) == AtiAdlxx.ADL_OK) { for (int i = 0; i < numberOfAdapters; i++) { AtiAdlxx.ADL_Adapter_Active_Get(adapterInfo[i].AdapterIndex, out var isActive); AtiAdlxx.ADL_Adapter_ID_Get(adapterInfo[i].AdapterIndex, out var adapterId); _report.Append("AdapterIndex: "); _report.AppendLine(i.ToString(CultureInfo.InvariantCulture)); _report.Append("isActive: "); _report.AppendLine(isActive.ToString(CultureInfo.InvariantCulture)); _report.Append("AdapterName: "); _report.AppendLine(adapterInfo[i].AdapterName); _report.Append("UDID: "); _report.AppendLine(adapterInfo[i].UDID); _report.Append("Present: "); _report.AppendLine(adapterInfo[i].Present.ToString(CultureInfo.InvariantCulture)); _report.Append("VendorID: 0x"); _report.AppendLine(adapterInfo[i].VendorID.ToString("X", CultureInfo.InvariantCulture)); _report.Append("BusNumber: "); _report.AppendLine(adapterInfo[i].BusNumber.ToString(CultureInfo.InvariantCulture)); _report.Append("DeviceNumber: "); _report.AppendLine(adapterInfo[i].DeviceNumber.ToString(CultureInfo.InvariantCulture)); _report.Append("FunctionNumber: "); _report.AppendLine(adapterInfo[i].FunctionNumber.ToString(CultureInfo.InvariantCulture)); _report.Append("AdapterID: 0x"); _report.AppendLine(adapterId.ToString("X", CultureInfo.InvariantCulture)); if (!string.IsNullOrEmpty(adapterInfo[i].UDID) && adapterInfo[i].VendorID == AtiAdlxx.ATI_VENDOR_ID) { bool found = false; foreach (AmdGpu gpu in _hardware) { if (gpu.BusNumber == adapterInfo[i].BusNumber && gpu.DeviceNumber == adapterInfo[i].DeviceNumber) { found = true; break; } } if (!found) { _hardware.Add(new AmdGpu( adapterInfo[i].AdapterName.Trim(), adapterInfo[i].AdapterIndex, adapterInfo[i].BusNumber, adapterInfo[i].DeviceNumber, settings)); } } _report.AppendLine(); } } } } } catch (DllNotFoundException) { } catch (EntryPointNotFoundException e) { _report.AppendLine(); _report.AppendLine(e.ToString()); _report.AppendLine(); } }
public AmdGpuGroup(ISettings settings) { try { _status = AtiAdlxx.ADL_Main_Control_Create(1); _report.AppendLine("AMD Display Library"); _report.AppendLine(); _report.Append("Status: "); _report.AppendLine(_status == AtiAdlxx.ADLStatus.ADL_OK ? "OK" : _status.ToString()); _report.AppendLine(); if (_status == AtiAdlxx.ADLStatus.ADL_OK) { int numberOfAdapters = 0; AtiAdlxx.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters); _report.Append("Number of adapters: "); _report.AppendLine(numberOfAdapters.ToString(CultureInfo.InvariantCulture)); _report.AppendLine(); if (numberOfAdapters > 0) { List <AmdGpu> potentialHardware = new(); AtiAdlxx.ADLAdapterInfo[] adapterInfo = new AtiAdlxx.ADLAdapterInfo[numberOfAdapters]; if (AtiAdlxx.ADL_Adapter_AdapterInfo_Get(adapterInfo) == AtiAdlxx.ADLStatus.ADL_OK) { for (int i = 0; i < numberOfAdapters; i++) { AtiAdlxx.ADL_Adapter_Active_Get(adapterInfo[i].AdapterIndex, out int isActive); AtiAdlxx.ADL_Adapter_ID_Get(adapterInfo[i].AdapterIndex, out int adapterId); _report.Append("AdapterIndex: "); _report.AppendLine(i.ToString(CultureInfo.InvariantCulture)); _report.Append("isActive: "); _report.AppendLine(isActive.ToString(CultureInfo.InvariantCulture)); _report.Append("AdapterName: "); _report.AppendLine(adapterInfo[i].AdapterName); _report.Append("UDID: "); _report.AppendLine(adapterInfo[i].UDID); _report.Append("PNPString: "); _report.AppendLine(adapterInfo[i].PNPString); _report.Append("Present: "); _report.AppendLine(adapterInfo[i].Present.ToString(CultureInfo.InvariantCulture)); _report.Append("VendorID: 0x"); _report.AppendLine(adapterInfo[i].VendorID.ToString("X", CultureInfo.InvariantCulture)); _report.Append("BusNumber: "); _report.AppendLine(adapterInfo[i].BusNumber.ToString(CultureInfo.InvariantCulture)); _report.Append("DeviceNumber: "); _report.AppendLine(adapterInfo[i].DeviceNumber.ToString(CultureInfo.InvariantCulture)); _report.Append("FunctionNumber: "); _report.AppendLine(adapterInfo[i].FunctionNumber.ToString(CultureInfo.InvariantCulture)); _report.Append("AdapterID: 0x"); _report.AppendLine(adapterId.ToString("X", CultureInfo.InvariantCulture)); if (!string.IsNullOrEmpty(adapterInfo[i].UDID) && adapterInfo[i].VendorID == AtiAdlxx.ATI_VENDOR_ID) { potentialHardware.Add(new AmdGpu(adapterInfo[i], settings)); } _report.AppendLine(); } } foreach (IGrouping <string, AmdGpu> amdGpus in potentialHardware.GroupBy(x => $"{x.BusNumber}-{x.DeviceNumber}")) { var amdGpu = amdGpus.OrderByDescending(x => x.Sensors.Length).FirstOrDefault(); if (amdGpu != null) { _hardware.Add(amdGpu); } } } } } catch (DllNotFoundException) { } catch (EntryPointNotFoundException e) { _report.AppendLine(); _report.AppendLine(e.ToString()); _report.AppendLine(); } }