anv: set maxFragmentDualSrcAttachments to 1
[mesa.git] / src / amd / vulkan / radv_pipeline_cache.c
index 032a7e460409665a8b233fc94cd6cb42c143e25d..db824a26306a2fc4f017741c504a42deecfde19d 100644 (file)
 #include "ac_nir_to_llvm.h"
 
 struct cache_entry {
-       unsigned char sha1[20];
+       union {
+               unsigned char sha1[20];
+               uint32_t sha1_dw[5];
+       };
        uint32_t code_size;
        struct ac_shader_variant_info variant_info;
        struct ac_shader_config config;
@@ -68,7 +71,7 @@ radv_pipeline_cache_finish(struct radv_pipeline_cache *cache)
                        if (cache->hash_table[i]->variant)
                                radv_shader_variant_destroy(cache->device,
                                                            cache->hash_table[i]->variant);
-                       radv_free(&cache->alloc, cache->hash_table[i]);
+                       vk_free(&cache->alloc, cache->hash_table[i]);
                }
        pthread_mutex_destroy(&cache->mutex);
        free(cache->hash_table);
@@ -185,7 +188,7 @@ radv_pipeline_cache_set_entry(struct radv_pipeline_cache *cache,
                              struct cache_entry *entry)
 {
        const uint32_t mask = cache->table_size - 1;
-       const uint32_t start = (*(uint32_t *) entry->sha1);
+       const uint32_t start = entry->sha1_dw[0];
 
        /* We'll always be able to insert when we get here. */
        assert(cache->kernel_count < cache->table_size / 2);
@@ -269,7 +272,7 @@ radv_pipeline_cache_insert_shader(struct radv_pipeline_cache *cache,
                return variant;
        }
 
-       entry = radv_alloc(&cache->alloc, sizeof(*entry) + code_size, 8,
+       entry = vk_alloc(&cache->alloc, sizeof(*entry) + code_size, 8,
                           VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
        if (!entry) {
                pthread_mutex_unlock(&cache->mutex);
@@ -305,8 +308,8 @@ radv_pipeline_cache_load(struct radv_pipeline_cache *cache,
                         const void *data, size_t size)
 {
        struct radv_device *device = cache->device;
+       struct radv_physical_device *pdevice = &device->instance->physicalDevice;
        struct cache_header header;
-       uint8_t uuid[VK_UUID_SIZE];
 
        if (size < sizeof(header))
                return;
@@ -319,8 +322,7 @@ radv_pipeline_cache_load(struct radv_pipeline_cache *cache,
                return;
        if (header.device_id != device->instance->physicalDevice.rad_info.pci_id)
                return;
-       radv_device_get_cache_uuid(uuid);
-       if (memcmp(header.uuid, uuid, VK_UUID_SIZE) != 0)
+       if (memcmp(header.uuid, pdevice->uuid, VK_UUID_SIZE) != 0)
                return;
 
        char *end = (void *) data + size;
@@ -332,7 +334,7 @@ radv_pipeline_cache_load(struct radv_pipeline_cache *cache,
                if(end - p < sizeof(*entry) + entry->code_size)
                        break;
 
-               dest_entry = radv_alloc(&cache->alloc, sizeof(*entry) + entry->code_size,
+               dest_entry = vk_alloc(&cache->alloc, sizeof(*entry) + entry->code_size,
                                        8, VK_SYSTEM_ALLOCATION_SCOPE_CACHE);
                if (dest_entry) {
                        memcpy(dest_entry, entry, sizeof(*entry) + entry->code_size);
@@ -355,7 +357,7 @@ VkResult radv_CreatePipelineCache(
        assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO);
        assert(pCreateInfo->flags == 0);
 
-       cache = radv_alloc2(&device->alloc, pAllocator,
+       cache = vk_alloc2(&device->alloc, pAllocator,
                            sizeof(*cache), 8,
                            VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (cache == NULL)
@@ -391,7 +393,7 @@ void radv_DestroyPipelineCache(
                return;
        radv_pipeline_cache_finish(cache);
 
-       radv_free2(&device->alloc, pAllocator, cache);
+       vk_free2(&device->alloc, pAllocator, cache);
 }
 
 VkResult radv_GetPipelineCacheData(
@@ -402,6 +404,7 @@ VkResult radv_GetPipelineCacheData(
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
        RADV_FROM_HANDLE(radv_pipeline_cache, cache, _cache);
+       struct radv_physical_device *pdevice = &device->instance->physicalDevice;
        struct cache_header *header;
        VkResult result = VK_SUCCESS;
        const size_t size = sizeof(*header) + cache->total_size;
@@ -419,7 +422,7 @@ VkResult radv_GetPipelineCacheData(
        header->header_version = VK_PIPELINE_CACHE_HEADER_VERSION_ONE;
        header->vendor_id = 0x1002;
        header->device_id = device->instance->physicalDevice.rad_info.pci_id;
-       radv_device_get_cache_uuid(header->uuid);
+       memcpy(header->uuid, pdevice->uuid, VK_UUID_SIZE);
        p += header->header_size;
 
        struct cache_entry *entry;