17ec681f3Smrg/*
27ec681f3Smrg * Copyright © 2021 Collabora Ltd.
37ec681f3Smrg *
47ec681f3Smrg * Derived from tu_pipeline_cache.c which is:
57ec681f3Smrg * Copyright © 2015 Intel Corporation
67ec681f3Smrg *
77ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
87ec681f3Smrg * copy of this software and associated documentation files (the "Software"),
97ec681f3Smrg * to deal in the Software without restriction, including without limitation
107ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
117ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
127ec681f3Smrg * Software is furnished to do so, subject to the following conditions:
137ec681f3Smrg *
147ec681f3Smrg * The above copyright notice and this permission notice (including the next
157ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the
167ec681f3Smrg * Software.
177ec681f3Smrg *
187ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
197ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
207ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
217ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
227ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
237ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
247ec681f3Smrg * DEALINGS IN THE SOFTWARE.
257ec681f3Smrg */
267ec681f3Smrg
277ec681f3Smrg#include "panvk_private.h"
287ec681f3Smrg
297ec681f3Smrg#include "util/debug.h"
307ec681f3Smrg#include "util/disk_cache.h"
317ec681f3Smrg#include "util/mesa-sha1.h"
327ec681f3Smrg#include "util/u_atomic.h"
337ec681f3Smrg
347ec681f3SmrgVkResult
357ec681f3Smrgpanvk_CreatePipelineCache(VkDevice _device,
367ec681f3Smrg                          const VkPipelineCacheCreateInfo *pCreateInfo,
377ec681f3Smrg                          const VkAllocationCallbacks *pAllocator,
387ec681f3Smrg                          VkPipelineCache *pPipelineCache)
397ec681f3Smrg{
407ec681f3Smrg   VK_FROM_HANDLE(panvk_device, device, _device);
417ec681f3Smrg   struct panvk_pipeline_cache *cache;
427ec681f3Smrg
437ec681f3Smrg   cache = vk_object_alloc(&device->vk, pAllocator, sizeof(*cache),
447ec681f3Smrg                           VK_OBJECT_TYPE_PIPELINE_CACHE);
457ec681f3Smrg   if (cache == NULL)
467ec681f3Smrg      return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
477ec681f3Smrg
487ec681f3Smrg   if (pAllocator)
497ec681f3Smrg      cache->alloc = *pAllocator;
507ec681f3Smrg   else
517ec681f3Smrg      cache->alloc = device->vk.alloc;
527ec681f3Smrg
537ec681f3Smrg   *pPipelineCache = panvk_pipeline_cache_to_handle(cache);
547ec681f3Smrg   return VK_SUCCESS;
557ec681f3Smrg}
567ec681f3Smrg
577ec681f3Smrgvoid
587ec681f3Smrgpanvk_DestroyPipelineCache(VkDevice _device,
597ec681f3Smrg                           VkPipelineCache _cache,
607ec681f3Smrg                           const VkAllocationCallbacks *pAllocator)
617ec681f3Smrg{
627ec681f3Smrg   VK_FROM_HANDLE(panvk_device, device, _device);
637ec681f3Smrg   VK_FROM_HANDLE(panvk_pipeline_cache, cache, _cache);
647ec681f3Smrg
657ec681f3Smrg   vk_object_free(&device->vk, pAllocator, cache);
667ec681f3Smrg}
677ec681f3Smrg
687ec681f3SmrgVkResult
697ec681f3Smrgpanvk_GetPipelineCacheData(VkDevice _device,
707ec681f3Smrg                           VkPipelineCache _cache,
717ec681f3Smrg                           size_t *pDataSize,
727ec681f3Smrg                           void *pData)
737ec681f3Smrg{
747ec681f3Smrg   panvk_stub();
757ec681f3Smrg   return VK_SUCCESS;
767ec681f3Smrg}
777ec681f3Smrg
787ec681f3SmrgVkResult
797ec681f3Smrgpanvk_MergePipelineCaches(VkDevice _device,
807ec681f3Smrg                          VkPipelineCache destCache,
817ec681f3Smrg                          uint32_t srcCacheCount,
827ec681f3Smrg                          const VkPipelineCache *pSrcCaches)
837ec681f3Smrg{
847ec681f3Smrg   panvk_stub();
857ec681f3Smrg   return VK_SUCCESS;
867ec681f3Smrg}
87