diff --git a/include/donut/app/DeviceManager.h b/include/donut/app/DeviceManager.h index 73a1a76..8abb073 100644 --- a/include/donut/app/DeviceManager.h +++ b/include/donut/app/DeviceManager.h @@ -80,6 +80,7 @@ freely, subject to the following restrictions: #include #include +#include namespace donut::app { @@ -169,10 +170,17 @@ namespace donut::app struct AdapterInfo { + typedef std::array UUID; + typedef std::array LUID; + std::string name; uint32_t vendorID = 0; uint32_t deviceID = 0; uint64_t dedicatedVideoMemory = 0; + + std::optional uuid; + std::optional luid; + #if DONUT_WITH_DX11 || DONUT_WITH_DX12 nvrhi::RefCountPtr dxgiAdapter; #endif diff --git a/src/app/dx11/DeviceManager_DX11.cpp b/src/app/dx11/DeviceManager_DX11.cpp index c386e13..19d90f7 100644 --- a/src/app/dx11/DeviceManager_DX11.cpp +++ b/src/app/dx11/DeviceManager_DX11.cpp @@ -268,6 +268,11 @@ bool DeviceManager_DX11::EnumerateAdapters(std::vector& outAdapters adapterInfo.deviceID = desc.DeviceId; adapterInfo.dedicatedVideoMemory = desc.DedicatedVideoMemory; + AdapterInfo::LUID luid; + static_assert(luid.size() == sizeof(desc.AdapterLuid)); + memcpy(luid.data(), &desc.AdapterLuid, luid.size()); + adapterInfo.luid = luid; + outAdapters.push_back(std::move(adapterInfo)); } } diff --git a/src/app/dx12/DeviceManager_DX12.cpp b/src/app/dx12/DeviceManager_DX12.cpp index cc3c678..cca1534 100644 --- a/src/app/dx12/DeviceManager_DX12.cpp +++ b/src/app/dx12/DeviceManager_DX12.cpp @@ -245,6 +245,11 @@ bool DeviceManager_DX12::EnumerateAdapters(std::vector& outAdapters adapterInfo.deviceID = desc.DeviceId; adapterInfo.dedicatedVideoMemory = desc.DedicatedVideoMemory; + AdapterInfo::LUID luid; + static_assert(luid.size() == sizeof(desc.AdapterLuid)); + memcpy(luid.data(), &desc.AdapterLuid, luid.size()); + adapterInfo.luid = luid; + outAdapters.push_back(std::move(adapterInfo)); } } diff --git a/src/app/vulkan/DeviceManager_VK.cpp b/src/app/vulkan/DeviceManager_VK.cpp index 8def393..07a0cdd 100644 --- a/src/app/vulkan/DeviceManager_VK.cpp +++ b/src/app/vulkan/DeviceManager_VK.cpp @@ -1070,7 +1070,12 @@ bool DeviceManager_VK::EnumerateAdapters(std::vector& outAdapters) for (auto physicalDevice : devices) { - vk::PhysicalDeviceProperties properties = physicalDevice.getProperties(); + vk::PhysicalDeviceProperties2 properties2; + vk::PhysicalDeviceIDProperties idProperties; + properties2.pNext = &idProperties; + physicalDevice.getProperties2(&properties2); + + auto const& properties = properties2.properties; AdapterInfo adapterInfo; adapterInfo.name = properties.deviceName.data(); @@ -1079,6 +1084,19 @@ bool DeviceManager_VK::EnumerateAdapters(std::vector& outAdapters) adapterInfo.vkPhysicalDevice = physicalDevice; adapterInfo.dedicatedVideoMemory = 0; + AdapterInfo::UUID uuid; + static_assert(uuid.size() == idProperties.deviceUUID.size()); + memcpy(uuid.data(), idProperties.deviceUUID.data(), uuid.size()); + adapterInfo.uuid = uuid; + + if (idProperties.deviceLUIDValid) + { + AdapterInfo::LUID luid; + static_assert(luid.size() == idProperties.deviceLUID.size()); + memcpy(luid.data(), idProperties.deviceLUID.data(), luid.size()); + adapterInfo.luid = luid; + } + // Go through the memory types to figure out the amount of VRAM on this physical device. vk::PhysicalDeviceMemoryProperties memoryProperties = physicalDevice.getMemoryProperties(); for (uint32_t heapIndex = 0; heapIndex < memoryProperties.memoryHeapCount; ++heapIndex)