-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: score gpu and rank before check physical device suitability to find the best gpu for rending #29
Fix: score gpu and rank before check physical device suitability to find the best gpu for rending #29
Changes from 1 commit
f4a92cf
91310ed
575acde
ee70114
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,24 +323,28 @@ void Pilot::PVulkanContext::initializePhysicalDevice() | |
std::vector<VkPhysicalDevice> physical_devices(physical_device_count); | ||
vkEnumeratePhysicalDevices(_instance, &physical_device_count, physical_devices.data()); | ||
|
||
std::vector<std::pair<int,VkPhysicalDevice>> ranked_physical_devices; | ||
for(const auto& device : physical_devices) { | ||
std::vector<std::pair<int, VkPhysicalDevice>> ranked_physical_devices; | ||
for (const auto& device : physical_devices) | ||
{ | ||
VkPhysicalDeviceProperties physical_device_properties; | ||
vkGetPhysicalDeviceProperties(device, &physical_device_properties); | ||
int score = 0; | ||
|
||
if(physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { | ||
score += 1000; | ||
} else if(physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) { | ||
if (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) | ||
{ | ||
score += 1000; | ||
} | ||
else if (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) | ||
{ | ||
score += 100; | ||
} | ||
|
||
ranked_physical_devices.push_back({score,device}); | ||
ranked_physical_devices.push_back({score, device}); | ||
} | ||
|
||
std::sort(ranked_physical_devices.begin(), ranked_physical_devices.end()); | ||
std::reverse(ranked_physical_devices.begin(), ranked_physical_devices.end()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass a lambda function to std::sort to eliminate the std::reverse function call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done that, thaks for corrected my mistacks about format and coding style |
||
|
||
for (const auto& device : ranked_physical_devices) | ||
{ | ||
if (isDeviceSuitable(device.second)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest following the algorithm of VulkanTutorial, not just considering the device type, but also including the limits, features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see taht. In my previous project (doing that while learning with Vulkan Tutorial) I will enumrate all the features to score gpu, I don't know if that's better.