nir: get ffma support from NIR options for nir_lower_flrp
[mesa.git] / src / gallium / frontends / vallium / val_pipeline_cache.c
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 "val_private.h"
25
26 VkResult val_CreatePipelineCache(
27 VkDevice _device,
28 const VkPipelineCacheCreateInfo* pCreateInfo,
29 const VkAllocationCallbacks* pAllocator,
30 VkPipelineCache* pPipelineCache)
31 {
32 VAL_FROM_HANDLE(val_device, device, _device);
33 struct val_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->alloc, pAllocator,
39 sizeof(*cache), 8,
40 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
41 if (cache == NULL)
42 return vk_error(device->instance, 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->alloc;
50
51 cache->device = device;
52 *pPipelineCache = val_pipeline_cache_to_handle(cache);
53
54 return VK_SUCCESS;
55 }
56
57 void val_DestroyPipelineCache(
58 VkDevice _device,
59 VkPipelineCache _cache,
60 const VkAllocationCallbacks* pAllocator)
61 {
62 VAL_FROM_HANDLE(val_device, device, _device);
63 VAL_FROM_HANDLE(val_pipeline_cache, cache, _cache);
64
65 if (!_cache)
66 return;
67 // val_pipeline_cache_finish(cache);
68 vk_object_base_finish(&cache->base);
69 vk_free2(&device->alloc, pAllocator, cache);
70 }
71
72 VkResult val_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 val_device_get_cache_uuid(&hdr[4]);
90 }
91 } else
92 *pDataSize = 32;
93 return result;
94 }
95
96 VkResult val_MergePipelineCaches(
97 VkDevice _device,
98 VkPipelineCache destCache,
99 uint32_t srcCacheCount,
100 const VkPipelineCache* pSrcCaches)
101 {
102 return VK_SUCCESS;
103 }