dEQP-VK.renderpass: Set IMAGE_USAGE_TRANSFER_SRC_BIT when needed
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / pipeline / vktPipelineSamplerTests.cpp
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Imagination Technologies Ltd.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and/or associated documentation files (the
10  * "Materials"), to deal in the Materials without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Materials, and to
13  * permit persons to whom the Materials are furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice(s) and this permission notice shall be included
17  * in all copies or substantial portions of the Materials.
18  *
19  * The Materials are Confidential Information as defined by the
20  * Khronos Membership Agreement until designated non-confidential by Khronos,
21  * at which point this condition clause shall be removed.
22  *
23  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
30  *
31  *//*!
32  * \file
33  * \brief Sampler Tests
34  *//*--------------------------------------------------------------------*/
35
36 #include "vktPipelineSamplerTests.hpp"
37 #include "vktPipelineImageSamplingInstance.hpp"
38 #include "vktPipelineImageUtil.hpp"
39 #include "vktPipelineVertexUtil.hpp"
40 #include "vktTestCase.hpp"
41 #include "vkImageUtil.hpp"
42 #include "vkPrograms.hpp"
43 #include "tcuPlatform.hpp"
44 #include "tcuTextureUtil.hpp"
45 #include "deStringUtil.hpp"
46 #include "deMemory.h"
47
48 #include <iomanip>
49 #include <sstream>
50 #include <vector>
51
52 namespace vkt
53 {
54 namespace pipeline
55 {
56
57 using namespace vk;
58 using de::MovePtr;
59
60 namespace
61 {
62
63 class SamplerTest : public vkt::TestCase
64 {
65 public:
66                                                                                 SamplerTest                             (tcu::TestContext&      testContext,
67                                                                                                                                  const char*            name,
68                                                                                                                                  const char*            description,
69                                                                                                                                  VkImageViewType        imageViewType,
70                                                                                                                                  VkFormat                       imageFormat,
71                                                                                                                                  int                            imageSize,
72                                                                                                                                  float                          samplerLod);
73         virtual                                                         ~SamplerTest                    (void) {}
74
75         virtual void                                            initPrograms                    (SourceCollections& sourceCollections) const;
76         virtual TestInstance*                           createInstance                  (Context& context) const;
77         virtual tcu::IVec2                                      getRenderSize                   (VkImageViewType viewType) const;
78         virtual std::vector<Vertex4Tex4>        createVertices                  (void) const;
79         virtual VkSamplerCreateInfo                     getSamplerCreateInfo    (void) const;
80
81         static std::string                                      getGlslSamplerType              (const tcu::TextureFormat& format, VkImageViewType type);
82         static tcu::IVec3                                       getImageSize                    (VkImageViewType viewType, int size);
83         static int                                                      getArraySize                    (VkImageViewType viewType);
84
85 protected:
86         VkImageViewType                                         m_imageViewType;
87         VkFormat                                                        m_imageFormat;
88         int                                                                     m_imageSize;
89         VkImageViewCreateInfo                           m_imageViewParams;
90         VkSamplerCreateInfo                                     m_samplerParams;
91         float                                                           m_samplerLod;
92 };
93
94 class SamplerMagFilterTest : public SamplerTest
95 {
96 public:
97                                                                         SamplerMagFilterTest    (tcu::TestContext&      testContext,
98                                                                                                                          const char*            name,
99                                                                                                                          const char*            description,
100                                                                                                                          VkImageViewType        imageViewType,
101                                                                                                                          VkFormat                       imageFormat,
102                                                                                                                          VkFilter                       magFilter);
103         virtual                                                 ~SamplerMagFilterTest   (void) {}
104         virtual VkSamplerCreateInfo             getSamplerCreateInfo    (void) const;
105
106 private:
107         VkFilter                                                m_magFilter;
108 };
109
110 class SamplerMinFilterTest : public SamplerTest
111 {
112 public:
113                                                                         SamplerMinFilterTest    (tcu::TestContext&      testContext,
114                                                                                                                          const char*            name,
115                                                                                                                          const char*            description,
116                                                                                                                          VkImageViewType        imageViewType,
117                                                                                                                          VkFormat                       imageFormat,
118                                                                                                                          VkFilter                       minFilter);
119         virtual                                                 ~SamplerMinFilterTest   (void) {}
120         virtual VkSamplerCreateInfo             getSamplerCreateInfo    (void) const;
121
122 private:
123         VkFilter                                                m_minFilter;
124 };
125
126 class SamplerLodTest : public SamplerTest
127 {
128 public:
129                                                                         SamplerLodTest                  (tcu::TestContext&              testContext,
130                                                                                                                          const char*                    name,
131                                                                                                                          const char*                    description,
132                                                                                                                          VkImageViewType                imageViewType,
133                                                                                                                          VkFormat                               imageFormat,
134                                                                                                                          VkSamplerMipmapMode    mipmapMode,
135                                                                                                                          float                                  minLod,
136                                                                                                                          float                                  maxLod,
137                                                                                                                          float                                  mipLodBias,
138                                                                                                                          float                                  samplerLod);
139         virtual                                                 ~SamplerLodTest                 (void) {}
140         virtual VkSamplerCreateInfo             getSamplerCreateInfo    (void) const;
141
142 private:
143         VkSamplerMipmapMode                             m_mipmapMode;
144         float                                                   m_minLod;
145         float                                                   m_maxLod;
146         float                                                   m_mipLodBias;
147 };
148
149 class SamplerAddressModesTest : public SamplerTest
150 {
151 public:
152                                                                                 SamplerAddressModesTest         (tcu::TestContext&              testContext,
153                                                                                                                                          const char*                    name,
154                                                                                                                                          const char*                    description,
155                                                                                                                                          VkImageViewType                imageViewType,
156                                                                                                                                          VkFormat                               imageFormat,
157                                                                                                                                          VkSamplerAddressMode   addressU,
158                                                                                                                                          VkSamplerAddressMode   addressV,
159                                                                                                                                          VkSamplerAddressMode   addressW,
160                                                                                                                                          VkBorderColor                  borderColor);
161         virtual                                                         ~SamplerAddressModesTest        (void) {}
162         virtual tcu::IVec2                                      getRenderSize (VkImageViewType viewType) const;
163         virtual std::vector<Vertex4Tex4>        createVertices                          (void) const;
164         virtual VkSamplerCreateInfo                     getSamplerCreateInfo            (void) const;
165
166 private:
167         VkSamplerAddressMode                            m_addressU;
168         VkSamplerAddressMode                            m_addressV;
169         VkSamplerAddressMode                            m_addressW;
170         VkBorderColor                                           m_borderColor;
171 };
172
173
174 // SamplerTest
175
176 SamplerTest::SamplerTest (tcu::TestContext&     testContext,
177                                                   const char*           name,
178                                                   const char*           description,
179                                                   VkImageViewType       imageViewType,
180                                                   VkFormat                      imageFormat,
181                                                   int                           imageSize,
182                                                   float                         samplerLod)
183         : vkt::TestCase         (testContext, name, description)
184         , m_imageViewType       (imageViewType)
185         , m_imageFormat         (imageFormat)
186         , m_imageSize           (imageSize)
187         , m_samplerLod          (samplerLod)
188 {
189 }
190
191 void SamplerTest::initPrograms (SourceCollections& sourceCollections) const
192 {
193         std::ostringstream                              vertexSrc;
194         std::ostringstream                              fragmentSrc;
195         const char*                                             texCoordSwizzle = DE_NULL;
196         tcu::TextureFormat                              format                  = (isCompressedFormat(m_imageFormat)) ? tcu::getUncompressedFormat(mapVkCompressedFormat(m_imageFormat))
197                                                                                                                                                                                   : mapVkFormat(m_imageFormat);
198         const tcu::TextureFormatInfo    formatInfo              = tcu::getTextureFormatInfo(format);
199
200         switch (m_imageViewType)
201         {
202                 case VK_IMAGE_VIEW_TYPE_1D:
203                         texCoordSwizzle = "x";
204                         break;
205                 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
206                 case VK_IMAGE_VIEW_TYPE_2D:
207                         texCoordSwizzle = "xy";
208                         break;
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";
213                         break;
214                 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
215                         texCoordSwizzle = "xyzw";
216                         break;
217                 default:
218                         DE_ASSERT(false);
219                         break;
220         }
221
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"
228                           << "};\n"
229                           << "void main (void)\n"
230                           << "{\n"
231                           << "  gl_Position = position;\n"
232                           << "  vtxTexCoords = texCoords;\n"
233                           << "}\n";
234
235         fragmentSrc << "#version 440\n"
236                                 << "layout(set = 0, binding = 0) uniform highp " << getGlslSamplerType(format, m_imageViewType) << " texSampler;\n"
237                                 << "layout(location = 0) in highp vec4 vtxTexCoords;\n"
238                                 << "layout(location = 0) out highp vec4 fragColor;\n"
239                                 << "void main (void)\n"
240                                 << "{\n"
241                                 << "    fragColor = ";
242
243         if (m_samplerLod > 0.0f)
244                 fragmentSrc << "textureLod(texSampler, vtxTexCoords." << texCoordSwizzle << ", " << std::fixed <<  m_samplerLod << ")";
245         else
246                 fragmentSrc << "texture(texSampler, vtxTexCoords." << texCoordSwizzle << ")" << std::fixed;
247
248         fragmentSrc << " * vec4" << std::scientific << formatInfo.lookupScale << " + vec4" << formatInfo.lookupBias << ";\n"
249                                 << "}\n";
250
251         sourceCollections.glslSources.add("tex_vert") << glu::VertexSource(vertexSrc.str());
252         sourceCollections.glslSources.add("tex_frag") << glu::FragmentSource(fragmentSrc.str());
253 }
254
255 TestInstance* SamplerTest::createInstance (Context& context) const
256 {
257         const tcu::IVec2                                renderSize                      = getRenderSize(m_imageViewType);
258         const std::vector<Vertex4Tex4>  vertices                        = createVertices();
259         const VkSamplerCreateInfo               samplerParams           = getSamplerCreateInfo();
260         const VkComponentMapping                componentMapping        = getFormatComponentMapping(m_imageFormat);
261         const VkImageSubresourceRange   subresourceRange        =
262         {
263                 VK_IMAGE_ASPECT_COLOR_BIT,                                                              // VkImageAspectFlags   aspectMask;
264                 0u,                                                                                                             // deUint32                             baseMipLevel;
265                 (deUint32)deLog2Floor32(m_imageSize) + 1,                               // deUint32                             mipLevels;
266                 0u,                                                                                                             // deUint32                             baseArrayLayer;
267                 (deUint32)SamplerTest::getArraySize(m_imageViewType)    // deUint32                             arraySize;
268         };
269
270
271
272         return new ImageSamplingInstance(context, renderSize, m_imageViewType, m_imageFormat,
273                                                                          getImageSize(m_imageViewType, m_imageSize),
274                                                                          getArraySize(m_imageViewType),
275                                                                          componentMapping, subresourceRange,
276                                                                          samplerParams, m_samplerLod,vertices);
277 }
278
279 tcu::IVec2 SamplerTest::getRenderSize (VkImageViewType viewType) const
280 {
281         if (viewType == VK_IMAGE_VIEW_TYPE_1D || viewType == VK_IMAGE_VIEW_TYPE_2D)
282         {
283                 return tcu::IVec2(16, 16);
284         }
285         else
286         {
287                 return tcu::IVec2(16 * 3, 16 * 2);
288         }
289 }
290
291 std::vector<Vertex4Tex4> SamplerTest::createVertices (void) const
292 {
293         std::vector<Vertex4Tex4> vertices = createTestQuadMosaic(m_imageViewType);
294         // Adjust texture coordinate to avoid doing NEAREST filtering exactly on texel boundaries.
295         // TODO: Would be nice to base this on number of texels and subtexel precision. But this
296         // seems to work.
297         for (unsigned int i = 0; i < vertices.size(); ++i) {
298                 vertices[i].texCoord += tcu::Vec4(0.001f, 0.001f, 0.001f, 0.0f);
299         }
300         return vertices;
301 }
302
303 VkSamplerCreateInfo SamplerTest::getSamplerCreateInfo (void) const
304 {
305         const VkSamplerCreateInfo defaultSamplerParams =
306         {
307                 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,                                                                  // VkStructureType                      sType;
308                 DE_NULL,                                                                                                                                // const void*                          pNext;
309                 0u,                                                                                                                                             // VkSamplerCreateFlags         flags;
310                 VK_FILTER_NEAREST,                                                                                                              // VkFilter                                     magFilter;
311                 VK_FILTER_NEAREST,                                                                                                              // VkFilter                                     minFilter;
312                 VK_SAMPLER_MIPMAP_MODE_BASE,                                                                                    // VkSamplerMipmapMode          mipmapMode;
313                 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                                                                  // VkSamplerAddressMode         addressModeU;
314                 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                                                                  // VkSamplerAddressMode         addressModeV;
315                 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                                                                  // VkSamplerAddressMode         addressModeW;
316                 0.0f,                                                                                                                                   // float                                        mipLodBias;
317                 1.0f,                                                                                                                                   // float                                        maxAnisotropy;
318                 false,                                                                                                                                  // VkBool32                                     compareEnable;
319                 VK_COMPARE_OP_NEVER,                                                                                                    // VkCompareOp                          compareOp;
320                 0.0f,                                                                                                                                   // float                                        minLod;
321                 (float)deLog2Floor32(m_imageSize) + 1,                                                                  // float                                        maxLod;
322                 getFormatBorderColor(BORDER_COLOR_TRANSPARENT_BLACK, m_imageFormat),    // VkBorderColor                        borderColor;
323                 false                                                                                                                                   // VkBool32                                     unnormalizedCoordinates;
324         };
325
326         return defaultSamplerParams;
327 }
328
329 std::string SamplerTest::getGlslSamplerType (const tcu::TextureFormat& format, VkImageViewType type)
330 {
331         std::ostringstream samplerType;
332
333         if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
334                 samplerType << "u";
335         else if (tcu::getTextureChannelClass(format.type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
336                 samplerType << "i";
337
338         switch (type)
339         {
340                 case VK_IMAGE_VIEW_TYPE_1D:
341                         samplerType << "sampler1D";
342                         break;
343
344                 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
345                         samplerType << "sampler1DArray";
346                         break;
347
348                 case VK_IMAGE_VIEW_TYPE_2D:
349                         samplerType << "sampler2D";
350                         break;
351
352                 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
353                         samplerType << "sampler2DArray";
354                         break;
355
356                 case VK_IMAGE_VIEW_TYPE_3D:
357                         samplerType << "sampler3D";
358                         break;
359
360                 case VK_IMAGE_VIEW_TYPE_CUBE:
361                         samplerType << "samplerCube";
362                         break;
363
364                 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
365                         samplerType << "samplerCubeArray";
366                         break;
367
368                 default:
369                         DE_FATAL("Unknown image view type");
370                         break;
371         }
372
373         return samplerType.str();
374 }
375
376 tcu::IVec3 SamplerTest::getImageSize (VkImageViewType viewType, int size)
377 {
378         switch (viewType)
379         {
380                 case VK_IMAGE_VIEW_TYPE_1D:
381                 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
382                         return tcu::IVec3(size, 1, 1);
383
384                 case VK_IMAGE_VIEW_TYPE_3D:
385                         return tcu::IVec3(size, size, 4);
386
387                 default:
388                         break;
389         }
390
391         return tcu::IVec3(size, size, 1);
392 }
393
394 int SamplerTest::getArraySize (VkImageViewType viewType)
395 {
396         switch (viewType)
397         {
398                 case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
399                 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
400                 case VK_IMAGE_VIEW_TYPE_CUBE:
401                         return 6;
402
403                 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
404                         return 36;
405
406                 default:
407                         break;
408         }
409
410         return 1;
411 }
412
413
414 // SamplerMagFilterTest
415
416 SamplerMagFilterTest::SamplerMagFilterTest (tcu::TestContext&   testContext,
417                                                                                         const char*                     name,
418                                                                                         const char*                     description,
419                                                                                         VkImageViewType         imageViewType,
420                                                                                         VkFormat                        imageFormat,
421                                                                                         VkFilter                        magFilter)
422         : SamplerTest   (testContext, name, description, imageViewType, imageFormat, 8, 0.0f)
423         , m_magFilter   (magFilter)
424 {
425 }
426
427 VkSamplerCreateInfo SamplerMagFilterTest::getSamplerCreateInfo (void) const
428 {
429         VkSamplerCreateInfo samplerParams = SamplerTest::getSamplerCreateInfo();
430         samplerParams.magFilter = m_magFilter;
431
432         return samplerParams;
433 }
434
435
436 // SamplerMinFilterTest
437
438 SamplerMinFilterTest::SamplerMinFilterTest (tcu::TestContext&   testContext,
439                                                                                         const char*                     name,
440                                                                                         const char*                     description,
441                                                                                         VkImageViewType         imageViewType,
442                                                                                         VkFormat                        imageFormat,
443                                                                                         VkFilter                        minFilter)
444         : SamplerTest   (testContext, name, description, imageViewType, imageFormat, 32, 0.0f)
445         , m_minFilter   (minFilter)
446 {
447 }
448
449 VkSamplerCreateInfo SamplerMinFilterTest::getSamplerCreateInfo (void) const
450 {
451         VkSamplerCreateInfo samplerParams = SamplerTest::getSamplerCreateInfo();
452         samplerParams.minFilter = m_minFilter;
453         // set minLod to epsilon, to force use of the minFilter
454         samplerParams.minLod = 0.01f;
455
456         return samplerParams;
457 }
458
459
460 // SamplerLodTest
461
462 SamplerLodTest::SamplerLodTest (tcu::TestContext&       testContext,
463                                                                 const char*                     name,
464                                                                 const char*                     description,
465                                                                 VkImageViewType         imageViewType,
466                                                                 VkFormat                        imageFormat,
467                                                                 VkSamplerMipmapMode     mipmapMode,
468                                                                 float                           minLod,
469                                                                 float                           maxLod,
470                                                                 float                           mipLodBias,
471                                                                 float                           samplerLod)
472         : SamplerTest   (testContext, name, description, imageViewType, imageFormat, 32, samplerLod)
473         , m_mipmapMode  (mipmapMode)
474         , m_minLod              (minLod)
475         , m_maxLod              (maxLod)
476         , m_mipLodBias  (mipLodBias)
477 {
478 }
479
480 VkSamplerCreateInfo SamplerLodTest::getSamplerCreateInfo (void) const
481 {
482         VkSamplerCreateInfo samplerParams = SamplerTest::getSamplerCreateInfo();
483
484         samplerParams.mipmapMode        = m_mipmapMode;
485         samplerParams.minLod            = m_minLod;
486         samplerParams.maxLod            = m_maxLod;
487         samplerParams.mipLodBias        = m_mipLodBias;
488
489         return samplerParams;
490 }
491
492
493 // SamplerAddressModesTest
494
495 SamplerAddressModesTest::SamplerAddressModesTest (tcu::TestContext&             testContext,
496                                                                                                   const char*                   name,
497                                                                                                   const char*                   description,
498                                                                                                   VkImageViewType               imageViewType,
499                                                                                                   VkFormat                              imageFormat,
500                                                                                                   VkSamplerAddressMode  addressU,
501                                                                                                   VkSamplerAddressMode  addressV,
502                                                                                                   VkSamplerAddressMode  addressW,
503                                                                                                   VkBorderColor                 borderColor)
504         : SamplerTest   (testContext, name, description, imageViewType, imageFormat, 8, 0.0f)
505         , m_addressU    (addressU)
506         , m_addressV    (addressV)
507         , m_addressW    (addressW)
508         , m_borderColor (borderColor)
509 {
510 }
511
512 tcu::IVec2 SamplerAddressModesTest::getRenderSize (VkImageViewType viewType) const
513 {
514         return 4 * SamplerTest::getRenderSize(viewType);
515 }
516
517 std::vector<Vertex4Tex4> SamplerAddressModesTest::createVertices (void) const
518 {
519         std::vector<Vertex4Tex4> vertices = SamplerTest::createVertices();
520
521         switch (m_imageViewType)
522         {
523                 case VK_IMAGE_VIEW_TYPE_1D: case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
524                         for (size_t vertexNdx = 0; vertexNdx < vertices.size(); vertexNdx++)
525                                 vertices[vertexNdx].texCoord.x() = (vertices[vertexNdx].texCoord.x() - 0.5f) * 4.0f;
526
527                         break;
528
529                 case VK_IMAGE_VIEW_TYPE_2D:
530                 case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
531                         for (size_t vertexNdx = 0; vertexNdx < vertices.size(); vertexNdx++)
532                                 vertices[vertexNdx].texCoord.xy() = (vertices[vertexNdx].texCoord.swizzle(0, 1) - tcu::Vec2(0.5f)) * 4.0f;
533
534                         break;
535
536                 case VK_IMAGE_VIEW_TYPE_3D:
537                         for (size_t vertexNdx = 0; vertexNdx < vertices.size(); vertexNdx++)
538                                 vertices[vertexNdx].texCoord.xyz() = (vertices[vertexNdx].texCoord.swizzle(0, 1, 2) - tcu::Vec3(0.5f)) * 4.0f;
539
540                         break;
541
542                 case VK_IMAGE_VIEW_TYPE_CUBE:
543                 case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
544                         break;
545
546                 default:
547                         DE_ASSERT(false);
548         }
549
550         return vertices;
551 }
552
553 VkSamplerCreateInfo SamplerAddressModesTest::getSamplerCreateInfo (void) const
554 {
555         VkSamplerCreateInfo samplerParams = SamplerTest::getSamplerCreateInfo();
556         samplerParams.addressModeU      = m_addressU;
557         samplerParams.addressModeV      = m_addressV;
558         samplerParams.addressModeW      = m_addressW;
559         samplerParams.borderColor       = m_borderColor;
560
561         return samplerParams;
562 }
563
564
565 // Utilities to create test nodes
566
567 std::string getFormatCaseName (const VkFormat format)
568 {
569         const std::string fullName = getFormatName(format);
570
571         DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_"));
572
573         return de::toLower(fullName.substr(10));
574 }
575
576 MovePtr<tcu::TestCaseGroup> createSamplerMagFilterTests (tcu::TestContext& testCtx, VkImageViewType imageViewType, VkFormat imageFormat)
577 {
578         MovePtr<tcu::TestCaseGroup> samplerMagFilterTests (new tcu::TestCaseGroup(testCtx, "mag_filter", "Tests for magnification filter"));
579
580         if (isCompressedFormat(imageFormat) || (!isIntFormat(imageFormat) && !isUintFormat(imageFormat)))
581                 samplerMagFilterTests->addChild(new SamplerMagFilterTest(testCtx, "linear", "Magnifies image using VK_TEX_FILTER_LINEAR", imageViewType, imageFormat, VK_FILTER_LINEAR));
582         samplerMagFilterTests->addChild(new SamplerMagFilterTest(testCtx, "nearest", "Magnifies image using VK_TEX_FILTER_NEAREST", imageViewType, imageFormat, VK_FILTER_NEAREST));
583
584         return samplerMagFilterTests;
585 }
586
587 MovePtr<tcu::TestCaseGroup> createSamplerMinFilterTests (tcu::TestContext& testCtx, VkImageViewType imageViewType, VkFormat imageFormat)
588 {
589         MovePtr<tcu::TestCaseGroup> samplerMinFilterTests (new tcu::TestCaseGroup(testCtx, "min_filter", "Tests for minification filter"));
590
591         if (isCompressedFormat(imageFormat) || (!isIntFormat(imageFormat) && !isUintFormat(imageFormat)))
592                 samplerMinFilterTests->addChild(new SamplerMinFilterTest(testCtx, "linear", "Minifies image using VK_TEX_FILTER_LINEAR", imageViewType, imageFormat, VK_FILTER_LINEAR));
593         samplerMinFilterTests->addChild(new SamplerMinFilterTest(testCtx, "nearest", "Minifies image using VK_TEX_FILTER_NEAREST", imageViewType, imageFormat, VK_FILTER_NEAREST));
594
595         return samplerMinFilterTests;
596 }
597
598 MovePtr<tcu::TestCaseGroup> createSamplerLodTests (tcu::TestContext& testCtx, VkImageViewType imageViewType, VkFormat imageFormat, VkSamplerMipmapMode mipmapMode)
599 {
600         struct TestCaseConfig
601         {
602                 const char*     name;
603                 const char*     description;
604                 float           minLod;
605                 float           maxLod;
606                 float           mipLodBias;
607                 float           lod;
608         };
609
610         TestCaseConfig testCaseConfigs [] =
611         {
612                 { "equal_min_3_max_3",          "minLod = 3, maxLod = 3, mipLodBias = 0, lod = 0",              3.0f, 3.0f, 0.0f, 0.0f },
613                 { "select_min_1",                       "minLod = 1, maxLod = 5, mipLodBias = 0, lod = 0",              1.0f, 5.0f, 0.0f, 0.0f },
614                 { "select_max_4",                       "minLod = 0, maxLod = 4, mipLodBias = 0, lod = 5",              0.0f, 4.0f, 0.0f, 5.0f },
615                 { "select_bias_2_1",            "minLod = 0, maxLod = 2.1, mipLodBias = 5.0, lod = 0",  0.0f, 2.1f, 5.0f, 0.0f },
616                 { "select_bias_2_5",            "minLod = 0, maxLod = 5, mipLodBias = 2.5, lod = 0",    0.0f, 5.0f, 2.5f, 0.00001f },
617                 { "select_bias_3_1",            "minLod = 0, maxLod = 5, mipLodBias = -0.9, lod = 4.0", 0.0f, 5.0f, -0.9f, 4.0f },
618                 { "select_bias_3_7",            "minLod = 0, maxLod = 5, mipLodBias = 3.0, lod = 0.7",  0.0f, 5.0f, 3.0f, 0.7f },
619         };
620
621         MovePtr<tcu::TestCaseGroup> samplerLodTests (new tcu::TestCaseGroup(testCtx, "lod", "Tests for sampler LOD"));
622
623         for (int configNdx = 0; configNdx < DE_LENGTH_OF_ARRAY(testCaseConfigs); configNdx++)
624         {
625                 const TestCaseConfig& config = testCaseConfigs[configNdx];
626
627                 samplerLodTests->addChild(new SamplerLodTest(testCtx, config.name, config.description, imageViewType, imageFormat, mipmapMode, config.minLod, config.maxLod, config.mipLodBias, config.lod));
628         }
629
630         return samplerLodTests;
631 }
632
633 MovePtr<tcu::TestCaseGroup> createSamplerMipmapTests (tcu::TestContext& testCtx, VkImageViewType imageViewType, VkFormat imageFormat)
634 {
635         MovePtr<tcu::TestCaseGroup> samplerMipmapTests (new tcu::TestCaseGroup(testCtx, "mipmap", "Tests for mipmap modes"));
636
637         // Mipmap mode: nearest
638         MovePtr<tcu::TestCaseGroup> mipmapNearestTests (new tcu::TestCaseGroup(testCtx, "nearest", "Uses VK_TEX_MIPMAP_MODE_NEAREST"));
639         mipmapNearestTests->addChild(createSamplerLodTests(testCtx, imageViewType, imageFormat, VK_SAMPLER_MIPMAP_MODE_NEAREST).release());
640         samplerMipmapTests->addChild(mipmapNearestTests.release());
641
642         // Mipmap mode: linear
643         if (isCompressedFormat(imageFormat) || (!isIntFormat(imageFormat) && !isUintFormat(imageFormat)))
644         {
645                 MovePtr<tcu::TestCaseGroup> mipmapLinearTests(new tcu::TestCaseGroup(testCtx, "linear", "Uses VK_TEX_MIPMAP_MODE_LINEAR"));
646                 mipmapLinearTests->addChild(createSamplerLodTests(testCtx, imageViewType, imageFormat, VK_SAMPLER_MIPMAP_MODE_LINEAR).release());
647                 samplerMipmapTests->addChild(mipmapLinearTests.release());
648         }
649
650         return samplerMipmapTests;
651 }
652
653 std::string getAddressModesCaseName (VkSamplerAddressMode u, VkSamplerAddressMode v, VkSamplerAddressMode w, BorderColor border)
654 {
655         static const char* borderColorNames[BORDER_COLOR_COUNT] =
656         {
657                 "opaque_black",
658                 "opaque_white",
659                 "transparent_black",
660         };
661
662         std::ostringstream caseName;
663
664         if (u == v && v == w)
665         {
666                 const std::string fullName = getSamplerAddressModeName(u);
667                 DE_ASSERT(de::beginsWith(fullName, "VK_SAMPLER_ADDRESS_"));
668
669                 caseName << "all_";
670                 caseName << de::toLower(fullName.substr(19));
671
672                 if (u == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)
673                 {
674                         caseName << "_" << borderColorNames[border];
675                 }
676         }
677         else
678         {
679                 const std::string fullNameU = getSamplerAddressModeName(u);
680                 const std::string fullNameV = getSamplerAddressModeName(v);
681                 const std::string fullNameW = getSamplerAddressModeName(w);
682
683                 DE_ASSERT(de::beginsWith(fullNameU, "VK_SAMPLER_ADDRESS_"));
684                 DE_ASSERT(de::beginsWith(fullNameV, "VK_SAMPLER_ADDRESS_"));
685                 DE_ASSERT(de::beginsWith(fullNameW, "VK_SAMPLER_ADDRESS_"));
686
687                 caseName << "uvw"
688                                  << "_" << de::toLower(fullNameU.substr(19))
689                                  << "_" << de::toLower(fullNameV.substr(19))
690                                  << "_" << de::toLower(fullNameW.substr(19));
691         }
692
693         return caseName.str();
694 }
695
696 MovePtr<tcu::TestCaseGroup> createSamplerAddressModesTests (tcu::TestContext& testCtx, VkImageViewType imageViewType, VkFormat imageFormat)
697 {
698         struct TestCaseConfig
699         {
700                 VkSamplerAddressMode    u;
701                 VkSamplerAddressMode    v;
702                 VkSamplerAddressMode    w;
703                 BorderColor                             border;
704         };
705
706         const TestCaseConfig testCaseConfigs[] =
707         {
708                 // All address modes equal
709                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  BORDER_COLOR_TRANSPARENT_BLACK },
710                 { VK_SAMPLER_ADDRESS_MODE_REPEAT,                               VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 BORDER_COLOR_TRANSPARENT_BLACK },
711                 { VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,              VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                BORDER_COLOR_TRANSPARENT_BLACK },
712                 { VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   BORDER_COLOR_TRANSPARENT_BLACK },
713
714                 // All address modes equal using border color
715                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_TRANSPARENT_BLACK },
716                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_OPAQUE_BLACK },
717                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_OPAQUE_WHITE },
718
719                 // Pairwise combinations of address modes not covered by previous tests
720                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 BORDER_COLOR_OPAQUE_WHITE},
721                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   BORDER_COLOR_OPAQUE_WHITE },
722                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                BORDER_COLOR_OPAQUE_WHITE },
723                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,              VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  BORDER_COLOR_OPAQUE_WHITE },
724                 { VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                BORDER_COLOR_OPAQUE_WHITE },
725                 { VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_OPAQUE_WHITE },
726                 { VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 BORDER_COLOR_OPAQUE_WHITE },
727                 { VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   BORDER_COLOR_OPAQUE_WHITE },
728                 { VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  BORDER_COLOR_OPAQUE_WHITE },
729                 { VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,              VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   BORDER_COLOR_OPAQUE_WHITE },
730                 { VK_SAMPLER_ADDRESS_MODE_REPEAT,                               VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   BORDER_COLOR_OPAQUE_WHITE },
731                 { VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,              VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_OPAQUE_WHITE },
732                 { VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,              VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 BORDER_COLOR_OPAQUE_WHITE },
733                 { VK_SAMPLER_ADDRESS_MODE_REPEAT,                               VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  BORDER_COLOR_OPAQUE_WHITE },
734                 { VK_SAMPLER_ADDRESS_MODE_REPEAT,                               VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_OPAQUE_WHITE },
735                 { VK_SAMPLER_ADDRESS_MODE_REPEAT,                               VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                BORDER_COLOR_OPAQUE_WHITE },
736                 { VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,              VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  BORDER_COLOR_OPAQUE_WHITE },
737                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                BORDER_COLOR_OPAQUE_WHITE },
738                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,                VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 BORDER_COLOR_OPAQUE_WHITE },
739                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                VK_SAMPLER_ADDRESS_MODE_REPEAT,                                 VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   BORDER_COLOR_OPAQUE_WHITE },
740                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                  BORDER_COLOR_OPAQUE_WHITE },
741                 { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,                VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE,   VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,                BORDER_COLOR_OPAQUE_WHITE },
742         };
743
744         MovePtr<tcu::TestCaseGroup> samplerAddressModesTests (new tcu::TestCaseGroup(testCtx, "address_modes", "Tests for address modes"));
745
746         for (int configNdx = 0; configNdx < DE_LENGTH_OF_ARRAY(testCaseConfigs); configNdx++)
747         {
748                 const TestCaseConfig& config = testCaseConfigs[configNdx];
749
750                 samplerAddressModesTests->addChild(new SamplerAddressModesTest(testCtx,
751                                                                                                                                            getAddressModesCaseName(config.u, config.v, config.w, config.border).c_str(),
752                                                                                                                                            "",
753                                                                                                                                            imageViewType,
754                                                                                                                                            imageFormat,
755                                                                                                                                            config.u, config.v, config.w,
756                                                                                                                                            getFormatBorderColor(config.border, imageFormat)));
757         }
758
759         return samplerAddressModesTests;
760 }
761
762 } // anonymous
763
764 tcu::TestCaseGroup* createSamplerTests (tcu::TestContext& testCtx)
765 {
766         const struct
767         {
768                 VkImageViewType         type;
769                 const char*                     name;
770         }
771         imageViewTypes[] =
772         {
773                 { VK_IMAGE_VIEW_TYPE_1D,                        "1d" },
774                 { VK_IMAGE_VIEW_TYPE_1D_ARRAY,          "1d_array" },
775                 { VK_IMAGE_VIEW_TYPE_2D,                        "2d" },
776                 { VK_IMAGE_VIEW_TYPE_2D_ARRAY,          "2d_array" },
777                 { VK_IMAGE_VIEW_TYPE_3D,                        "3d" },
778                 { VK_IMAGE_VIEW_TYPE_CUBE,                      "cube" },
779                 { VK_IMAGE_VIEW_TYPE_CUBE_ARRAY,        "cube_array" }
780         };
781
782         const VkFormat formats[] =
783         {
784                 // Packed formats
785                 VK_FORMAT_R4G4_UNORM_PACK8,
786                 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
787                 VK_FORMAT_R5G6B5_UNORM_PACK16,
788                 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
789                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
790                 VK_FORMAT_A2R10G10B10_UINT_PACK32,
791                 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
792                 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
793                 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
794                 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
795
796                 // Pairwise combinations of 8-bit channel formats, UNORM/SNORM/SINT/UINT/SRGB type x 1-to-4 channels x RGBA/BGRA order
797                 VK_FORMAT_R8_SRGB,
798                 VK_FORMAT_R8G8B8_UINT,
799                 VK_FORMAT_B8G8R8A8_SINT,
800                 VK_FORMAT_R8G8_UNORM,
801                 VK_FORMAT_B8G8R8_SNORM,
802                 VK_FORMAT_R8G8B8A8_SNORM,
803                 VK_FORMAT_R8G8_UINT,
804                 VK_FORMAT_R8_SINT,
805                 VK_FORMAT_R8G8B8A8_SRGB,
806                 VK_FORMAT_R8G8B8A8_UNORM,
807                 VK_FORMAT_B8G8R8A8_UNORM,
808                 VK_FORMAT_B8G8R8_SRGB,
809                 VK_FORMAT_R8G8_SRGB,
810                 VK_FORMAT_R8_UINT,
811                 VK_FORMAT_R8G8B8A8_UINT,
812                 VK_FORMAT_R8G8_SINT,
813                 VK_FORMAT_R8_SNORM,
814                 VK_FORMAT_B8G8R8_SINT,
815                 VK_FORMAT_R8G8_SNORM,
816                 VK_FORMAT_B8G8R8_UNORM,
817                 VK_FORMAT_R8_UNORM,
818
819                 // Pairwise combinations of 16/32-bit channel formats x SINT/UINT/SFLOAT type x 1-to-4 channels
820                 VK_FORMAT_R32G32_SFLOAT,
821                 VK_FORMAT_R32G32B32_UINT,
822                 VK_FORMAT_R16G16B16A16_SFLOAT,
823                 VK_FORMAT_R16G16_UINT,
824                 VK_FORMAT_R32G32B32A32_SINT,
825                 VK_FORMAT_R16G16B16_SINT,
826                 VK_FORMAT_R16_SFLOAT,
827                 VK_FORMAT_R32_SINT,
828                 VK_FORMAT_R32_UINT,
829                 VK_FORMAT_R16G16B16_SFLOAT,
830                 VK_FORMAT_R16G16_SINT,
831
832                 // Scaled formats
833                 VK_FORMAT_R8G8B8A8_SSCALED,
834                 VK_FORMAT_A2R10G10B10_USCALED_PACK32,
835
836                 // Compressed formats
837                 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
838                 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
839                 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
840                 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
841                 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
842                 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
843                 VK_FORMAT_EAC_R11_UNORM_BLOCK,
844                 VK_FORMAT_EAC_R11_SNORM_BLOCK,
845                 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
846                 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
847                 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
848                 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
849                 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
850                 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
851                 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
852                 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
853                 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
854                 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
855                 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
856                 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
857         };
858
859         de::MovePtr<tcu::TestCaseGroup> samplerTests            (new tcu::TestCaseGroup(testCtx, "sampler", "Sampler tests"));
860         de::MovePtr<tcu::TestCaseGroup> viewTypeTests           (new tcu::TestCaseGroup(testCtx, "view_type", ""));
861
862         for (int viewTypeNdx = 0; viewTypeNdx < DE_LENGTH_OF_ARRAY(imageViewTypes); viewTypeNdx++)
863         {
864                 const VkImageViewType                   viewType                = imageViewTypes[viewTypeNdx].type;
865                 de::MovePtr<tcu::TestCaseGroup> viewTypeGroup   (new tcu::TestCaseGroup(testCtx, imageViewTypes[viewTypeNdx].name, (std::string("Uses a ") + imageViewTypes[viewTypeNdx].name + " view").c_str()));
866                 de::MovePtr<tcu::TestCaseGroup> formatTests             (new tcu::TestCaseGroup(testCtx, "format", "Tests samplable formats"));
867
868                 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(formats); formatNdx++)
869                 {
870                         const VkFormat  format                  = formats[formatNdx];
871                         const bool              isCompressed    = isCompressedFormat(format);
872
873                         if (isCompressed)
874                         {
875                                 // Do not use compressed formats with 1D and 1D array textures.
876                                 if (viewType == VK_IMAGE_VIEW_TYPE_1D || viewType == VK_IMAGE_VIEW_TYPE_1D_ARRAY)
877                                         break;
878
879                                 // 3D ASTC textures are not supported.
880                                 if (tcu::isAstcFormat(mapVkCompressedFormat(format)) && viewType == VK_IMAGE_VIEW_TYPE_3D)
881                                         break;
882                         }
883
884                         de::MovePtr<tcu::TestCaseGroup> formatGroup     (new tcu::TestCaseGroup(testCtx,
885                                                                                                                                                                 getFormatCaseName(format).c_str(),
886                                                                                                                                                                 (std::string("Samples a texture of format ") + getFormatName(format)).c_str()));
887
888                         if (!isCompressed)
889                         {
890                                 // Do not include minFilter tests with compressed formats.
891                                 // Randomly generated compressed textures are too noisy and will derive in false positives.
892                                 de::MovePtr<tcu::TestCaseGroup> minFilterTests          = createSamplerMinFilterTests(testCtx, viewType, format);
893                                 formatGroup->addChild(minFilterTests.release());
894                         }
895
896                         de::MovePtr<tcu::TestCaseGroup> magFilterTests          = createSamplerMagFilterTests(testCtx, viewType, format);
897                         de::MovePtr<tcu::TestCaseGroup> mipmapTests                     = createSamplerMipmapTests(testCtx, viewType, format);
898
899                         formatGroup->addChild(magFilterTests.release());
900                         formatGroup->addChild(mipmapTests.release());
901
902                         if (viewType != VK_IMAGE_VIEW_TYPE_CUBE && viewType != VK_IMAGE_VIEW_TYPE_CUBE_ARRAY)
903                         {
904                                 de::MovePtr<tcu::TestCaseGroup> addressModesTests       = createSamplerAddressModesTests(testCtx, viewType, format);
905                                 formatGroup->addChild(addressModesTests.release());
906                         }
907
908                         formatTests->addChild(formatGroup.release());
909                 }
910
911                 viewTypeGroup->addChild(formatTests.release());
912                 viewTypeTests->addChild(viewTypeGroup.release());
913         }
914
915         samplerTests->addChild(viewTypeTests.release());
916
917         return samplerTests.release();
918 }
919
920 } // pipeline
921 } // vkt