-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
after modify, vulcan context will first rank gpu, and give score by device type (discrete gpu, integrated gpu or virtual gpu) then give a score(1000 for discrete gpu, 100 for integrated gpu and 0 for others) then sort by score. In this case, it will first check suitability for better(discrete gpu) first.
Clang-format has been used to foramt file |
Thanks for told me that, file has been formatted by clang-format file.
…------------------ 原始邮件 ------------------
发件人: "BoomingTech/Pilot" ***@***.***>;
发送时间: 2022年4月5日(星期二) 晚上10:47
***@***.***>;
***@***.******@***.***>;
主题: Re: [BoomingTech/Pilot] Fix: score gpu and rank before check physical device suitability to find the best gpu for rending (PR #29)
@hyv1001 commented on this pull request.
In engine/source/runtime/function/render/source/vulkan_manager/context/vulkan_context.cpp:
> @@ -323,11 +323,29 @@ void Pilot::PVulkanContext::initializePhysicalDevice() std::vector<VkPhysicalDevice> physical_devices(physical_device_count); vkEnumeratePhysicalDevices(_instance, &physical_device_count, physical_devices.data()); - for (const auto& device : physical_devices) + std::vector<std::pair<int,VkPhysicalDevice>> ranked_physical_devices; + for(const auto& device : physical_devices) {
please format code with the .clang-format file
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
vkGetPhysicalDeviceProperties(device, &physical_device_properties); | ||
int score = 0; | ||
|
||
if (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) |
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.
} | ||
|
||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done that, thaks for corrected my mistacks about format and coding style
after modify, vulcan context will first rank gpu, and give score by device type (discrete gpu, integrated gpu or virtual gpu) then give a score(1000 for discrete gpu, 100 for integrated gpu and 0 for others) then sort by score.
In this case, it will first check suitability for better(discrete gpu) first. If the system has a higher scored gpu that suitable it will select the higher scored one, if the higher scored one doesn't support some fatal feature engine need, it will check lower scored gpu. Mean while, we'll get "the best"(in most cases) suitable gpu for vulkan.