From 279b5ca10cecd27ba9496ccbc2a9c465e7a4ee6a Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 2 Sep 2024 12:38:37 +0200 Subject: [PATCH] vulkan: skip the disk cache when disableInternalCache is true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vulkan spec says: "disableInternalCache can be used to disable the driver’s internal cache, allowing an application to take full control of both memory and disk usage." Signed-off-by: Samuel Pitoiset Part-of: --- src/vulkan/runtime/vk_device.c | 13 +++++++++++++ src/vulkan/runtime/vk_device.h | 3 +++ src/vulkan/runtime/vk_pipeline_cache.c | 1 + 3 files changed, 17 insertions(+) diff --git a/src/vulkan/runtime/vk_device.c b/src/vulkan/runtime/vk_device.c index 9b95e319724..60af69b1faf 100644 --- a/src/vulkan/runtime/vk_device.c +++ b/src/vulkan/runtime/vk_device.c @@ -187,6 +187,19 @@ vk_device_init(struct vk_device *device, simple_mtx_init(&device->trace_mtx, mtx_plain); + vk_foreach_struct_const (ext, pCreateInfo->pNext) { + switch (ext->sType) { + case VK_STRUCTURE_TYPE_DEVICE_PIPELINE_BINARY_INTERNAL_CACHE_CONTROL_KHR: { + const VkDevicePipelineBinaryInternalCacheControlKHR *cache_control = (const void *)ext; + if (cache_control->disableInternalCache) + device->disable_internal_cache = true; + break; + } + default: + break; + } + } + return VK_SUCCESS; } diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index e20b259ba98..2a6d1d14338 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -267,6 +267,9 @@ struct vk_device { struct hash_table *swapchain_private; mtx_t swapchain_name_mtx; struct hash_table *swapchain_name; + + /* For VK_KHR_pipeline_binary */ + bool disable_internal_cache; }; VK_DEFINE_HANDLE_CASTS(vk_device, base, VkDevice, diff --git a/src/vulkan/runtime/vk_pipeline_cache.c b/src/vulkan/runtime/vk_pipeline_cache.c index 71471dd0239..c38855ac528 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.c +++ b/src/vulkan/runtime/vk_pipeline_cache.c @@ -682,6 +682,7 @@ vk_common_CreatePipelineCache(VkDevice _device, struct vk_pipeline_cache_create_info info = { .pCreateInfo = pCreateInfo, + .skip_disk_cache = device->disable_internal_cache, }; cache = vk_pipeline_cache_create(device, &info, pAllocator); if (cache == NULL)