1 #ifndef _VKTQUERYPOOLIMAGEOBJECTUTIL_HPP
2 #define _VKTQUERYPOOLIMAGEOBJECTUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2015 The Khronos Group Inc.
8 * Copyright (c) 2015 Intel Corporation
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief Image Object Util
25 *//*--------------------------------------------------------------------*/
27 #include "vkMemUtil.hpp"
28 #include "vkRefUtil.hpp"
30 #include "deSharedPtr.hpp"
32 #include "tcuTexture.hpp"
42 static void pack (int pixelSize,
46 vk::VkDeviceSize rowPitchOrZero,
47 vk::VkDeviceSize depthPitchOrZero,
48 const void * srcBuffer,
51 static void unpack (int pixelSize,
55 vk::VkDeviceSize rowPitchOrZero,
56 vk::VkDeviceSize depthPitchOrZero,
57 const void * srcBuffer,
64 static de::SharedPtr<Image> create (const vk::DeviceInterface& vk, vk::VkDevice device, const vk::VkImageCreateInfo& createInfo);
66 static de::SharedPtr<Image> createAndAlloc (const vk::DeviceInterface& vk,
68 const vk::VkImageCreateInfo& createInfo,
69 vk::Allocator& allocator,
70 vk::MemoryRequirement memoryRequirement = vk::MemoryRequirement::Any);
72 tcu::ConstPixelBufferAccess readSurface1D (vk::VkQueue queue,
73 vk::Allocator& allocator,
74 vk::VkImageLayout layout,
75 vk::VkOffset3D offset,
77 vk::VkImageAspectFlagBits aspect,
78 unsigned int mipLevel = 0,
79 unsigned int arrayElement = 0);
81 tcu::ConstPixelBufferAccess readVolume (vk::VkQueue queue,
82 vk::Allocator& allocator,
83 vk::VkImageLayout layout,
84 vk::VkOffset3D offset,
88 vk::VkImageAspectFlagBits aspect,
89 unsigned int mipLevel = 0,
90 unsigned int arrayElement = 0);
92 tcu::ConstPixelBufferAccess readSurfaceLinear (vk::VkOffset3D offset,
96 vk::VkImageAspectFlagBits aspect,
97 unsigned int mipLevel = 0,
98 unsigned int arrayElement = 0);
100 void read (vk::VkQueue queue,
101 vk::Allocator& allocator,
102 vk::VkImageLayout layout,
103 vk::VkOffset3D offset,
107 unsigned int mipLevel,
108 unsigned int arrayElement,
109 vk::VkImageAspectFlagBits aspect,
110 vk::VkImageType type,
113 void readUsingBuffer (vk::VkQueue queue,
114 vk::Allocator& allocator,
115 vk::VkImageLayout layout,
116 vk::VkOffset3D offset,
120 unsigned int mipLevel,
121 unsigned int arrayElement,
122 vk::VkImageAspectFlagBits aspect,
125 void readLinear (vk::VkOffset3D offset,
129 unsigned int mipLevel,
130 unsigned int arrayElement,
131 vk::VkImageAspectFlagBits aspect,
134 void uploadVolume (const tcu::ConstPixelBufferAccess& access,
136 vk::Allocator& allocator,
137 vk::VkImageLayout layout,
138 vk::VkOffset3D offset,
139 vk::VkImageAspectFlagBits aspect,
140 unsigned int mipLevel = 0,
141 unsigned int arrayElement = 0);
143 void uploadSurface (const tcu::ConstPixelBufferAccess& access,
145 vk::Allocator& allocator,
146 vk::VkImageLayout layout,
147 vk::VkOffset3D offset,
148 vk::VkImageAspectFlagBits aspect,
149 unsigned int mipLevel = 0,
150 unsigned int arrayElement = 0);
152 void uploadSurface1D (const tcu::ConstPixelBufferAccess& access,
154 vk::Allocator& allocator,
155 vk::VkImageLayout layout,
156 vk::VkOffset3D offset,
157 vk::VkImageAspectFlagBits aspect,
158 unsigned int mipLevel = 0,
159 unsigned int arrayElement = 0);
161 void uploadSurfaceLinear (const tcu::ConstPixelBufferAccess& access,
162 vk::VkOffset3D offset,
166 vk::VkImageAspectFlagBits aspect,
167 unsigned int mipLevel = 0,
168 unsigned int arrayElement = 0);
170 void upload (vk::VkQueue queue,
171 vk::Allocator& allocator,
172 vk::VkImageLayout layout,
173 vk::VkOffset3D offset,
177 unsigned int mipLevel,
178 unsigned int arrayElement,
179 vk::VkImageAspectFlagBits aspect,
180 vk::VkImageType type,
183 void uploadUsingBuffer (vk::VkQueue queue,
184 vk::Allocator& allocator,
185 vk::VkImageLayout layout,
186 vk::VkOffset3D offset,
190 unsigned int mipLevel,
191 unsigned int arrayElement,
192 vk::VkImageAspectFlagBits aspect,
195 void uploadLinear (vk::VkOffset3D offset,
199 unsigned int mipLevel,
200 unsigned int arrayElement,
201 vk::VkImageAspectFlagBits aspect,
204 de::SharedPtr<Image> copyToLinearImage (vk::VkQueue queue,
205 vk::Allocator& allocator,
206 vk::VkImageLayout layout,
207 vk::VkOffset3D offset,
211 unsigned int mipLevel,
212 unsigned int arrayElement,
213 vk::VkImageAspectFlagBits aspect,
214 vk::VkImageType type);
216 const vk::VkFormat& getFormat (void) const { return m_format; }
217 vk::VkImage object (void) const { return *m_object; }
218 void bindMemory (de::MovePtr<vk::Allocation> allocation);
219 vk::Allocation getBoundMemory (void) const { return *m_allocation; }
222 vk::VkDeviceSize getPixelOffset (vk::VkOffset3D offset,
223 vk::VkDeviceSize rowPitch,
224 vk::VkDeviceSize depthPitch,
225 unsigned int mipLevel,
226 unsigned int arrayElement);
228 Image (const vk::DeviceInterface& vk,
231 const vk::VkExtent3D& extend,
234 vk::Move<vk::VkImage> object);
236 Image (const Image& other); // Not allowed!
237 Image& operator= (const Image& other); // Not allowed!
239 de::MovePtr<vk::Allocation> m_allocation;
240 vk::Unique<vk::VkImage> m_object;
242 vk::VkFormat m_format;
243 vk::VkExtent3D m_extent;
244 deUint32 m_levelCount;
245 deUint32 m_layerCount;
247 std::vector<deUint8> m_pixelAccessData;
249 const vk::DeviceInterface& m_vk;
250 vk::VkDevice m_device;
253 void transition2DImage (const vk::DeviceInterface& vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageAspectFlags aspectMask, vk::VkImageLayout oldLayout, vk::VkImageLayout newLayout);
255 void initialTransitionColor2DImage (const vk::DeviceInterface& vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
257 void initialTransitionDepth2DImage (const vk::DeviceInterface& vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
259 void initialTransitionStencil2DImage (const vk::DeviceInterface& vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
261 void initialTransitionDepthStencil2DImage (const vk::DeviceInterface& vk, vk::VkCommandBuffer cmdBuffer, vk::VkImage image, vk::VkImageLayout layout);
266 #endif // _VKTQUERYPOOLIMAGEOBJECTUTIL_HPP