Don't crash on available devices if we can't even create an instance.

This commit is contained in:
Adam Treat 2023-09-16 12:17:29 -04:00 committed by Cebtenzzre
parent addac25293
commit 2c24d67e7b
2 changed files with 9 additions and 2 deletions

View File

@ -131,7 +131,7 @@ static std::string ggml_vk_getVendorName(uint32_t vendorID) {
std::vector<ggml_vk_device> ggml_vk_available_devices(size_t memoryRequired) {
std::vector<ggml_vk_device> results;
if (!komputeManager()->hasVulkan())
if (!komputeManager()->hasVulkan() || !komputeManager()->hasInstance())
return results;
std::vector<vk::PhysicalDevice> physicalDevices = komputeManager()->listDevices();

View File

@ -245,8 +245,15 @@ Manager::createInstance()
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
this->mInstance = std::make_shared<vk::Instance>();
vk::createInstance(
vk::Result r = vk::createInstance(
&computeInstanceCreateInfo, nullptr, this->mInstance.get());
if (r != vk::Result::eSuccess) {
KP_LOG_ERROR(
"Kompute Manager Error allocating vulkan instance", vk::to_string(r));
this->mInstance = nullptr;
this->mFreeInstance = false;
return;
}
VULKAN_HPP_DEFAULT_DISPATCHER.init(*this->mInstance);