vulkan: skip the disk cache when disableInternalCache is true

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 <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30812>
This commit is contained in:
Samuel Pitoiset 2024-09-02 12:38:37 +02:00 committed by Marge Bot
parent 60474c9d69
commit 279b5ca10c
3 changed files with 17 additions and 0 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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)