[Mesa-dev] [PATCH 2/4] radv: always create an fallback pipeline cache
Timothy Arceri
tarceri at itsqueeze.com
Wed Mar 15 04:17:31 UTC 2017
This will be used as an in-memory cache when a pipeline cache is
not provided by the app.
---
src/amd/vulkan/radv_device.c | 15 +++++++++++++++
src/amd/vulkan/radv_private.h | 3 +++
2 files changed, 18 insertions(+)
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index d1fd58d..875057c 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -978,20 +978,32 @@ VkResult radv_CreateDevice(
goto fail;
device->trace_id_ptr = device->ws->buffer_map(device->trace_bo);
if (!device->trace_id_ptr)
goto fail;
}
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 = radv_pipeline_cache_to_handle(device->mem_cache);
+ result = radv_CreatePipelineCache(radv_device_to_handle(device),
+ &ci, NULL, &pc);
+ if (result != VK_SUCCESS)
+ goto fail;
+
*pDevice = radv_device_to_handle(device);
return VK_SUCCESS;
fail:
if (device->trace_bo)
device->ws->buffer_destroy(device->trace_bo);
if (device->gfx_init)
device->ws->buffer_destroy(device->gfx_init);
@@ -1026,20 +1038,23 @@ void radv_DestroyDevice(
radv_queue_finish(&device->queues[i][q]);
if (device->queue_count[i])
vk_free(&device->alloc, device->queues[i]);
if (device->empty_cs[i])
device->ws->cs_destroy(device->empty_cs[i]);
if (device->flush_cs[i])
device->ws->cs_destroy(device->flush_cs[i]);
}
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);
}
VkResult radv_EnumerateInstanceExtensionProperties(
const char* pLayerName,
uint32_t* pPropertyCount,
VkExtensionProperties* pProperties)
{
if (pProperties == NULL) {
*pPropertyCount = ARRAY_SIZE(instance_extensions);
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 890e6b8..c11fb74 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -501,20 +501,23 @@ struct radv_device {
float sample_locations_16x[16][2];
/* CIK and later */
uint32_t gfx_init_size_dw;
struct radeon_winsys_bo *gfx_init;
struct radeon_winsys_bo *trace_bo;
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 {
struct radeon_winsys_bo *bo;
/* for dedicated allocations */
struct radv_image *image;
struct radv_buffer *buffer;
uint32_t type_index;
VkDeviceSize map_size;
void * map;
--
2.9.3
More information about the mesa-dev
mailing list