Properly check and enable vulkan extensions
This commit is contained in:
parent
51496cf5ef
commit
86c349e5f2
@ -759,6 +759,26 @@ void GEVulkanDriver::createInstance(SDL_Window* window)
|
||||
vk_version >= VK_API_VERSION_1_1);
|
||||
#endif
|
||||
|
||||
if (vk_version < VK_API_VERSION_1_1)
|
||||
{
|
||||
uint32_t extension_count;
|
||||
vkEnumerateInstanceExtensionProperties(NULL, &extension_count, NULL);
|
||||
|
||||
std::vector<VkExtensionProperties> instance_extensions(extension_count);
|
||||
vkEnumerateInstanceExtensionProperties(NULL, &extension_count,
|
||||
&instance_extensions[0]);
|
||||
for (auto& ext : instance_extensions)
|
||||
{
|
||||
if (strcmp(ext.extensionName,
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0)
|
||||
{
|
||||
extensions.push_back(
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t layer_count = 0;
|
||||
vkEnumerateInstanceLayerProperties(&layer_count, NULL);
|
||||
std::vector<VkLayerProperties> available_layers(layer_count);
|
||||
@ -771,7 +791,7 @@ void GEVulkanDriver::createInstance(SDL_Window* window)
|
||||
g_debug_print = true;
|
||||
for (VkLayerProperties& prop : available_layers)
|
||||
{
|
||||
if (std::string(prop.layerName) == "VK_LAYER_KHRONOS_validation")
|
||||
if (strcmp(prop.layerName, "VK_LAYER_KHRONOS_validation") == 0)
|
||||
enabled_validation_layers.push_back("VK_LAYER_KHRONOS_validation");
|
||||
}
|
||||
|
||||
@ -783,8 +803,7 @@ void GEVulkanDriver::createInstance(SDL_Window* window)
|
||||
validation_features.pEnabledValidationFeatures = &enabled_validation_features;
|
||||
|
||||
create_info.pNext = &validation_features;
|
||||
const char* debug_ext = "VK_EXT_debug_utils";
|
||||
extensions.push_back(debug_ext);
|
||||
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
VkApplicationInfo app_info = {};
|
||||
@ -869,6 +888,22 @@ bool GEVulkanDriver::checkDeviceExtensions(VkPhysicalDevice device)
|
||||
vkEnumerateDeviceExtensionProperties(device, NULL, &extension_count,
|
||||
&extensions[0]);
|
||||
|
||||
VkPhysicalDeviceProperties properties = {};
|
||||
vkGetPhysicalDeviceProperties(device, &properties);
|
||||
if (properties.apiVersion < VK_API_VERSION_1_2)
|
||||
{
|
||||
for (auto& ext : extensions)
|
||||
{
|
||||
if (strcmp(ext.extensionName,
|
||||
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) == 0)
|
||||
{
|
||||
m_device_extensions.push_back(
|
||||
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> required_extensions(m_device_extensions.begin(),
|
||||
m_device_extensions.end());
|
||||
|
||||
@ -984,13 +1019,12 @@ void GEVulkanDriver::createDevice()
|
||||
device_features.drawIndirectFirstInstance =
|
||||
GEVulkanFeatures::supportsMultiDrawIndirect();
|
||||
|
||||
VkPhysicalDeviceVulkan12Features vulkan12_features = {};
|
||||
vulkan12_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||
vulkan12_features.descriptorIndexing =
|
||||
GEVulkanFeatures::supportsDescriptorIndexing();
|
||||
vulkan12_features.shaderSampledImageArrayNonUniformIndexing =
|
||||
VkPhysicalDeviceDescriptorIndexingFeatures descriptor_indexing_features = {};
|
||||
descriptor_indexing_features.sType =
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;
|
||||
descriptor_indexing_features.shaderSampledImageArrayNonUniformIndexing =
|
||||
GEVulkanFeatures::supportsNonUniformIndexing();
|
||||
vulkan12_features.descriptorBindingPartiallyBound =
|
||||
descriptor_indexing_features.descriptorBindingPartiallyBound =
|
||||
GEVulkanFeatures::supportsPartiallyBound();
|
||||
|
||||
if (m_features.samplerAnisotropy == VK_TRUE)
|
||||
@ -1004,7 +1038,7 @@ void GEVulkanDriver::createDevice()
|
||||
create_info.enabledExtensionCount = m_device_extensions.size();
|
||||
create_info.ppEnabledExtensionNames = &m_device_extensions[0];
|
||||
create_info.enabledLayerCount = 0;
|
||||
create_info.pNext = &vulkan12_features;
|
||||
create_info.pNext = &descriptor_indexing_features;
|
||||
|
||||
VkResult result = vkCreateDevice(m_physical_device, &create_info, NULL, &m_vk->device);
|
||||
|
||||
|
@ -98,7 +98,8 @@ void GEVulkanFeatures::init(GEVulkanDriver* vk)
|
||||
|
||||
for (VkExtensionProperties& prop : extensions)
|
||||
{
|
||||
if (std::string(prop.extensionName) == "VK_EXT_descriptor_indexing")
|
||||
if (strcmp(prop.extensionName,
|
||||
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME) == 0)
|
||||
g_supports_descriptor_indexing = true;
|
||||
}
|
||||
|
||||
@ -126,10 +127,16 @@ void GEVulkanFeatures::init(GEVulkanDriver* vk)
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;
|
||||
supported_features.pNext = &descriptor_indexing_features;
|
||||
|
||||
PFN_vkGetPhysicalDeviceFeatures2 get_features = vkGetPhysicalDeviceFeatures2;
|
||||
if (vk->getPhysicalDeviceProperties().apiVersion < VK_API_VERSION_1_1 ||
|
||||
!vkGetPhysicalDeviceFeatures2)
|
||||
!get_features)
|
||||
{
|
||||
get_features = (PFN_vkGetPhysicalDeviceFeatures2)
|
||||
vkGetPhysicalDeviceFeatures2KHR;
|
||||
}
|
||||
if (!get_features)
|
||||
return;
|
||||
vkGetPhysicalDeviceFeatures2(vk->getPhysicalDevice(), &supported_features);
|
||||
get_features(vk->getPhysicalDevice(), &supported_features);
|
||||
if (supported_features.sType !=
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2)
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user