radv: always create an fallback pipeline cache
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 15 Mar 2017 03:14:24 +0000 (14:14 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 17 Mar 2017 05:17:10 +0000 (16:17 +1100)
This will be used as an in-memory cache when a pipeline cache is
not provided by the app.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h

index bc136e4489b133378e4f13dc72f63fcca4698e8b..893dceae047d2ed3a5f0d91df2d037a1592eca57 100644 (file)
@@ -1009,6 +1009,20 @@ VkResult radv_CreateDevice(
        if (device->physical_device->rad_info.chip_class >= CIK)
                cik_create_gfx_config(device);
 
+       VkPipelineCacheCreateInfo ci;
+       ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
+       ci.pNext = NULL;
+       ci.flags = 0;
+       ci.pInitialData = NULL;
+       ci.initialDataSize = 0;
+       VkPipelineCache pc;
+       result = radv_CreatePipelineCache(radv_device_to_handle(device),
+                                         &ci, NULL, &pc);
+       if (result != VK_SUCCESS)
+               goto fail;
+
+       device->mem_cache = radv_pipeline_cache_from_handle(pc);
+
        *pDevice = radv_device_to_handle(device);
        return VK_SUCCESS;
 
@@ -1057,6 +1071,9 @@ void radv_DestroyDevice(
        }
        radv_device_finish_meta(device);
 
+       VkPipelineCache pc = radv_pipeline_cache_to_handle(device->mem_cache);
+       radv_DestroyPipelineCache(radv_device_to_handle(device), pc, NULL);
+
        vk_free(&device->alloc, device);
 }
 
index dce1d508785648adc5a187f7a756401abacd889e..e4654bb4d4af7c95b739da95fbc92aac26872f7a 100644 (file)
@@ -508,6 +508,9 @@ struct radv_device {
        uint32_t                                     *trace_id_ptr;
 
        struct radv_physical_device                  *physical_device;
+
+       /* Backup in-memory cache to be used if the app doesn't provide one */
+       struct radv_pipeline_cache *                mem_cache;
 };
 
 struct radv_device_memory {