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,
63 bool pipelineProtectedAccess,
64 bool pipelineProtectedFlag);
66 ImageSamplingInstanceParams getImageSamplingInstanceParams (AllocationKind allocationKind,
67 VkDescriptorType samplingType,
68 VkImageViewType imageViewType,
70 const tcu::IVec3& imageSize,
74 virtual void initPrograms (SourceCollections& sourceCollections) const;
75 virtual void checkSupport (Context& context) const;
76 virtual TestInstance* createInstance (Context& context) const;
77 static std::string getGlslSamplerType (const tcu::TextureFormat& format, VkImageViewType type);
78 static std::string getGlslTextureType (const tcu::TextureFormat& format, VkImageViewType type);
79 static std::string getGlslSamplerDecl (int imageCount);
80 static std::string getGlslTextureDecl (int imageCount);
81 static std::string getGlslFragColorDecl (int imageCount);
82 static std::string getGlslSampler (const tcu::TextureFormat& format,
84 VkDescriptorType samplingType,
88 AllocationKind m_allocationKind;
89 PipelineConstructionType m_pipelineConstructionType;
90 VkDescriptorType m_samplingType;
91 VkImageViewType m_imageViewType;
92 VkFormat m_imageFormat;
93 tcu::IVec3 m_imageSize;
96 bool m_pipelineProtectedAccess;
97 bool m_pipelineProtectedFlag;
100 ImageTest::ImageTest (tcu::TestContext& testContext,
102 const char* description,
103 AllocationKind allocationKind,
104 PipelineConstructionType pipelineConstructionType,
105 VkDescriptorType samplingType,
106 VkImageViewType imageViewType,
107 VkFormat imageFormat,
108 const tcu::IVec3& imageSize,
111 bool pipelineProtectedAccess,
112 bool pipelineProtectedFlag)
114 : vkt::TestCase (testContext, name, description)
115 , m_allocationKind (allocationKind)
116 , m_pipelineConstructionType (pipelineConstructionType)
117 , m_samplingType (samplingType)
118 , m_imageViewType (imageViewType)
119 , m_imageFormat (imageFormat)
120 , m_imageSize (imageSize)
121 , m_imageCount (imageCount)
122 , m_arraySize (arraySize)
123 , m_pipelineProtectedAccess (pipelineProtectedAccess)
124 , m_pipelineProtectedFlag (pipelineProtectedFlag)
128 void ImageTest::checkSupport (Context& context) const
130 // Using a loop to index into an array of images requires shaderSampledImageArrayDynamicIndexing
131 if (m_imageCount > 1)
132 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING);
134 checkPipelineLibraryRequirements(context.getInstanceInterface(), context.getPhysicalDevice(), m_pipelineConstructionType);
135 checkSupportImageSamplingInstance(context, getImageSamplingInstanceParams(m_allocationKind, m_samplingType, m_imageViewType, m_imageFormat, m_imageSize, m_imageCount, m_arraySize));
137 if (m_pipelineProtectedAccess) {
138 #ifndef CTS_USES_VULKANSC
139 context.requireDeviceFunctionality("VK_EXT_pipeline_protected_access");
141 if (!context.getPipelineProtectedAccessFeaturesEXT().pipelineProtectedAccess)
143 throw tcu::NotSupportedError("pipelineProtectedAccess feature is not supported");
145 #else // CTS_USES_VULKANSC
146 throw tcu::NotSupportedError("pipeline protected access is not supported");
147 #endif // CTS_USES_VULKANSC
151 ImageSamplingInstanceParams ImageTest::getImageSamplingInstanceParams (AllocationKind allocationKind,
152 VkDescriptorType samplingType,
153 VkImageViewType imageViewType,
154 VkFormat imageFormat,
155 const tcu::IVec3& imageSize,
159 tcu::UVec2 renderSize;
161 if (imageViewType == VK_IMAGE_VIEW_TYPE_1D || imageViewType == VK_IMAGE_VIEW_TYPE_2D)
163 renderSize = tcu::UVec2((deUint32)imageSize.x(), (deUint32)imageSize.y());
167 // Draw a 3x2 grid of texture layers
168 renderSize = tcu::UVec2((deUint32)imageSize.x() * 3, (deUint32)imageSize.y() * 2);
171 const bool separateStencilUsage = false;
172 const std::vector<Vertex4Tex4> vertices = createTestQuadMosaic(imageViewType);
173 const VkComponentMapping componentMapping = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
174 const VkImageSubresourceRange subresourceRange =
176 VK_IMAGE_ASPECT_COLOR_BIT,
178 (deUint32)deLog2Floor32(deMax32(imageSize.x(), deMax32(imageSize.y(), imageSize.z()))) + 1,
183 const VkSamplerCreateInfo samplerParams =
185 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, // VkStructureType sType;
186 DE_NULL, // const void* pNext;
187 0u, // VkSamplerCreateFlags flags;
188 VK_FILTER_NEAREST, // VkFilter magFilter;
189 VK_FILTER_NEAREST, // VkFilter minFilter;
190 VK_SAMPLER_MIPMAP_MODE_NEAREST, // VkSamplerMipmapMode mipmapMode;
191 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeU;
192 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeV;
193 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // VkSamplerAddressMode addressModeW;
194 0.0f, // float mipLodBias;
195 VK_FALSE, // VkBool32 anisotropyEnable;
196 1.0f, // float maxAnisotropy;
197 false, // VkBool32 compareEnable;
198 VK_COMPARE_OP_NEVER, // VkCompareOp compareOp;
199 0.0f, // float minLod;
200 (float)(subresourceRange.levelCount - 1), // float maxLod;
201 getFormatBorderColor(BORDER_COLOR_TRANSPARENT_BLACK, imageFormat, false), // VkBorderColor borderColor;
202 false // VkBool32 unnormalizedCoordinates;
205 #ifdef CTS_USES_VULKANSC
206 const vk::VkPipelineCreateFlags pipelineFlags = (vk::VkPipelineCreateFlagBits)0u;
207 (void)m_pipelineProtectedFlag;
208 #else // CTS_USES_VULKANSC
209 const vk::VkPipelineCreateFlags pipelineFlags = m_pipelineProtectedFlag ? vk::VK_PIPELINE_CREATE_NO_PROTECTED_ACCESS_BIT_EXT : (vk::VkPipelineCreateFlagBits)0u;
210 #endif // CTS_USES_VULKANSC
212 return ImageSamplingInstanceParams(m_pipelineConstructionType, renderSize, imageViewType, imageFormat, imageSize, arraySize, componentMapping, subresourceRange, samplerParams, 0.0f, vertices, separateStencilUsage, samplingType, imageCount, allocationKind, vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, pipelineFlags);
215 void ImageTest::initPrograms (SourceCollections& sourceCollections) const
217 std::ostringstream vertexSrc;
218 std::ostringstream fragmentSrc;
219 const char* texCoordSwizzle = DE_NULL;
220 const tcu::TextureFormat format = (isCompressedFormat(m_imageFormat)) ? tcu::getUncompressedFormat(mapVkCompressedFormat(m_imageFormat))
221 : mapVkFormat(m_imageFormat);
223 tcu::Vec4 lookupScale;
224 tcu::Vec4 lookupBias;
226 getLookupScaleBias(m_imageFormat, lookupScale, lookupBias);
228 switch (m_imageViewType)
230 case VK_IMAGE_VIEW_TYPE_1D:
231 texCoordSwizzle = "x";
233 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
234 case VK_IMAGE_VIEW_TYPE_2D:
235 texCoordSwizzle = "xy";
237 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
238 case VK_IMAGE_VIEW_TYPE_3D:
239 case VK_IMAGE_VIEW_TYPE_CUBE:
240 texCoordSwizzle = "xyz";
242 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
243 texCoordSwizzle = "xyzw";
250 vertexSrc << "#version 440\n"
251 << "layout(location = 0) in vec4 position;\n"
252 << "layout(location = 1) in vec4 texCoords;\n"
253 << "layout(location = 0) out highp vec4 vtxTexCoords;\n"
254 << "out gl_PerVertex {\n"
255 << " vec4 gl_Position;\n"
257 << "void main (void)\n"
259 << " gl_Position = position;\n"
260 << " vtxTexCoords = texCoords;\n"
263 fragmentSrc << "#version 440\n";
264 switch (m_samplingType)
266 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
268 << "layout(set = 0, binding = 0) uniform highp sampler texSampler;\n"
269 << "layout(set = 0, binding = 1) uniform highp " << getGlslTextureType(format, m_imageViewType) << " " << getGlslTextureDecl(m_imageCount) << ";\n";
271 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
274 << "layout(set = 0, binding = 0) uniform highp " << getGlslSamplerType(format, m_imageViewType) << " " << getGlslSamplerDecl(m_imageCount) << ";\n";
276 fragmentSrc << "layout(location = 0) in highp vec4 vtxTexCoords;\n"
277 << "layout(location = 0) out highp vec4 " << getGlslFragColorDecl(m_imageCount) << ";\n"
278 << "void main (void)\n"
280 if (m_imageCount > 1)
282 << " for (uint i = 0; i < " << m_imageCount << "; ++i)\n"
283 << " fragColors[i] = (texture(" << getGlslSampler(format, m_imageViewType, m_samplingType, m_imageCount) << ", vtxTexCoords." << texCoordSwizzle << std::scientific << ") * vec4" << lookupScale << ") + vec4" << lookupBias << "; \n";
286 << " fragColor = (texture(" << getGlslSampler(format, m_imageViewType, m_samplingType, m_imageCount) << ", vtxTexCoords." << texCoordSwizzle << std::scientific << ") * vec4" << lookupScale << ") + vec4" << lookupBias << "; \n";
287 fragmentSrc << "}\n";
289 sourceCollections.glslSources.add("tex_vert") << glu::VertexSource(vertexSrc.str());
290 sourceCollections.glslSources.add("tex_frag") << glu::FragmentSource(fragmentSrc.str());
293 TestInstance* ImageTest::createInstance (Context& context) const
295 return new ImageSamplingInstance(context, getImageSamplingInstanceParams(m_allocationKind, m_samplingType, m_imageViewType, m_imageFormat, m_imageSize, m_imageCount, m_arraySize));
298 std::string ImageTest::getGlslSamplerType (const tcu::TextureFormat& format, VkImageViewType type)
300 std::ostringstream samplerType;
302 if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
304 else if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
309 case VK_IMAGE_VIEW_TYPE_1D:
310 samplerType << "sampler1D";
313 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
314 samplerType << "sampler1DArray";
317 case VK_IMAGE_VIEW_TYPE_2D:
318 samplerType << "sampler2D";
321 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
322 samplerType << "sampler2DArray";
325 case VK_IMAGE_VIEW_TYPE_3D:
326 samplerType << "sampler3D";
329 case VK_IMAGE_VIEW_TYPE_CUBE:
330 samplerType << "samplerCube";
333 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
334 samplerType << "samplerCubeArray";
338 DE_FATAL("Unknown image view type");
342 return samplerType.str();
345 std::string ImageTest::getGlslTextureType (const tcu::TextureFormat& format, VkImageViewType type)
347 std::ostringstream textureType;
349 if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
351 else if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
356 case VK_IMAGE_VIEW_TYPE_1D:
357 textureType << "texture1D";
360 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
361 textureType << "texture1DArray";
364 case VK_IMAGE_VIEW_TYPE_2D:
365 textureType << "texture2D";
368 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
369 textureType << "texture2DArray";
372 case VK_IMAGE_VIEW_TYPE_3D:
373 textureType << "texture3D";
376 case VK_IMAGE_VIEW_TYPE_CUBE:
377 textureType << "textureCube";
380 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
381 textureType << "textureCubeArray";
385 DE_FATAL("Unknown image view type");
388 return textureType.str();
391 std::string ImageTest::getGlslSamplerDecl (int imageCount)
393 std::ostringstream samplerArray;
394 samplerArray << "texSamplers[" << imageCount << "]";
396 return imageCount > 1 ? samplerArray.str() : "texSampler";
399 std::string ImageTest::getGlslTextureDecl (int imageCount)
401 std::ostringstream textureArray;
402 textureArray << "texImages[" << imageCount << "]";
404 return imageCount > 1 ? textureArray.str() : "texImage";
407 std::string ImageTest::getGlslFragColorDecl (int imageCount)
409 std::ostringstream samplerArray;
410 samplerArray << "fragColors[" << imageCount << "]";
412 return imageCount > 1 ? samplerArray.str() : "fragColor";
415 std::string ImageTest::getGlslSampler (const tcu::TextureFormat& format, VkImageViewType type, VkDescriptorType samplingType, int imageCount)
417 std::string texSampler = imageCount > 1 ? "texSamplers[i]" : "texSampler";
418 std::string texImage = imageCount > 1 ? "texImages[i]" : "texImage";
420 switch (samplingType)
422 case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
423 return getGlslSamplerType(format, type) + "(" + texImage + ", texSampler)";
424 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
430 std::string getFormatCaseName (const VkFormat format)
432 const std::string fullName = getFormatName(format);
434 DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_"));
436 return de::toLower(fullName.substr(10));
439 std::string getSizeName (VkImageViewType viewType, const tcu::IVec3& size, int arraySize, bool pipelineProtectedAccess, bool pipelineProtectedFlag)
441 std::ostringstream caseName;
443 if (pipelineProtectedAccess) {
444 caseName << "pipeline_protected_access_";
446 if (pipelineProtectedFlag) {
447 caseName << "pipeline_protected_flag_";
452 case VK_IMAGE_VIEW_TYPE_1D:
453 case VK_IMAGE_VIEW_TYPE_2D:
454 case VK_IMAGE_VIEW_TYPE_CUBE:
455 caseName << size.x() << "x" << size.y();
458 case VK_IMAGE_VIEW_TYPE_3D:
459 caseName << size.x() << "x" << size.y() << "x" << size.z();
462 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
463 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
464 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
465 caseName << size.x() << "x" << size.y() << "_array_of_" << arraySize;
473 return caseName.str();
476 de::MovePtr<tcu::TestCaseGroup> createImageSizeTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType, VkImageViewType imageViewType, VkFormat imageFormat, int imageCount)
480 std::vector<IVec3> imageSizes;
481 std::vector<int> arraySizes;
482 de::MovePtr<tcu::TestCaseGroup> imageSizeTests (new tcu::TestCaseGroup(testCtx, "size", ""));
484 const bool pipelineProtectedAccess[] = {
486 #ifndef CTS_USES_VULKANSC
490 const bool pipelineProtectedFlag[] = {
492 #ifndef CTS_USES_VULKANSC
497 // Select image imageSizes
498 switch (imageViewType)
500 case VK_IMAGE_VIEW_TYPE_1D:
501 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
505 imageSizes.push_back(IVec3(1, 1, 1));
506 imageSizes.push_back(IVec3(2, 1, 1));
507 imageSizes.push_back(IVec3(32, 1, 1));
508 imageSizes.push_back(IVec3(128, 1, 1));
510 imageSizes.push_back(IVec3(512, 1, 1));
515 imageSizes.push_back(IVec3(3, 1, 1));
516 imageSizes.push_back(IVec3(13, 1, 1));
517 imageSizes.push_back(IVec3(127, 1, 1));
519 imageSizes.push_back(IVec3(443, 1, 1));
522 case VK_IMAGE_VIEW_TYPE_2D:
523 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
527 imageSizes.push_back(IVec3(1, 1, 1));
528 imageSizes.push_back(IVec3(2, 2, 1));
529 imageSizes.push_back(IVec3(32, 32, 1));
532 imageSizes.push_back(IVec3(3, 3, 1));
533 imageSizes.push_back(IVec3(13, 13, 1));
538 imageSizes.push_back(IVec3(8, 16, 1));
539 imageSizes.push_back(IVec3(32, 16, 1));
542 imageSizes.push_back(IVec3(13, 23, 1));
544 imageSizes.push_back(IVec3(23, 8, 1));
547 case VK_IMAGE_VIEW_TYPE_3D:
551 imageSizes.push_back(IVec3(1, 1, 1));
552 imageSizes.push_back(IVec3(2, 2, 2));
554 imageSizes.push_back(IVec3(16, 16, 16));
559 imageSizes.push_back(IVec3(3, 3, 3));
560 imageSizes.push_back(IVec3(5, 5, 5));
562 imageSizes.push_back(IVec3(11, 11, 11));
566 imageSizes.push_back(IVec3(32, 16, 8));
567 imageSizes.push_back(IVec3(8, 16, 32));
570 imageSizes.push_back(IVec3(17, 11, 5));
572 imageSizes.push_back(IVec3(5, 11, 17));
575 case VK_IMAGE_VIEW_TYPE_CUBE:
576 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
578 imageSizes.push_back(IVec3(32, 32, 1));
581 imageSizes.push_back(IVec3(13, 13, 1));
589 // Select array sizes
590 switch (imageViewType)
592 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
593 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
595 arraySizes.push_back(3);
596 arraySizes.push_back(6);
599 case VK_IMAGE_VIEW_TYPE_CUBE:
600 arraySizes.push_back(6);
603 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
605 arraySizes.push_back(6);
606 arraySizes.push_back(6 * 6);
610 arraySizes.push_back(1);
614 for (size_t protectedNdx = 0; protectedNdx < DE_LENGTH_OF_ARRAY(pipelineProtectedAccess); ++protectedNdx) {
615 for (size_t flagNdx = 0; flagNdx < DE_LENGTH_OF_ARRAY(pipelineProtectedAccess); ++flagNdx) {
616 if (!pipelineProtectedAccess[protectedNdx] && pipelineProtectedFlag[flagNdx]) continue;
618 for (size_t sizeNdx = 0; sizeNdx < imageSizes.size(); sizeNdx++)
620 for (size_t arraySizeNdx = 0; arraySizeNdx < arraySizes.size(); arraySizeNdx++)
622 imageSizeTests->addChild(new ImageTest(testCtx,
623 getSizeName(imageViewType, imageSizes[sizeNdx], arraySizes[arraySizeNdx], pipelineProtectedAccess[protectedNdx], pipelineProtectedFlag[flagNdx]).c_str(),
626 pipelineConstructionType,
632 arraySizes[arraySizeNdx],
633 pipelineProtectedAccess[protectedNdx],
634 pipelineProtectedFlag[flagNdx]));
640 return imageSizeTests;
643 void createImageCountTests (tcu::TestCaseGroup* parentGroup, tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType, VkImageViewType imageViewType, VkFormat imageFormat)
645 const int coreImageCounts[] = { 1, 4, 8 };
646 const int dedicatedAllocationImageCounts[] = { 1 };
647 const int* imageCounts = (allocationKind == ALLOCATION_KIND_DEDICATED)
648 ? dedicatedAllocationImageCounts
650 const size_t imageCountsLength = (allocationKind == ALLOCATION_KIND_DEDICATED)
651 ? DE_LENGTH_OF_ARRAY(dedicatedAllocationImageCounts)
652 : DE_LENGTH_OF_ARRAY(coreImageCounts);
654 for (size_t countNdx = 0; countNdx < imageCountsLength; countNdx++)
656 std::ostringstream caseName;
657 caseName << "count_" << imageCounts[countNdx];
658 de::MovePtr<tcu::TestCaseGroup> countGroup(new tcu::TestCaseGroup(testCtx, caseName.str().c_str(), ""));
659 de::MovePtr<tcu::TestCaseGroup> sizeTests = createImageSizeTests(testCtx, allocationKind, pipelineConstructionType, samplingType, imageViewType, imageFormat, imageCounts[countNdx]);
661 countGroup->addChild(sizeTests.release());
662 parentGroup->addChild(countGroup.release());
666 de::MovePtr<tcu::TestCaseGroup> createImageFormatTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType, VkImageViewType imageViewType)
668 // All supported dEQP formats that are not intended for depth or stencil.
669 const VkFormat coreFormats[] =
671 VK_FORMAT_R4G4_UNORM_PACK8,
672 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
673 VK_FORMAT_R5G6B5_UNORM_PACK16,
674 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
677 VK_FORMAT_R8_USCALED,
678 VK_FORMAT_R8_SSCALED,
682 VK_FORMAT_R8G8_UNORM,
683 VK_FORMAT_R8G8_SNORM,
684 VK_FORMAT_R8G8_USCALED,
685 VK_FORMAT_R8G8_SSCALED,
689 VK_FORMAT_R8G8B8_UNORM,
690 VK_FORMAT_R8G8B8_SNORM,
691 VK_FORMAT_R8G8B8_USCALED,
692 VK_FORMAT_R8G8B8_SSCALED,
693 VK_FORMAT_R8G8B8_UINT,
694 VK_FORMAT_R8G8B8_SINT,
695 VK_FORMAT_R8G8B8_SRGB,
696 VK_FORMAT_R8G8B8A8_UNORM,
697 VK_FORMAT_R8G8B8A8_SNORM,
698 VK_FORMAT_R8G8B8A8_USCALED,
699 VK_FORMAT_R8G8B8A8_SSCALED,
700 VK_FORMAT_R8G8B8A8_UINT,
701 VK_FORMAT_R8G8B8A8_SINT,
702 VK_FORMAT_R8G8B8A8_SRGB,
703 VK_FORMAT_A2R10G10B10_UNORM_PACK32,
704 VK_FORMAT_A2R10G10B10_UINT_PACK32,
705 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
706 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
707 VK_FORMAT_A2B10G10R10_UINT_PACK32,
708 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
711 VK_FORMAT_R16_USCALED,
712 VK_FORMAT_R16_SSCALED,
715 VK_FORMAT_R16_SFLOAT,
716 VK_FORMAT_R16G16_UNORM,
717 VK_FORMAT_R16G16_SNORM,
718 VK_FORMAT_R16G16_USCALED,
719 VK_FORMAT_R16G16_SSCALED,
720 VK_FORMAT_R16G16_UINT,
721 VK_FORMAT_R16G16_SINT,
722 VK_FORMAT_R16G16_SFLOAT,
723 VK_FORMAT_R16G16B16_UNORM,
724 VK_FORMAT_R16G16B16_SNORM,
725 VK_FORMAT_R16G16B16_USCALED,
726 VK_FORMAT_R16G16B16_SSCALED,
727 VK_FORMAT_R16G16B16_UINT,
728 VK_FORMAT_R16G16B16_SINT,
729 VK_FORMAT_R16G16B16_SFLOAT,
730 VK_FORMAT_R16G16B16A16_UNORM,
731 VK_FORMAT_R16G16B16A16_SNORM,
732 VK_FORMAT_R16G16B16A16_USCALED,
733 VK_FORMAT_R16G16B16A16_SSCALED,
734 VK_FORMAT_R16G16B16A16_UINT,
735 VK_FORMAT_R16G16B16A16_SINT,
736 VK_FORMAT_R16G16B16A16_SFLOAT,
739 VK_FORMAT_R32_SFLOAT,
740 VK_FORMAT_R32G32_UINT,
741 VK_FORMAT_R32G32_SINT,
742 VK_FORMAT_R32G32_SFLOAT,
743 VK_FORMAT_R32G32B32_UINT,
744 VK_FORMAT_R32G32B32_SINT,
745 VK_FORMAT_R32G32B32_SFLOAT,
746 VK_FORMAT_R32G32B32A32_UINT,
747 VK_FORMAT_R32G32B32A32_SINT,
748 VK_FORMAT_R32G32B32A32_SFLOAT,
749 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
750 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
751 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
752 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
753 VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT,
754 VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT,
756 // Compressed formats
757 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
758 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
759 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
760 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
761 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
762 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
763 VK_FORMAT_EAC_R11_UNORM_BLOCK,
764 VK_FORMAT_EAC_R11_SNORM_BLOCK,
765 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
766 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
767 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
768 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
769 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
770 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
771 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
772 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
773 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
774 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
775 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
776 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
777 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
778 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
779 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
780 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
781 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
782 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
783 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
784 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
785 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
786 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
787 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
788 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
789 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
790 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
791 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
792 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
793 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
794 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
796 // Formats to test with dedicated allocation
797 const VkFormat dedicatedAllocationFormats[] =
799 VK_FORMAT_R8G8B8A8_UNORM,
800 VK_FORMAT_R16_SFLOAT,
802 const VkFormat* formats = (allocationKind == ALLOCATION_KIND_DEDICATED)
803 ? dedicatedAllocationFormats
805 const size_t formatsLength = (allocationKind == ALLOCATION_KIND_DEDICATED)
806 ? DE_LENGTH_OF_ARRAY(dedicatedAllocationFormats)
807 : DE_LENGTH_OF_ARRAY(coreFormats);
809 de::MovePtr<tcu::TestCaseGroup> imageFormatTests(new tcu::TestCaseGroup(testCtx, "format", "Tests samplable formats"));
811 for (size_t formatNdx = 0; formatNdx < formatsLength; formatNdx++)
813 const VkFormat format = formats[formatNdx];
815 if (isCompressedFormat(format))
817 // Do not use compressed formats with 1D and 1D array textures.
818 if (imageViewType == VK_IMAGE_VIEW_TYPE_1D || imageViewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY)
822 de::MovePtr<tcu::TestCaseGroup> formatGroup(new tcu::TestCaseGroup(testCtx,
823 getFormatCaseName(format).c_str(),
824 (std::string("Samples a texture of format ") + getFormatName(format)).c_str()));
825 createImageCountTests(formatGroup.get(), testCtx, allocationKind, pipelineConstructionType, samplingType, imageViewType, format);
827 imageFormatTests->addChild(formatGroup.release());
830 return imageFormatTests;
833 de::MovePtr<tcu::TestCaseGroup> createImageViewTypeTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType, VkDescriptorType samplingType)
837 VkImageViewType type;
842 { VK_IMAGE_VIEW_TYPE_1D, "1d" },
843 { VK_IMAGE_VIEW_TYPE_1D_ARRAY, "1d_array" },
844 { VK_IMAGE_VIEW_TYPE_2D, "2d" },
845 { VK_IMAGE_VIEW_TYPE_2D_ARRAY, "2d_array" },
846 { VK_IMAGE_VIEW_TYPE_3D, "3d" },
847 { VK_IMAGE_VIEW_TYPE_CUBE, "cube" },
848 { VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, "cube_array" }
851 de::MovePtr<tcu::TestCaseGroup> imageViewTypeTests(new tcu::TestCaseGroup(testCtx, "view_type", ""));
853 for (int viewTypeNdx = 0; viewTypeNdx < DE_LENGTH_OF_ARRAY(imageViewTypes); viewTypeNdx++)
855 const VkImageViewType viewType = imageViewTypes[viewTypeNdx].type;
856 de::MovePtr<tcu::TestCaseGroup> viewTypeGroup(new tcu::TestCaseGroup(testCtx, imageViewTypes[viewTypeNdx].name, (std::string("Uses a ") + imageViewTypes[viewTypeNdx].name + " view").c_str()));
857 de::MovePtr<tcu::TestCaseGroup> formatTests = createImageFormatTests(testCtx, allocationKind, pipelineConstructionType, samplingType, viewType);
859 viewTypeGroup->addChild(formatTests.release());
860 imageViewTypeTests->addChild(viewTypeGroup.release());
863 return imageViewTypeTests;
866 de::MovePtr<tcu::TestCaseGroup> createImageSamplingTypeTests (tcu::TestContext& testCtx, AllocationKind allocationKind, PipelineConstructionType pipelineConstructionType)
868 VkDescriptorType samplingTypes[] =
870 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
871 VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
874 de::MovePtr<tcu::TestCaseGroup> imageSamplingTypeTests(new tcu::TestCaseGroup(testCtx, "sampling_type", ""));
876 for (int smpTypeNdx = 0; smpTypeNdx < DE_LENGTH_OF_ARRAY(samplingTypes); smpTypeNdx++)
878 const char* smpTypeName = samplingTypes[smpTypeNdx] == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ? "combined" : "separate";
879 de::MovePtr<tcu::TestCaseGroup> samplingTypeGroup(new tcu::TestCaseGroup(testCtx, smpTypeName, (std::string("Uses a ") + smpTypeName + " sampler").c_str()));
880 de::MovePtr<tcu::TestCaseGroup> viewTypeTests = createImageViewTypeTests(testCtx, allocationKind, pipelineConstructionType, samplingTypes[smpTypeNdx]);
882 samplingTypeGroup->addChild(viewTypeTests.release());
883 imageSamplingTypeTests->addChild(samplingTypeGroup.release());
886 return imageSamplingTypeTests;
889 de::MovePtr<tcu::TestCaseGroup> createSuballocationTests(tcu::TestContext& testCtx, PipelineConstructionType pipelineConstructionType)
891 de::MovePtr<tcu::TestCaseGroup> suballocationTestsGroup(new tcu::TestCaseGroup(testCtx, "suballocation", "Suballocation Image Tests"));
892 de::MovePtr<tcu::TestCaseGroup> samplingTypeTests = createImageSamplingTypeTests(testCtx, ALLOCATION_KIND_SUBALLOCATED, pipelineConstructionType);
894 suballocationTestsGroup->addChild(samplingTypeTests.release());
896 return suballocationTestsGroup;
899 de::MovePtr<tcu::TestCaseGroup> createDedicatedAllocationTests(tcu::TestContext& testCtx, PipelineConstructionType pipelineConstructionType)
901 de::MovePtr<tcu::TestCaseGroup> dedicatedAllocationTestsGroup(new tcu::TestCaseGroup(testCtx, "dedicated_allocation", "Image Tests For Dedicated Allocation"));
902 de::MovePtr<tcu::TestCaseGroup> samplingTypeTests = createImageSamplingTypeTests(testCtx, ALLOCATION_KIND_DEDICATED, pipelineConstructionType);
904 dedicatedAllocationTestsGroup->addChild(samplingTypeTests.release());
906 return dedicatedAllocationTestsGroup;
910 tcu::TestCaseGroup* createImageTests (tcu::TestContext& testCtx, PipelineConstructionType pipelineConstructionType)
912 de::MovePtr<tcu::TestCaseGroup> imageTests(new tcu::TestCaseGroup(testCtx, "image", "Image tests"));
913 de::MovePtr<tcu::TestCaseGroup> imageSuballocationTests = createSuballocationTests(testCtx, pipelineConstructionType);
914 de::MovePtr<tcu::TestCaseGroup> imageDedicatedAllocationTests = createDedicatedAllocationTests(testCtx, pipelineConstructionType);
916 imageTests->addChild(imageSuballocationTests.release());
917 imageTests->addChild(imageDedicatedAllocationTests.release());
919 return imageTests.release();