• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 }
38 
39 namespace vkt
40 {
41 
42 namespace api
43 {
44 
45 using namespace vk;
46 
47 class IBufferAllocator
48 {
49 public:
50 	virtual void						createTestBuffer				(VkDeviceSize				size,
51 																		 VkBufferUsageFlags			usage,
52 																		 Context&					context,
53 																		 Allocator&			allocator,
54 																		 Move<VkBuffer>&			buffer,
55 																		 const MemoryRequirement&	requirement,
56 																		 de::MovePtr<Allocation>&	memory) const = 0;
57 };
58 
59 class BufferSuballocation : public IBufferAllocator
60 {
61 public:
62 	virtual void						createTestBuffer				(VkDeviceSize				size,
63 																		 VkBufferUsageFlags			usage,
64 																		 Context&					context,
65 																		 Allocator&					allocator,
66 																		 Move<VkBuffer>&			buffer,
67 																		 const MemoryRequirement&	requirement,
68 																		 de::MovePtr<Allocation>&	memory) const; // override
69 };
70 
71 class BufferDedicatedAllocation	: public IBufferAllocator
72 {
73 public:
74 	virtual void						createTestBuffer				(VkDeviceSize				size,
75 																		 VkBufferUsageFlags			usage,
76 																		 Context&					context,
77 																		 Allocator&					allocator,
78 																		 Move<VkBuffer>&			buffer,
79 																		 const MemoryRequirement&	requirement,
80 																		 de::MovePtr<Allocation>&	memory) const; // override
81 };
82 
83 class IImageAllocator
84 {
85 public:
86 	virtual void						createTestImage					(tcu::IVec2					size,
87 																		 VkFormat					format,
88 																		 Context&					context,
89 																		 Allocator&					allocator,
90 																		 Move<VkImage>&				image,
91 																		 const MemoryRequirement&	requirement,
92 																		 de::MovePtr<Allocation>&	memory,
93 																		 VkImageTiling				tiling = VK_IMAGE_TILING_OPTIMAL) const = 0;
94 };
95 
96 class ImageSuballocation : public IImageAllocator
97 {
98 public:
99 	virtual void						createTestImage					(tcu::IVec2					size,
100 																		 VkFormat					format,
101 																		 Context&					context,
102 																		 Allocator&					allocator,
103 																		 Move<VkImage>&				image,
104 																		 const MemoryRequirement&	requirement,
105 																		 de::MovePtr<Allocation>&	memory,
106 																		 VkImageTiling				tiling = VK_IMAGE_TILING_OPTIMAL) const; // override
107 };
108 
109 class ImageDedicatedAllocation	: public IImageAllocator
110 {
111 public:
112 	virtual void						createTestImage					(tcu::IVec2					size,
113 																		 VkFormat					format,
114 																		 Context&					context,
115 																		 Allocator&					allocator,
116 																		 Move<VkImage>&				image,
117 																		 const MemoryRequirement&	requirement,
118 																		 de::MovePtr<Allocation>&	memory,
119 																		 VkImageTiling				tiling = VK_IMAGE_TILING_OPTIMAL) const; // override
120 };
121 
122 } // api
123 } // vkt
124 
125 #endif // _VKTAPIBUFFERANDIMAGEALLOCATIONUTIL_HPP
126