2 * Copyright © 2019 Red Hat.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "val_private.h"
26 VkResult
val_CreatePipelineCache(
28 const VkPipelineCacheCreateInfo
* pCreateInfo
,
29 const VkAllocationCallbacks
* pAllocator
,
30 VkPipelineCache
* pPipelineCache
)
32 VAL_FROM_HANDLE(val_device
, device
, _device
);
33 struct val_pipeline_cache
*cache
;
35 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO
);
36 assert(pCreateInfo
->flags
== 0);
38 cache
= vk_alloc2(&device
->alloc
, pAllocator
,
40 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
42 return vk_error(device
->instance
, VK_ERROR_OUT_OF_HOST_MEMORY
);
44 vk_object_base_init(&device
->vk
, &cache
->base
,
45 VK_OBJECT_TYPE_PIPELINE_CACHE
);
47 cache
->alloc
= *pAllocator
;
49 cache
->alloc
= device
->alloc
;
51 cache
->device
= device
;
52 *pPipelineCache
= val_pipeline_cache_to_handle(cache
);
57 void val_DestroyPipelineCache(
59 VkPipelineCache _cache
,
60 const VkAllocationCallbacks
* pAllocator
)
62 VAL_FROM_HANDLE(val_device
, device
, _device
);
63 VAL_FROM_HANDLE(val_pipeline_cache
, cache
, _cache
);
67 // val_pipeline_cache_finish(cache);
68 vk_object_base_finish(&cache
->base
);
69 vk_free2(&device
->alloc
, pAllocator
, cache
);
72 VkResult
val_GetPipelineCacheData(
74 VkPipelineCache _cache
,
78 VkResult result
= VK_SUCCESS
;
80 if (*pDataSize
< 32) {
82 result
= VK_INCOMPLETE
;
84 uint32_t *hdr
= (uint32_t *)pData
;
87 hdr
[2] = VK_VENDOR_ID_MESA
;
89 val_device_get_cache_uuid(&hdr
[4]);
96 VkResult
val_MergePipelineCaches(
98 VkPipelineCache destCache
,
99 uint32_t srcCacheCount
,
100 const VkPipelineCache
* pSrcCaches
)