diff --git a/src/dxvk/dxvk_device_filter.cpp b/src/dxvk/dxvk_device_filter.cpp index 29f40de7..02d8329e 100644 --- a/src/dxvk/dxvk_device_filter.cpp +++ b/src/dxvk/dxvk_device_filter.cpp @@ -2,7 +2,8 @@ namespace dxvk { - DxvkDeviceFilter::DxvkDeviceFilter() { + DxvkDeviceFilter::DxvkDeviceFilter(DxvkDeviceFilterFlags flags) + : m_flags(flags) { m_matchDeviceName = env::getEnvVar("DXVK_FILTER_DEVICE_NAME"); if (m_matchDeviceName.size() != 0) @@ -16,11 +17,23 @@ namespace dxvk { bool DxvkDeviceFilter::testAdapter(const VkPhysicalDeviceProperties& properties) const { + if (properties.apiVersion < VK_MAKE_VERSION(1, 1, 0)) { + Logger::warn(str::format("Skipping Vulkan 1.0 adapter: ", properties.deviceName)); + return false; + } + if (m_flags.test(DxvkDeviceFilterFlag::MatchDeviceName)) { if (std::string(properties.deviceName).find(m_matchDeviceName) == std::string::npos) return false; } + if (m_flags.test(DxvkDeviceFilterFlag::SkipCpuDevices)) { + if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) { + Logger::warn(str::format("Skipping CPU adapter: ", properties.deviceName)); + return false; + } + } + return true; } diff --git a/src/dxvk/dxvk_device_filter.h b/src/dxvk/dxvk_device_filter.h index a0cb9d04..7b411e6a 100644 --- a/src/dxvk/dxvk_device_filter.h +++ b/src/dxvk/dxvk_device_filter.h @@ -13,6 +13,7 @@ namespace dxvk { */ enum class DxvkDeviceFilterFlag { MatchDeviceName = 0, + SkipCpuDevices = 1, }; using DxvkDeviceFilterFlags = Flags; @@ -30,7 +31,7 @@ namespace dxvk { public: - DxvkDeviceFilter(); + DxvkDeviceFilter(DxvkDeviceFilterFlags flags); ~DxvkDeviceFilter(); /** diff --git a/src/dxvk/dxvk_instance.cpp b/src/dxvk/dxvk_instance.cpp index 8af4a051..262bef63 100644 --- a/src/dxvk/dxvk_instance.cpp +++ b/src/dxvk/dxvk_instance.cpp @@ -154,8 +154,6 @@ namespace dxvk { std::vector> DxvkInstance::queryAdapters() { - DxvkDeviceFilter filter; - uint32_t numAdapters = 0; if (m_vki->vkEnumeratePhysicalDevices(m_vki->instance(), &numAdapters, nullptr) != VK_SUCCESS) throw DxvkError("DxvkInstance::enumAdapters: Failed to enumerate adapters"); @@ -163,15 +161,22 @@ namespace dxvk { std::vector adapters(numAdapters); if (m_vki->vkEnumeratePhysicalDevices(m_vki->instance(), &numAdapters, adapters.data()) != VK_SUCCESS) throw DxvkError("DxvkInstance::enumAdapters: Failed to enumerate adapters"); - - std::vector> result; - for (uint32_t i = 0; i < numAdapters; i++) { - VkPhysicalDeviceProperties deviceProperties; - m_vki->vkGetPhysicalDeviceProperties(adapters[i], &deviceProperties); - if (deviceProperties.apiVersion < VK_MAKE_VERSION(1, 1, 0)) - Logger::warn(str::format("Skipping Vulkan 1.0 adapter: ", deviceProperties.deviceName)); - else if (filter.testAdapter(deviceProperties)) + std::vector deviceProperties(numAdapters); + DxvkDeviceFilterFlags filterFlags = 0; + + for (uint32_t i = 0; i < numAdapters; i++) { + m_vki->vkGetPhysicalDeviceProperties(adapters[i], &deviceProperties[i]); + + if (deviceProperties[i].deviceType != VK_PHYSICAL_DEVICE_TYPE_CPU) + filterFlags.set(DxvkDeviceFilterFlag::SkipCpuDevices); + } + + DxvkDeviceFilter filter(filterFlags); + std::vector> result; + + for (uint32_t i = 0; i < numAdapters; i++) { + if (filter.testAdapter(deviceProperties[i])) result.push_back(new DxvkAdapter(m_vki, adapters[i])); }