anv: Use 1.0 pipeline cache header

The final version of the pipeline cache header adds a few more fields.
This commit is contained in:
Kristian Høgsberg Kristensen
2016-03-03 16:39:59 -08:00
parent 26ed943eb9
commit cd812f086e

View File

@@ -237,20 +237,31 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
return state.offset + preamble_size; return state.offset + preamble_size;
} }
struct cache_header {
uint32_t header_size;
uint32_t header_version;
uint32_t vendor_id;
uint32_t device_id;
uint8_t uuid[VK_UUID_SIZE];
};
static void static void
anv_pipeline_cache_load(struct anv_pipeline_cache *cache, anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
const void *data, size_t size) const void *data, size_t size)
{ {
struct anv_device *device = cache->device; struct anv_device *device = cache->device;
struct cache_header header;
uint8_t uuid[VK_UUID_SIZE]; uint8_t uuid[VK_UUID_SIZE];
struct {
uint32_t device_id;
uint8_t uuid[VK_UUID_SIZE];
} header;
if (size < sizeof(header)) if (size < sizeof(header))
return; return;
memcpy(&header, data, sizeof(header)); memcpy(&header, data, sizeof(header));
if (header.header_size < sizeof(header))
return;
if (header.header_version != VK_PIPELINE_CACHE_HEADER_VERSION_ONE)
return;
if (header.vendor_id != 0x8086)
return;
if (header.device_id != device->chipset_id) if (header.device_id != device->chipset_id)
return; return;
anv_device_get_cache_uuid(uuid); anv_device_get_cache_uuid(uuid);
@@ -258,7 +269,7 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
return; return;
const void *end = data + size; const void *end = data + size;
const void *p = data + sizeof(header); const void *p = data + header.header_size;
while (p < end) { while (p < end) {
/* The kernels aren't 64 byte aligned in the serialized format so /* The kernels aren't 64 byte aligned in the serialized format so
@@ -325,8 +336,9 @@ VkResult anv_GetPipelineCacheData(
{ {
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache); ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache);
struct cache_header *header;
const size_t size = 4 + VK_UUID_SIZE + cache->total_size; const size_t size = sizeof(*header) + cache->total_size;
if (pData == NULL) { if (pData == NULL) {
*pDataSize = size; *pDataSize = size;
@@ -339,11 +351,13 @@ VkResult anv_GetPipelineCacheData(
} }
void *p = pData; void *p = pData;
memcpy(p, &device->chipset_id, sizeof(device->chipset_id)); header = p;
p += sizeof(device->chipset_id); header->header_size = sizeof(*header);
header->header_version = VK_PIPELINE_CACHE_HEADER_VERSION_ONE;
anv_device_get_cache_uuid(p); header->vendor_id = 0x8086;
p += VK_UUID_SIZE; header->device_id = device->chipset_id;
anv_device_get_cache_uuid(header->uuid);
p += header->header_size;
struct cache_entry *entry; struct cache_entry *entry;
for (uint32_t i = 0; i < cache->table_size; i++) { for (uint32_t i = 0; i < cache->table_size; i++) {