Skip to content

Commit

Permalink
only enable the portability subset if its available
Browse files Browse the repository at this point in the history
  • Loading branch information
Bam4d committed Dec 30, 2023
1 parent 8ef1933 commit 9623461
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/Griddly/Core/Observers/Vulkan/VulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,28 @@ void VulkanDevice::initDevice(bool useGPU) {
auto graphicsQueueFamilyIndex = physicalDeviceInfo->queueFamilyIndices.graphicsIndices;
auto computeQueueFamilyIndex = physicalDeviceInfo->queueFamilyIndices.computeIndices;

const char* ppEnabledExtensionNames[] = {
"VK_KHR_portability_subset"
};
// Get the device extensions
uint32_t deviceExtensionCount;
vkEnumerateDeviceExtensionProperties(physicalDeviceInfo->physicalDevice, nullptr, &deviceExtensionCount, nullptr);
std::vector<VkExtensionProperties> deviceExtensions(deviceExtensionCount);
vkEnumerateDeviceExtensionProperties(physicalDeviceInfo->physicalDevice, nullptr, &deviceExtensionCount, deviceExtensions.data());

std::vector<const char*> deviceExtensionNames;
for (auto& extension : deviceExtensions) {
deviceExtensionNames.push_back(extension.extensionName);
}

//if portable subset is available, enable it
std::vector<const char*> enabledExtensions;
if (std::find(deviceExtensionNames.begin(), deviceExtensionNames.end(), VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) != deviceExtensionNames.end()) {
enabledExtensions.push_back(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
}


auto deviceQueueCreateInfo = vk::initializers::deviceQueueCreateInfo(graphicsQueueFamilyIndex, 1.0f);
auto deviceCreateInfo = vk::initializers::deviceCreateInfo(deviceQueueCreateInfo);
deviceCreateInfo.enabledExtensionCount = 1;
deviceCreateInfo.ppEnabledExtensionNames = ppEnabledExtensionNames;
deviceCreateInfo.enabledExtensionCount = enabledExtensions.size();
deviceCreateInfo.ppEnabledExtensionNames = enabledExtensions.data();

physicalDevice_ = physicalDeviceInfo->physicalDevice;
spdlog::debug("Creating physical device.");
Expand Down
1 change: 1 addition & 0 deletions src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <spdlog/spdlog.h>

#define VK_ENABLE_BETA_EXTENSIONS
#include <volk.h>

#include <cassert>
Expand Down

0 comments on commit 9623461

Please sign in to comment.