radv: move RADV_TRACE_FILE functions to radv_debug.c
[mesa.git] / src / amd / vulkan / radv_pipeline_cache.c
index e57c99b8e948605c00360811afcb0388fd0ba284..ef1f513f369cdd69cca263a43023f156a9a1ec45 100644 (file)
@@ -24,6 +24,7 @@
 #include "util/mesa-sha1.h"
 #include "util/debug.h"
 #include "util/u_atomic.h"
+#include "radv_debug.h"
 #include "radv_private.h"
 
 #include "ac_nir_to_llvm.h"
@@ -89,7 +90,7 @@ radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
                 const char *entrypoint,
                 const VkSpecializationInfo *spec_info,
                 const struct radv_pipeline_layout *layout,
-                const union ac_shader_variant_key *key,
+                const struct ac_shader_variant_key *key,
                 uint32_t is_geom_copy_shader)
 {
        struct mesa_sha1 ctx;
@@ -118,6 +119,9 @@ radv_pipeline_cache_search_unlocked(struct radv_pipeline_cache *cache,
        const uint32_t mask = cache->table_size - 1;
        const uint32_t start = (*(uint32_t *) sha1);
 
+       if (cache->table_size == 0)
+               return NULL;
+
        for (uint32_t i = 0; i < cache->table_size; i++) {
                const uint32_t index = (start + i) & mask;
                struct cache_entry *entry = cache->hash_table[index];
@@ -168,6 +172,7 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
                if (!variant)
                        return NULL;
 
+               variant->code_size = entry->code_size;
                variant->config = entry->config;
                variant->info = entry->variant_info;
                variant->rsrc1 = entry->rsrc1;
@@ -175,12 +180,8 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
                variant->code_size = entry->code_size;
                variant->ref_count = 1;
 
-               variant->bo = device->ws->buffer_create(device->ws, entry->code_size, 256,
-                                               RADEON_DOMAIN_VRAM, RADEON_FLAG_CPU_ACCESS);
-
-               void *ptr = device->ws->buffer_map(variant->bo);
+               void *ptr = radv_alloc_shader_memory(device, variant);
                memcpy(ptr, entry->code, entry->code_size);
-               device->ws->buffer_unmap(variant->bo);
 
                entry->variant = variant;
        }
@@ -332,7 +333,7 @@ radv_pipeline_cache_load(struct radv_pipeline_cache *cache,
                return;
        if (header.device_id != device->physical_device->rad_info.pci_id)
                return;
-       if (memcmp(header.uuid, device->physical_device->uuid, VK_UUID_SIZE) != 0)
+       if (memcmp(header.uuid, device->physical_device->cache_uuid, VK_UUID_SIZE) != 0)
                return;
 
        char *end = (void *) data + size;
@@ -431,7 +432,7 @@ VkResult radv_GetPipelineCacheData(
        header->header_version = VK_PIPELINE_CACHE_HEADER_VERSION_ONE;
        header->vendor_id = 0x1002;
        header->device_id = device->physical_device->rad_info.pci_id;
-       memcpy(header->uuid, device->physical_device->uuid, VK_UUID_SIZE);
+       memcpy(header->uuid, device->physical_device->cache_uuid, VK_UUID_SIZE);
        p += header->header_size;
 
        struct cache_entry *entry;