summaryrefslogtreecommitdiffstats
path: root/drivers/vulkan
diff options
context:
space:
mode:
authorMatias N. Goldberg <dark_sylinc@yahoo.com.ar>2023-09-16 18:59:04 -0300
committerMatias N. Goldberg <dark_sylinc@yahoo.com.ar>2023-09-16 18:59:04 -0300
commitcfeccc2146990a82d865ef3658bd953c5920a8d6 (patch)
tree916fd8235a25b903776e48ac9e305a9eef6ab5d4 /drivers/vulkan
parentba54c34551d1bda5139515d74e7d614ccbc43cea (diff)
downloadredot-engine-cfeccc2146990a82d865ef3658bd953c5920a8d6.tar.gz
Fix validation error when using pipeline cache control
PR #80296 introduced a regression because it checks if the VK_EXT_pipeline_creation_cache_control extension has been enabled before using it, but turns out the process is a bit more convoluted than that (a Vulkan driver may support the extension but then say the feature is not supported)
Diffstat (limited to 'drivers/vulkan')
-rw-r--r--drivers/vulkan/rendering_device_vulkan.cpp2
-rw-r--r--drivers/vulkan/vulkan_context.cpp24
-rw-r--r--drivers/vulkan/vulkan_context.h2
3 files changed, 27 insertions, 1 deletions
diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp
index 55c394b3bf..bd4d76a1b6 100644
--- a/drivers/vulkan/rendering_device_vulkan.cpp
+++ b/drivers/vulkan/rendering_device_vulkan.cpp
@@ -9158,7 +9158,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de
VkPipelineCacheCreateInfo cache_info = {};
cache_info.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
cache_info.pNext = nullptr;
- if (context->is_device_extension_enabled(VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME)) {
+ if (context->get_pipeline_cache_control_support()) {
cache_info.flags = VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT;
}
cache_info.initialDataSize = pipelines_cache.buffer.size();
diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp
index 9f35230eaf..344ea0d324 100644
--- a/drivers/vulkan/vulkan_context.cpp
+++ b/drivers/vulkan/vulkan_context.cpp
@@ -769,6 +769,7 @@ Error VulkanContext::_check_capabilities() {
VkPhysicalDeviceFragmentShadingRateFeaturesKHR vrs_features = {};
VkPhysicalDevice16BitStorageFeaturesKHR storage_feature = {};
VkPhysicalDeviceMultiviewFeatures multiview_features = {};
+ VkPhysicalDevicePipelineCreationCacheControlFeatures pipeline_cache_control_features = {};
if (device_api_version >= VK_API_VERSION_1_2) {
device_features_vk12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
@@ -820,6 +821,15 @@ Error VulkanContext::_check_capabilities() {
next = &multiview_features;
}
+ if (is_device_extension_enabled(VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME)) {
+ pipeline_cache_control_features = {
+ /*sType*/ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES,
+ /*pNext*/ next,
+ /*pipelineCreationCacheControl*/ false,
+ };
+ next = &pipeline_cache_control_features;
+ }
+
VkPhysicalDeviceFeatures2 device_features;
device_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
device_features.pNext = next;
@@ -860,6 +870,10 @@ Error VulkanContext::_check_capabilities() {
storage_buffer_capabilities.storage_push_constant_16_is_supported = storage_feature.storagePushConstant16;
storage_buffer_capabilities.storage_input_output_16 = storage_feature.storageInputOutput16;
}
+
+ if (is_device_extension_enabled(VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME)) {
+ pipeline_cache_control_support = pipeline_cache_control_features.pipelineCreationCacheControl;
+ }
}
// Check extended properties.
@@ -1422,6 +1436,16 @@ Error VulkanContext::_create_device() {
nextptr = &vrs_features;
}
+ VkPhysicalDevicePipelineCreationCacheControlFeatures pipeline_cache_control_features = {};
+ if (pipeline_cache_control_support) {
+ pipeline_cache_control_features.sType =
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES;
+ pipeline_cache_control_features.pNext = nextptr;
+ pipeline_cache_control_features.pipelineCreationCacheControl = pipeline_cache_control_support;
+
+ nextptr = &pipeline_cache_control_features;
+ }
+
VkPhysicalDeviceVulkan11Features vulkan11features = {};
VkPhysicalDevice16BitStorageFeaturesKHR storage_feature = {};
VkPhysicalDeviceMultiviewFeatures multiview_features = {};
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h
index 9fd2c40a06..ef40aba9e1 100644
--- a/drivers/vulkan/vulkan_context.h
+++ b/drivers/vulkan/vulkan_context.h
@@ -116,6 +116,7 @@ private:
VRSCapabilities vrs_capabilities;
ShaderCapabilities shader_capabilities;
StorageBufferCapabilities storage_buffer_capabilities;
+ bool pipeline_cache_control_support = false;
String device_vendor;
String device_name;
@@ -281,6 +282,7 @@ public:
const ShaderCapabilities &get_shader_capabilities() const { return shader_capabilities; };
const StorageBufferCapabilities &get_storage_buffer_capabilities() const { return storage_buffer_capabilities; };
const VkPhysicalDeviceFeatures &get_physical_device_features() const { return physical_device_features; };
+ bool get_pipeline_cache_control_support() const { return pipeline_cache_control_support; };
VkDevice get_device();
VkPhysicalDevice get_physical_device();