15db71995Sopenharmony_ci/* 25db71995Sopenharmony_ci * 35db71995Sopenharmony_ci * Copyright (c) 2014-2021 The Khronos Group Inc. 45db71995Sopenharmony_ci * Copyright (c) 2014-2021 Valve Corporation 55db71995Sopenharmony_ci * Copyright (c) 2014-2021 LunarG, Inc. 65db71995Sopenharmony_ci * Copyright (C) 2015 Google Inc. 75db71995Sopenharmony_ci * 85db71995Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 95db71995Sopenharmony_ci * you may not use this file except in compliance with the License. 105db71995Sopenharmony_ci * You may obtain a copy of the License at 115db71995Sopenharmony_ci * 125db71995Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 135db71995Sopenharmony_ci * 145db71995Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 155db71995Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 165db71995Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 175db71995Sopenharmony_ci * See the License for the specific language governing permissions and 185db71995Sopenharmony_ci * limitations under the License. 195db71995Sopenharmony_ci * 205db71995Sopenharmony_ci * Author: Jon Ashburn <jon@lunarg.com> 215db71995Sopenharmony_ci * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> 225db71995Sopenharmony_ci * Author: Chia-I Wu <olvaffe@gmail.com> 235db71995Sopenharmony_ci * Author: Chia-I Wu <olv@lunarg.com> 245db71995Sopenharmony_ci * Author: Mark Lobodzinski <mark@LunarG.com> 255db71995Sopenharmony_ci * Author: Lenny Komow <lenny@lunarg.com> 265db71995Sopenharmony_ci * Author: Charles Giessen <charles@lunarg.com> 275db71995Sopenharmony_ci */ 285db71995Sopenharmony_ci 295db71995Sopenharmony_ci#pragma once 305db71995Sopenharmony_ci 315db71995Sopenharmony_ci#include "loader_common.h" 325db71995Sopenharmony_ci#include "stack_allocation.h" 335db71995Sopenharmony_ci 345db71995Sopenharmony_civoid *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocation_scope); 355db71995Sopenharmony_civoid *loader_instance_heap_calloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocation_scope); 365db71995Sopenharmony_civoid loader_instance_heap_free(const struct loader_instance *instance, void *pMemory); 375db71995Sopenharmony_civoid *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size, 385db71995Sopenharmony_ci VkSystemAllocationScope allocation_scope); 395db71995Sopenharmony_ci 405db71995Sopenharmony_civoid *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope); 415db71995Sopenharmony_civoid *loader_device_heap_calloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope); 425db71995Sopenharmony_civoid loader_device_heap_free(const struct loader_device *device, void *pMemory); 435db71995Sopenharmony_civoid *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size, 445db71995Sopenharmony_ci VkSystemAllocationScope alloc_scope); 455db71995Sopenharmony_ci 465db71995Sopenharmony_ci// Wrappers around various memory functions. The loader will use the VkAllocationCallbacks functions if pAllocator is not NULL, 475db71995Sopenharmony_ci// otherwise use the system functions 485db71995Sopenharmony_civoid *loader_alloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope); 495db71995Sopenharmony_civoid *loader_calloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope); 505db71995Sopenharmony_civoid loader_free(const VkAllocationCallbacks *pAllocator, void *pMemory); 515db71995Sopenharmony_civoid *loader_realloc(const VkAllocationCallbacks *pAllocator, void *pMemory, size_t orig_size, size_t size, 525db71995Sopenharmony_ci VkSystemAllocationScope allocation_scope); 535db71995Sopenharmony_ci 545db71995Sopenharmony_ci// helper allocation functions that will use pAllocator and if it is NULL, fallback to the allocator of instance 555db71995Sopenharmony_civoid *loader_alloc_with_instance_fallback(const VkAllocationCallbacks *pAllocator, const struct loader_instance *instance, 565db71995Sopenharmony_ci size_t size, VkSystemAllocationScope allocation_scope); 575db71995Sopenharmony_civoid *loader_calloc_with_instance_fallback(const VkAllocationCallbacks *pAllocator, const struct loader_instance *instance, 585db71995Sopenharmony_ci size_t size, VkSystemAllocationScope allocation_scope); 595db71995Sopenharmony_civoid loader_free_with_instance_fallback(const VkAllocationCallbacks *pAllocator, const struct loader_instance *instance, 605db71995Sopenharmony_ci void *pMemory); 615db71995Sopenharmony_civoid *loader_realloc_with_instance_fallback(const VkAllocationCallbacks *pAllocator, const struct loader_instance *instance, 625db71995Sopenharmony_ci void *pMemory, size_t orig_size, size_t size, VkSystemAllocationScope allocation_scope); 63