Skip to content
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

Merged
merged 4 commits into from
Apr 5, 2022

Conversation

CRAFTSTARCN
Copy link
Contributor

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.

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.
@CRAFTSTARCN
Copy link
Contributor Author

Clang-format has been used to foramt file

@CRAFTSTARCN
Copy link
Contributor Author

CRAFTSTARCN commented Apr 5, 2022 via email

vkGetPhysicalDeviceProperties(device, &physical_device_properties);
int score = 0;

if (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
Copy link
Collaborator

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

Copy link
Contributor Author

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());
Copy link
Collaborator

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

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants