From d3f06cf5ce0764b37a03a0f2bfbb109a4d75884d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 4 May 2023 12:48:08 +0200 Subject: [PATCH] vulkan/pipeline_cache: don't log warnings for internal caches Cc: mesa-stable Part-of: --- src/amd/vulkan/meta/radv_meta.c | 12 ++++++++---- src/amd/vulkan/radv_device.c | 4 +++- src/freedreno/vulkan/tu_device.cc | 4 +++- src/intel/vulkan/anv_device.c | 4 +++- src/intel/vulkan_hasvk/anv_device.c | 4 +++- src/vulkan/runtime/vk_pipeline_cache.c | 30 +++++++++++++++++------------- src/vulkan/runtime/vk_pipeline_cache.h | 5 +++++ 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/amd/vulkan/meta/radv_meta.c b/src/amd/vulkan/meta/radv_meta.c index d79c186..0781996 100644 --- a/src/amd/vulkan/meta/radv_meta.c +++ b/src/amd/vulkan/meta/radv_meta.c @@ -339,11 +339,14 @@ radv_load_meta_pipeline(struct radv_device *device) void *data = NULL; bool ret = false; int fd = -1; - VkResult result = VK_SUCCESS; VkPipelineCacheCreateInfo create_info = { .sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, }; + struct vk_pipeline_cache_create_info info = { + .pCreateInfo = &create_info, + .internal = true, + }; if (!radv_builtin_cache_path(path)) goto fail; @@ -363,9 +366,10 @@ radv_load_meta_pipeline(struct radv_device *device) create_info.pInitialData = data; fail: - result = vk_common_CreatePipelineCache(radv_device_to_handle(device), &create_info, NULL, - &device->meta_state.cache); - if (result == VK_SUCCESS) { + device->meta_state.cache = + vk_pipeline_cache_to_handle(vk_pipeline_cache_create(&device->vk, &info, NULL)); + + if (device->meta_state.cache) { device->meta_state.initial_cache_entries = num_cache_entries(device->meta_state.cache); ret = device->meta_state.initial_cache_entries > 0; } diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index f5559ba..cce1251 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -1048,7 +1048,9 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr if (device->physical_device->rad_info.gfx_level >= GFX7) cik_create_gfx_config(device); - struct vk_pipeline_cache_create_info info = {0}; + struct vk_pipeline_cache_create_info info = { + .internal = true, + }; device->mem_cache = vk_pipeline_cache_create(&device->vk, &info, NULL); if (!device->mem_cache) goto fail_meta; diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc index ef8d525..9f4be7d 100644 --- a/src/freedreno/vulkan/tu_device.cc +++ b/src/freedreno/vulkan/tu_device.cc @@ -2225,7 +2225,9 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice, struct tu6_global *global = NULL; uint32_t global_size = sizeof(struct tu6_global); - struct vk_pipeline_cache_create_info pcc_info = { }; + struct vk_pipeline_cache_create_info pcc_info = { + .internal = true, + }; for (unsigned i = 0; i < pCreateInfo->queueCreateInfoCount; i++) { const VkDeviceQueueCreateInfo *queue_create = diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 6a8b1ff..b5a77e2 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3385,7 +3385,9 @@ VkResult anv_CreateDevice( if (result != VK_SUCCESS) goto fail_btd_fifo_bo; - struct vk_pipeline_cache_create_info pcc_info = { }; + struct vk_pipeline_cache_create_info pcc_info = { + .internal = true, + }; device->default_pipeline_cache = vk_pipeline_cache_create(&device->vk, &pcc_info, NULL); if (!device->default_pipeline_cache) { diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index af4d759..d947e9f 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -2956,7 +2956,9 @@ VkResult anv_CreateDevice( if (result != VK_SUCCESS) goto fail_trivial_batch_bo_and_scratch_pool; - struct vk_pipeline_cache_create_info pcc_info = { }; + struct vk_pipeline_cache_create_info pcc_info = { + .internal = true, + }; device->default_pipeline_cache = vk_pipeline_cache_create(&device->vk, &pcc_info, NULL); if (!device->default_pipeline_cache) { diff --git a/src/vulkan/runtime/vk_pipeline_cache.c b/src/vulkan/runtime/vk_pipeline_cache.c index d9d8695..59937d4 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.c +++ b/src/vulkan/runtime/vk_pipeline_cache.c @@ -37,6 +37,12 @@ #include "util/hash_table.h" #include "util/set.h" +#define vk_pipeline_cache_log(cache, ...) \ + if (cache->internal) \ + vk_logw(VK_LOG_OBJS(cache->base.device), __VA_ARGS__); \ + else \ + vk_logw(VK_LOG_OBJS(cache), __VA_ARGS__) + static bool vk_raw_data_cache_object_serialize(struct vk_pipeline_cache_object *object, struct blob *blob) @@ -191,21 +197,19 @@ vk_pipeline_cache_object_serialize(struct vk_pipeline_cache *cache, } if (!object->ops->serialize(object, blob)) { - vk_logw(VK_LOG_OBJS(cache), - "Failed to serialize pipeline cache object"); + vk_pipeline_cache_log(cache, "Failed to serialize pipeline cache object"); return false; } size_t size = blob->size - start; if (size > UINT32_MAX) { - vk_logw(VK_LOG_OBJS(cache), - "Skipping giant (4 GiB or larger) object"); + vk_pipeline_cache_log(cache, "Skipping giant (4 GiB or larger) object"); return false; } if (blob->out_of_memory) { - vk_logw(VK_LOG_OBJS(cache), - "Insufficient memory for pipeline cache data"); + vk_pipeline_cache_log(cache, + "Insufficient memory for pipeline cache data"); return false; } @@ -225,8 +229,8 @@ vk_pipeline_cache_object_deserialize(struct vk_pipeline_cache *cache, ops = &vk_raw_data_cache_object_ops; if (unlikely(ops->deserialize == NULL)) { - vk_logw(VK_LOG_OBJS(cache), - "Pipeline cache object cannot be deserialized"); + vk_pipeline_cache_log(cache, + "Pipeline cache object cannot be deserialized"); return NULL; } @@ -361,8 +365,8 @@ vk_pipeline_cache_lookup_object(struct vk_pipeline_cache *cache, data_obj->data, data_obj->data_size, ops); if (real_object == NULL) { - vk_logw(VK_LOG_OBJS(cache), - "Deserializing pipeline cache object failed"); + vk_pipeline_cache_log(cache, + "Deserializing pipeline cache object failed"); vk_pipeline_cache_remove_object(cache, hash, object); return NULL; @@ -476,7 +480,7 @@ vk_pipeline_cache_add_nir(struct vk_pipeline_cache *cache, nir_serialize(&blob, nir, false); if (blob.out_of_memory) { - vk_logw(VK_LOG_OBJS(cache), "Ran out of memory serializing NIR shader"); + vk_pipeline_cache_log(cache, "Ran out of memory serializing NIR shader"); blob_finish(&blob); return; } @@ -557,8 +561,7 @@ vk_pipeline_cache_load(struct vk_pipeline_cache *cache, data, data_size, ops); if (object == NULL) { - vk_logw(VK_LOG_OBJS(cache), - "Failed to load pipeline cache object"); + vk_pipeline_cache_log(cache, "Failed to load pipeline cache object"); continue; } @@ -587,6 +590,7 @@ vk_pipeline_cache_create(struct vk_device *device, return NULL; cache->flags = pCreateInfo->flags; + cache->internal = info->internal; struct VkPhysicalDeviceProperties pdevice_props; device->physical->dispatch_table.GetPhysicalDeviceProperties( diff --git a/src/vulkan/runtime/vk_pipeline_cache.h b/src/vulkan/runtime/vk_pipeline_cache.h index 8a621ed..bdb5f68 100644 --- a/src/vulkan/runtime/vk_pipeline_cache.h +++ b/src/vulkan/runtime/vk_pipeline_cache.h @@ -163,6 +163,9 @@ struct vk_pipeline_cache { /** Protects object_cache */ simple_mtx_t lock; + /* Whether this cache is created by the driver. */ + bool internal; + struct set *object_cache; }; @@ -178,6 +181,8 @@ struct vk_pipeline_cache_create_info { /** If true, ignore VK_ENABLE_PIPELINE_CACHE and enable anyway */ bool force_enable; + + bool internal; }; struct vk_pipeline_cache * -- 2.7.4