Path: blob/21.2-virgl/src/gallium/frontends/lavapipe/lvp_pipeline_cache.c
4565 views
/*1* Copyright © 2019 Red Hat.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#include "lvp_private.h"2425VKAPI_ATTR VkResult VKAPI_CALL lvp_CreatePipelineCache(26VkDevice _device,27const VkPipelineCacheCreateInfo* pCreateInfo,28const VkAllocationCallbacks* pAllocator,29VkPipelineCache* pPipelineCache)30{31LVP_FROM_HANDLE(lvp_device, device, _device);32struct lvp_pipeline_cache *cache;3334assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO);35assert(pCreateInfo->flags == 0);3637cache = vk_alloc2(&device->vk.alloc, pAllocator,38sizeof(*cache), 8,39VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);40if (cache == NULL)41return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);4243vk_object_base_init(&device->vk, &cache->base,44VK_OBJECT_TYPE_PIPELINE_CACHE);45if (pAllocator)46cache->alloc = *pAllocator;47else48cache->alloc = device->vk.alloc;4950cache->device = device;51*pPipelineCache = lvp_pipeline_cache_to_handle(cache);5253return VK_SUCCESS;54}5556VKAPI_ATTR void VKAPI_CALL lvp_DestroyPipelineCache(57VkDevice _device,58VkPipelineCache _cache,59const VkAllocationCallbacks* pAllocator)60{61LVP_FROM_HANDLE(lvp_device, device, _device);62LVP_FROM_HANDLE(lvp_pipeline_cache, cache, _cache);6364if (!_cache)65return;66// lvp_pipeline_cache_finish(cache);67vk_object_base_finish(&cache->base);68vk_free2(&device->vk.alloc, pAllocator, cache);69}7071VKAPI_ATTR VkResult VKAPI_CALL lvp_GetPipelineCacheData(72VkDevice _device,73VkPipelineCache _cache,74size_t* pDataSize,75void* pData)76{77VkResult result = VK_SUCCESS;78if (pData) {79if (*pDataSize < 32) {80*pDataSize = 0;81result = VK_INCOMPLETE;82} else {83uint32_t *hdr = (uint32_t *)pData;84hdr[0] = 32;85hdr[1] = 1;86hdr[2] = VK_VENDOR_ID_MESA;87hdr[3] = 0;88lvp_device_get_cache_uuid(&hdr[4]);89}90} else91*pDataSize = 32;92return result;93}9495VKAPI_ATTR VkResult VKAPI_CALL lvp_MergePipelineCaches(96VkDevice _device,97VkPipelineCache destCache,98uint32_t srcCacheCount,99const VkPipelineCache* pSrcCaches)100{101return VK_SUCCESS;102}103104105