Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / framework / vulkan / vkImageUtil.hpp
1 #ifndef _VKIMAGEUTIL_HPP
2 #define _VKIMAGEUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan CTS Framework
5  * --------------------
6  *
7  * Copyright (c) 2015 The Khronos Group Inc.
8  * Copyright (c) 2015 Imagination Technologies Ltd.
9  * Copyright (c) 2015 Google Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  *//*!
24  * \file
25  * \brief Utilities for images.
26  *//*--------------------------------------------------------------------*/
27
28 #include "vkDefs.hpp"
29 #include "tcuTexture.hpp"
30 #include "tcuCompressedTexture.hpp"
31 #include "deSharedPtr.hpp"
32 #include "vkImageWithMemory.hpp"
33 #include "vkBufferWithMemory.hpp"
34 #include "vkMemUtil.hpp"
35 #include "vkTypeUtil.hpp"
36 #include <memory>
37
38 namespace vk
39 {
40
41 bool                                            isFloatFormat                           (VkFormat format);
42 bool                                            isUfloatFormat                          (VkFormat format);
43 bool                                            isSfloatFormat                          (VkFormat format);
44 bool                                            isUnormFormat                           (VkFormat format);
45 bool                                            isSnormFormat                           (VkFormat format);
46 bool                                            isIntFormat                                     (VkFormat format);
47 bool                                            isUintFormat                            (VkFormat format);
48 bool                                            isScaledFormat                          (VkFormat format);
49 bool                                            isDepthStencilFormat            (VkFormat format);
50 bool                                            isCompressedFormat                      (VkFormat format);
51 bool                                            isSrgbFormat                            (VkFormat format);
52
53 bool                                            is64BitIntegerFormat            (VkFormat format);
54
55 bool                                            isSupportedByFramework          (VkFormat format);
56 void                                            checkImageSupport                       (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, const VkImageCreateInfo& imageCreateInfo);
57
58 tcu::TextureFormat                      mapVkFormat                                     (VkFormat format);
59 tcu::CompressedTexFormat        mapVkCompressedFormat           (VkFormat format);
60 tcu::TextureFormat                      getDepthCopyFormat                      (VkFormat combinedFormat);
61 tcu::TextureFormat                      getStencilCopyFormat            (VkFormat combinedFormat);
62
63 tcu::Sampler                            mapVkSampler                            (const VkSamplerCreateInfo& samplerCreateInfo);
64 tcu::Sampler::CompareMode       mapVkSamplerCompareOp           (VkCompareOp compareOp);
65 tcu::Sampler::WrapMode          mapVkSamplerAddressMode         (VkSamplerAddressMode addressMode);
66 tcu::Sampler::ReductionMode mapVkSamplerReductionMode   (VkSamplerReductionMode reductionMode);
67 tcu::Sampler::FilterMode        mapVkMinTexFilter                       (VkFilter filter, VkSamplerMipmapMode mipMode);
68 tcu::Sampler::FilterMode        mapVkMagTexFilter                       (VkFilter filter);
69
70 VkFilter                                        mapFilterMode                           (tcu::Sampler::FilterMode filterMode);
71 VkSamplerMipmapMode                     mapMipmapMode                           (tcu::Sampler::FilterMode filterMode);
72 VkSamplerAddressMode            mapWrapMode                                     (tcu::Sampler::WrapMode wrapMode);
73 VkCompareOp                                     mapCompareMode                          (tcu::Sampler::CompareMode mode);
74 VkFormat                                        mapTextureFormat                        (const tcu::TextureFormat& format);
75 VkFormat                                        mapCompressedTextureFormat      (const tcu::CompressedTexFormat format);
76 VkSamplerCreateInfo                     mapSampler                                      (const tcu::Sampler& sampler, const tcu::TextureFormat& format, float minLod = 0.0f, float maxLod = 1000.0f, bool unnormal = false);
77 rr::GenericVec4                         mapVkColor                                      (const VkClearColorValue& color);
78 VkClearColorValue                       mapVkColor                                      (const rr::GenericVec4& color);
79
80 void                                            imageUtilSelfTest                       (void);
81
82 float                                           getRepresentableDiffUnorm       (const VkFormat format, const deUint32 componentNdx);
83 float                                           getRepresentableDiffSnorm       (const VkFormat format, const deUint32 componentNdx);
84 deUint32                                        getFormatComponentWidth         (const VkFormat format, const deUint32 componentNdx);
85 deUint32                                        getBlockSizeInBytes                     (const VkFormat compressedFormat);
86 deUint32                                        getBlockWidth                           (const VkFormat compressedFormat);
87 deUint32                                        getBlockHeight                          (const VkFormat compressedFormat);
88
89 bool                                            hasSpirvFormat                          (VkFormat fmt);
90 const std::string                       getSpirvFormat                          (VkFormat fmt);
91
92 const deUint32 BUFFER_IMAGE_COPY_OFFSET_GRANULARITY = 4u;
93
94 // \todo [2017-05-18 pyry] Consider moving this to tcu
95 struct PlanarFormatDescription
96 {
97         enum
98         {
99                 MAX_CHANNELS    = 4,
100                 MAX_PLANES              = 3
101         };
102
103         enum ChannelFlags
104         {
105                 CHANNEL_R       = (1u<<0),      // Has "R" (0) channel
106                 CHANNEL_G       = (1u<<1),      // Has "G" (1) channel
107                 CHANNEL_B       = (1u<<2),      // Has "B" (2) channel
108                 CHANNEL_A       = (1u<<3),      // Has "A" (3) channel
109         };
110
111         struct Plane
112         {
113                 deUint8         elementSizeBytes;
114                 deUint8         widthDivisor;
115                 deUint8         heightDivisor;
116                 VkFormat        planeCompatibleFormat;
117         };
118
119         struct Channel
120         {
121                 deUint8         planeNdx;
122                 deUint8         type;                           // tcu::TextureChannelClass value
123                 deUint8         offsetBits;                     // Offset in element in bits
124                 deUint8         sizeBits;                       // Value size in bits
125                 deUint8         strideBytes;            // Pixel stride (in bytes), usually plane elementSize
126         };
127
128         deUint8         numPlanes;
129         deUint8         presentChannels;
130         deUint8         blockWidth;
131         deUint8         blockHeight;
132         Plane           planes[MAX_PLANES];
133         Channel         channels[MAX_CHANNELS];
134
135         inline bool hasChannelNdx (deUint32 ndx) const
136         {
137                 DE_ASSERT(de::inBounds(ndx, 0u, 4u));
138                 return (presentChannels & (1u<<ndx)) != 0;
139         }
140 };
141
142 class ImageWithBuffer {
143         std::unique_ptr<ImageWithMemory>        image;
144         Move<vk::VkImageView>                           imageView;
145         std::unique_ptr<BufferWithMemory>       buffer;
146         VkDeviceSize                                            size;
147
148         public:
149         ImageWithBuffer(
150                         const DeviceInterface&          vkd,
151                         const VkDevice                          device,
152                         Allocator&                                      alloc,
153                         vk::VkExtent3D                          extent,
154                         vk::VkFormat                            imageFormat,
155                         vk::VkImageUsageFlags           usage,
156                         vk::VkImageType                         imageType,
157                         vk::VkImageSubresourceRange ssr = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u),
158                         uint32_t                                        arrayLayers = 1,
159                         vk::VkSampleCountFlagBits   samples = VK_SAMPLE_COUNT_1_BIT,
160                         vk::VkImageTiling                       tiling = VK_IMAGE_TILING_OPTIMAL,
161                         uint32_t                                        mipLevels = 1,
162                         vk::VkSharingMode                       sharingMode = VK_SHARING_MODE_EXCLUSIVE);
163
164         VkImage                 getImage();
165         VkImageView             getImageView();
166         VkBuffer                getBuffer();
167         VkDeviceSize    getBufferSize();
168         Allocation&             getImageAllocation();
169         Allocation&             getBufferAllocation();
170 };
171
172 bool                                                    isYCbCrFormat                                   (VkFormat                                               format);
173 bool                                                    isYCbCrExtensionFormat                  (VkFormat                                               format);
174 bool                                                    isYCbCrConversionFormat                 (VkFormat                                               format);
175 PlanarFormatDescription                 getPlanarFormatDescription              (VkFormat                                               format);
176 int                                                             getPlaneCount                                   (VkFormat                                               format);
177 deUint32                                                getMipmapCount                                  (VkFormat                                               format,
178                                                                                                                                  const vk::PlanarFormatDescription&     formatDescription,
179                                                                                                                                  const vk::VkImageFormatProperties& imageFormatProperties,
180                                                                                                                                  const vk::VkExtent3D&                          extent);
181
182 deUint32                                                getPlaneSizeInBytes                             (const PlanarFormatDescription& formatInfo,
183                                                                                                                                  const VkExtent3D&                              baseExtents,
184                                                                                                                                  const deUint32                                 planeNdx,
185                                                                                                                                  const deUint32                                 mipmapLevel,
186                                                                                                                                  const deUint32                                 mipmapMemoryAlignment);
187 deUint32                                                getPlaneSizeInBytes                             (const PlanarFormatDescription& formatInfo,
188                                                                                                                                  const tcu::UVec2&                              baseExtents,
189                                                                                                                                  const deUint32                                 planeNdx,
190                                                                                                                                  const deUint32                                 mipmapLevel,
191                                                                                                                                  const deUint32                                 mipmapMemoryAlignment);
192 VkExtent3D                                              getPlaneExtent                                  (const PlanarFormatDescription& formatInfo,
193                                                                                                                                  const VkExtent3D&                              baseExtents,
194                                                                                                                                  const deUint32                                 planeNdx,
195                                                                                                                                  const deUint32                                 mipmapLevel);
196 tcu::UVec2                                              getPlaneExtent                                  (const PlanarFormatDescription& formatInfo,
197                                                                                                                                  const tcu::UVec2&                              baseExtents,
198                                                                                                                                  const deUint32                                 planeNdx,
199                                                                                                                                  const deUint32                                 mipmapLevel);
200 tcu::UVec3                                              getImageSizeAlignment                   (VkFormat                                               format);
201 tcu::UVec3                                              getImageSizeAlignment                   (const PlanarFormatDescription& formatInfo);
202 tcu::UVec2                                              getBlockExtent                                  (VkFormat                                               format);
203 tcu::UVec2                                              getBlockExtent                                  (const PlanarFormatDescription& formatInfo);
204 VkFormat                                                getPlaneCompatibleFormat                (VkFormat                                               format,
205                                                                                                                                  deUint32                                               planeNdx);
206 VkFormat                                                getPlaneCompatibleFormat                (const PlanarFormatDescription& formatInfo,
207                                                                                                                                  deUint32                                               planeNdx);
208
209 VkImageAspectFlagBits                   getPlaneAspect                                  (deUint32                                               planeNdx);
210 deUint32                                                getAspectPlaneNdx                               (VkImageAspectFlagBits                  planeAspect);
211 bool                                                    isChromaSubsampled                              (VkFormat                                               format);
212 bool                                                    isYCbCr422Format                                (VkFormat                                               format);
213 bool                                                    isYCbCr420Format                                (VkFormat                                               format);
214
215 tcu::PixelBufferAccess                  getChannelAccess                                (const PlanarFormatDescription& formatInfo,
216                                                                                                                                  const tcu::UVec2&                              size,
217                                                                                                                                  const deUint32*                                planeRowPitches,
218                                                                                                                                  void* const*                                   planePtrs,
219                                                                                                                                  deUint32                                               channelNdx);
220 tcu::ConstPixelBufferAccess             getChannelAccess                                (const PlanarFormatDescription& formatInfo,
221                                                                                                                                  const tcu::UVec2&                              size,
222                                                                                                                                  const deUint32*                                planeRowPitches,
223                                                                                                                                  const void* const*                             planePtrs,
224                                                                                                                                  deUint32                                               channelNdx);
225 tcu::PixelBufferAccess                  getChannelAccess                                (const PlanarFormatDescription& formatInfo,
226                                                                                                                                  const tcu::UVec3&                              size,
227                                                                                                                                  const deUint32*                                planeRowPitches,
228                                                                                                                                  void* const*                                   planePtrs,
229                                                                                                                                  deUint32                                               channelNdx);
230 tcu::ConstPixelBufferAccess             getChannelAccess                                (const PlanarFormatDescription& formatInfo,
231                                                                                                                                  const tcu::UVec3&                              size,
232                                                                                                                                  const deUint32*                                planeRowPitches,
233                                                                                                                                  const void* const*                             planePtrs,
234                                                                                                                                  deUint32                                               channelNdx);
235 VkImageAspectFlags                              getImageAspectFlags                             (const tcu::TextureFormat               textureFormat);
236 VkExtent3D                                              mipLevelExtents                                 (const VkExtent3D&                              baseExtents,
237                                                                                                                                  const deUint32                                 mipLevel);
238 tcu::UVec3                                              alignedDivide                                   (const VkExtent3D&                              extent,
239                                                                                                                                  const VkExtent3D&                              divisor);
240
241 /*--------------------------------------------------------------------*//*!
242  * Copies buffer data into an image. The buffer is expected to be
243  * in a state after host write.
244 *//*--------------------------------------------------------------------*/
245 void    copyBufferToImage                                               (const DeviceInterface&                                                 vk,
246                                                                                                  vk::VkDevice                                                                   device,
247                                                                                                  vk::VkQueue                                                                    queue,
248                                                                                                  deUint32                                                                               queueFamilyIndex,
249                                                                                                  const vk::VkBuffer&                                                    buffer,
250                                                                                                  vk::VkDeviceSize                                                               bufferSize,
251                                                                                                  const std::vector<vk::VkBufferImageCopy>&              copyRegions,
252                                                                                                  const vk::VkSemaphore*                                                 waitSemaphore,
253                                                                                                  vk::VkImageAspectFlags                                                 imageAspectFlags,
254                                                                                                  deUint32                                                                               mipLevels,
255                                                                                                  deUint32                                                                               arrayLayers,
256                                                                                                  vk::VkImage                                                                    destImage,
257                                                                                                  VkImageLayout                                                                  destImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
258                                                                                                  VkPipelineStageFlags                                                   destImageDstStageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
259                                                                                                 const VkCommandPool*                                                    externalCommandPool = DE_NULL,
260                                                                                                  deUint32                                                                               baseMipLevel = 0);
261
262 void    copyBufferToImage                                               (const DeviceInterface&                                                 vk,
263                                                                                                  const VkCommandBuffer&                                                 cmdBuffer,
264                                                                                                  const VkBuffer&                                                                buffer,
265                                                                                                  vk::VkDeviceSize                                                               bufferSize,
266                                                                                                  const std::vector<VkBufferImageCopy>&                  copyRegions,
267                                                                                                  VkImageAspectFlags                                                             imageAspectFlags,
268                                                                                                  deUint32                                                                               mipLevels,
269                                                                                                  deUint32                                                                               arrayLayers,
270                                                                                                  VkImage                                                                                destImage,
271                                                                                                  VkImageLayout                                                                  destImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
272                                                                                                  VkPipelineStageFlags                                                   destImageDstStageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
273                                                                                                  deUint32                                                                               baseMipLevel = 0);
274
275 /*--------------------------------------------------------------------*//*!
276  * Copies image data into a buffer. The buffer is expected to be
277  * read by the host.
278 *//*--------------------------------------------------------------------*/
279 void    copyImageToBuffer                                               (const DeviceInterface&                                                 vk,
280                                                                                                  vk::VkCommandBuffer                                                    cmdBuffer,
281                                                                                                  vk::VkImage                                                                    image,
282                                                                                                  vk::VkBuffer                                                                   buffer,
283                                                                                                  tcu::IVec2                                                                             size,
284                                                                                                  vk::VkAccessFlags                                                              srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
285                                                                                                  vk::VkImageLayout                                                              oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
286                                                                                                  deUint32                                                                               numLayers = 1u,
287                                                                                                  VkImageAspectFlags                                                             barrierAspect = VK_IMAGE_ASPECT_COLOR_BIT,
288                                                                                                  VkImageAspectFlags                                                             copyAspect = VK_IMAGE_ASPECT_COLOR_BIT,
289                                                                                                  VkPipelineStageFlags                                                   srcMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
290
291 void    copyImageToBuffer                                               (const DeviceInterface&                                                 vk,
292                                                                                                  vk::VkCommandBuffer                                                    cmdBuffer,
293                                                                                                  vk::VkImage                                                                    image,
294                                                                                                  vk::VkBuffer                                                                   buffer,
295                                                                                                  vk::VkFormat                                                                   format,
296                                                                                                  tcu::IVec2                                                                             size,
297                                                                                                  deUint32                                                                               mipLevel = 0u,
298                                                                                                  vk::VkAccessFlags                                                              srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
299                                                                                                  vk::VkImageLayout                                                              oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
300                                                                                                  deUint32                                                                               numLayers = 1u,
301                                                                                                  VkImageAspectFlags                                                             barrierAspect = VK_IMAGE_ASPECT_COLOR_BIT,
302                                                                                                  VkImageAspectFlags                                                             copyAspect = VK_IMAGE_ASPECT_COLOR_BIT);
303
304 /*--------------------------------------------------------------------*//*!
305  * Clear a color image
306 *//*--------------------------------------------------------------------*/
307 void    clearColorImage                                                 (const DeviceInterface&                                                 vk,
308                                                                                                  const vk::VkDevice                                                             device,
309                                                                                                  const vk::VkQueue                                                              queue,
310                                                                                                  deUint32                                                                               queueFamilyIndex,
311                                                                                                  vk::VkImage                                                                    image,
312                                                                                                  tcu::Vec4                                                                              clearColor,
313                                                                                                  vk::VkImageLayout                                                              oldLayout,
314                                                                                                  vk::VkImageLayout                                                              newLayout,
315                                                                                                  vk::VkPipelineStageFlags                                               dstStageFlags,
316                                                                                                  deUint32                                                                               baseArrayLayer = 0u,
317                                                                                                  deUint32                                                                               layerCount = 1u,
318                                                                                                  deUint32                                                                               baseMipLevel = 0u,
319                                                                                                  deUint32                                                                               levelCount = 1u);
320
321 void    clearColorImage                                                 (const DeviceInterface&                                                 vk,
322                                                                                                  const vk::VkDevice                                                             device,
323                                                                                                  const vk::VkQueue                                                              queue,
324                                                                                                  deUint32                                                                               queueFamilyIndex,
325                                                                                                  vk::VkImage                                                                    image,
326                                                                                                  vk::VkClearColorValue                                                  clearColor,
327                                                                                                  vk::VkImageLayout                                                              oldLayout,
328                                                                                                  vk::VkImageLayout                                                              newLayout,
329                                                                                                  vk::VkAccessFlags                                                              dstAccessFlags,
330                                                                                                  vk::VkPipelineStageFlags                                               dstStageFlags,
331                                                                                                  deUint32                                                                               baseArrayLayer = 0u,
332                                                                                                  deUint32                                                                               layerCount = 1u,
333                                                                                                  deUint32                                                                               baseMipLevel = 0u,
334                                                                                                  deUint32                                                                               levelCount = 1u);
335
336 /*--------------------------------------------------------------------*//*!
337  * Initialize color image with a chessboard pattern
338 *//*--------------------------------------------------------------------*/
339 void    initColorImageChessboardPattern                 (const DeviceInterface&                                                 vk,
340                                                                                                  const vk::VkDevice                                                             device,
341                                                                                                  const vk::VkQueue                                                              queue,
342                                                                                                  deUint32                                                                               queueFamilyIndex,
343                                                                                                  Allocator&                                                                             allocator,
344                                                                                                  vk::VkImage                                                                    image,
345                                                                                                  vk::VkFormat                                                                   format,
346                                                                                                  tcu::Vec4                                                                              colorValue0,
347                                                                                                  tcu::Vec4                                                                              colorValue1,
348                                                                                                  deUint32                                                                               imageWidth,
349                                                                                                  deUint32                                                                               imageHeight,
350                                                                                                  deUint32                                                                               tileSize,
351                                                                                                  vk::VkImageLayout                                                              oldLayout,
352                                                                                                  vk::VkImageLayout                                                              newLayout,
353                                                                                                  vk::VkPipelineStageFlags                                               dstStageFlags);
354
355 /*--------------------------------------------------------------------*//*!
356  * Copies depth/stencil image data into two separate buffers.
357  * The buffers are expected to be read by the host.
358 *//*--------------------------------------------------------------------*/
359 void    copyDepthStencilImageToBuffers                  (const DeviceInterface&                                                 vk,
360                                                                                                  vk::VkCommandBuffer                                                    cmdBuffer,
361                                                                                                  vk::VkImage                                                                    image,
362                                                                                                  vk::VkBuffer                                                                   depthBuffer,
363                                                                                                  vk::VkBuffer                                                                   stencilBuffer,
364                                                                                                  tcu::IVec2                                                                             size,
365                                                                                                  vk::VkAccessFlags                                                              srcAccessMask,
366                                                                                                  vk::VkImageLayout                                                              oldLayout,
367                                                                                                  deUint32                                                                               numLayers = 1u);
368
369 /*--------------------------------------------------------------------*//*!
370  * Clear a depth/stencil image
371 *//*--------------------------------------------------------------------*/
372 void    clearDepthStencilImage                                  (const DeviceInterface&                                                 vk,
373                                                                                                  const vk::VkDevice                                                             device,
374                                                                                                  const vk::VkQueue                                                              queue,
375                                                                                                  deUint32                                                                               queueFamilyIndex,
376                                                                                                  vk::VkImage                                                                    image,
377                                                                                                  vk::VkFormat                                                                   format,
378                                                                                                  float                                                                                  depthValue,
379                                                                                                  deUint32                                                                               stencilValue,
380                                                                                                  vk::VkImageLayout                                                              oldLayout,
381                                                                                                  vk::VkImageLayout                                                              newLayout,
382                                                                                                  vk::VkAccessFlags                                                              dstAccessFlags,
383                                                                                                  vk::VkPipelineStageFlags                                               dstStageFlags);
384
385 /*--------------------------------------------------------------------*//*!
386  * Initialize depth and stencil channels with a chessboard pattern
387 *//*--------------------------------------------------------------------*/
388 void    initDepthStencilImageChessboardPattern  (const DeviceInterface&                                                 vk,
389                                                                                                  const vk::VkDevice                                                             device,
390                                                                                                  const vk::VkQueue                                                              queue,
391                                                                                                  deUint32                                                                               queueFamilyIndex,
392                                                                                                  Allocator&                                                                             allocator,
393                                                                                                  vk::VkImage                                                                    image,
394                                                                                                  vk::VkFormat                                                                   format,
395                                                                                                  float                                                                                  depthValue0,
396                                                                                                  float                                                                                  depthValue1,
397                                                                                                  deUint32                                                                               stencilValue0,
398                                                                                                  deUint32                                                                               stencilValue1,
399                                                                                                  deUint32                                                                               imageWidth,
400                                                                                                  deUint32                                                                               imageHeight,
401                                                                                                  deUint32                                                                               tileSize,
402                                                                                                  vk::VkImageLayout                                                              oldLayout,
403                                                                                                  vk::VkImageLayout                                                              newLayout,
404                                                                                                  vk::VkPipelineStageFlags                                               dstStageFlags);
405
406 /*--------------------------------------------------------------------*//*!
407  * Makes common image subresource structures with common defaults
408 *//*--------------------------------------------------------------------*/
409 vk::VkImageSubresourceRange makeDefaultImageSubresourceRange();
410
411 vk::VkImageSubresourceLayers makeDefaultImageSubresourceLayers();
412
413 #ifndef CTS_USES_VULKANSC
414 /*--------------------------------------------------------------------*//*!
415  * Checks if the physical device supports creation of the specified
416  * image format.
417  *//*--------------------------------------------------------------------*/
418 bool    checkSparseImageFormatSupport                   (const VkPhysicalDevice                                                 physicalDevice,
419                                                                                                  const InstanceInterface&                                               instance,
420                                                                                                  const VkFormat                                                                 format,
421                                                                                                  const VkImageType                                                              imageType,
422                                                                                                  const VkSampleCountFlagBits                                    sampleCount,
423                                                                                                  const VkImageUsageFlags                                                usageFlags,
424                                                                                                  const VkImageTiling                                                    imageTiling);
425
426 bool    checkSparseImageFormatSupport                   (const vk::VkPhysicalDevice                                             physicalDevice,
427                                                                                                  const vk::InstanceInterface&                                   instance,
428                                                                                                  const vk::VkImageCreateInfo&                                   imageCreateInfo);
429
430 /*--------------------------------------------------------------------*//*!
431  * Allocates memory for a sparse image and handles the memory binding.
432  *//*--------------------------------------------------------------------*/
433 void    allocateAndBindSparseImage                              (const vk::DeviceInterface&                                             vk,
434                                                                                                  vk::VkDevice                                                                   device,
435                                                                                                  const vk::VkPhysicalDevice                                             physicalDevice,
436                                                                                                  const vk::InstanceInterface&                                   instance,
437                                                                                                  const vk::VkImageCreateInfo&                                   imageCreateInfo,
438                                                                                                  const vk::VkSemaphore&                                                 signalSemaphore,
439                                                                                                  vk::VkQueue                                                                    queue,
440                                                                                                  vk::Allocator&                                                                 allocator,
441                                                                                                  std::vector<de::SharedPtr<vk::Allocation> >&   allocations,
442                                                                                                  tcu::TextureFormat                                                             format,
443                                                                                                  vk::VkImage                                                                    destImage);
444 #endif // CTS_USES_VULKANSC
445 } // vk
446
447 #endif // _VKIMAGEUTIL_HPP