blob: 76afb0ec74a252847b9f72aea3466c34ef2864f8 [file] [log] [blame]
Alexis Hetu767b41b2018-09-26 11:25:46 -04001// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef VK_OBJECT_HPP_
16#define VK_OBJECT_HPP_
17
Alexis Hetu767b41b2018-09-26 11:25:46 -040018#include "VkMemory.h"
Ben Clayton2ed93ab2019-12-17 20:38:03 +000019#include "VkConfig.h"
Alexis Hetue70c3512018-10-17 13:18:04 -040020#include "System/Memory.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040021
Nicolas Capens157ba262019-12-10 17:49:14 -050022namespace vk {
Alexis Hetu767b41b2018-09-26 11:25:46 -040023
Ben Clayton2ed93ab2019-12-17 20:38:03 +000024void *allocate(size_t count, size_t alignment, const VkAllocationCallbacks *pAllocator, VkSystemAllocationScope allocationScope)
Alexis Hetu767b41b2018-09-26 11:25:46 -040025{
Ben Clayton2ed93ab2019-12-17 20:38:03 +000026 return pAllocator ? pAllocator->pfnAllocation(pAllocator->pUserData, count, alignment, allocationScope) : sw::allocate(count, alignment);
Alexis Hetu767b41b2018-09-26 11:25:46 -040027}
28
Ben Clayton2ed93ab2019-12-17 20:38:03 +000029void deallocate(void *ptr, const VkAllocationCallbacks *pAllocator)
Alexis Hetu767b41b2018-09-26 11:25:46 -040030{
31 pAllocator ? pAllocator->pfnFree(pAllocator->pUserData, ptr) : sw::deallocate(ptr);
32}
33
Nicolas Capens157ba262019-12-10 17:49:14 -050034} // namespace vk
Alexis Hetu767b41b2018-09-26 11:25:46 -040035
Ben Clayton2ed93ab2019-12-17 20:38:03 +000036#endif // VK_OBJECT_HPP_