• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2019 Red Hat.
3  *
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:
10  *
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
13  * Software.
14  *
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
21  * IN THE SOFTWARE.
22  */
23 
24 #include "lvp_private.h"
25 
lvp_CreatePipelineCache(VkDevice _device,const VkPipelineCacheCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkPipelineCache * pPipelineCache)26 VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineCache(
27     VkDevice                                    _device,
28     const VkPipelineCacheCreateInfo*            pCreateInfo,
29     const VkAllocationCallbacks*                pAllocator,
30     VkPipelineCache*                            pPipelineCache)
31 {
32    LVP_FROM_HANDLE(lvp_device, device, _device);
33    struct lvp_pipeline_cache *cache;
34 
35    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO);
36    assert(pCreateInfo->flags == 0);
37 
38    cache = vk_alloc2(&device->vk.alloc, pAllocator,
39                        sizeof(*cache), 8,
40                        VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
41    if (cache == NULL)
42       return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
43 
44    vk_object_base_init(&device->vk, &cache->base,
45                        VK_OBJECT_TYPE_PIPELINE_CACHE);
46    if (pAllocator)
47      cache->alloc = *pAllocator;
48    else
49      cache->alloc = device->vk.alloc;
50 
51    cache->device = device;
52    *pPipelineCache = lvp_pipeline_cache_to_handle(cache);
53 
54    return VK_SUCCESS;
55 }
56 
lvp_DestroyPipelineCache(VkDevice _device,VkPipelineCache _cache,const VkAllocationCallbacks * pAllocator)57 VKAPI_ATTR void VKAPI_CALL lvp_DestroyPipelineCache(
58     VkDevice                                    _device,
59     VkPipelineCache                             _cache,
60     const VkAllocationCallbacks*                pAllocator)
61 {
62    LVP_FROM_HANDLE(lvp_device, device, _device);
63    LVP_FROM_HANDLE(lvp_pipeline_cache, cache, _cache);
64 
65    if (!_cache)
66       return;
67 //   lvp_pipeline_cache_finish(cache);
68    vk_object_base_finish(&cache->base);
69    vk_free2(&device->vk.alloc, pAllocator, cache);
70 }
71 
lvp_GetPipelineCacheData(VkDevice _device,VkPipelineCache _cache,size_t * pDataSize,void * pData)72 VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPipelineCacheData(
73         VkDevice                                    _device,
74         VkPipelineCache                             _cache,
75         size_t*                                     pDataSize,
76         void*                                       pData)
77 {
78    VkResult result = VK_SUCCESS;
79    if (pData) {
80       if (*pDataSize < 32) {
81          *pDataSize = 0;
82          result = VK_INCOMPLETE;
83       } else {
84          uint32_t *hdr = (uint32_t *)pData;
85          hdr[0] = 32;
86          hdr[1] = 1;
87          hdr[2] = VK_VENDOR_ID_MESA;
88          hdr[3] = 0;
89          lvp_device_get_cache_uuid(&hdr[4]);
90       }
91    } else
92       *pDataSize = 32;
93    return result;
94 }
95 
lvp_MergePipelineCaches(VkDevice _device,VkPipelineCache destCache,uint32_t srcCacheCount,const VkPipelineCache * pSrcCaches)96 VKAPI_ATTR VkResult VKAPI_CALL lvp_MergePipelineCaches(
97         VkDevice                                    _device,
98         VkPipelineCache                             destCache,
99         uint32_t                                    srcCacheCount,
100         const VkPipelineCache*                      pSrcCaches)
101 {
102    return VK_SUCCESS;
103 }
104