vulkan/pipeline_cache: don't log warnings for internal caches
authorDaniel Schürmann <daniel@schuermann.dev>
Thu, 4 May 2023 10:48:08 +0000 (12:48 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 11 May 2023 08:36:12 +0000 (08:36 +0000)
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22850>

src/amd/vulkan/meta/radv_meta.c
src/amd/vulkan/radv_device.c
src/freedreno/vulkan/tu_device.cc
src/intel/vulkan/anv_device.c
src/intel/vulkan_hasvk/anv_device.c
src/vulkan/runtime/vk_pipeline_cache.c
src/vulkan/runtime/vk_pipeline_cache.h

index d79c186..0781996 100644 (file)
@@ -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;
    }
index f5559ba..cce1251 100644 (file)
@@ -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;
index ef8d525..9f4be7d 100644 (file)
@@ -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 =
index 6a8b1ff..b5a77e2 100644 (file)
@@ -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) {
index af4d759..d947e9f 100644 (file)
@@ -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) {
index d9d8695..59937d4 100644 (file)
 #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(
index 8a621ed..bdb5f68 100644 (file)
@@ -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 *