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

Raises an error when having no/exceeding vulkan device's limit #207

Merged
merged 2 commits into from
Apr 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,25 @@ Manager::createDevice(const std::vector<uint32_t>& familyQueueIndices,
}

this->mFreeDevice = true;

// Getting an integer that says how many vuklan devices we have
uint32_t deviceCount = 0;
vkEnumeratePhysicalDevices(*(this->mInstance), &deviceCount, nullptr);

// This means there are no devices at all
if (deviceCount == 0) {
throw std::runtime_error("Failed to find GPUs with Vulkan support! "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation

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

"Maybe you haven't installed vulkan drivers?");
}

// This means that we're exceeding our device limit, for
// example if we have 2 devices, just physicalDeviceIndex
// 0 and 1 are acceptable. Hence, physicalDeviceIndex should
// always be less than deviceCount, else we raise an error
if ( !(deviceCount > physicalDeviceIndex) ) {
throw std::runtime_error("There is no such physical index or device, "
"please use your existing device");
}

std::vector<vk::PhysicalDevice> physicalDevices =
this->mInstance->enumeratePhysicalDevices();
Expand Down