diff --git a/src/vulkan/runtime/vk_device.c b/src/vulkan/runtime/vk_device.c index d4aca6803b5..31cb331e9ab 100644 --- a/src/vulkan/runtime/vk_device.c +++ b/src/vulkan/runtime/vk_device.c @@ -150,6 +150,7 @@ vk_device_init(struct vk_device *device, list_inithead(&device->queues); device->drm_fd = -1; + device->mem_cache = NULL; device->timeline_mode = get_timeline_mode(physical_device); diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index 5bdd3a3ddd8..37e56771062 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -195,6 +195,9 @@ struct vk_device { /* Set by vk_device_set_drm_fd() */ int drm_fd; + /** Implicit pipeline cache, or NULL */ + struct vk_pipeline_cache *mem_cache; + /** An enum describing how timeline semaphores work */ enum vk_device_timeline_mode { /** Timeline semaphores are not supported */ diff --git a/src/vulkan/runtime/vk_pipeline.c b/src/vulkan/runtime/vk_pipeline.c index 421afc2ca89..a22f682ecb9 100644 --- a/src/vulkan/runtime/vk_pipeline.c +++ b/src/vulkan/runtime/vk_pipeline.c @@ -1267,7 +1267,7 @@ vk_graphics_pipeline_compile_shaders(struct vk_device *device, all_cache_hits = false; } - if (all_cache_hits) { + if (all_cache_hits && cache != device->mem_cache) { /* The pipeline cache only really helps if we hit for everything * in the partition. Otherwise, we have to go re-compile it all * anyway. @@ -1798,6 +1798,10 @@ vk_common_CreateGraphicsPipelines(VkDevice _device, VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache); VkResult first_error_or_success = VK_SUCCESS; + /* Use implicit pipeline cache if there's no cache set */ + if (!cache && device->mem_cache) + cache = device->mem_cache; + /* From the Vulkan 1.3.274 spec: * * "When attempting to create many pipelines in a single command, it is @@ -2092,7 +2096,7 @@ vk_create_compute_pipeline(struct vk_device *device, .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, .duration = pipeline_end - pipeline_start, }; - if (cache_hit) { + if (cache_hit && cache != device->mem_cache) { pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT; } @@ -2128,6 +2132,10 @@ vk_common_CreateComputePipelines(VkDevice _device, VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache); VkResult first_error_or_success = VK_SUCCESS; + /* Use implicit pipeline cache if there's no cache set */ + if (!cache && device->mem_cache) + cache = device->mem_cache; + /* From the Vulkan 1.3.274 spec: * * "When attempting to create many pipelines in a single command, it is