1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Imagination Technologies Ltd.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 *//*--------------------------------------------------------------------*/
25 #include "vktPipelineImageTests.hpp"
26 #include "vktPipelineImageSamplingInstance.hpp"
27 #include "vktPipelineImageUtil.hpp"
28 #include "vktPipelineVertexUtil.hpp"
29 #include "vktTestCase.hpp"
30 #include "vkImageUtil.hpp"
31 #include "vkPrograms.hpp"
32 #include "tcuTextureUtil.hpp"
33 #include "deStringUtil.hpp"
49 class ImageTest : public vkt::TestCase
52 ImageTest (tcu::TestContext& testContext,
54 const char* description,
55 AllocationKind allocationKind,
56 PipelineConstructionType pipelineConstructionType,
57 VkDescriptorType samplingType,
58 VkImageViewType imageViewType,
60 const tcu::IVec3& imageSize,
64 ImageSamplingInstanceParams getImageSamplingInstanceParams (AllocationKind allocationKind,
65 VkDescriptorType samplingType,
66 VkImageViewType imageViewType,
68 const tcu::IVec3& imageSize,
72 virtual void initPrograms (SourceCollections& sourceCollections) const;
73 virtual void checkSupport (Context& context) const;
74 virtual TestInstance* createInstance (Context& context) const;
75 static std::string getGlslSamplerType (const tcu::TextureFormat& format, VkImageViewType type);
76 static std::string getGlslTextureType (const tcu::TextureFormat& format, VkImageViewType type);
77 static std::string getGlslSamplerDecl (int imageCount);
78 static std::string getGlslTextureDecl (int imageCount);
79 static std::string getGlslFragColorDecl (int imageCount);
80 static std::string getGlslSampler (const tcu::TextureFormat& format,
82 VkDescriptorType samplingType,
86 AllocationKind m_allocationKind;
87 PipelineConstructionType m_pipelineConstructionType;
88 VkDescriptorType m_samplingType;
89 VkImageViewType m_imageViewType;
90 VkFormat m_imageFormat;
91 tcu::IVec3 m_imageSize;
96 ImageTest::ImageTest (tcu::TestContext& testContext,
98 const char* description,
99 AllocationKind allocationKind,
100 PipelineConstructionType pipelineConstructionType,
101 VkDescriptorType samplingType,
102 VkImageViewType imageViewType,
103 VkFormat imageFormat,
104 const tcu::IVec3& imageSize,
108 : vkt::TestCase (testContext, name, description)
109 , m_allocationKind (allocationKind)
110 , m_pipelineConstructionType (pipelineConstructionType)
111 , m_samplingType (samplingType)
112 , m_imageViewType (imageViewType)
113 , m_imageFormat (imageFormat)
114 , m_imageSize (imageSize)
115 , m_imageCount (imageCount)
116 , m_arraySize (arraySize)
120 void ImageTest::checkSupport (Context& context) const
122 // Using a loop to index into an array of images requires shaderSampledImageArrayDynamicIndexing
123 if (m_imageCount > 1)
124 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING);
126 checkPipelineLibraryRequirements(context.getInstanceInterface(), context.getPhysicalDevice(), m_pipelineConstructionType);
127 checkSupportImageSamplingInstance(context, getImageSamplingInstanceParams(m_allocationKind, m_samplingType, m_imageViewType, m_imageFormat, m_imageSize, m_imageCount, m_arraySize));
130 ImageSamplingInstanceParams ImageTest::getImageSamplingInstanceParams (AllocationKind allocationKind,
131 VkDescriptorType samplingType,
132 VkImageViewType imageViewType,
133 VkFormat imageFormat,
134 const tcu::IVec3& imageSize,
138 tcu::UVec2 renderSize;
140 if (imageViewType == VK_IMAGE_VIEW_TYPE_1D || imageViewType == VK_IMAGE_VIEW_TYPE_2D)
142 renderSize = tcu::UVec2((deUint32)imageSize.x(), (deUint32)imageSize.y());
146 // Draw a 3x2 grid of texture layers
147 renderSize = tcu::UVec2((deUint32)imageSize.x() * 3, (deUint32)imageSize.y() * 2);
150 const bool separateStencilUsage = false;
151 const std::vector<Vertex4Tex4> vertices = createTestQuadMosaic(imageViewType);
152 const VkComponentMapping componentMapping = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
153 const VkImageSubresourceRange subresourceRange =
155 VK_IMAGE_ASPECT_COLOR_BIT,
157 (deUint32)deLog2Floor32(deMax32(imageSize.x(), deMax32(imageSize.y(), imageSize.z()))) + 1,
162 const VkSamplerCreateInfo samplerParams =
164 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // VkStructureType sType;
165 DE_NULL, // const void* pNext;
166 0u, // VkSamplerCreateFlags flags;
167 VK_FILTER_NEAREST, // VkFilter magFilter;
168 VK_FILTER_NEAREST, // VkFilter minFilter;
169 VK_SAMPLER_MIPMAP_MODE_NEAREST, // VkSamplerMipmapMode mipmapMode;
170 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeU;
171 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeV;
172 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeW;
173 0.0f, // float mipLodBias;
174 VK_FALSE, // VkBool32 anisotropyEnable;
175 1.0f, // float maxAnisotropy;
176 false, // VkBool32 compareEnable;
177 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
178 0.0f, // float minLod;
179 (float)(subresourceRange.levelCount - 1), // float maxLod;
180 getFormatBorderColor(BORDER_COLOR_TRANSPARENT_BLACK, imageFormat), // VkBorderColor borderColor;
181 false // VkBool32 unnormalizedCoordinates;
184 return ImageSamplingInstanceParams(m_pipelineConstructionType, renderSize, imageViewType, imageFormat, imageSize, arraySize, componentMapping, subresourceRange, samplerParams, 0.0f, vertices, separateStencilUsage, samplingType, imageCount, allocationKind);
187 void ImageTest::initPrograms (SourceCollections& sourceCollections) const
189 std::ostringstream vertexSrc;
190 std::ostringstream fragmentSrc;
191 const char* texCoordSwizzle = DE_NULL;
192 const tcu::TextureFormat format = (isCompressedFormat(m_imageFormat)) ? tcu::getUncompressedFormat(mapVkCompressedFormat(m_imageFormat))
193 : mapVkFormat(m_imageFormat);
195 tcu::Vec4 lookupScale;
196 tcu::Vec4 lookupBias;
198 getLookupScaleBias(m_imageFormat, lookupScale, lookupBias);
200 switch (m_imageViewType)
202 case VK_IMAGE_VIEW_TYPE_1D:
203 texCoordSwizzle = "x";
205 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
206 case VK_IMAGE_VIEW_TYPE_2D:
207 texCoordSwizzle = "xy";
209 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
210 case VK_IMAGE_VIEW_TYPE_3D:
211 case VK_IMAGE_VIEW_TYPE_CUBE:
212 texCoordSwizzle = "xyz";
214 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
215 texCoordSwizzle = "xyzw";
222 vertexSrc << "#version 440\n"
223 << "layout(location = 0) in vec4 position;\n"
224 << "layout(location = 1) in vec4 texCoords;\n"
225 << "layout(location = 0) out highp vec4 vtxTexCoords;\n"
226 << "out gl_PerVertex {\n"
227 << " vec4 gl_Position;\n"
229 << "void main (void)\n"
231 << " gl_Position = position;\n"
232 << " vtxTexCoords = texCoords;\n"
235 fragmentSrc << "#version 440\n";
236 switch (m_samplingType)
238 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
240 << "layout(set = 0, binding = 0) uniform highp sampler texSampler;\n"
241 << "layout(set = 0, binding = 1) uniform highp " << getGlslTextureType(format, m_imageViewType) << " " << getGlslTextureDecl(m_imageCount) << ";\n";
243 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
246 << "layout(set = 0, binding = 0) uniform highp " << getGlslSamplerType(format, m_imageViewType) << " " << getGlslSamplerDecl(m_imageCount) << ";\n";
248 fragmentSrc << "layout(location = 0) in highp vec4 vtxTexCoords;\n"
249 << "layout(location = 0) out highp vec4 " << getGlslFragColorDecl(m_imageCount) << ";\n"
250 << "void main (void)\n"
252 if (m_imageCount > 1)
254 << " for (uint i = 0; i < " << m_imageCount << "; ++i)\n"
255 << " fragColors[i] = (texture(" << getGlslSampler(format, m_imageViewType, m_samplingType, m_imageCount) << ", vtxTexCoords." << texCoordSwizzle << std::scientific << ") * vec4" << lookupScale << ") + vec4" << lookupBias << "; \n";
258 << " fragColor = (texture(" << getGlslSampler(format, m_imageViewType, m_samplingType, m_imageCount) << ", vtxTexCoords." << texCoordSwizzle << std::scientific << ") * vec4" << lookupScale << ") + vec4" << lookupBias << "; \n";
259 fragmentSrc << "}\n";
261 sourceCollections.glslSources.add("tex_vert") << glu::VertexSource(vertexSrc.str());
262 sourceCollections.glslSources.add("tex_frag") << glu::FragmentSource(fragmentSrc.str());
265 TestInstance* ImageTest::createInstance (Context& context) const
267 return new ImageSamplingInstance(context, getImageSamplingInstanceParams(m_allocationKind, m_samplingType, m_imageViewType, m_imageFormat, m_imageSize, m_imageCount, m_arraySize));
270 std::string ImageTest::getGlslSamplerType (const tcu::TextureFormat& format, VkImageViewType type)
272 std::ostringstream samplerType;
274 if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
276 else if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
281 case VK_IMAGE_VIEW_TYPE_1D:
282 samplerType << "sampler1D";
285 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
286 samplerType << "sampler1DArray";
289 case VK_IMAGE_VIEW_TYPE_2D:
290 samplerType << "sampler2D";
293 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
294 samplerType << "sampler2DArray";
297 case VK_IMAGE_VIEW_TYPE_3D:
298 samplerType << "sampler3D";
301 case VK_IMAGE_VIEW_TYPE_CUBE:
302 samplerType << "samplerCube";
305 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
306 samplerType << "samplerCubeArray";
310 DE_FATAL("Unknown image view type");
314 return samplerType.str();
317 std::string ImageTest::getGlslTextureType (const tcu::TextureFormat& format, VkImageViewType type)
319 std::ostringstream textureType;
321 if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
323 else if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
328 case VK_IMAGE_VIEW_TYPE_1D:
329 textureType << "texture1D";
332 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
333 textureType << "texture1DArray";
336 case VK_IMAGE_VIEW_TYPE_2D:
337 textureType << "texture2D";
340 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
341 textureType << "texture2DArray";
344 case VK_IMAGE_VIEW_TYPE_3D:
345 textureType << "texture3D";
348 case VK_IMAGE_VIEW_TYPE_CUBE:
349 textureType << "textureCube";
352 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
353 textureType << "textureCubeArray";
357 DE_FATAL("Unknown image view type");
360 return textureType.str();
363 std::string ImageTest::getGlslSamplerDecl (int imageCount)
365 std::ostringstream samplerArray;
366 samplerArray << "texSamplers[" << imageCount << "]";
368 return imageCount > 1 ? samplerArray.str() : "texSampler";
371 std::string ImageTest::getGlslTextureDecl (int imageCount)
373 std::ostringstream textureArray;
374 textureArray << "texImages[" << imageCount << "]";
376 return imageCount > 1 ? textureArray.str() : "texImage";
379 std::string ImageTest::getGlslFragColorDecl (int imageCount)
381 std::ostringstream samplerArray;
382 samplerArray << "fragColors[" << imageCount << "]";
384 return imageCount > 1 ? samplerArray.str() : "fragColor";
387 std::string ImageTest::getGlslSampler (const tcu::TextureFormat& format, VkImageViewType type, VkDescriptorType samplingType, int imageCount)
389 std::string texSampler = imageCount > 1 ? "texSamplers[i]" : "texSampler";
390 std::string texImage = imageCount > 1 ? "texImages[i]" : "texImage";
392 switch (samplingType)
394 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
395 return getGlslSamplerType(format, type) + "(" + texImage + ", texSampler)";
396 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
402 std::string getFormatCaseName (const VkFormat format)
404 const std::string fullName = getFormatName(format);
406 DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_"));
408 return de::toLower(fullName.substr(10));
411 std::string getSizeName (VkImageViewType viewType, const tcu::IVec3& size, int arraySize)
413 std::ostringstream caseName;
417 case VK_IMAGE_VIEW_TYPE_1D:
418 case VK_IMAGE_VIEW_TYPE_2D:
419 case VK_IMAGE_VIEW_TYPE_CUBE:
420 caseName << size.x() << "x" << size.y();
423 case VK_IMAGE_VIEW_TYPE_3D:
424 caseName << size.x() << "x" << size.y() << "x" << size.z();
427 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
428 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
429 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
430 caseName << size.x() << "x" << size.y() << "_array_of_" << arraySize;
438 return caseName.str();
441 de::MovePtr<tcu::TestCaseGroup> createImageSizeTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType, VkImageViewType imageViewType, VkFormat imageFormat, int imageCount)
445 std::vector<IVec3> imageSizes;
446 std::vector<int> arraySizes;
447 de::MovePtr<tcu::TestCaseGroup> imageSizeTests (new tcu::TestCaseGroup(testCtx, "size", ""));
449 // Select image imageSizes
450 switch (imageViewType)
452 case VK_IMAGE_VIEW_TYPE_1D:
453 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
457 imageSizes.push_back(IVec3(1, 1, 1));
458 imageSizes.push_back(IVec3(2, 1, 1));
459 imageSizes.push_back(IVec3(32, 1, 1));
460 imageSizes.push_back(IVec3(128, 1, 1));
462 imageSizes.push_back(IVec3(512, 1, 1));
467 imageSizes.push_back(IVec3(3, 1, 1));
468 imageSizes.push_back(IVec3(13, 1, 1));
469 imageSizes.push_back(IVec3(127, 1, 1));
471 imageSizes.push_back(IVec3(443, 1, 1));
474 case VK_IMAGE_VIEW_TYPE_2D:
475 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
479 imageSizes.push_back(IVec3(1, 1, 1));
480 imageSizes.push_back(IVec3(2, 2, 1));
481 imageSizes.push_back(IVec3(32, 32, 1));
484 imageSizes.push_back(IVec3(3, 3, 1));
485 imageSizes.push_back(IVec3(13, 13, 1));
490 imageSizes.push_back(IVec3(8, 16, 1));
491 imageSizes.push_back(IVec3(32, 16, 1));
494 imageSizes.push_back(IVec3(13, 23, 1));
496 imageSizes.push_back(IVec3(23, 8, 1));
499 case VK_IMAGE_VIEW_TYPE_3D:
503 imageSizes.push_back(IVec3(1, 1, 1));
504 imageSizes.push_back(IVec3(2, 2, 2));
506 imageSizes.push_back(IVec3(16, 16, 16));
511 imageSizes.push_back(IVec3(3, 3, 3));
512 imageSizes.push_back(IVec3(5, 5, 5));
514 imageSizes.push_back(IVec3(11, 11, 11));
518 imageSizes.push_back(IVec3(32, 16, 8));
519 imageSizes.push_back(IVec3(8, 16, 32));
522 imageSizes.push_back(IVec3(17, 11, 5));
524 imageSizes.push_back(IVec3(5, 11, 17));
527 case VK_IMAGE_VIEW_TYPE_CUBE:
528 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
530 imageSizes.push_back(IVec3(32, 32, 1));
533 imageSizes.push_back(IVec3(13, 13, 1));
541 // Select array sizes
542 switch (imageViewType)
544 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
545 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
547 arraySizes.push_back(3);
548 arraySizes.push_back(6);
551 case VK_IMAGE_VIEW_TYPE_CUBE:
552 arraySizes.push_back(6);
555 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
557 arraySizes.push_back(6);
558 arraySizes.push_back(6 * 6);
562 arraySizes.push_back(1);
566 for (size_t sizeNdx = 0; sizeNdx < imageSizes.size(); sizeNdx++)
568 for (size_t arraySizeNdx = 0; arraySizeNdx < arraySizes.size(); arraySizeNdx++)
570 imageSizeTests->addChild(new ImageTest(testCtx,
571 getSizeName(imageViewType, imageSizes[sizeNdx], arraySizes[arraySizeNdx]).c_str(),
574 pipelineConstructionType,
580 arraySizes[arraySizeNdx]));
584 return imageSizeTests;
587 void createImageCountTests (tcu::TestCaseGroup* parentGroup, tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType, VkImageViewType imageViewType, VkFormat imageFormat)
589 const int coreImageCounts[] = { 1, 4, 8 };
590 const int dedicatedAllocationImageCounts[] = { 1 };
591 const int* imageCounts = (allocationKind == ALLOCATION_KIND_DEDICATED)
592 ? dedicatedAllocationImageCounts
594 const size_t imageCountsLength = (allocationKind == ALLOCATION_KIND_DEDICATED)
595 ? DE_LENGTH_OF_ARRAY(dedicatedAllocationImageCounts)
596 : DE_LENGTH_OF_ARRAY(coreImageCounts);
598 for (size_t countNdx = 0; countNdx < imageCountsLength; countNdx++)
600 std::ostringstream caseName;
601 caseName << "count_" << imageCounts[countNdx];
602 de::MovePtr<tcu::TestCaseGroup> countGroup(new tcu::TestCaseGroup(testCtx, caseName.str().c_str(), ""));
603 de::MovePtr<tcu::TestCaseGroup> sizeTests = createImageSizeTests(testCtx, allocationKind, pipelineConstructionType, samplingType, imageViewType, imageFormat, imageCounts[countNdx]);
605 countGroup->addChild(sizeTests.release());
606 parentGroup->addChild(countGroup.release());
610 de::MovePtr<tcu::TestCaseGroup> createImageFormatTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType, VkImageViewType imageViewType)
612 // All supported dEQP formats that are not intended for depth or stencil.
613 const VkFormat coreFormats[] =
615 VK_FORMAT_R4G4_UNORM_PACK8,
616 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
617 VK_FORMAT_R5G6B5_UNORM_PACK16,
618 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
621 VK_FORMAT_R8_USCALED,
622 VK_FORMAT_R8_SSCALED,
626 VK_FORMAT_R8G8_UNORM,
627 VK_FORMAT_R8G8_SNORM,
628 VK_FORMAT_R8G8_USCALED,
629 VK_FORMAT_R8G8_SSCALED,
633 VK_FORMAT_R8G8B8_UNORM,
634 VK_FORMAT_R8G8B8_SNORM,
635 VK_FORMAT_R8G8B8_USCALED,
636 VK_FORMAT_R8G8B8_SSCALED,
637 VK_FORMAT_R8G8B8_UINT,
638 VK_FORMAT_R8G8B8_SINT,
639 VK_FORMAT_R8G8B8_SRGB,
640 VK_FORMAT_R8G8B8A8_UNORM,
641 VK_FORMAT_R8G8B8A8_SNORM,
642 VK_FORMAT_R8G8B8A8_USCALED,
643 VK_FORMAT_R8G8B8A8_SSCALED,
644 VK_FORMAT_R8G8B8A8_UINT,
645 VK_FORMAT_R8G8B8A8_SINT,
646 VK_FORMAT_R8G8B8A8_SRGB,
647 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
648 VK_FORMAT_A2R10G10B10_UINT_PACK32,
649 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
650 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
651 VK_FORMAT_A2B10G10R10_UINT_PACK32,
652 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
655 VK_FORMAT_R16_USCALED,
656 VK_FORMAT_R16_SSCALED,
659 VK_FORMAT_R16_SFLOAT,
660 VK_FORMAT_R16G16_UNORM,
661 VK_FORMAT_R16G16_SNORM,
662 VK_FORMAT_R16G16_USCALED,
663 VK_FORMAT_R16G16_SSCALED,
664 VK_FORMAT_R16G16_UINT,
665 VK_FORMAT_R16G16_SINT,
666 VK_FORMAT_R16G16_SFLOAT,
667 VK_FORMAT_R16G16B16_UNORM,
668 VK_FORMAT_R16G16B16_SNORM,
669 VK_FORMAT_R16G16B16_USCALED,
670 VK_FORMAT_R16G16B16_SSCALED,
671 VK_FORMAT_R16G16B16_UINT,
672 VK_FORMAT_R16G16B16_SINT,
673 VK_FORMAT_R16G16B16_SFLOAT,
674 VK_FORMAT_R16G16B16A16_UNORM,
675 VK_FORMAT_R16G16B16A16_SNORM,
676 VK_FORMAT_R16G16B16A16_USCALED,
677 VK_FORMAT_R16G16B16A16_SSCALED,
678 VK_FORMAT_R16G16B16A16_UINT,
679 VK_FORMAT_R16G16B16A16_SINT,
680 VK_FORMAT_R16G16B16A16_SFLOAT,
683 VK_FORMAT_R32_SFLOAT,
684 VK_FORMAT_R32G32_UINT,
685 VK_FORMAT_R32G32_SINT,
686 VK_FORMAT_R32G32_SFLOAT,
687 VK_FORMAT_R32G32B32_UINT,
688 VK_FORMAT_R32G32B32_SINT,
689 VK_FORMAT_R32G32B32_SFLOAT,
690 VK_FORMAT_R32G32B32A32_UINT,
691 VK_FORMAT_R32G32B32A32_SINT,
692 VK_FORMAT_R32G32B32A32_SFLOAT,
693 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
694 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
695 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
696 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
697 VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT,
698 VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT,
700 // Compressed formats
701 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
702 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
703 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
704 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
705 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
706 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
707 VK_FORMAT_EAC_R11_UNORM_BLOCK,
708 VK_FORMAT_EAC_R11_SNORM_BLOCK,
709 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
710 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
711 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
712 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
713 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
714 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
715 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
716 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
717 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
718 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
719 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
720 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
721 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
722 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
723 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
724 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
725 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
726 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
727 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
728 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
729 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
730 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
731 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
732 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
733 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
734 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
735 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
736 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
737 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
738 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
740 // Formats to test with dedicated allocation
741 const VkFormat dedicatedAllocationFormats[] =
743 VK_FORMAT_R8G8B8A8_UNORM,
744 VK_FORMAT_R16_SFLOAT,
746 const VkFormat* formats = (allocationKind == ALLOCATION_KIND_DEDICATED)
747 ? dedicatedAllocationFormats
749 const size_t formatsLength = (allocationKind == ALLOCATION_KIND_DEDICATED)
750 ? DE_LENGTH_OF_ARRAY(dedicatedAllocationFormats)
751 : DE_LENGTH_OF_ARRAY(coreFormats);
753 de::MovePtr<tcu::TestCaseGroup> imageFormatTests(new tcu::TestCaseGroup(testCtx, "format", "Tests samplable formats"));
755 for (size_t formatNdx = 0; formatNdx < formatsLength; formatNdx++)
757 const VkFormat format = formats[formatNdx];
759 if (isCompressedFormat(format))
761 // Do not use compressed formats with 1D and 1D array textures.
762 if (imageViewType == VK_IMAGE_VIEW_TYPE_1D || imageViewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY)
766 de::MovePtr<tcu::TestCaseGroup> formatGroup(new tcu::TestCaseGroup(testCtx,
767 getFormatCaseName(format).c_str(),
768 (std::string("Samples a texture of format ") + getFormatName(format)).c_str()));
769 createImageCountTests(formatGroup.get(), testCtx, allocationKind, pipelineConstructionType, samplingType, imageViewType, format);
771 imageFormatTests->addChild(formatGroup.release());
774 return imageFormatTests;
777 de::MovePtr<tcu::TestCaseGroup> createImageViewTypeTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType)
781 VkImageViewType type;
786 { VK_IMAGE_VIEW_TYPE_1D, "1d" },
787 { VK_IMAGE_VIEW_TYPE_1D_ARRAY, "1d_array" },
788 { VK_IMAGE_VIEW_TYPE_2D, "2d" },
789 { VK_IMAGE_VIEW_TYPE_2D_ARRAY, "2d_array" },
790 { VK_IMAGE_VIEW_TYPE_3D, "3d" },
791 { VK_IMAGE_VIEW_TYPE_CUBE, "cube" },
792 { VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, "cube_array" }
795 de::MovePtr<tcu::TestCaseGroup> imageViewTypeTests(new tcu::TestCaseGroup(testCtx, "view_type", ""));
797 for (int viewTypeNdx = 0; viewTypeNdx < DE_LENGTH_OF_ARRAY(imageViewTypes); viewTypeNdx++)
799 const VkImageViewType viewType = imageViewTypes[viewTypeNdx].type;
800 de::MovePtr<tcu::TestCaseGroup> viewTypeGroup(new tcu::TestCaseGroup(testCtx, imageViewTypes[viewTypeNdx].name, (std::string("Uses a ") + imageViewTypes[viewTypeNdx].name + " view").c_str()));
801 de::MovePtr<tcu::TestCaseGroup> formatTests = createImageFormatTests(testCtx, allocationKind, pipelineConstructionType, samplingType, viewType);
803 viewTypeGroup->addChild(formatTests.release());
804 imageViewTypeTests->addChild(viewTypeGroup.release());
807 return imageViewTypeTests;
810 de::MovePtr<tcu::TestCaseGroup> createImageSamplingTypeTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType)
812 VkDescriptorType samplingTypes[] =
814 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
815 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
818 de::MovePtr<tcu::TestCaseGroup> imageSamplingTypeTests(new tcu::TestCaseGroup(testCtx, "sampling_type", ""));
820 for (int smpTypeNdx = 0; smpTypeNdx < DE_LENGTH_OF_ARRAY(samplingTypes); smpTypeNdx++)
822 const char* smpTypeName = samplingTypes[smpTypeNdx] == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ? "combined" : "separate";
823 de::MovePtr<tcu::TestCaseGroup> samplingTypeGroup(new tcu::TestCaseGroup(testCtx, smpTypeName, (std::string("Uses a ") + smpTypeName + " sampler").c_str()));
824 de::MovePtr<tcu::TestCaseGroup> viewTypeTests = createImageViewTypeTests(testCtx, allocationKind, pipelineConstructionType, samplingTypes[smpTypeNdx]);
826 samplingTypeGroup->addChild(viewTypeTests.release());
827 imageSamplingTypeTests->addChild(samplingTypeGroup.release());
830 return imageSamplingTypeTests;
833 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, PipelineConstructionType pipelineConstructionType)
835 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation Image Tests"));
836 de::MovePtr<tcu::TestCaseGroup> samplingTypeTests = createImageSamplingTypeTests(testCtx, ALLOCATION_KIND_SUBALLOCATED, pipelineConstructionType);
838 suballocationTestsGroup->addChild(samplingTypeTests.release());
840 return suballocationTestsGroup;
843 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, PipelineConstructionType pipelineConstructionType)
845 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "Image Tests For Dedicated Allocation"));
846 de::MovePtr<tcu::TestCaseGroup> samplingTypeTests = createImageSamplingTypeTests(testCtx, ALLOCATION_KIND_DEDICATED, pipelineConstructionType);
848 dedicatedAllocationTestsGroup->addChild(samplingTypeTests.release());
850 return dedicatedAllocationTestsGroup;
854 tcu::TestCaseGroup* createImageTests (tcu::TestContext& testCtx, PipelineConstructionType pipelineConstructionType)
856 de::MovePtr<tcu::TestCaseGroup> imageTests(new tcu::TestCaseGroup(testCtx, "image", "Image tests"));
857 de::MovePtr<tcu::TestCaseGroup> imageSuballocationTests = createSuballocationTests(testCtx, pipelineConstructionType);
858 de::MovePtr<tcu::TestCaseGroup> imageDedicatedAllocationTests = createDedicatedAllocationTests(testCtx, pipelineConstructionType);
860 imageTests->addChild(imageSuballocationTests.release());
861 imageTests->addChild(imageDedicatedAllocationTests.release());
863 return imageTests.release();