From f7b3b9ca5c389ecff0820708f8c21c12f84fa0ca Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 3 Dec 2018 21:18:19 +0100 Subject: [PATCH] [dxvk] Add new methods to find adapters by LUID or device ID Co-authored-by: Zhiyi Zhang --- src/dxvk/dxvk_instance.cpp | 25 +++++++++++++++++++++++++ src/dxvk/dxvk_instance.h | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/dxvk/dxvk_instance.cpp b/src/dxvk/dxvk_instance.cpp index 86999cbb6..705c7429a 100644 --- a/src/dxvk/dxvk_instance.cpp +++ b/src/dxvk/dxvk_instance.cpp @@ -37,6 +37,31 @@ namespace dxvk { ? m_adapters[index] : nullptr; } + + + Rc DxvkInstance::findAdapterByLuid(const void* luid) const { + for (const auto& adapter : m_adapters) { + const auto& props = adapter->devicePropertiesExt().coreDeviceId; + + if (props.deviceLUIDValid && !std::memcmp(luid, props.deviceLUID, VK_LUID_SIZE)) + return adapter; + } + + return nullptr; + } + + + Rc DxvkInstance::findAdapterByDeviceId(uint16_t vendorId, uint16_t deviceId) const { + for (const auto& adapter : m_adapters) { + const auto& props = adapter->deviceProperties(); + + if (props.vendorID == vendorId + && props.deviceID == deviceId) + return adapter; + } + + return nullptr; + } VkInstance DxvkInstance::createInstance() { diff --git a/src/dxvk/dxvk_instance.h b/src/dxvk/dxvk_instance.h index 200942cf3..154f37df5 100644 --- a/src/dxvk/dxvk_instance.h +++ b/src/dxvk/dxvk_instance.h @@ -48,6 +48,26 @@ namespace dxvk { Rc enumAdapters( uint32_t index) const; + /** + * \brief Finds adapter by LUID + * + * \param [in] luid Pointer to LUID + * \returns Matching adapter, if any + */ + Rc findAdapterByLuid( + const void* luid) const; + + /** + * \brief Finds adapter by device IDs + * + * \param [in] vendorId Vendor ID + * \param [in] deviceId Device ID + * \returns Matching adapter, if any + */ + Rc findAdapterByDeviceId( + uint16_t vendorId, + uint16_t deviceId) const; + /** * \brief Retrieves configuration options *