[dxvk] Improve device ordering

Make sure that integrated GPUs are preferred over CPU
implementations on systems that have no dedicated GPU.
This commit is contained in:
Philip Rebohle 2021-02-11 14:58:11 +01:00
parent bcadc04932
commit a60916f7ee
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 15 additions and 2 deletions

View File

@ -169,8 +169,21 @@ namespace dxvk {
std::sort(result.begin(), result.end(),
[] (const Rc<DxvkAdapter>& a, const Rc<DxvkAdapter>& b) -> bool {
return a->deviceProperties().deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
&& b->deviceProperties().deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
static const std::array<VkPhysicalDeviceType, 3> deviceTypes = {{
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,
VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU,
}};
uint32_t aRank = deviceTypes.size();
uint32_t bRank = deviceTypes.size();
for (uint32_t i = 0; i < std::min(aRank, bRank); i++) {
if (a->deviceProperties().deviceType == deviceTypes[i]) aRank = i;
if (b->deviceProperties().deviceType == deviceTypes[i]) bRank = i;
}
return aRank < bRank;
});
if (result.size() == 0) {