06b0e24dd5efbbf5800f0a4ca435c846a0ca8837
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / api / vktApiFeatureInfo.cpp
1 /*-------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 Google Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Api Feature Query tests
22  *//*--------------------------------------------------------------------*/
23
24 #include "vktApiFeatureInfo.hpp"
25
26 #include "vktTestCaseUtil.hpp"
27 #include "vktTestGroupUtil.hpp"
28
29 #include "vkPlatform.hpp"
30 #include "vkStrUtil.hpp"
31 #include "vkRef.hpp"
32 #include "vkDeviceUtil.hpp"
33 #include "vkQueryUtil.hpp"
34 #include "vkImageUtil.hpp"
35 #include "vkApiVersion.hpp"
36
37 #include "tcuTestLog.hpp"
38 #include "tcuFormatUtil.hpp"
39 #include "tcuTextureUtil.hpp"
40 #include "tcuResultCollector.hpp"
41
42 #include "deUniquePtr.hpp"
43 #include "deString.h"
44 #include "deStringUtil.hpp"
45 #include "deSTLUtil.hpp"
46 #include "deMemory.h"
47 #include "deMath.h"
48
49 #include <vector>
50 #include <set>
51 #include <string>
52
53 namespace vkt
54 {
55 namespace api
56 {
57 namespace
58 {
59
60 using namespace vk;
61 using std::vector;
62 using std::set;
63 using std::string;
64 using tcu::TestLog;
65 using tcu::ScopedLogSection;
66
67 enum
68 {
69         GUARD_SIZE                                                              = 0x20,                 //!< Number of bytes to check
70         GUARD_VALUE                                                             = 0xcd,                 //!< Data pattern
71 };
72
73 static const VkDeviceSize MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE =        (1LLU<<31);     //!< Minimum value for VkImageFormatProperties::maxResourceSize (2GiB)
74
75 enum LimitFormat
76 {
77         LIMIT_FORMAT_SIGNED_INT,
78         LIMIT_FORMAT_UNSIGNED_INT,
79         LIMIT_FORMAT_FLOAT,
80         LIMIT_FORMAT_DEVICE_SIZE,
81         LIMIT_FORMAT_BITMASK,
82
83         LIMIT_FORMAT_LAST
84 };
85
86 enum LimitType
87 {
88         LIMIT_TYPE_MIN,
89         LIMIT_TYPE_MAX,
90         LIMIT_TYPE_NONE,
91
92         LIMIT_TYPE_LAST
93 };
94
95 #define LIMIT(_X_)              (deUint32)DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_), (const char*)(#_X_)
96 #define FEATURE(_X_)    (deUint32)DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_)
97
98 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
99 {
100         bool                                            limitsOk        = true;
101         VkPhysicalDeviceLimits*         limits          = &properties->limits;
102         struct FeatureLimitTable
103         {
104                 deUint32                offset;
105                 const char*             name;
106                 deUint32                uintVal;                        //!< Format is UNSIGNED_INT
107                 deInt32                 intVal;                         //!< Format is SIGNED_INT
108                 deUint64                deviceSizeVal;          //!< Format is DEVICE_SIZE
109                 float                   floatVal;                       //!< Format is FLOAT
110                 LimitFormat             format;
111                 LimitType               type;
112                 deInt32                 unsuppTableNdx;
113         } featureLimitTable[] =   //!< Based on 1.0.28 Vulkan spec
114         {
115                 { LIMIT(maxImageDimension1D),                                                           4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
116                 { LIMIT(maxImageDimension2D),                                                           4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
117                 { LIMIT(maxImageDimension3D),                                                           256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
118                 { LIMIT(maxImageDimensionCube),                                                         4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
119                 { LIMIT(maxImageArrayLayers),                                                           256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
120                 { LIMIT(maxTexelBufferElements),                                                        65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
121                 { LIMIT(maxUniformBufferRange),                                                         16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
122                 { LIMIT(maxStorageBufferRange),                                                         0, 0, 0, 0, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
123                 { LIMIT(maxPushConstantsSize),                                                          128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
124                 { LIMIT(maxMemoryAllocationCount),                                                      4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
125                 { LIMIT(maxSamplerAllocationCount),                                                     0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
126                 { LIMIT(bufferImageGranularity),                                                        0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
127                 { LIMIT(bufferImageGranularity),                                                        0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
128                 { LIMIT(sparseAddressSpaceSize),                                                        0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
129                 { LIMIT(maxBoundDescriptorSets),                                                        4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
130                 { LIMIT(maxPerStageDescriptorSamplers),                                         16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
131                 { LIMIT(maxPerStageDescriptorUniformBuffers),                           12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
132                 { LIMIT(maxPerStageDescriptorStorageBuffers),                           4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
133                 { LIMIT(maxPerStageDescriptorSampledImages),                            16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
134                 { LIMIT(maxPerStageDescriptorStorageImages),                            4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
135                 { LIMIT(maxPerStageDescriptorInputAttachments),                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
136                 { LIMIT(maxPerStageResources),                                                          0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
137                 { LIMIT(maxDescriptorSetSamplers),                                                      96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
138                 { LIMIT(maxDescriptorSetUniformBuffers),                                        72, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
139                 { LIMIT(maxDescriptorSetUniformBuffersDynamic),                         8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
140                 { LIMIT(maxDescriptorSetStorageBuffers),                                        24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
141                 { LIMIT(maxDescriptorSetStorageBuffersDynamic),                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
142                 { LIMIT(maxDescriptorSetSampledImages),                                         96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
143                 { LIMIT(maxDescriptorSetStorageImages),                                         24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
144                 { LIMIT(maxDescriptorSetInputAttachments),                                      0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE  , -1 },
145                 { LIMIT(maxVertexInputAttributes),                                                      16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
146                 { LIMIT(maxVertexInputBindings),                                                        16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
147                 { LIMIT(maxVertexInputAttributeOffset),                                         2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
148                 { LIMIT(maxVertexInputBindingStride),                                           2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
149                 { LIMIT(maxVertexOutputComponents),                                                     64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
150                 { LIMIT(maxTessellationGenerationLevel),                                        64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
151                 { LIMIT(maxTessellationPatchSize),                                                      32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
152                 { LIMIT(maxTessellationControlPerVertexInputComponents),        64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
153                 { LIMIT(maxTessellationControlPerVertexOutputComponents),       64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
154                 { LIMIT(maxTessellationControlPerPatchOutputComponents),        120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
155                 { LIMIT(maxTessellationControlTotalOutputComponents),           2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
156                 { LIMIT(maxTessellationEvaluationInputComponents),                      64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
157                 { LIMIT(maxTessellationEvaluationOutputComponents),                     64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
158                 { LIMIT(maxGeometryShaderInvocations),                                          32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
159                 { LIMIT(maxGeometryInputComponents),                                            64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
160                 { LIMIT(maxGeometryOutputComponents),                                           64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
161                 { LIMIT(maxGeometryOutputVertices),                                                     256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
162                 { LIMIT(maxGeometryTotalOutputComponents),                                      1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
163                 { LIMIT(maxFragmentInputComponents),                                            64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
164                 { LIMIT(maxFragmentOutputAttachments),                                          4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
165                 { LIMIT(maxFragmentDualSrcAttachments),                                         1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
166                 { LIMIT(maxFragmentCombinedOutputResources),                            4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
167                 { LIMIT(maxComputeSharedMemorySize),                                            16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
168                 { LIMIT(maxComputeWorkGroupCount[0]),                                           65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
169                 { LIMIT(maxComputeWorkGroupCount[1]),                                           65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
170                 { LIMIT(maxComputeWorkGroupCount[2]),                                           65535,  0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
171                 { LIMIT(maxComputeWorkGroupInvocations),                                        128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
172                 { LIMIT(maxComputeWorkGroupSize[0]),                                            128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
173                 { LIMIT(maxComputeWorkGroupSize[1]),                                            128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
174                 { LIMIT(maxComputeWorkGroupSize[2]),                                            64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
175                 { LIMIT(subPixelPrecisionBits),                                                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
176                 { LIMIT(subTexelPrecisionBits),                                                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
177                 { LIMIT(mipmapPrecisionBits),                                                           4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
178                 { LIMIT(maxDrawIndexedIndexValue),                                                      (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
179                 { LIMIT(maxDrawIndirectCount),                                                          65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
180                 { LIMIT(maxSamplerLodBias),                                                                     0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
181                 { LIMIT(maxSamplerAnisotropy),                                                          0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
182                 { LIMIT(maxViewports),                                                                          16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
183                 { LIMIT(maxViewportDimensions[0]),                                                      4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
184                 { LIMIT(maxViewportDimensions[1]),                                                      4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
185                 { LIMIT(viewportBoundsRange[0]),                                                        0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
186                 { LIMIT(viewportBoundsRange[1]),                                                        0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
187                 { LIMIT(viewportSubPixelBits),                                                          0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
188                 { LIMIT(minMemoryMapAlignment),                                                         64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
189                 { LIMIT(minTexelBufferOffsetAlignment),                                         0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
190                 { LIMIT(minTexelBufferOffsetAlignment),                                         0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
191                 { LIMIT(minUniformBufferOffsetAlignment),                                       0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
192                 { LIMIT(minUniformBufferOffsetAlignment),                                       0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
193                 { LIMIT(minStorageBufferOffsetAlignment),                                       0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
194                 { LIMIT(minStorageBufferOffsetAlignment),                                       0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
195                 { LIMIT(minTexelOffset),                                                                        0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
196                 { LIMIT(maxTexelOffset),                                                                        7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
197                 { LIMIT(minTexelGatherOffset),                                                          0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
198                 { LIMIT(maxTexelGatherOffset),                                                          7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
199                 { LIMIT(minInterpolationOffset),                                                        0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
200                 { LIMIT(maxInterpolationOffset),                                                        0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
201                 { LIMIT(subPixelInterpolationOffsetBits),                                       4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
202                 { LIMIT(maxFramebufferWidth),                                                           4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
203                 { LIMIT(maxFramebufferHeight),                                                          4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
204                 { LIMIT(maxFramebufferLayers),                                                          0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
205                 { LIMIT(framebufferColorSampleCounts),                                          VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
206                 { LIMIT(framebufferDepthSampleCounts),                                          VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
207                 { LIMIT(framebufferStencilSampleCounts),                                        VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
208                 { LIMIT(framebufferNoAttachmentsSampleCounts),                          VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
209                 { LIMIT(maxColorAttachments),                                                           4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
210                 { LIMIT(sampledImageColorSampleCounts),                                         VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
211                 { LIMIT(sampledImageIntegerSampleCounts),                                       VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
212                 { LIMIT(sampledImageDepthSampleCounts),                                         VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
213                 { LIMIT(sampledImageStencilSampleCounts),                                       VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
214                 { LIMIT(storageImageSampleCounts),                                                      VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
215                 { LIMIT(maxSampleMaskWords),                                                            1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
216                 { LIMIT(timestampComputeAndGraphics),                                           0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
217                 { LIMIT(timestampPeriod),                                                                       0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
218                 { LIMIT(maxClipDistances),                                                                      8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
219                 { LIMIT(maxCullDistances),                                                                      8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
220                 { LIMIT(maxCombinedClipAndCullDistances),                                       8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
221                 { LIMIT(discreteQueuePriorities),                                                       8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
222                 { LIMIT(pointSizeRange[0]),                                                                     0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
223                 { LIMIT(pointSizeRange[0]),                                                                     0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
224                 { LIMIT(pointSizeRange[1]),                                                                     0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
225                 { LIMIT(lineWidthRange[0]),                                                                     0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
226                 { LIMIT(lineWidthRange[0]),                                                                     0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
227                 { LIMIT(lineWidthRange[1]),                                                                     0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
228                 { LIMIT(pointSizeGranularity),                                                          0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
229                 { LIMIT(lineWidthGranularity),                                                          0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
230                 { LIMIT(strictLines),                                                                           0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
231                 { LIMIT(standardSampleLocations),                                                       0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
232                 { LIMIT(optimalBufferCopyOffsetAlignment),                                      0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
233                 { LIMIT(optimalBufferCopyRowPitchAlignment),                            0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
234                 { LIMIT(nonCoherentAtomSize),                                                           0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
235                 { LIMIT(nonCoherentAtomSize),                                                           0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
236         };
237
238         const struct UnsupportedFeatureLimitTable
239         {
240                 deUint32                limitOffset;
241                 const char*             name;
242                 deUint32                featureOffset;
243                 deUint32                uintVal;                        //!< Format is UNSIGNED_INT
244                 deInt32                 intVal;                         //!< Format is SIGNED_INT
245                 deUint64                deviceSizeVal;          //!< Format is DEVICE_SIZE
246                 float                   floatVal;                       //!< Format is FLOAT
247         } unsupportedFeatureTable[] =
248         {
249                 { LIMIT(sparseAddressSpaceSize),                                                        FEATURE(sparseBinding),                                 0, 0, 0, 0.0f },
250                 { LIMIT(maxTessellationGenerationLevel),                                        FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
251                 { LIMIT(maxTessellationPatchSize),                                                      FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
252                 { LIMIT(maxTessellationControlPerVertexInputComponents),        FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
253                 { LIMIT(maxTessellationControlPerVertexOutputComponents),       FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
254                 { LIMIT(maxTessellationControlPerPatchOutputComponents),        FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
255                 { LIMIT(maxTessellationControlTotalOutputComponents),           FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
256                 { LIMIT(maxTessellationEvaluationInputComponents),                      FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
257                 { LIMIT(maxTessellationEvaluationOutputComponents),                     FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
258                 { LIMIT(maxGeometryShaderInvocations),                                          FEATURE(geometryShader),                                0, 0, 0, 0.0f },
259                 { LIMIT(maxGeometryInputComponents),                                            FEATURE(geometryShader),                                0, 0, 0, 0.0f },
260                 { LIMIT(maxGeometryOutputComponents),                                           FEATURE(geometryShader),                                0, 0, 0, 0.0f },
261                 { LIMIT(maxGeometryOutputVertices),                                                     FEATURE(geometryShader),                                0, 0, 0, 0.0f },
262                 { LIMIT(maxGeometryTotalOutputComponents),                                      FEATURE(geometryShader),                                0, 0, 0, 0.0f },
263                 { LIMIT(maxFragmentDualSrcAttachments),                                         FEATURE(dualSrcBlend),                                  0, 0, 0, 0.0f },
264                 { LIMIT(maxDrawIndexedIndexValue),                                                      FEATURE(fullDrawIndexUint32),                   (1<<24)-1, 0, 0, 0.0f },
265                 { LIMIT(maxDrawIndirectCount),                                                          FEATURE(multiDrawIndirect),                             1, 0, 0, 0.0f },
266                 { LIMIT(maxSamplerAnisotropy),                                                          FEATURE(samplerAnisotropy),                             1, 0, 0, 0.0f },
267                 { LIMIT(maxViewports),                                                                          FEATURE(multiViewport),                                 1, 0, 0, 0.0f },
268                 { LIMIT(minTexelGatherOffset),                                                          FEATURE(shaderImageGatherExtended),             0, 0, 0, 0.0f },
269                 { LIMIT(maxTexelGatherOffset),                                                          FEATURE(shaderImageGatherExtended),             0, 0, 0, 0.0f },
270                 { LIMIT(minInterpolationOffset),                                                        FEATURE(sampleRateShading),                             0, 0, 0, 0.0f },
271                 { LIMIT(maxInterpolationOffset),                                                        FEATURE(sampleRateShading),                             0, 0, 0, 0.0f },
272                 { LIMIT(subPixelInterpolationOffsetBits),                                       FEATURE(sampleRateShading),                             0, 0, 0, 0.0f },
273                 { LIMIT(storageImageSampleCounts),                                                      FEATURE(shaderStorageImageMultisample), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f },
274                 { LIMIT(maxClipDistances),                                                                      FEATURE(shaderClipDistance),                    0, 0, 0, 0.0f },
275                 { LIMIT(maxCullDistances),                                                                      FEATURE(shaderClipDistance),                    0, 0, 0, 0.0f },
276                 { LIMIT(maxCombinedClipAndCullDistances),                                       FEATURE(shaderClipDistance),                    0, 0, 0, 0.0f },
277                 { LIMIT(pointSizeRange[0]),                                                                     FEATURE(largePoints),                                   0, 0, 0, 1.0f },
278                 { LIMIT(pointSizeRange[1]),                                                                     FEATURE(largePoints),                                   0, 0, 0, 1.0f },
279                 { LIMIT(lineWidthRange[0]),                                                                     FEATURE(wideLines),                                             0, 0, 0, 1.0f },
280                 { LIMIT(lineWidthRange[1]),                                                                     FEATURE(wideLines),                                             0, 0, 0, 1.0f },
281                 { LIMIT(pointSizeGranularity),                                                          FEATURE(largePoints),                                   0, 0, 0, 0.0f },
282                 { LIMIT(lineWidthGranularity),                                                          FEATURE(wideLines),                                             0, 0, 0, 0.0f }
283         };
284
285         log << TestLog::Message << *limits << TestLog::EndMessage;
286
287         //!< First build a map from limit to unsupported table index
288         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
289         {
290                 for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++)
291                 {
292                         if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset)
293                         {
294                                 featureLimitTable[ndx].unsuppTableNdx = unsuppNdx;
295                                 break;
296                         }
297                 }
298         }
299
300         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
301         {
302                 switch (featureLimitTable[ndx].format)
303                 {
304                         case LIMIT_FORMAT_UNSIGNED_INT:
305                         {
306                                 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
307                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
308                                 {
309                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
310                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
311                                 }
312
313                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
314                                 {
315
316                                         if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
317                                         {
318                                                 log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name
319                                                         << " not valid-limit type MIN - actual is "
320                                                         << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
321                                                 limitsOk = false;
322                                         }
323                                 }
324                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
325                                 {
326                                         if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
327                                         {
328                                                 log << TestLog::Message << "limit validation failed,  " << featureLimitTable[ndx].name
329                                                         << " not valid-limit type MAX - actual is "
330                                                         << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
331                                                 limitsOk = false;
332                                         }
333                                 }
334                                 break;
335                         }
336
337                         case LIMIT_FORMAT_FLOAT:
338                         {
339                                 float limitToCheck = featureLimitTable[ndx].floatVal;
340                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
341                                 {
342                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
343                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal;
344                                 }
345
346                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
347                                 {
348                                         if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
349                                         {
350                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
351                                                         << " not valid-limit type MIN - actual is "
352                                                         << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
353                                                 limitsOk = false;
354                                         }
355                                 }
356                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
357                                 {
358                                         if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
359                                         {
360                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
361                                                         << " not valid-limit type MAX actual is "
362                                                         << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
363                                                 limitsOk = false;
364                                         }
365                                 }
366                                 break;
367                         }
368
369                         case LIMIT_FORMAT_SIGNED_INT:
370                         {
371                                 deInt32 limitToCheck = featureLimitTable[ndx].intVal;
372                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
373                                 {
374                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
375                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal;
376                                 }
377                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
378                                 {
379                                         if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
380                                         {
381                                                 log << TestLog::Message <<  "limit validation failed, " << featureLimitTable[ndx].name
382                                                         << " not valid-limit type MIN actual is "
383                                                         << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
384                                                 limitsOk = false;
385                                         }
386                                 }
387                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
388                                 {
389                                         if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
390                                         {
391                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
392                                                         << " not valid-limit type MAX actual is "
393                                                         << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
394                                                 limitsOk = false;
395                                         }
396                                 }
397                                 break;
398                         }
399
400                         case LIMIT_FORMAT_DEVICE_SIZE:
401                         {
402                                 deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal;
403                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
404                                 {
405                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
406                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal;
407                                 }
408
409                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
410                                 {
411                                         if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
412                                         {
413                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
414                                                         << " not valid-limit type MIN actual is "
415                                                         << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
416                                                 limitsOk = false;
417                                         }
418                                 }
419                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
420                                 {
421                                         if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
422                                         {
423                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
424                                                         << " not valid-limit type MAX actual is "
425                                                         << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
426                                                 limitsOk = false;
427                                         }
428                                 }
429                                 break;
430                         }
431
432                         case LIMIT_FORMAT_BITMASK:
433                         {
434                                 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
435                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
436                                 {
437                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
438                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
439                                 }
440
441                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
442                                 {
443                                         if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck)
444                                         {
445                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
446                                                         << " not valid-limit type bitmask actual is "
447                                                         << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
448                                                 limitsOk = false;
449                                         }
450                                 }
451                                 break;
452                         }
453
454                         default:
455                                 DE_ASSERT(0);
456                                 limitsOk = false;
457                 }
458         }
459
460         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits->maxViewportDimensions); ndx++)
461         {
462                 if (limits->maxImageDimension2D > limits->maxViewportDimensions[ndx])
463                 {
464                         log << TestLog::Message << "limit validation failed, maxImageDimension2D of " << limits->maxImageDimension2D
465                                 << "is larger than maxViewportDimension[" << ndx << "] of " << limits->maxViewportDimensions[ndx] << TestLog::EndMessage;
466                         limitsOk = false;
467                 }
468         }
469
470         if (limits->viewportBoundsRange[0] > -2 * limits->maxViewportDimensions[0])
471         {
472                 log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0]
473                         << "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage;
474                 limitsOk = false;
475         }
476
477         if (limits->viewportBoundsRange[1] < 2 * limits->maxViewportDimensions[1] - 1)
478         {
479                 log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1]
480                         << "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage;
481                 limitsOk = false;
482         }
483
484         return limitsOk;
485 }
486
487 tcu::TestStatus enumeratePhysicalDevices (Context& context)
488 {
489         TestLog&                                                log             = context.getTestContext().getLog();
490         const vector<VkPhysicalDevice>  devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
491
492         log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
493
494         for (size_t ndx = 0; ndx < devices.size(); ndx++)
495                 log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage;
496
497         return tcu::TestStatus::pass("Enumerating devices succeeded");
498 }
499
500 template<typename T>
501 void collectDuplicates (set<T>& duplicates, const vector<T>& values)
502 {
503         set<T> seen;
504
505         for (size_t ndx = 0; ndx < values.size(); ndx++)
506         {
507                 const T& value = values[ndx];
508
509                 if (!seen.insert(value).second)
510                         duplicates.insert(value);
511         }
512 }
513
514 void checkDuplicates (tcu::ResultCollector& results, const char* what, const vector<string>& values)
515 {
516         set<string> duplicates;
517
518         collectDuplicates(duplicates, values);
519
520         for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter)
521         {
522                 std::ostringstream msg;
523                 msg << "Duplicate " << what << ": " << *iter;
524                 results.fail(msg.str());
525         }
526 }
527
528 void checkDuplicateExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
529 {
530         checkDuplicates(results, "extension", extensions);
531 }
532
533 void checkDuplicateLayers (tcu::ResultCollector& results, const vector<string>& layers)
534 {
535         checkDuplicates(results, "layer", layers);
536 }
537
538 void checkKhrExtensions (tcu::ResultCollector&          results,
539                                                  const vector<string>&          extensions,
540                                                  const int                                      numAllowedKhrExtensions,
541                                                  const char* const*                     allowedKhrExtensions)
542 {
543         const set<string>       allowedExtSet           (allowedKhrExtensions, allowedKhrExtensions+numAllowedKhrExtensions);
544
545         for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter)
546         {
547                 // Only Khronos-controlled extensions are checked
548                 if ((de::beginsWith(*extIter, "VK_KHR_") || de::beginsWith(*extIter, "VK_KHX_")) &&
549                         !de::contains(allowedExtSet, *extIter))
550                 {
551                         results.fail("Unknown KHR extension " + *extIter);
552                 }
553         }
554 }
555
556 void checkInstanceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
557 {
558         static const char* s_allowedInstanceKhrExtensions[] =
559         {
560                 "VK_KHR_surface",
561                 "VK_KHR_display",
562                 "VK_KHR_android_surface",
563                 "VK_KHR_mir_surface",
564                 "VK_KHR_wayland_surface",
565                 "VK_KHR_win32_surface",
566                 "VK_KHR_xcb_surface",
567                 "VK_KHR_xlib_surface",
568         };
569
570         checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
571         checkDuplicateExtensions(results, extensions);
572 }
573
574 void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
575 {
576         static const char* s_allowedInstanceKhrExtensions[] =
577         {
578                 "VK_KHR_swapchain",
579                 "VK_KHR_display_swapchain",
580                 "VK_KHR_sampler_mirror_clamp_to_edge"
581         };
582
583         checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
584         checkDuplicateExtensions(results, extensions);
585 }
586
587 tcu::TestStatus enumerateInstanceLayers (Context& context)
588 {
589         TestLog&                                                log                                     = context.getTestContext().getLog();
590         tcu::ResultCollector                    results                         (log);
591         const vector<VkLayerProperties> properties                      = enumerateInstanceLayerProperties(context.getPlatformInterface());
592         vector<string>                                  layerNames;
593
594         for (size_t ndx = 0; ndx < properties.size(); ndx++)
595         {
596                 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
597
598                 layerNames.push_back(properties[ndx].layerName);
599         }
600
601         checkDuplicateLayers(results, layerNames);
602
603         return tcu::TestStatus(results.getResult(), results.getMessage());
604 }
605
606 tcu::TestStatus enumerateInstanceExtensions (Context& context)
607 {
608         TestLog&                                log             = context.getTestContext().getLog();
609         tcu::ResultCollector    results (log);
610
611         {
612                 const ScopedLogSection                          section         (log, "Global", "Global Extensions");
613                 const vector<VkExtensionProperties>     properties      = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
614                 vector<string>                                          extensionNames;
615
616                 for (size_t ndx = 0; ndx < properties.size(); ndx++)
617                 {
618                         log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
619
620                         extensionNames.push_back(properties[ndx].extensionName);
621                 }
622
623                 checkInstanceExtensions(results, extensionNames);
624         }
625
626         {
627                 const vector<VkLayerProperties> layers  = enumerateInstanceLayerProperties(context.getPlatformInterface());
628
629                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
630                 {
631                         const ScopedLogSection                          section                         (log, layer->layerName, string("Layer: ") + layer->layerName);
632                         const vector<VkExtensionProperties>     properties                      = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
633                         vector<string>                                          extensionNames;
634
635                         for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
636                         {
637                                 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
638
639                                 extensionNames.push_back(properties[extNdx].extensionName);
640                         }
641
642                         checkInstanceExtensions(results, extensionNames);
643                 }
644         }
645
646         return tcu::TestStatus(results.getResult(), results.getMessage());
647 }
648
649 tcu::TestStatus enumerateDeviceLayers (Context& context)
650 {
651         TestLog&                                                log                     = context.getTestContext().getLog();
652         tcu::ResultCollector                    results         (log);
653         const vector<VkLayerProperties> properties      = vk::enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
654         vector<string>                                  layerNames;
655
656         for (size_t ndx = 0; ndx < properties.size(); ndx++)
657         {
658                 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
659
660                 layerNames.push_back(properties[ndx].layerName);
661         }
662
663         checkDuplicateLayers(results, layerNames);
664
665         return tcu::TestStatus(results.getResult(), results.getMessage());
666 }
667
668 tcu::TestStatus enumerateDeviceExtensions (Context& context)
669 {
670         TestLog&                                log             = context.getTestContext().getLog();
671         tcu::ResultCollector    results (log);
672
673         {
674                 const ScopedLogSection                          section         (log, "Global", "Global Extensions");
675                 const vector<VkExtensionProperties>     properties      = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
676                 vector<string>                                          extensionNames;
677
678                 for (size_t ndx = 0; ndx < properties.size(); ndx++)
679                 {
680                         log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
681
682                         extensionNames.push_back(properties[ndx].extensionName);
683                 }
684
685                 checkDeviceExtensions(results, extensionNames);
686         }
687
688         {
689                 const vector<VkLayerProperties> layers  = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
690
691                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
692                 {
693                         const ScopedLogSection                          section         (log, layer->layerName, string("Layer: ") + layer->layerName);
694                         const vector<VkExtensionProperties>     properties      = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
695                         vector<string>                                          extensionNames;
696
697                         for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
698                         {
699                                 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
700
701
702                                 extensionNames.push_back(properties[extNdx].extensionName);
703                         }
704
705                         checkDeviceExtensions(results, extensionNames);
706                 }
707         }
708
709         return tcu::TestStatus(results.getResult(), results.getMessage());
710 }
711
712 #define VK_SIZE_OF(STRUCT, MEMBER)                                      (sizeof(((STRUCT*)0)->MEMBER))
713 #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER)                      { (size_t)DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) }
714
715 tcu::TestStatus deviceFeatures (Context& context)
716 {
717         TestLog&                                                log                     = context.getTestContext().getLog();
718         VkPhysicalDeviceFeatures*               features;
719         deUint8                                                 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE];
720
721         const QueryMemberTableEntry featureOffsetTable[] =
722         {
723                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess),
724                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32),
725                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray),
726                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend),
727                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader),
728                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader),
729                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading),
730                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend),
731                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp),
732                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect),
733                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance),
734                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp),
735                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp),
736                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid),
737                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds),
738                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines),
739                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints),
740                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne),
741                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport),
742                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy),
743                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2),
744                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR),
745                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC),
746                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise),
747                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery),
748                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics),
749                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics),
750                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize),
751                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended),
752                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats),
753                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample),
754                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat),
755                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat),
756                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing),
757                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing),
758                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing),
759                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing),
760                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance),
761                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance),
762                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64),
763                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64),
764                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16),
765                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency),
766                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod),
767                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding),
768                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer),
769                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D),
770                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D),
771                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples),
772                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples),
773                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples),
774                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples),
775                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased),
776                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate),
777                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries),
778                 { 0, 0 }
779         };
780
781
782         deMemset(buffer, GUARD_VALUE, sizeof(buffer));
783         features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer);
784
785         context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features);
786
787         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
788                 << TestLog::Message << *features << TestLog::EndMessage;
789
790         if (!features->robustBufferAccess)
791                 return tcu::TestStatus::fail("robustBufferAccess is not supported");
792
793         for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
794         {
795                 if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE)
796                 {
797                         log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
798                         return tcu::TestStatus::fail("deviceFeatures buffer overflow");
799                 }
800         }
801
802         if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable))
803         {
804                 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage;
805                 return tcu::TestStatus::fail("deviceFeatures incomplete initialization");
806         }
807
808
809         return tcu::TestStatus::pass("Query succeeded");
810 }
811
812 tcu::TestStatus deviceProperties (Context& context)
813 {
814         TestLog&                                                log                     = context.getTestContext().getLog();
815         VkPhysicalDeviceProperties*             props;
816         VkPhysicalDeviceFeatures                features;
817         deUint8                                                 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE];
818
819         const QueryMemberTableEntry physicalDevicePropertiesOffsetTable[] =
820         {
821                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion),
822                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion),
823                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID),
824                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID),
825                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType),
826                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID),
827                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D),
828                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D),
829                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D),
830                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube),
831                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers),
832                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements),
833                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange),
834                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange),
835                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize),
836                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount),
837                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount),
838                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity),
839                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize),
840                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets),
841                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers),
842                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers),
843                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers),
844                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages),
845                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages),
846                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments),
847                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources),
848                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers),
849                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers),
850                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic),
851                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers),
852                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic),
853                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages),
854                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages),
855                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments),
856                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes),
857                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings),
858                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset),
859                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride),
860                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents),
861                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel),
862                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize),
863                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents),
864                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents),
865                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents),
866                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents),
867                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents),
868                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents),
869                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations),
870                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents),
871                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents),
872                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices),
873                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents),
874                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents),
875                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments),
876                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments),
877                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources),
878                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize),
879                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]),
880                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations),
881                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]),
882                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits),
883                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits),
884                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits),
885                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue),
886                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount),
887                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias),
888                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy),
889                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports),
890                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]),
891                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]),
892                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits),
893                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment),
894                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment),
895                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment),
896                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment),
897                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset),
898                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset),
899                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset),
900                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset),
901                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset),
902                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset),
903                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits),
904                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth),
905                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight),
906                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers),
907                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts),
908                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts),
909                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts),
910                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts),
911                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments),
912                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts),
913                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts),
914                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts),
915                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts),
916                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts),
917                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords),
918                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics),
919                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod),
920                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances),
921                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances),
922                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances),
923                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities),
924                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]),
925                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]),
926                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity),
927                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity),
928                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines),
929                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations),
930                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment),
931                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment),
932                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize),
933                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape),
934                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape),
935                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape),
936                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize),
937                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict),
938                 { 0, 0 }
939         };
940
941         props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer);
942         deMemset(props, GUARD_VALUE, sizeof(buffer));
943
944         context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props);
945         context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features);
946
947         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
948                 << TestLog::Message << *props << TestLog::EndMessage;
949
950         if (!validateFeatureLimits(props, &features, log))
951                 return tcu::TestStatus::fail("deviceProperties - feature limits failed");
952
953         for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
954         {
955                 if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE)
956                 {
957                         log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
958                         return tcu::TestStatus::fail("deviceProperties buffer overflow");
959                 }
960         }
961
962         if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), physicalDevicePropertiesOffsetTable))
963         {
964                 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage;
965                 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
966         }
967
968         // Check if deviceName string is properly terminated.
969         if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE)
970         {
971                 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage;
972                 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
973         }
974
975         {
976                 const ApiVersion deviceVersion = unpackVersion(props->apiVersion);
977                 const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION);
978
979                 if (deviceVersion.majorNum != deqpVersion.majorNum)
980                 {
981                         log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage;
982                         return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
983                 }
984
985                 if (deviceVersion.minorNum > deqpVersion.minorNum)
986                 {
987                         log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage;
988                         return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
989                 }
990         }
991
992         return tcu::TestStatus::pass("DeviceProperites query succeeded");
993 }
994
995 tcu::TestStatus deviceQueueFamilyProperties (Context& context)
996 {
997         TestLog&                                                                log                                     = context.getTestContext().getLog();
998         const vector<VkQueueFamilyProperties>   queueProperties         = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
999
1000         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage;
1001
1002         for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++)
1003                 log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage;
1004
1005         return tcu::TestStatus::pass("Querying queue properties succeeded");
1006 }
1007
1008 tcu::TestStatus deviceMemoryProperties (Context& context)
1009 {
1010         TestLog&                                                        log                     = context.getTestContext().getLog();
1011         VkPhysicalDeviceMemoryProperties*       memProps;
1012         deUint8                                                         buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE];
1013
1014         memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer);
1015         deMemset(buffer, GUARD_VALUE, sizeof(buffer));
1016
1017         context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps);
1018
1019         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
1020                 << TestLog::Message << *memProps << TestLog::EndMessage;
1021
1022         for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
1023         {
1024                 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE)
1025                 {
1026                         log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
1027                         return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow");
1028                 }
1029         }
1030
1031         if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS)
1032         {
1033                 log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage;
1034                 return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large");
1035         }
1036
1037         if (memProps->memoryHeapCount == 1)
1038         {
1039                 if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
1040                 {
1041                         log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage;
1042                         return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags");
1043                 }
1044         }
1045
1046         const VkMemoryPropertyFlags validPropertyFlags[] =
1047         {
1048                 0,
1049                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
1050                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1051                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
1052                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1053                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1054                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
1055                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1056                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
1057         };
1058
1059         const VkMemoryPropertyFlags requiredPropertyFlags[] =
1060         {
1061                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
1062         };
1063
1064         bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)];
1065         std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
1066
1067         for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++)
1068         {
1069                 bool validPropTypeFound = false;
1070
1071                 if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount)
1072                 {
1073                         log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage;
1074                         return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex");
1075                 }
1076
1077                 const VkMemoryPropertyFlags bitsToCheck = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT;
1078
1079                 for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++)
1080                         if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator)
1081                                 requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true;
1082
1083                 if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck))
1084                         validPropTypeFound = true;
1085
1086                 if (!validPropTypeFound)
1087                 {
1088                         log << TestLog::Message << "deviceMemoryProperties - propertyFlags "
1089                                 << memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage;
1090                         return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
1091                 }
1092
1093                 if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
1094                 {
1095                         if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
1096                         {
1097                                 log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage;
1098                                 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
1099                         }
1100                 }
1101                 else
1102                 {
1103                         if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1104                         {
1105                                 log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage;
1106                                 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
1107                         }
1108                 }
1109         }
1110
1111         bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
1112         if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound))
1113         {
1114                 DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags));
1115                 log << TestLog::Message << "deviceMemoryProperties - required property flags "
1116                         << getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage;
1117
1118                 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
1119         }
1120
1121         return tcu::TestStatus::pass("Querying memory properties succeeded");
1122 }
1123
1124 // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead
1125
1126 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format)
1127 {
1128         static const VkFormat s_requiredSampledImageBlitSrcFormats[] =
1129         {
1130                 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1131                 VK_FORMAT_R5G6B5_UNORM_PACK16,
1132                 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1133                 VK_FORMAT_R8_UNORM,
1134                 VK_FORMAT_R8_SNORM,
1135                 VK_FORMAT_R8_UINT,
1136                 VK_FORMAT_R8_SINT,
1137                 VK_FORMAT_R8G8_UNORM,
1138                 VK_FORMAT_R8G8_SNORM,
1139                 VK_FORMAT_R8G8_UINT,
1140                 VK_FORMAT_R8G8_SINT,
1141                 VK_FORMAT_R8G8B8A8_UNORM,
1142                 VK_FORMAT_R8G8B8A8_SNORM,
1143                 VK_FORMAT_R8G8B8A8_UINT,
1144                 VK_FORMAT_R8G8B8A8_SINT,
1145                 VK_FORMAT_R8G8B8A8_SRGB,
1146                 VK_FORMAT_B8G8R8A8_UNORM,
1147                 VK_FORMAT_B8G8R8A8_SRGB,
1148                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1149                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1150                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1151                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1152                 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1153                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1154                 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1155                 VK_FORMAT_R16_UINT,
1156                 VK_FORMAT_R16_SINT,
1157                 VK_FORMAT_R16_SFLOAT,
1158                 VK_FORMAT_R16G16_UINT,
1159                 VK_FORMAT_R16G16_SINT,
1160                 VK_FORMAT_R16G16_SFLOAT,
1161                 VK_FORMAT_R16G16B16A16_UINT,
1162                 VK_FORMAT_R16G16B16A16_SINT,
1163                 VK_FORMAT_R16G16B16A16_SFLOAT,
1164                 VK_FORMAT_R32_UINT,
1165                 VK_FORMAT_R32_SINT,
1166                 VK_FORMAT_R32_SFLOAT,
1167                 VK_FORMAT_R32G32_UINT,
1168                 VK_FORMAT_R32G32_SINT,
1169                 VK_FORMAT_R32G32_SFLOAT,
1170                 VK_FORMAT_R32G32B32A32_UINT,
1171                 VK_FORMAT_R32G32B32A32_SINT,
1172                 VK_FORMAT_R32G32B32A32_SFLOAT,
1173                 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1174                 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1175                 VK_FORMAT_D16_UNORM,
1176                 VK_FORMAT_D32_SFLOAT
1177         };
1178         static const VkFormat s_requiredSampledImageFilterLinearFormats[] =
1179         {
1180                 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1181                 VK_FORMAT_R5G6B5_UNORM_PACK16,
1182                 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1183                 VK_FORMAT_R8_UNORM,
1184                 VK_FORMAT_R8_SNORM,
1185                 VK_FORMAT_R8G8_UNORM,
1186                 VK_FORMAT_R8G8_SNORM,
1187                 VK_FORMAT_R8G8B8A8_UNORM,
1188                 VK_FORMAT_R8G8B8A8_SNORM,
1189                 VK_FORMAT_R8G8B8A8_SRGB,
1190                 VK_FORMAT_B8G8R8A8_UNORM,
1191                 VK_FORMAT_B8G8R8A8_SRGB,
1192                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1193                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1194                 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1195                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1196                 VK_FORMAT_R16_SFLOAT,
1197                 VK_FORMAT_R16G16_SFLOAT,
1198                 VK_FORMAT_R16G16B16A16_SFLOAT,
1199                 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1200                 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1201         };
1202         static const VkFormat s_requiredStorageImageFormats[] =
1203         {
1204                 VK_FORMAT_R8G8B8A8_UNORM,
1205                 VK_FORMAT_R8G8B8A8_SNORM,
1206                 VK_FORMAT_R8G8B8A8_UINT,
1207                 VK_FORMAT_R8G8B8A8_SINT,
1208                 VK_FORMAT_R16G16B16A16_UINT,
1209                 VK_FORMAT_R16G16B16A16_SINT,
1210                 VK_FORMAT_R16G16B16A16_SFLOAT,
1211                 VK_FORMAT_R32_UINT,
1212                 VK_FORMAT_R32_SINT,
1213                 VK_FORMAT_R32_SFLOAT,
1214                 VK_FORMAT_R32G32_UINT,
1215                 VK_FORMAT_R32G32_SINT,
1216                 VK_FORMAT_R32G32_SFLOAT,
1217                 VK_FORMAT_R32G32B32A32_UINT,
1218                 VK_FORMAT_R32G32B32A32_SINT,
1219                 VK_FORMAT_R32G32B32A32_SFLOAT
1220         };
1221         static const VkFormat s_requiredStorageImageAtomicFormats[] =
1222         {
1223                 VK_FORMAT_R32_UINT,
1224                 VK_FORMAT_R32_SINT
1225         };
1226         static const VkFormat s_requiredColorAttachmentBlitDstFormats[] =
1227         {
1228                 VK_FORMAT_R5G6B5_UNORM_PACK16,
1229                 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1230                 VK_FORMAT_R8_UNORM,
1231                 VK_FORMAT_R8_UINT,
1232                 VK_FORMAT_R8_SINT,
1233                 VK_FORMAT_R8G8_UNORM,
1234                 VK_FORMAT_R8G8_UINT,
1235                 VK_FORMAT_R8G8_SINT,
1236                 VK_FORMAT_R8G8B8A8_UNORM,
1237                 VK_FORMAT_R8G8B8A8_UINT,
1238                 VK_FORMAT_R8G8B8A8_SINT,
1239                 VK_FORMAT_R8G8B8A8_SRGB,
1240                 VK_FORMAT_B8G8R8A8_UNORM,
1241                 VK_FORMAT_B8G8R8A8_SRGB,
1242                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1243                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1244                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1245                 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1246                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1247                 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1248                 VK_FORMAT_R16_UINT,
1249                 VK_FORMAT_R16_SINT,
1250                 VK_FORMAT_R16_SFLOAT,
1251                 VK_FORMAT_R16G16_UINT,
1252                 VK_FORMAT_R16G16_SINT,
1253                 VK_FORMAT_R16G16_SFLOAT,
1254                 VK_FORMAT_R16G16B16A16_UINT,
1255                 VK_FORMAT_R16G16B16A16_SINT,
1256                 VK_FORMAT_R16G16B16A16_SFLOAT,
1257                 VK_FORMAT_R32_UINT,
1258                 VK_FORMAT_R32_SINT,
1259                 VK_FORMAT_R32_SFLOAT,
1260                 VK_FORMAT_R32G32_UINT,
1261                 VK_FORMAT_R32G32_SINT,
1262                 VK_FORMAT_R32G32_SFLOAT,
1263                 VK_FORMAT_R32G32B32A32_UINT,
1264                 VK_FORMAT_R32G32B32A32_SINT,
1265                 VK_FORMAT_R32G32B32A32_SFLOAT
1266         };
1267         static const VkFormat s_requiredColorAttachmentBlendFormats[] =
1268         {
1269                 VK_FORMAT_R5G6B5_UNORM_PACK16,
1270                 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1271                 VK_FORMAT_R8_UNORM,
1272                 VK_FORMAT_R8G8_UNORM,
1273                 VK_FORMAT_R8G8B8A8_UNORM,
1274                 VK_FORMAT_R8G8B8A8_SRGB,
1275                 VK_FORMAT_B8G8R8A8_UNORM,
1276                 VK_FORMAT_B8G8R8A8_SRGB,
1277                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1278                 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1279                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1280                 VK_FORMAT_R16_SFLOAT,
1281                 VK_FORMAT_R16G16_SFLOAT,
1282                 VK_FORMAT_R16G16B16A16_SFLOAT
1283         };
1284         static const VkFormat s_requiredDepthStencilAttachmentFormats[] =
1285         {
1286                 VK_FORMAT_D16_UNORM
1287         };
1288
1289         VkFormatFeatureFlags    flags   = (VkFormatFeatureFlags)0;
1290
1291         if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format))
1292                 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT;
1293
1294         if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterLinearFormats), DE_ARRAY_END(s_requiredSampledImageFilterLinearFormats), format))
1295                 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
1296
1297         if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format))
1298                 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
1299
1300         if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format))
1301                 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
1302
1303         if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format))
1304                 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT;
1305
1306         if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format))
1307                 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
1308
1309         if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format))
1310                 flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
1311
1312         return flags;
1313 }
1314
1315 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format)
1316 {
1317         static const VkFormat s_requiredVertexBufferFormats[] =
1318         {
1319                 VK_FORMAT_R8_UNORM,
1320                 VK_FORMAT_R8_SNORM,
1321                 VK_FORMAT_R8_UINT,
1322                 VK_FORMAT_R8_SINT,
1323                 VK_FORMAT_R8G8_UNORM,
1324                 VK_FORMAT_R8G8_SNORM,
1325                 VK_FORMAT_R8G8_UINT,
1326                 VK_FORMAT_R8G8_SINT,
1327                 VK_FORMAT_R8G8B8A8_UNORM,
1328                 VK_FORMAT_R8G8B8A8_SNORM,
1329                 VK_FORMAT_R8G8B8A8_UINT,
1330                 VK_FORMAT_R8G8B8A8_SINT,
1331                 VK_FORMAT_B8G8R8A8_UNORM,
1332                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1333                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1334                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1335                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1336                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1337                 VK_FORMAT_R16_UNORM,
1338                 VK_FORMAT_R16_SNORM,
1339                 VK_FORMAT_R16_UINT,
1340                 VK_FORMAT_R16_SINT,
1341                 VK_FORMAT_R16_SFLOAT,
1342                 VK_FORMAT_R16G16_UNORM,
1343                 VK_FORMAT_R16G16_SNORM,
1344                 VK_FORMAT_R16G16_UINT,
1345                 VK_FORMAT_R16G16_SINT,
1346                 VK_FORMAT_R16G16_SFLOAT,
1347                 VK_FORMAT_R16G16B16A16_UNORM,
1348                 VK_FORMAT_R16G16B16A16_SNORM,
1349                 VK_FORMAT_R16G16B16A16_UINT,
1350                 VK_FORMAT_R16G16B16A16_SINT,
1351                 VK_FORMAT_R16G16B16A16_SFLOAT,
1352                 VK_FORMAT_R32_UINT,
1353                 VK_FORMAT_R32_SINT,
1354                 VK_FORMAT_R32_SFLOAT,
1355                 VK_FORMAT_R32G32_UINT,
1356                 VK_FORMAT_R32G32_SINT,
1357                 VK_FORMAT_R32G32_SFLOAT,
1358                 VK_FORMAT_R32G32B32_UINT,
1359                 VK_FORMAT_R32G32B32_SINT,
1360                 VK_FORMAT_R32G32B32_SFLOAT,
1361                 VK_FORMAT_R32G32B32A32_UINT,
1362                 VK_FORMAT_R32G32B32A32_SINT,
1363                 VK_FORMAT_R32G32B32A32_SFLOAT
1364         };
1365         static const VkFormat s_requiredUniformTexelBufferFormats[] =
1366         {
1367                 VK_FORMAT_R8_UNORM,
1368                 VK_FORMAT_R8_SNORM,
1369                 VK_FORMAT_R8_UINT,
1370                 VK_FORMAT_R8_SINT,
1371                 VK_FORMAT_R8G8_UNORM,
1372                 VK_FORMAT_R8G8_SNORM,
1373                 VK_FORMAT_R8G8_UINT,
1374                 VK_FORMAT_R8G8_SINT,
1375                 VK_FORMAT_R8G8B8A8_UNORM,
1376                 VK_FORMAT_R8G8B8A8_SNORM,
1377                 VK_FORMAT_R8G8B8A8_UINT,
1378                 VK_FORMAT_R8G8B8A8_SINT,
1379                 VK_FORMAT_B8G8R8A8_UNORM,
1380                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1381                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1382                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1383                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1384                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1385                 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1386                 VK_FORMAT_R16_UINT,
1387                 VK_FORMAT_R16_SINT,
1388                 VK_FORMAT_R16_SFLOAT,
1389                 VK_FORMAT_R16G16_UINT,
1390                 VK_FORMAT_R16G16_SINT,
1391                 VK_FORMAT_R16G16_SFLOAT,
1392                 VK_FORMAT_R16G16B16A16_UINT,
1393                 VK_FORMAT_R16G16B16A16_SINT,
1394                 VK_FORMAT_R16G16B16A16_SFLOAT,
1395                 VK_FORMAT_R32_UINT,
1396                 VK_FORMAT_R32_SINT,
1397                 VK_FORMAT_R32_SFLOAT,
1398                 VK_FORMAT_R32G32_UINT,
1399                 VK_FORMAT_R32G32_SINT,
1400                 VK_FORMAT_R32G32_SFLOAT,
1401                 VK_FORMAT_R32G32B32A32_UINT,
1402                 VK_FORMAT_R32G32B32A32_SINT,
1403                 VK_FORMAT_R32G32B32A32_SFLOAT,
1404                 VK_FORMAT_B10G11R11_UFLOAT_PACK32
1405         };
1406         static const VkFormat s_requiredStorageTexelBufferFormats[] =
1407         {
1408                 VK_FORMAT_R8G8B8A8_UNORM,
1409                 VK_FORMAT_R8G8B8A8_SNORM,
1410                 VK_FORMAT_R8G8B8A8_UINT,
1411                 VK_FORMAT_R8G8B8A8_SINT,
1412                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1413                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1414                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1415                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1416                 VK_FORMAT_R16G16B16A16_UINT,
1417                 VK_FORMAT_R16G16B16A16_SINT,
1418                 VK_FORMAT_R16G16B16A16_SFLOAT,
1419                 VK_FORMAT_R32_UINT,
1420                 VK_FORMAT_R32_SINT,
1421                 VK_FORMAT_R32_SFLOAT,
1422                 VK_FORMAT_R32G32_UINT,
1423                 VK_FORMAT_R32G32_SINT,
1424                 VK_FORMAT_R32G32_SFLOAT,
1425                 VK_FORMAT_R32G32B32A32_UINT,
1426                 VK_FORMAT_R32G32B32A32_SINT,
1427                 VK_FORMAT_R32G32B32A32_SFLOAT
1428         };
1429         static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] =
1430         {
1431                 VK_FORMAT_R32_UINT,
1432                 VK_FORMAT_R32_SINT
1433         };
1434
1435         VkFormatFeatureFlags    flags   = (VkFormatFeatureFlags)0;
1436
1437         if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format))
1438                 flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
1439
1440         if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format))
1441                 flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
1442
1443         if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format))
1444                 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
1445
1446         if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format))
1447                 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
1448
1449         return flags;
1450 }
1451
1452 tcu::TestStatus formatProperties (Context& context, VkFormat format)
1453 {
1454         TestLog&                                        log                             = context.getTestContext().getLog();
1455         const VkFormatProperties        properties              = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1456         bool                                            allOk                   = true;
1457
1458         const struct
1459         {
1460                 VkFormatFeatureFlags VkFormatProperties::*      field;
1461                 const char*                                                                     fieldName;
1462                 VkFormatFeatureFlags                                            requiredFeatures;
1463         } fields[] =
1464         {
1465                 { &VkFormatProperties::linearTilingFeatures,    "linearTilingFeatures",         (VkFormatFeatureFlags)0                                         },
1466                 { &VkFormatProperties::optimalTilingFeatures,   "optimalTilingFeatures",        getRequiredOptimalTilingFeatures(format)        },
1467                 { &VkFormatProperties::bufferFeatures,                  "buffeFeatures",                        getRequiredBufferFeatures(format)                       }
1468         };
1469
1470         log << TestLog::Message << properties << TestLog::EndMessage;
1471
1472         for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
1473         {
1474                 const char* const                               fieldName       = fields[fieldNdx].fieldName;
1475                 const VkFormatFeatureFlags              supported       = properties.*fields[fieldNdx].field;
1476                 const VkFormatFeatureFlags              required        = fields[fieldNdx].requiredFeatures;
1477
1478                 if ((supported & required) != required)
1479                 {
1480                         log << TestLog::Message << "ERROR in " << fieldName << ":\n"
1481                                                                     << "  required: " << getFormatFeatureFlagsStr(required) << "\n  "
1482                                                                         << "  missing: " << getFormatFeatureFlagsStr(~supported & required)
1483                                 << TestLog::EndMessage;
1484                         allOk = false;
1485                 }
1486         }
1487
1488         if (allOk)
1489                 return tcu::TestStatus::pass("Query and validation passed");
1490         else
1491                 return tcu::TestStatus::fail("Required features not supported");
1492 }
1493
1494 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features)
1495 {
1496         const VkFormatProperties        properties      = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1497
1498         return (properties.optimalTilingFeatures & features) == features;
1499 }
1500
1501 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features)
1502 {
1503         for (const VkFormat* cur = begin; cur != end; ++cur)
1504         {
1505                 if (!optimalTilingFeaturesSupported(context, *cur, features))
1506                         return false;
1507         }
1508
1509         return true;
1510 }
1511
1512 tcu::TestStatus testDepthStencilSupported (Context& context)
1513 {
1514         if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
1515                 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
1516                 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT");
1517
1518         if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
1519                 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
1520                 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT");
1521
1522         return tcu::TestStatus::pass("Required depth/stencil formats supported");
1523 }
1524
1525 tcu::TestStatus testCompressedFormatsSupported (Context& context)
1526 {
1527         static const VkFormat s_allBcFormats[] =
1528         {
1529                 VK_FORMAT_BC1_RGB_UNORM_BLOCK,
1530                 VK_FORMAT_BC1_RGB_SRGB_BLOCK,
1531                 VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
1532                 VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
1533                 VK_FORMAT_BC2_UNORM_BLOCK,
1534                 VK_FORMAT_BC2_SRGB_BLOCK,
1535                 VK_FORMAT_BC3_UNORM_BLOCK,
1536                 VK_FORMAT_BC3_SRGB_BLOCK,
1537                 VK_FORMAT_BC4_UNORM_BLOCK,
1538                 VK_FORMAT_BC4_SNORM_BLOCK,
1539                 VK_FORMAT_BC5_UNORM_BLOCK,
1540                 VK_FORMAT_BC5_SNORM_BLOCK,
1541                 VK_FORMAT_BC6H_UFLOAT_BLOCK,
1542                 VK_FORMAT_BC6H_SFLOAT_BLOCK,
1543                 VK_FORMAT_BC7_UNORM_BLOCK,
1544                 VK_FORMAT_BC7_SRGB_BLOCK,
1545         };
1546         static const VkFormat s_allEtc2Formats[] =
1547         {
1548                 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1549                 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1550                 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1551                 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1552                 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1553                 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1554                 VK_FORMAT_EAC_R11_UNORM_BLOCK,
1555                 VK_FORMAT_EAC_R11_SNORM_BLOCK,
1556                 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1557                 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1558         };
1559         static const VkFormat s_allAstcLdrFormats[] =
1560         {
1561                 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1562                 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1563                 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1564                 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1565                 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1566                 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1567                 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1568                 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1569                 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1570                 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1571                 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1572                 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1573                 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1574                 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1575                 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1576                 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1577                 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1578                 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1579                 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1580                 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1581                 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1582                 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1583                 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1584                 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1585                 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1586                 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1587                 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1588                 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
1589         };
1590
1591         static const struct
1592         {
1593                 const char*                                                                     setName;
1594                 const char*                                                                     featureName;
1595                 const VkBool32 VkPhysicalDeviceFeatures::*      feature;
1596                 const VkFormat*                                                         formatsBegin;
1597                 const VkFormat*                                                         formatsEnd;
1598         } s_compressedFormatSets[] =
1599         {
1600                 { "BC",                 "textureCompressionBC",                 &VkPhysicalDeviceFeatures::textureCompressionBC,                DE_ARRAY_BEGIN(s_allBcFormats),                 DE_ARRAY_END(s_allBcFormats)            },
1601                 { "ETC2",               "textureCompressionETC2",               &VkPhysicalDeviceFeatures::textureCompressionETC2,              DE_ARRAY_BEGIN(s_allEtc2Formats),               DE_ARRAY_END(s_allEtc2Formats)          },
1602                 { "ASTC LDR",   "textureCompressionASTC_LDR",   &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR,  DE_ARRAY_BEGIN(s_allAstcLdrFormats),    DE_ARRAY_END(s_allAstcLdrFormats)       },
1603         };
1604
1605         TestLog&                                                log                                     = context.getTestContext().getLog();
1606         const VkPhysicalDeviceFeatures& features                        = context.getDeviceFeatures();
1607         int                                                             numSupportedSets        = 0;
1608         int                                                             numErrors                       = 0;
1609         int                                                             numWarnings                     = 0;
1610
1611         for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx)
1612         {
1613                 const char* const       setName                 = s_compressedFormatSets[setNdx].setName;
1614                 const char* const       featureName             = s_compressedFormatSets[setNdx].featureName;
1615                 const bool                      featureBitSet   = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE;
1616                 const bool                      allSupported    = optimalTilingFeaturesSupportedForAll(context,
1617                                                                                                                                                                    s_compressedFormatSets[setNdx].formatsBegin,
1618                                                                                                                                                                    s_compressedFormatSets[setNdx].formatsEnd,
1619                                                                                                                                                                    VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
1620
1621                 if (featureBitSet && !allSupported)
1622                 {
1623                         log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage;
1624                         numErrors += 1;
1625                 }
1626                 else if (allSupported && !featureBitSet)
1627                 {
1628                         log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage;
1629                         numWarnings += 1;
1630                 }
1631
1632                 if (featureBitSet)
1633                 {
1634                         log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage;
1635                         numSupportedSets += 1;
1636                 }
1637                 else
1638                         log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage;
1639         }
1640
1641         if (numSupportedSets == 0)
1642         {
1643                 log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage;
1644                 numErrors += 1;
1645         }
1646
1647         if (numErrors > 0)
1648                 return tcu::TestStatus::fail("Compressed format support not valid");
1649         else if (numWarnings > 0)
1650                 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support");
1651         else
1652                 return tcu::TestStatus::pass("Compressed texture format support is valid");
1653 }
1654
1655 void createFormatTests (tcu::TestCaseGroup* testGroup)
1656 {
1657         DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0);
1658
1659         for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_FORMAT_LAST; ++formatNdx)
1660         {
1661                 const VkFormat          format                  = (VkFormat)formatNdx;
1662                 const char* const       enumName                = getFormatName(format);
1663                 const string            caseName                = de::toLower(string(enumName).substr(10));
1664
1665                 addFunctionCase(testGroup, caseName, enumName, formatProperties, format);
1666         }
1667
1668         addFunctionCase(testGroup, "depth_stencil",                     "",     testDepthStencilSupported);
1669         addFunctionCase(testGroup, "compressed_formats",        "",     testCompressedFormatsSupported);
1670 }
1671
1672 VkImageUsageFlags getValidImageUsageFlags (VkFormat, VkFormatFeatureFlags supportedFeatures)
1673 {
1674         VkImageUsageFlags       flags   = (VkImageUsageFlags)0;
1675
1676         // If format is supported at all, it must be valid transfer src+dst
1677         if (supportedFeatures != 0)
1678                 flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
1679
1680         if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
1681                 flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
1682
1683         if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0)
1684                 flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1685
1686         if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1687                 flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1688
1689         if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
1690                 flags |= VK_IMAGE_USAGE_STORAGE_BIT;
1691
1692         return flags;
1693 }
1694
1695 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
1696 {
1697         if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)
1698         {
1699                 const VkImageUsageFlags         allowedFlags    = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
1700                                                                                                         | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
1701                                                                                                         | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
1702                                                                                                         | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1703
1704                 // Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT
1705                 if ((usage & ~allowedFlags) != 0)
1706                         return false;
1707
1708                 // TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT
1709                 if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
1710                         return false;
1711         }
1712
1713         return usage != 0;
1714 }
1715
1716 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage)
1717 {
1718         VkImageCreateFlags      flags   = (VkImageCreateFlags)0;
1719
1720         if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1721         {
1722                 flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
1723
1724                 if (type == VK_IMAGE_TYPE_2D)
1725                         flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
1726         }
1727
1728         if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 &&
1729                 (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1730         {
1731                 if (deviceFeatures.sparseBinding)
1732                         flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
1733
1734                 if (deviceFeatures.sparseResidencyAliased)
1735                         flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
1736         }
1737
1738         return flags;
1739 }
1740
1741 bool isValidImageCreateFlagCombination (VkImageCreateFlags)
1742 {
1743         return true;
1744 }
1745
1746 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures&       deviceFeatures,
1747                                                                                   const VkFormat                                        format,
1748                                                                                   const VkFormatProperties&                     formatProperties,
1749                                                                                   const VkImageType                                     imageType,
1750                                                                                   const VkImageTiling                           imageTiling,
1751                                                                                   const VkImageUsageFlags                       usageFlags,
1752                                                                                   const VkImageCreateFlags                      createFlags)
1753 {
1754         DE_UNREF(deviceFeatures);
1755         DE_UNREF(formatProperties);
1756         DE_UNREF(createFlags);
1757
1758         // Linear images can have arbitrary limitations
1759         if (imageTiling == VK_IMAGE_TILING_LINEAR)
1760                 return false;
1761
1762         // Support for other usages for compressed formats is optional
1763         if (isCompressedFormat(format) &&
1764                 (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0)
1765                 return false;
1766
1767         // Support for 1D, and sliced 3D compressed formats is optional
1768         if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
1769                 return false;
1770
1771         DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
1772         DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
1773
1774         if (createFlags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)
1775         {
1776                 if (isCompressedFormat(format))
1777                         return false;
1778
1779                 if (isDepthStencilFormat(format))
1780                         return false;
1781
1782                 if (!deIsPowerOfTwo32(mapVkFormat(format).getPixelSize()))
1783                         return false;
1784
1785                 switch (imageType)
1786                 {
1787                         case VK_IMAGE_TYPE_2D:
1788                                 return (deviceFeatures.sparseResidencyImage2D == VK_TRUE);
1789                         case VK_IMAGE_TYPE_3D:
1790                                 return (deviceFeatures.sparseResidencyImage3D == VK_TRUE);
1791                         default:
1792                                 return false;
1793                 }
1794         }
1795
1796         return true;
1797 }
1798
1799 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits&  deviceLimits,
1800                                                                                                                  const VkFormat                                 format,
1801                                                                                                                  const VkImageUsageFlags                usageFlags)
1802 {
1803         if (!isCompressedFormat(format))
1804         {
1805                 const tcu::TextureFormat                tcuFormat               = mapVkFormat(format);
1806                 const bool                                              hasDepthComp    = (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS);
1807                 const bool                                              hasStencilComp  = (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS);
1808                 const bool                                              isColorFormat   = !hasDepthComp && !hasStencilComp;
1809                 VkSampleCountFlags                              sampleCounts    = ~(VkSampleCountFlags)0;
1810
1811                 DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat);
1812
1813                 if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0)
1814                         sampleCounts &= deviceLimits.storageImageSampleCounts;
1815
1816                 if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1817                 {
1818                         if (hasDepthComp)
1819                                 sampleCounts &= deviceLimits.sampledImageDepthSampleCounts;
1820
1821                         if (hasStencilComp)
1822                                 sampleCounts &= deviceLimits.sampledImageStencilSampleCounts;
1823
1824                         if (isColorFormat)
1825                         {
1826                                 const tcu::TextureChannelClass  chnClass        = tcu::getTextureChannelClass(tcuFormat.type);
1827
1828                                 if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
1829                                         chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
1830                                         sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts;
1831                                 else
1832                                         sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
1833                         }
1834                 }
1835
1836                 if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
1837                         sampleCounts &= deviceLimits.framebufferColorSampleCounts;
1838
1839                 if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1840                 {
1841                         if (hasDepthComp)
1842                                 sampleCounts &= deviceLimits.framebufferDepthSampleCounts;
1843
1844                         if (hasStencilComp)
1845                                 sampleCounts &= deviceLimits.framebufferStencilSampleCounts;
1846                 }
1847
1848                 // If there is no usage flag set that would have corresponding device limit,
1849                 // only VK_SAMPLE_COUNT_1_BIT is required.
1850                 if (sampleCounts == ~(VkSampleCountFlags)0)
1851                         sampleCounts &= VK_SAMPLE_COUNT_1_BIT;
1852
1853                 return sampleCounts;
1854         }
1855         else
1856                 return VK_SAMPLE_COUNT_1_BIT;
1857 }
1858
1859 struct ImageFormatPropertyCase
1860 {
1861         VkFormat                format;
1862         VkImageType             imageType;
1863         VkImageTiling   tiling;
1864
1865         ImageFormatPropertyCase (VkFormat format_, VkImageType imageType_, VkImageTiling tiling_)
1866                 : format        (format_)
1867                 , imageType     (imageType_)
1868                 , tiling        (tiling_)
1869         {}
1870
1871         ImageFormatPropertyCase (void)
1872                 : format        (VK_FORMAT_LAST)
1873                 , imageType     (VK_IMAGE_TYPE_LAST)
1874                 , tiling        (VK_IMAGE_TILING_LAST)
1875         {}
1876 };
1877
1878 tcu::TestStatus imageFormatProperties (Context& context, ImageFormatPropertyCase params)
1879 {
1880         TestLog&                                                log                                     = context.getTestContext().getLog();
1881         const VkFormat                                  format                          = params.format;
1882         const VkImageType                               imageType                       = params.imageType;
1883         const VkImageTiling                             tiling                          = params.tiling;
1884         const VkPhysicalDeviceFeatures& deviceFeatures          = context.getDeviceFeatures();
1885         const VkPhysicalDeviceLimits&   deviceLimits            = context.getDeviceProperties().limits;
1886         const VkFormatProperties                formatProperties        = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1887
1888         const VkFormatFeatureFlags              supportedFeatures       = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
1889         const VkImageUsageFlags                 usageFlagSet            = getValidImageUsageFlags(format, supportedFeatures);
1890
1891         tcu::ResultCollector                    results                         (log, "ERROR: ");
1892
1893         for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
1894         {
1895                 if ((curUsageFlags & ~usageFlagSet) != 0 ||
1896                         !isValidImageUsageFlagCombination(curUsageFlags))
1897                         continue;
1898
1899                 const VkImageCreateFlags        createFlagSet           = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags);
1900
1901                 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++)
1902                 {
1903                         if ((curCreateFlags & ~createFlagSet) != 0 ||
1904                                 !isValidImageCreateFlagCombination(curCreateFlags))
1905                                 continue;
1906
1907                         const bool                              isRequiredCombination   = isRequiredImageParameterCombination(deviceFeatures,
1908                                                                                                                                                                                                   format,
1909                                                                                                                                                                                                   formatProperties,
1910                                                                                                                                                                                                   imageType,
1911                                                                                                                                                                                                   tiling,
1912                                                                                                                                                                                                   curUsageFlags,
1913                                                                                                                                                                                                   curCreateFlags);
1914                         VkImageFormatProperties properties;
1915                         VkResult                                queryResult;
1916
1917                         log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", "
1918                                                                         << getImageTilingStr(tiling) << ", "
1919                                                                         << getImageUsageFlagsStr(curUsageFlags) << ", "
1920                                                                         << getImageCreateFlagsStr(curCreateFlags)
1921                                 << TestLog::EndMessage;
1922
1923                         // Set return value to known garbage
1924                         deMemset(&properties, 0xcd, sizeof(properties));
1925
1926                         queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(),
1927                                                                                                                                                                                                 format,
1928                                                                                                                                                                                                 imageType,
1929                                                                                                                                                                                                 tiling,
1930                                                                                                                                                                                                 curUsageFlags,
1931                                                                                                                                                                                                 curCreateFlags,
1932                                                                                                                                                                                                 &properties);
1933
1934                         if (queryResult == VK_SUCCESS)
1935                         {
1936                                 const deUint32  fullMipPyramidSize      = de::max(de::max(deLog2Ceil32(properties.maxExtent.width),
1937                                                                                                                                           deLog2Ceil32(properties.maxExtent.height)),
1938                                                                                                                           deLog2Ceil32(properties.maxExtent.depth)) + 1;
1939
1940                                 log << TestLog::Message << properties << "\n" << TestLog::EndMessage;
1941
1942                                 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image");
1943                                 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image");
1944                                 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image");
1945                                 results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image");
1946
1947                                 if (tiling == VK_IMAGE_TILING_OPTIMAL && imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
1948                                          ((supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) ||
1949                                          ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) && deviceFeatures.shaderStorageImageMultisample)))
1950                                 {
1951                                         const VkSampleCountFlags        requiredSampleCounts    = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
1952                                         results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
1953                                 }
1954                                 else
1955                                         results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT");
1956
1957                                 if (isRequiredCombination)
1958                                 {
1959                                         results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width      >= deviceLimits.maxImageDimension1D),
1960                                                                   "Reported dimensions smaller than device limits");
1961                                         results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width      >= deviceLimits.maxImageDimension2D &&
1962                                                                                                                                         properties.maxExtent.height     >= deviceLimits.maxImageDimension2D),
1963                                                                   "Reported dimensions smaller than device limits");
1964                                         results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width      >= deviceLimits.maxImageDimension3D &&
1965                                                                                                                                         properties.maxExtent.height     >= deviceLimits.maxImageDimension3D &&
1966                                                                                                                                         properties.maxExtent.depth      >= deviceLimits.maxImageDimension3D),
1967                                                                   "Reported dimensions smaller than device limits");
1968                                         results.check(properties.maxMipLevels == fullMipPyramidSize, "maxMipLevels is not full mip pyramid size");
1969                                         results.check(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers,
1970                                                                   "maxArrayLayers smaller than device limits");
1971                                 }
1972                                 else
1973                                 {
1974                                         results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size");
1975                                         results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers");
1976                                 }
1977
1978                                 results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE,
1979                                                           "maxResourceSize smaller than minimum required size");
1980                         }
1981                         else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED)
1982                         {
1983                                 log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage;
1984
1985                                 if (isRequiredCombination)
1986                                         results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination");
1987
1988                                 // Specification requires that all fields are set to 0
1989                                 results.check(properties.maxExtent.width        == 0, "maxExtent.width != 0");
1990                                 results.check(properties.maxExtent.height       == 0, "maxExtent.height != 0");
1991                                 results.check(properties.maxExtent.depth        == 0, "maxExtent.depth != 0");
1992                                 results.check(properties.maxMipLevels           == 0, "maxMipLevels != 0");
1993                                 results.check(properties.maxArrayLayers         == 0, "maxArrayLayers != 0");
1994                                 results.check(properties.sampleCounts           == 0, "sampleCounts != 0");
1995                                 results.check(properties.maxResourceSize        == 0, "maxResourceSize != 0");
1996                         }
1997                         else
1998                         {
1999                                 results.fail("Got unexpected error" + de::toString(queryResult));
2000                         }
2001                 }
2002         }
2003
2004         return tcu::TestStatus(results.getResult(), results.getMessage());
2005 }
2006
2007 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
2008 {
2009         DE_ASSERT(params.format == VK_FORMAT_LAST);
2010
2011         for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_FORMAT_LAST; ++formatNdx)
2012         {
2013                 const VkFormat          format                  = (VkFormat)formatNdx;
2014                 const char* const       enumName                = getFormatName(format);
2015                 const string            caseName                = de::toLower(string(enumName).substr(10));
2016
2017                 params.format = format;
2018
2019                 addFunctionCase(testGroup, caseName, enumName, imageFormatProperties, params);
2020         }
2021 }
2022
2023 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
2024 {
2025         DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST);
2026
2027         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal",     "",     createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_LAST, params.imageType, VK_IMAGE_TILING_OPTIMAL)));
2028         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear",      "",     createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_LAST, params.imageType, VK_IMAGE_TILING_LINEAR)));
2029 }
2030
2031 void createImageFormatTests (tcu::TestCaseGroup* testGroup)
2032 {
2033         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST)));
2034         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST)));
2035         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST)));
2036 }
2037
2038 } // anonymous
2039
2040 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx)
2041 {
2042         de::MovePtr<tcu::TestCaseGroup> infoTests       (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
2043
2044         {
2045                 de::MovePtr<tcu::TestCaseGroup> instanceInfoTests       (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests"));
2046
2047                 addFunctionCase(instanceInfoTests.get(), "physical_devices",            "Physical devices",                     enumeratePhysicalDevices);
2048                 addFunctionCase(instanceInfoTests.get(), "layers",                                      "Layers",                                       enumerateInstanceLayers);
2049                 addFunctionCase(instanceInfoTests.get(), "extensions",                          "Extensions",                           enumerateInstanceExtensions);
2050
2051                 infoTests->addChild(instanceInfoTests.release());
2052         }
2053
2054         {
2055                 de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests"));
2056
2057                 addFunctionCase(deviceInfoTests.get(), "features",                                      "Device Features",                      deviceFeatures);
2058                 addFunctionCase(deviceInfoTests.get(), "properties",                            "Device Properties",            deviceProperties);
2059                 addFunctionCase(deviceInfoTests.get(), "queue_family_properties",       "Queue family properties",      deviceQueueFamilyProperties);
2060                 addFunctionCase(deviceInfoTests.get(), "memory_properties",                     "Memory properties",            deviceMemoryProperties);
2061                 addFunctionCase(deviceInfoTests.get(), "layers",                                        "Layers",                                       enumerateDeviceLayers);
2062                 addFunctionCase(deviceInfoTests.get(), "extensions",                            "Extensions",                           enumerateDeviceExtensions);
2063
2064                 infoTests->addChild(deviceInfoTests.release());
2065         }
2066
2067         infoTests->addChild(createTestGroup(testCtx, "format_properties",               "VkGetPhysicalDeviceFormatProperties() Tests",          createFormatTests));
2068         infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests",     createImageFormatTests));
2069
2070         return infoTests.release();
2071 }
2072
2073 } // api
2074 } // vkt