Fix: score gpu and rank before check physical device suitability to find the best gpu for rending#29
Merged
hyv1001 merged 4 commits intoBoomingTech:mainfrom Apr 5, 2022
CRAFTSTARCN:main
Merged
Fix: score gpu and rank before check physical device suitability to find the best gpu for rending#29hyv1001 merged 4 commits intoBoomingTech:mainfrom CRAFTSTARCN:main
hyv1001 merged 4 commits intoBoomingTech:mainfrom
CRAFTSTARCN:main
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.
Contributor
Author
|
Clang-format has been used to foramt file |
Contributor
Author
|
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: ***@***.***>
|
hyv1001
reviewed
Apr 5, 2022
| vkGetPhysicalDeviceProperties(device, &physical_device_properties); | ||
| int score = 0; | ||
|
|
||
| if (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) |
Collaborator
There was a problem hiding this comment.
Suggest following the algorithm of VulkanTutorial, not just considering the device type, but also including the limits, features
Contributor
Author
There was a problem hiding this comment.
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()); |
Collaborator
There was a problem hiding this comment.
Pass a lambda function to std::sort to eliminate the std::reverse function call
Contributor
Author
There was a problem hiding this comment.
Done that, thaks for corrected my mistacks about format and coding style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.