Fix for integer formats in framebuffer extension tests am: 3bb47b5c57
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / image / vktImageTestsUtil.cpp
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2016 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Image Tests Utility Classes
22  *//*--------------------------------------------------------------------*/
23
24 #include "vktImageTestsUtil.hpp"
25 #include "vkQueryUtil.hpp"
26 #include "vkTypeUtil.hpp"
27 #include "tcuTextureUtil.hpp"
28
29 using namespace vk;
30
31 namespace vkt
32 {
33 namespace image
34 {
35
36 Buffer::Buffer (const DeviceInterface&          vk,
37                                 const VkDevice                          device,
38                                 Allocator&                                      allocator,
39                                 const VkBufferCreateInfo&       bufferCreateInfo,
40                                 const MemoryRequirement         memoryRequirement)
41 {
42         m_buffer = createBuffer(vk, device, &bufferCreateInfo);
43         m_allocation = allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement);
44         VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
45 }
46
47 Image::Image (const DeviceInterface&    vk,
48                           const VkDevice                        device,
49                           Allocator&                            allocator,
50                           const VkImageCreateInfo&      imageCreateInfo,
51                           const MemoryRequirement       memoryRequirement)
52 {
53         m_image = createImage(vk, device, &imageCreateInfo);
54         m_allocation = allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement);
55         VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocation->getMemory(), m_allocation->getOffset()));
56 }
57
58 tcu::UVec3 getShaderGridSize (const ImageType imageType, const tcu::UVec3& imageSize)
59 {
60         switch (imageType)
61         {
62                 case IMAGE_TYPE_1D:
63                 case IMAGE_TYPE_BUFFER:
64                         return tcu::UVec3(imageSize.x(), 1u, 1u);
65
66                 case IMAGE_TYPE_1D_ARRAY:
67                         return tcu::UVec3(imageSize.x(), imageSize.z(), 1u);
68
69                 case IMAGE_TYPE_2D:
70                         return tcu::UVec3(imageSize.x(), imageSize.y(), 1u);
71
72                 case IMAGE_TYPE_2D_ARRAY:
73                 case IMAGE_TYPE_3D:
74                         return tcu::UVec3(imageSize.x(), imageSize.y(), imageSize.z());
75
76                 case IMAGE_TYPE_CUBE:
77                         return tcu::UVec3(imageSize.x(), imageSize.y(), 6u);
78
79                 case IMAGE_TYPE_CUBE_ARRAY:
80                         return tcu::UVec3(imageSize.x(), imageSize.y(), 6u * imageSize.z());
81
82                 default:
83                         DE_FATAL("Unknown image type");
84                         return tcu::UVec3(1u, 1u, 1u);
85         }
86 }
87
88 tcu::UVec3 getLayerSize (const ImageType imageType, const tcu::UVec3& imageSize)
89 {
90         switch (imageType)
91         {
92                 case IMAGE_TYPE_1D:
93                 case IMAGE_TYPE_1D_ARRAY:
94                 case IMAGE_TYPE_BUFFER:
95                         return tcu::UVec3(imageSize.x(), 1u, 1u);
96
97                 case IMAGE_TYPE_2D:
98                 case IMAGE_TYPE_2D_ARRAY:
99                 case IMAGE_TYPE_CUBE:
100                 case IMAGE_TYPE_CUBE_ARRAY:
101                         return tcu::UVec3(imageSize.x(), imageSize.y(), 1u);
102
103                 case IMAGE_TYPE_3D:
104                         return tcu::UVec3(imageSize.x(), imageSize.y(), imageSize.z());
105
106                 default:
107                         DE_FATAL("Unknown image type");
108                         return tcu::UVec3(1u, 1u, 1u);
109         }
110 }
111
112 deUint32 getNumLayers (const ImageType imageType, const tcu::UVec3& imageSize)
113 {
114         switch (imageType)
115         {
116                 case IMAGE_TYPE_1D:
117                 case IMAGE_TYPE_2D:
118                 case IMAGE_TYPE_3D:
119                 case IMAGE_TYPE_BUFFER:
120                         return 1u;
121
122                 case IMAGE_TYPE_1D_ARRAY:
123                 case IMAGE_TYPE_2D_ARRAY:
124                         return imageSize.z();
125
126                 case IMAGE_TYPE_CUBE:
127                         return 6u;
128
129                 case IMAGE_TYPE_CUBE_ARRAY:
130                         return imageSize.z() * 6u;
131
132                 default:
133                         DE_FATAL("Unknown image type");
134                         return 0u;
135         }
136 }
137
138 deUint32 getNumPixels (const ImageType imageType, const tcu::UVec3& imageSize)
139 {
140         const tcu::UVec3 gridSize = getShaderGridSize(imageType, imageSize);
141
142         return gridSize.x() * gridSize.y() * gridSize.z();
143 }
144
145 deUint32 getDimensions (const ImageType imageType)
146 {
147         switch (imageType)
148         {
149                 case IMAGE_TYPE_1D:
150                 case IMAGE_TYPE_BUFFER:
151                         return 1u;
152
153                 case IMAGE_TYPE_1D_ARRAY:
154                 case IMAGE_TYPE_2D:
155                         return 2u;
156
157                 case IMAGE_TYPE_2D_ARRAY:
158                 case IMAGE_TYPE_CUBE:
159                 case IMAGE_TYPE_CUBE_ARRAY:
160                 case IMAGE_TYPE_3D:
161                         return 3u;
162
163                 default:
164                         DE_FATAL("Unknown image type");
165                         return 0u;
166         }
167 }
168
169 deUint32 getLayerDimensions (const ImageType imageType)
170 {
171         switch (imageType)
172         {
173                 case IMAGE_TYPE_1D:
174                 case IMAGE_TYPE_BUFFER:
175                 case IMAGE_TYPE_1D_ARRAY:
176                         return 1u;
177
178                 case IMAGE_TYPE_2D:
179                 case IMAGE_TYPE_2D_ARRAY:
180                 case IMAGE_TYPE_CUBE:
181                 case IMAGE_TYPE_CUBE_ARRAY:
182                         return 2u;
183
184                 case IMAGE_TYPE_3D:
185                         return 3u;
186
187                 default:
188                         DE_FATAL("Unknown image type");
189                         return 0u;
190         }
191 }
192
193 VkBufferCreateInfo makeBufferCreateInfo (const VkDeviceSize                     bufferSize,
194                                                                                  const VkBufferUsageFlags       usage)
195 {
196         const VkBufferCreateInfo bufferCreateInfo =
197         {
198                 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,   // VkStructureType              sType;
199                 DE_NULL,                                                                // const void*                  pNext;
200                 0u,                                                                             // VkBufferCreateFlags  flags;
201                 bufferSize,                                                             // VkDeviceSize                 size;
202                 usage,                                                                  // VkBufferUsageFlags   usage;
203                 VK_SHARING_MODE_EXCLUSIVE,                              // VkSharingMode                sharingMode;
204                 0u,                                                                             // deUint32                             queueFamilyIndexCount;
205                 DE_NULL,                                                                // const deUint32*              pQueueFamilyIndices;
206         };
207         return bufferCreateInfo;
208 }
209
210 VkBufferImageCopy makeBufferImageCopy (const VkExtent3D extent,
211                                                                            const deUint32       arraySize)
212 {
213         const VkBufferImageCopy copyParams =
214         {
215                 0ull,                                                                                                                                           //      VkDeviceSize                            bufferOffset;
216                 0u,                                                                                                                                                     //      deUint32                                        bufferRowLength;
217                 0u,                                                                                                                                                     //      deUint32                                        bufferImageHeight;
218                 makeImageSubresourceLayers(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, arraySize),       //      VkImageSubresourceLayers        imageSubresource;
219                 makeOffset3D(0, 0, 0),                                                                                                          //      VkOffset3D                                      imageOffset;
220                 extent,                                                                                                                                         //      VkExtent3D                                      imageExtent;
221         };
222         return copyParams;
223 }
224
225 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface&               vk,
226                                                                                    const VkDevice                               device,
227                                                                                    const VkDescriptorSetLayout  descriptorSetLayout)
228 {
229         const VkPipelineLayoutCreateInfo pipelineLayoutParams =
230         {
231                 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,          // VkStructureType                                      sType;
232                 DE_NULL,                                                                                        // const void*                                          pNext;
233                 0u,                                                                                                     // VkPipelineLayoutCreateFlags          flags;
234                 1u,                                                                                                     // deUint32                                                     setLayoutCount;
235                 &descriptorSetLayout,                                                           // const VkDescriptorSetLayout*         pSetLayouts;
236                 0u,                                                                                                     // deUint32                                                     pushConstantRangeCount;
237                 DE_NULL,                                                                                        // const VkPushConstantRange*           pPushConstantRanges;
238         };
239         return createPipelineLayout(vk, device, &pipelineLayoutParams);
240 }
241
242 Move<VkPipeline> makeComputePipeline (const DeviceInterface&    vk,
243                                                                           const VkDevice                        device,
244                                                                           const VkPipelineLayout        pipelineLayout,
245                                                                           const VkShaderModule          shaderModule)
246 {
247         const VkPipelineShaderStageCreateInfo pipelineShaderStageParams =
248         {
249                 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,    // VkStructureType                                              sType;
250                 DE_NULL,                                                                                                // const void*                                                  pNext;
251                 0u,                                                                                                             // VkPipelineShaderStageCreateFlags             flags;
252                 VK_SHADER_STAGE_COMPUTE_BIT,                                                    // VkShaderStageFlagBits                                stage;
253                 shaderModule,                                                                                   // VkShaderModule                                               module;
254                 "main",                                                                                                 // const char*                                                  pName;
255                 DE_NULL,                                                                                                // const VkSpecializationInfo*                  pSpecializationInfo;
256         };
257         const VkComputePipelineCreateInfo pipelineCreateInfo =
258         {
259                 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,         // VkStructureType                                      sType;
260                 DE_NULL,                                                                                        // const void*                                          pNext;
261                 0u,                                                                                                     // VkPipelineCreateFlags                        flags;
262                 pipelineShaderStageParams,                                                      // VkPipelineShaderStageCreateInfo      stage;
263                 pipelineLayout,                                                                         // VkPipelineLayout                                     layout;
264                 DE_NULL,                                                                                        // VkPipeline                                           basePipelineHandle;
265                 0,                                                                                                      // deInt32                                                      basePipelineIndex;
266         };
267         return createComputePipeline(vk, device, DE_NULL , &pipelineCreateInfo);
268 }
269
270 Move<VkBufferView> makeBufferView (const DeviceInterface&       vk,
271                                                                    const VkDevice                       vkDevice,
272                                                                    const VkBuffer                       buffer,
273                                                                    const VkFormat                       format,
274                                                                    const VkDeviceSize           offset,
275                                                                    const VkDeviceSize           size)
276 {
277         const VkBufferViewCreateInfo bufferViewParams =
278         {
279                 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,      // VkStructureType                      sType;
280                 DE_NULL,                                                                        // const void*                          pNext;
281                 0u,                                                                                     // VkBufferViewCreateFlags      flags;
282                 buffer,                                                                         // VkBuffer                                     buffer;
283                 format,                                                                         // VkFormat                                     format;
284                 offset,                                                                         // VkDeviceSize                         offset;
285                 size,                                                                           // VkDeviceSize                         range;
286         };
287         return createBufferView(vk, vkDevice, &bufferViewParams);
288 }
289
290 Move<VkImageView> makeImageView (const DeviceInterface&                 vk,
291                                                                  const VkDevice                                 vkDevice,
292                                                                  const VkImage                                  image,
293                                                                  const VkImageViewType                  imageViewType,
294                                                                  const VkFormat                                 format,
295                                                                  const VkImageSubresourceRange  subresourceRange)
296 {
297         const VkImageViewCreateInfo imageViewParams =
298         {
299                 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,               // VkStructureType                      sType;
300                 DE_NULL,                                                                                // const void*                          pNext;
301                 0u,                                                                                             // VkImageViewCreateFlags       flags;
302                 image,                                                                                  // VkImage                                      image;
303                 imageViewType,                                                                  // VkImageViewType                      viewType;
304                 format,                                                                                 // VkFormat                                     format;
305                 makeComponentMappingRGBA(),                                             // VkComponentMapping           components;
306                 subresourceRange,                                                               // VkImageSubresourceRange      subresourceRange;
307         };
308         return createImageView(vk, vkDevice, &imageViewParams);
309 }
310
311 Move<VkDescriptorSet> makeDescriptorSet (const DeviceInterface&                 vk,
312                                                                                  const VkDevice                                 device,
313                                                                                  const VkDescriptorPool                 descriptorPool,
314                                                                                  const VkDescriptorSetLayout    setLayout)
315 {
316         const VkDescriptorSetAllocateInfo allocateParams =
317         {
318                 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,         // VkStructureType                              sType;
319                 DE_NULL,                                                                                        // const void*                                  pNext;
320                 descriptorPool,                                                                         // VkDescriptorPool                             descriptorPool;
321                 1u,                                                                                                     // deUint32                                             setLayoutCount;
322                 &setLayout,                                                                                     // const VkDescriptorSetLayout* pSetLayouts;
323         };
324         return allocateDescriptorSet(vk, device, &allocateParams);
325 }
326
327 VkBufferMemoryBarrier makeBufferMemoryBarrier (const VkAccessFlags      srcAccessMask,
328                                                                                            const VkAccessFlags  dstAccessMask,
329                                                                                            const VkBuffer               buffer,
330                                                                                            const VkDeviceSize   offset,
331                                                                                            const VkDeviceSize   bufferSizeBytes)
332 {
333         const VkBufferMemoryBarrier barrier =
334         {
335                 VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,        // VkStructureType      sType;
336                 DE_NULL,                                                                        // const void*          pNext;
337                 srcAccessMask,                                                          // VkAccessFlags        srcAccessMask;
338                 dstAccessMask,                                                          // VkAccessFlags        dstAccessMask;
339                 VK_QUEUE_FAMILY_IGNORED,                                        // deUint32                     srcQueueFamilyIndex;
340                 VK_QUEUE_FAMILY_IGNORED,                                        // deUint32                     destQueueFamilyIndex;
341                 buffer,                                                                         // VkBuffer                     buffer;
342                 offset,                                                                         // VkDeviceSize         offset;
343                 bufferSizeBytes,                                                        // VkDeviceSize         size;
344         };
345         return barrier;
346 }
347
348 VkImageMemoryBarrier makeImageMemoryBarrier     (const VkAccessFlags                    srcAccessMask,
349                                                                                          const VkAccessFlags                    dstAccessMask,
350                                                                                          const VkImageLayout                    oldLayout,
351                                                                                          const VkImageLayout                    newLayout,
352                                                                                          const VkImage                                  image,
353                                                                                          const VkImageSubresourceRange  subresourceRange)
354 {
355         const VkImageMemoryBarrier barrier =
356         {
357                 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,                 // VkStructureType                      sType;
358                 DE_NULL,                                                                                // const void*                          pNext;
359                 srcAccessMask,                                                                  // VkAccessFlags                        outputMask;
360                 dstAccessMask,                                                                  // VkAccessFlags                        inputMask;
361                 oldLayout,                                                                              // VkImageLayout                        oldLayout;
362                 newLayout,                                                                              // VkImageLayout                        newLayout;
363                 VK_QUEUE_FAMILY_IGNORED,                                                // deUint32                                     srcQueueFamilyIndex;
364                 VK_QUEUE_FAMILY_IGNORED,                                                // deUint32                                     destQueueFamilyIndex;
365                 image,                                                                                  // VkImage                                      image;
366                 subresourceRange,                                                               // VkImageSubresourceRange      subresourceRange;
367         };
368         return barrier;
369 }
370
371 void beginCommandBuffer (const DeviceInterface& vk, const VkCommandBuffer commandBuffer)
372 {
373         const VkCommandBufferBeginInfo commandBufBeginParams =
374         {
375                 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,    // VkStructureType                                      sType;
376                 DE_NULL,                                                                                // const void*                                          pNext;
377                 0u,                                                                                             // VkCommandBufferUsageFlags            flags;
378                 (const VkCommandBufferInheritanceInfo*)DE_NULL,
379         };
380         VK_CHECK(vk.beginCommandBuffer(commandBuffer, &commandBufBeginParams));
381 }
382 void endCommandBuffer (const DeviceInterface& vk, const VkCommandBuffer commandBuffer)
383 {
384         VK_CHECK(vk.endCommandBuffer(commandBuffer));
385 }
386
387 void submitCommandsAndWait (const DeviceInterface&      vk,
388                                                         const VkDevice                  device,
389                                                         const VkQueue                   queue,
390                                                         const VkCommandBuffer   commandBuffer)
391 {
392         const Unique<VkFence> fence(createFence(vk, device));
393
394         const VkSubmitInfo submitInfo =
395         {
396                 VK_STRUCTURE_TYPE_SUBMIT_INFO,          // VkStructureType                      sType;
397                 DE_NULL,                                                        // const void*                          pNext;
398                 0u,                                                                     // deUint32                                     waitSemaphoreCount;
399                 DE_NULL,                                                        // const VkSemaphore*           pWaitSemaphores;
400                 (const VkPipelineStageFlags*)DE_NULL,
401                 1u,                                                                     // deUint32                                     commandBufferCount;
402                 &commandBuffer,                                         // const VkCommandBuffer*       pCommandBuffers;
403                 0u,                                                                     // deUint32                                     signalSemaphoreCount;
404                 DE_NULL,                                                        // const VkSemaphore*           pSignalSemaphores;
405         };
406
407         VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
408         VK_CHECK(vk.waitForFences(device, 1u, &fence.get(), DE_TRUE, ~0ull));
409 }
410
411 VkImageType     mapImageType (const ImageType imageType)
412 {
413         switch (imageType)
414         {
415                 case IMAGE_TYPE_1D:
416                 case IMAGE_TYPE_1D_ARRAY:
417                 case IMAGE_TYPE_BUFFER:
418                         return VK_IMAGE_TYPE_1D;
419
420                 case IMAGE_TYPE_2D:
421                 case IMAGE_TYPE_2D_ARRAY:
422                 case IMAGE_TYPE_CUBE:
423                 case IMAGE_TYPE_CUBE_ARRAY:
424                         return VK_IMAGE_TYPE_2D;
425
426                 case IMAGE_TYPE_3D:
427                         return VK_IMAGE_TYPE_3D;
428
429                 default:
430                         DE_ASSERT(false);
431                         return VK_IMAGE_TYPE_LAST;
432         }
433 }
434
435 VkImageViewType mapImageViewType (const ImageType imageType)
436 {
437         switch (imageType)
438         {
439                 case IMAGE_TYPE_1D:                     return VK_IMAGE_VIEW_TYPE_1D;
440                 case IMAGE_TYPE_1D_ARRAY:       return VK_IMAGE_VIEW_TYPE_1D_ARRAY;
441                 case IMAGE_TYPE_2D:                     return VK_IMAGE_VIEW_TYPE_2D;
442                 case IMAGE_TYPE_2D_ARRAY:       return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
443                 case IMAGE_TYPE_3D:                     return VK_IMAGE_VIEW_TYPE_3D;
444                 case IMAGE_TYPE_CUBE:           return VK_IMAGE_VIEW_TYPE_CUBE;
445                 case IMAGE_TYPE_CUBE_ARRAY:     return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
446
447                 default:
448                         DE_ASSERT(false);
449                         return VK_IMAGE_VIEW_TYPE_LAST;
450         }
451 }
452
453 std::string getImageTypeName (const ImageType imageType)
454 {
455         switch (imageType)
456         {
457                 case IMAGE_TYPE_1D:                     return "1d";
458                 case IMAGE_TYPE_1D_ARRAY:       return "1d_array";
459                 case IMAGE_TYPE_2D:                     return "2d";
460                 case IMAGE_TYPE_2D_ARRAY:       return "2d_array";
461                 case IMAGE_TYPE_3D:                     return "3d";
462                 case IMAGE_TYPE_CUBE:           return "cube";
463                 case IMAGE_TYPE_CUBE_ARRAY:     return "cube_array";
464                 case IMAGE_TYPE_BUFFER:         return "buffer";
465
466                 default:
467                         DE_ASSERT(false);
468                         return "";
469         }
470 }
471
472 std::string getShaderImageType (const tcu::TextureFormat& format, const ImageType imageType, const bool multisample)
473 {
474         std::string formatPart = tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ? "u" :
475                                                          tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER   ? "i" : "";
476
477         std::string imageTypePart;
478         if (multisample)
479         {
480                 switch (imageType)
481                 {
482                         case IMAGE_TYPE_2D:                     imageTypePart = "2DMS";                 break;
483                         case IMAGE_TYPE_2D_ARRAY:       imageTypePart = "2DMSArray";    break;
484
485                         default:
486                                 DE_ASSERT(false);
487                 }
488         }
489         else
490         {
491                 switch (imageType)
492                 {
493                         case IMAGE_TYPE_1D:                     imageTypePart = "1D";                   break;
494                         case IMAGE_TYPE_1D_ARRAY:       imageTypePart = "1DArray";              break;
495                         case IMAGE_TYPE_2D:                     imageTypePart = "2D";                   break;
496                         case IMAGE_TYPE_2D_ARRAY:       imageTypePart = "2DArray";              break;
497                         case IMAGE_TYPE_3D:                     imageTypePart = "3D";                   break;
498                         case IMAGE_TYPE_CUBE:           imageTypePart = "Cube";                 break;
499                         case IMAGE_TYPE_CUBE_ARRAY:     imageTypePart = "CubeArray";    break;
500                         case IMAGE_TYPE_BUFFER:         imageTypePart = "Buffer";               break;
501
502                         default:
503                                 DE_ASSERT(false);
504                 }
505         }
506
507         return formatPart + "image" + imageTypePart;
508 }
509
510 std::string getShaderImageFormatQualifier (const tcu::TextureFormat& format)
511 {
512         const char* orderPart;
513         const char* typePart;
514
515         switch (format.order)
516         {
517                 case tcu::TextureFormat::R:             orderPart = "r";        break;
518                 case tcu::TextureFormat::RG:    orderPart = "rg";       break;
519                 case tcu::TextureFormat::RGB:   orderPart = "rgb";      break;
520                 case tcu::TextureFormat::RGBA:  orderPart = "rgba";     break;
521
522                 default:
523                         DE_ASSERT(false);
524                         orderPart = DE_NULL;
525         }
526
527         switch (format.type)
528         {
529                 case tcu::TextureFormat::FLOAT:                         typePart = "32f";               break;
530                 case tcu::TextureFormat::HALF_FLOAT:            typePart = "16f";               break;
531
532                 case tcu::TextureFormat::UNSIGNED_INT32:        typePart = "32ui";              break;
533                 case tcu::TextureFormat::UNSIGNED_INT16:        typePart = "16ui";              break;
534                 case tcu::TextureFormat::UNSIGNED_INT8:         typePart = "8ui";               break;
535
536                 case tcu::TextureFormat::SIGNED_INT32:          typePart = "32i";               break;
537                 case tcu::TextureFormat::SIGNED_INT16:          typePart = "16i";               break;
538                 case tcu::TextureFormat::SIGNED_INT8:           typePart = "8i";                break;
539
540                 case tcu::TextureFormat::UNORM_INT16:           typePart = "16";                break;
541                 case tcu::TextureFormat::UNORM_INT8:            typePart = "8";                 break;
542
543                 case tcu::TextureFormat::SNORM_INT16:           typePart = "16_snorm";  break;
544                 case tcu::TextureFormat::SNORM_INT8:            typePart = "8_snorm";   break;
545
546                 default:
547                         DE_ASSERT(false);
548                         typePart = DE_NULL;
549         }
550
551         return std::string() + orderPart + typePart;
552 }
553
554 std::string getFormatShortString (const VkFormat format)
555 {
556         const std::string fullName = getFormatName(format);
557
558         DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_"));
559
560         return de::toLower(fullName.substr(10));
561 }
562
563 } // image
564 } // vkt