1 #ifndef _VKTAPIBUFFERANDIMAGEALLOCATIONUTIL_HPP 2 #define _VKTAPIBUFFERANDIMAGEALLOCATIONUTIL_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2017 The Khronos Group Inc. 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Utility classes for various kinds of allocation memory for buffers and images 24 *//*--------------------------------------------------------------------*/ 25 26 #include "deUniquePtr.hpp" 27 #include "vkDefs.hpp" 28 #include "vkRef.hpp" 29 #include "vktTestCase.hpp" 30 #include "tcuVectorType.hpp" 31 32 namespace vk 33 { 34 class Allocator; 35 class MemoryRequirement; 36 class Allocation; 37 } // namespace vk 38 39 namespace vkt 40 { 41 42 namespace api 43 { 44 45 using namespace vk; 46 47 class IBufferAllocator 48 { 49 public: ~IBufferAllocator()50 virtual ~IBufferAllocator() 51 { 52 } 53 54 virtual void createTestBuffer(const DeviceInterface &vk, VkDevice vkDevice, uint32_t queueFamilyIndex, 55 VkDeviceSize size, VkBufferUsageFlags usage, Context &context, Allocator &allocator, 56 Move<VkBuffer> &buffer, const MemoryRequirement &requirement, 57 de::MovePtr<Allocation> &memory) const = 0; 58 }; 59 60 class BufferSuballocation : public IBufferAllocator 61 { 62 public: 63 virtual void createTestBuffer(const DeviceInterface &vk, VkDevice vkDevice, uint32_t queueFamilyIndex, 64 VkDeviceSize size, VkBufferUsageFlags usage, Context &context, Allocator &allocator, 65 Move<VkBuffer> &buffer, const MemoryRequirement &requirement, 66 de::MovePtr<Allocation> &memory) const; // override 67 }; 68 69 class BufferDedicatedAllocation : public IBufferAllocator 70 { 71 public: 72 virtual void createTestBuffer(const DeviceInterface &vk, VkDevice vkDevice, uint32_t queueFamilyIndex, 73 VkDeviceSize size, VkBufferUsageFlags usage, Context &context, Allocator &allocator, 74 Move<VkBuffer> &buffer, const MemoryRequirement &requirement, 75 de::MovePtr<Allocation> &memory) const; // override 76 }; 77 78 class IImageAllocator 79 { 80 public: ~IImageAllocator()81 virtual ~IImageAllocator() 82 { 83 } 84 85 virtual void createTestImage(tcu::IVec2 size, VkFormat format, Context &context, Allocator &allocator, 86 Move<VkImage> &image, const MemoryRequirement &requirement, 87 de::MovePtr<Allocation> &memory, 88 VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL) const = 0; 89 }; 90 91 class ImageSuballocation : public IImageAllocator 92 { 93 public: 94 virtual void createTestImage(tcu::IVec2 size, VkFormat format, Context &context, Allocator &allocator, 95 Move<VkImage> &image, const MemoryRequirement &requirement, 96 de::MovePtr<Allocation> &memory, 97 VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL) const; // override 98 }; 99 100 class ImageDedicatedAllocation : public IImageAllocator 101 { 102 public: 103 virtual void createTestImage(tcu::IVec2 size, VkFormat format, Context &context, Allocator &allocator, 104 Move<VkImage> &image, const MemoryRequirement &requirement, 105 de::MovePtr<Allocation> &memory, 106 VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL) const; // override 107 }; 108 109 } // namespace api 110 } // namespace vkt 111 112 #endif // _VKTAPIBUFFERANDIMAGEALLOCATIONUTIL_HPP 113