/// <summary> /// Provides access to <see cref="DeviceGetPciInfo_Interop"/> /// without using raw pointers. /// </summary> public unsafe NvmlReturn DeviceGetPciInfo( IntPtr device, out NvmlPciInfo pci) { var result = DeviceGetPciInfo_Interop(device, out var interopResult); if (result == NvmlReturn.NVML_SUCCESS) { var busIdLegacySpan = new Span <byte>( interopResult.BusIdLegacy, (int)NvmlConstants.NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE); var busIdLegacyStrLen = busIdLegacySpan.IndexOf <byte>(0); var busIdLegacy = Encoding.UTF8.GetString( interopResult.BusIdLegacy, busIdLegacyStrLen); var busIdSpan = new Span <byte>( interopResult.BusId, (int)NvmlConstants.NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE); var busIdStrLen = busIdSpan.IndexOf <byte>(0); var busId = Encoding.UTF8.GetString( interopResult.BusId, busIdStrLen); pci = new NvmlPciInfo() { BusIdLegacy = busIdLegacy, Domain = interopResult.Domain, Bus = interopResult.Bus, Device = interopResult.Device, PciDeviceId = interopResult.PciDeviceId, PciSubSystemId = interopResult.PciSubSystemId, BusId = busId, }; } else { pci = default; } return(result); }
public static extern nvmlReturn nvmlDeviceGetPciInfo([In] IntPtr device, [Out] out NvmlPciInfo pci);