Merge vk-gl-cts/vulkan-cts-1.2.7 into vk-gl-cts/vulkan-cts-1.2.8
[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 #include "vktCustomInstancesDevices.hpp"
29
30 #include "vkPlatform.hpp"
31 #include "vkStrUtil.hpp"
32 #include "vkRef.hpp"
33 #include "vkRefUtil.hpp"
34 #include "vkDeviceUtil.hpp"
35 #include "vkQueryUtil.hpp"
36 #include "vkImageUtil.hpp"
37 #include "vkApiVersion.hpp"
38
39 #include "tcuTestLog.hpp"
40 #include "tcuFormatUtil.hpp"
41 #include "tcuTextureUtil.hpp"
42 #include "tcuResultCollector.hpp"
43 #include "tcuCommandLine.hpp"
44
45 #include "deUniquePtr.hpp"
46 #include "deString.h"
47 #include "deStringUtil.hpp"
48 #include "deSTLUtil.hpp"
49 #include "deMemory.h"
50 #include "deMath.h"
51
52 #include <vector>
53 #include <set>
54 #include <string>
55 #include <limits>
56
57 namespace vkt
58 {
59 namespace api
60 {
61 namespace
62 {
63
64 #include "vkApiExtensionDependencyInfo.inl"
65
66 using namespace vk;
67 using std::vector;
68 using std::set;
69 using std::string;
70 using tcu::TestLog;
71 using tcu::ScopedLogSection;
72
73 const deUint32 DEUINT32_MAX = std::numeric_limits<deUint32>::max();
74
75 enum
76 {
77         GUARD_SIZE                                                              = 0x20,                 //!< Number of bytes to check
78         GUARD_VALUE                                                             = 0xcd,                 //!< Data pattern
79 };
80
81 static const VkDeviceSize MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE =        (1LLU<<31);     //!< Minimum value for VkImageFormatProperties::maxResourceSize (2GiB)
82
83 enum LimitFormat
84 {
85         LIMIT_FORMAT_SIGNED_INT,
86         LIMIT_FORMAT_UNSIGNED_INT,
87         LIMIT_FORMAT_FLOAT,
88         LIMIT_FORMAT_DEVICE_SIZE,
89         LIMIT_FORMAT_BITMASK,
90
91         LIMIT_FORMAT_LAST
92 };
93
94 enum LimitType
95 {
96         LIMIT_TYPE_MIN,
97         LIMIT_TYPE_MAX,
98         LIMIT_TYPE_NONE,
99
100         LIMIT_TYPE_LAST
101 };
102
103 #define LIMIT(_X_)              DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_), (const char*)(#_X_)
104 #define FEATURE(_X_)    DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_)
105
106 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
107 {
108         bool                                            limitsOk                                = true;
109         VkPhysicalDeviceLimits*         limits                                  = &properties->limits;
110         deUint32                                        shaderStages                    = 3;
111         deUint32                                        maxPerStageResourcesMin = deMin32(128,  limits->maxPerStageDescriptorUniformBuffers             +
112                                                                                                                                                 limits->maxPerStageDescriptorStorageBuffers             +
113                                                                                                                                                 limits->maxPerStageDescriptorSampledImages              +
114                                                                                                                                                 limits->maxPerStageDescriptorStorageImages              +
115                                                                                                                                                 limits->maxPerStageDescriptorInputAttachments   +
116                                                                                                                                                 limits->maxColorAttachments);
117
118         if (features->tessellationShader)
119         {
120                 shaderStages += 2;
121         }
122
123         if (features->geometryShader)
124         {
125                 shaderStages++;
126         }
127
128         struct FeatureLimitTable
129         {
130                 deUint32                offset;
131                 const char*             name;
132                 deUint32                uintVal;                        //!< Format is UNSIGNED_INT
133                 deInt32                 intVal;                         //!< Format is SIGNED_INT
134                 deUint64                deviceSizeVal;          //!< Format is DEVICE_SIZE
135                 float                   floatVal;                       //!< Format is FLOAT
136                 LimitFormat             format;
137                 LimitType               type;
138                 deInt32                 unsuppTableNdx;
139         } featureLimitTable[] =   //!< Based on 1.0.28 Vulkan spec
140         {
141                 { LIMIT(maxImageDimension1D),                                                           4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
142                 { LIMIT(maxImageDimension2D),                                                           4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
143                 { LIMIT(maxImageDimension3D),                                                           256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
144                 { LIMIT(maxImageDimensionCube),                                                         4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
145                 { LIMIT(maxImageArrayLayers),                                                           256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
146                 { LIMIT(maxTexelBufferElements),                                                        65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
147                 { LIMIT(maxUniformBufferRange),                                                         16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
148                 { LIMIT(maxStorageBufferRange),                                                         134217728, 0, 0, 0, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
149                 { LIMIT(maxPushConstantsSize),                                                          128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
150                 { LIMIT(maxMemoryAllocationCount),                                                      4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
151                 { LIMIT(maxSamplerAllocationCount),                                                     4000, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
152                 { LIMIT(bufferImageGranularity),                                                        0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
153                 { LIMIT(bufferImageGranularity),                                                        0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
154                 { LIMIT(sparseAddressSpaceSize),                                                        0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
155                 { LIMIT(maxBoundDescriptorSets),                                                        4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
156                 { LIMIT(maxPerStageDescriptorSamplers),                                         16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
157                 { LIMIT(maxPerStageDescriptorUniformBuffers),                           12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
158                 { LIMIT(maxPerStageDescriptorStorageBuffers),                           4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
159                 { LIMIT(maxPerStageDescriptorSampledImages),                            16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
160                 { LIMIT(maxPerStageDescriptorStorageImages),                            4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
161                 { LIMIT(maxPerStageDescriptorInputAttachments),                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
162                 { LIMIT(maxPerStageResources),                                                          maxPerStageResourcesMin, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
163                 { LIMIT(maxDescriptorSetSamplers),                                                      shaderStages * 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
164                 { LIMIT(maxDescriptorSetUniformBuffers),                                        shaderStages * 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
165                 { LIMIT(maxDescriptorSetUniformBuffersDynamic),                         8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
166                 { LIMIT(maxDescriptorSetStorageBuffers),                                        shaderStages * 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
167                 { LIMIT(maxDescriptorSetStorageBuffersDynamic),                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
168                 { LIMIT(maxDescriptorSetSampledImages),                                         shaderStages * 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
169                 { LIMIT(maxDescriptorSetStorageImages),                                         shaderStages * 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
170                 { LIMIT(maxDescriptorSetInputAttachments),                                      4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
171                 { LIMIT(maxVertexInputAttributes),                                                      16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
172                 { LIMIT(maxVertexInputBindings),                                                        16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
173                 { LIMIT(maxVertexInputAttributeOffset),                                         2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
174                 { LIMIT(maxVertexInputBindingStride),                                           2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
175                 { LIMIT(maxVertexOutputComponents),                                                     64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
176                 { LIMIT(maxTessellationGenerationLevel),                                        64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
177                 { LIMIT(maxTessellationPatchSize),                                                      32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
178                 { LIMIT(maxTessellationControlPerVertexInputComponents),        64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
179                 { LIMIT(maxTessellationControlPerVertexOutputComponents),       64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
180                 { LIMIT(maxTessellationControlPerPatchOutputComponents),        120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
181                 { LIMIT(maxTessellationControlTotalOutputComponents),           2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
182                 { LIMIT(maxTessellationEvaluationInputComponents),                      64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
183                 { LIMIT(maxTessellationEvaluationOutputComponents),                     64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
184                 { LIMIT(maxGeometryShaderInvocations),                                          32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
185                 { LIMIT(maxGeometryInputComponents),                                            64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
186                 { LIMIT(maxGeometryOutputComponents),                                           64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
187                 { LIMIT(maxGeometryOutputVertices),                                                     256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
188                 { LIMIT(maxGeometryTotalOutputComponents),                                      1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
189                 { LIMIT(maxFragmentInputComponents),                                            64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
190                 { LIMIT(maxFragmentOutputAttachments),                                          4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
191                 { LIMIT(maxFragmentDualSrcAttachments),                                         1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
192                 { LIMIT(maxFragmentCombinedOutputResources),                            4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
193                 { LIMIT(maxComputeSharedMemorySize),                                            16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
194                 { LIMIT(maxComputeWorkGroupCount[0]),                                           65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
195                 { LIMIT(maxComputeWorkGroupCount[1]),                                           65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
196                 { LIMIT(maxComputeWorkGroupCount[2]),                                           65535,  0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
197                 { LIMIT(maxComputeWorkGroupInvocations),                                        128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
198                 { LIMIT(maxComputeWorkGroupSize[0]),                                            128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
199                 { LIMIT(maxComputeWorkGroupSize[1]),                                            128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
200                 { LIMIT(maxComputeWorkGroupSize[2]),                                            64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
201                 { LIMIT(subPixelPrecisionBits),                                                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
202                 { LIMIT(subTexelPrecisionBits),                                                         4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
203                 { LIMIT(mipmapPrecisionBits),                                                           4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
204                 { LIMIT(maxDrawIndexedIndexValue),                                                      (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
205                 { LIMIT(maxDrawIndirectCount),                                                          65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
206                 { LIMIT(maxSamplerLodBias),                                                                     0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
207                 { LIMIT(maxSamplerAnisotropy),                                                          0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
208                 { LIMIT(maxViewports),                                                                          16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
209                 { LIMIT(maxViewportDimensions[0]),                                                      4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
210                 { LIMIT(maxViewportDimensions[1]),                                                      4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
211                 { LIMIT(viewportBoundsRange[0]),                                                        0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
212                 { LIMIT(viewportBoundsRange[1]),                                                        0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
213                 { LIMIT(viewportSubPixelBits),                                                          0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
214                 { LIMIT(minMemoryMapAlignment),                                                         64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
215                 { LIMIT(minTexelBufferOffsetAlignment),                                         0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
216                 { LIMIT(minTexelBufferOffsetAlignment),                                         0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
217                 { LIMIT(minUniformBufferOffsetAlignment),                                       0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
218                 { LIMIT(minUniformBufferOffsetAlignment),                                       0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
219                 { LIMIT(minStorageBufferOffsetAlignment),                                       0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
220                 { LIMIT(minStorageBufferOffsetAlignment),                                       0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
221                 { LIMIT(minTexelOffset),                                                                        0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
222                 { LIMIT(maxTexelOffset),                                                                        7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
223                 { LIMIT(minTexelGatherOffset),                                                          0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
224                 { LIMIT(maxTexelGatherOffset),                                                          7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
225                 { LIMIT(minInterpolationOffset),                                                        0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
226                 { LIMIT(maxInterpolationOffset),                                                        0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
227                 { LIMIT(subPixelInterpolationOffsetBits),                                       4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
228                 { LIMIT(maxFramebufferWidth),                                                           4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
229                 { LIMIT(maxFramebufferHeight),                                                          4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
230                 { LIMIT(maxFramebufferLayers),                                                          0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
231                 { LIMIT(framebufferColorSampleCounts),                                          VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
232                 { LIMIT(framebufferDepthSampleCounts),                                          VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
233                 { LIMIT(framebufferStencilSampleCounts),                                        VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
234                 { LIMIT(framebufferNoAttachmentsSampleCounts),                          VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
235                 { LIMIT(maxColorAttachments),                                                           4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
236                 { LIMIT(sampledImageColorSampleCounts),                                         VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
237                 { LIMIT(sampledImageIntegerSampleCounts),                                       VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
238                 { LIMIT(sampledImageDepthSampleCounts),                                         VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
239                 { LIMIT(sampledImageStencilSampleCounts),                                       VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
240                 { LIMIT(storageImageSampleCounts),                                                      VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
241                 { LIMIT(maxSampleMaskWords),                                                            1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
242                 { LIMIT(timestampComputeAndGraphics),                                           0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
243                 { LIMIT(timestampPeriod),                                                                       0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
244                 { LIMIT(maxClipDistances),                                                                      8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
245                 { LIMIT(maxCullDistances),                                                                      8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
246                 { LIMIT(maxCombinedClipAndCullDistances),                                       8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
247                 { LIMIT(discreteQueuePriorities),                                                       2, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
248                 { LIMIT(pointSizeRange[0]),                                                                     0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
249                 { LIMIT(pointSizeRange[0]),                                                                     0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
250                 { LIMIT(pointSizeRange[1]),                                                                     0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
251                 { LIMIT(lineWidthRange[0]),                                                                     0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
252                 { LIMIT(lineWidthRange[0]),                                                                     0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
253                 { LIMIT(lineWidthRange[1]),                                                                     0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
254                 { LIMIT(pointSizeGranularity),                                                          0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
255                 { LIMIT(lineWidthGranularity),                                                          0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
256                 { LIMIT(strictLines),                                                                           0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
257                 { LIMIT(standardSampleLocations),                                                       0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
258                 { LIMIT(optimalBufferCopyOffsetAlignment),                                      0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
259                 { LIMIT(optimalBufferCopyRowPitchAlignment),                            0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
260                 { LIMIT(nonCoherentAtomSize),                                                           0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
261                 { LIMIT(nonCoherentAtomSize),                                                           0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
262         };
263
264         const struct UnsupportedFeatureLimitTable
265         {
266                 deUint32                limitOffset;
267                 const char*             name;
268                 deUint32                featureOffset;
269                 deUint32                uintVal;                        //!< Format is UNSIGNED_INT
270                 deInt32                 intVal;                         //!< Format is SIGNED_INT
271                 deUint64                deviceSizeVal;          //!< Format is DEVICE_SIZE
272                 float                   floatVal;                       //!< Format is FLOAT
273         } unsupportedFeatureTable[] =
274         {
275                 { LIMIT(sparseAddressSpaceSize),                                                        FEATURE(sparseBinding),                                 0, 0, 0, 0.0f },
276                 { LIMIT(maxTessellationGenerationLevel),                                        FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
277                 { LIMIT(maxTessellationPatchSize),                                                      FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
278                 { LIMIT(maxTessellationControlPerVertexInputComponents),        FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
279                 { LIMIT(maxTessellationControlPerVertexOutputComponents),       FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
280                 { LIMIT(maxTessellationControlPerPatchOutputComponents),        FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
281                 { LIMIT(maxTessellationControlTotalOutputComponents),           FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
282                 { LIMIT(maxTessellationEvaluationInputComponents),                      FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
283                 { LIMIT(maxTessellationEvaluationOutputComponents),                     FEATURE(tessellationShader),                    0, 0, 0, 0.0f },
284                 { LIMIT(maxGeometryShaderInvocations),                                          FEATURE(geometryShader),                                0, 0, 0, 0.0f },
285                 { LIMIT(maxGeometryInputComponents),                                            FEATURE(geometryShader),                                0, 0, 0, 0.0f },
286                 { LIMIT(maxGeometryOutputComponents),                                           FEATURE(geometryShader),                                0, 0, 0, 0.0f },
287                 { LIMIT(maxGeometryOutputVertices),                                                     FEATURE(geometryShader),                                0, 0, 0, 0.0f },
288                 { LIMIT(maxGeometryTotalOutputComponents),                                      FEATURE(geometryShader),                                0, 0, 0, 0.0f },
289                 { LIMIT(maxFragmentDualSrcAttachments),                                         FEATURE(dualSrcBlend),                                  0, 0, 0, 0.0f },
290                 { LIMIT(maxDrawIndexedIndexValue),                                                      FEATURE(fullDrawIndexUint32),                   (1<<24)-1, 0, 0, 0.0f },
291                 { LIMIT(maxDrawIndirectCount),                                                          FEATURE(multiDrawIndirect),                             1, 0, 0, 0.0f },
292                 { LIMIT(maxSamplerAnisotropy),                                                          FEATURE(samplerAnisotropy),                             1, 0, 0, 0.0f },
293                 { LIMIT(maxViewports),                                                                          FEATURE(multiViewport),                                 1, 0, 0, 0.0f },
294                 { LIMIT(minTexelGatherOffset),                                                          FEATURE(shaderImageGatherExtended),             0, 0, 0, 0.0f },
295                 { LIMIT(maxTexelGatherOffset),                                                          FEATURE(shaderImageGatherExtended),             0, 0, 0, 0.0f },
296                 { LIMIT(minInterpolationOffset),                                                        FEATURE(sampleRateShading),                             0, 0, 0, 0.0f },
297                 { LIMIT(maxInterpolationOffset),                                                        FEATURE(sampleRateShading),                             0, 0, 0, 0.0f },
298                 { LIMIT(subPixelInterpolationOffsetBits),                                       FEATURE(sampleRateShading),                             0, 0, 0, 0.0f },
299                 { LIMIT(storageImageSampleCounts),                                                      FEATURE(shaderStorageImageMultisample), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f },
300                 { LIMIT(maxClipDistances),                                                                      FEATURE(shaderClipDistance),                    0, 0, 0, 0.0f },
301                 { LIMIT(maxCullDistances),                                                                      FEATURE(shaderCullDistance),                    0, 0, 0, 0.0f },
302                 { LIMIT(maxCombinedClipAndCullDistances),                                       FEATURE(shaderClipDistance),                    0, 0, 0, 0.0f },
303                 { LIMIT(pointSizeRange[0]),                                                                     FEATURE(largePoints),                                   0, 0, 0, 1.0f },
304                 { LIMIT(pointSizeRange[1]),                                                                     FEATURE(largePoints),                                   0, 0, 0, 1.0f },
305                 { LIMIT(lineWidthRange[0]),                                                                     FEATURE(wideLines),                                             0, 0, 0, 1.0f },
306                 { LIMIT(lineWidthRange[1]),                                                                     FEATURE(wideLines),                                             0, 0, 0, 1.0f },
307                 { LIMIT(pointSizeGranularity),                                                          FEATURE(largePoints),                                   0, 0, 0, 0.0f },
308                 { LIMIT(lineWidthGranularity),                                                          FEATURE(wideLines),                                             0, 0, 0, 0.0f }
309         };
310
311         log << TestLog::Message << *limits << TestLog::EndMessage;
312
313         //!< First build a map from limit to unsupported table index
314         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
315         {
316                 for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++)
317                 {
318                         if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset)
319                         {
320                                 featureLimitTable[ndx].unsuppTableNdx = unsuppNdx;
321                                 break;
322                         }
323                 }
324         }
325
326         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
327         {
328                 switch (featureLimitTable[ndx].format)
329                 {
330                         case LIMIT_FORMAT_UNSIGNED_INT:
331                         {
332                                 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
333                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
334                                 {
335                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
336                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
337                                 }
338
339                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
340                                 {
341
342                                         if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
343                                         {
344                                                 log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name
345                                                         << " not valid-limit type MIN - actual is "
346                                                         << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
347                                                 limitsOk = false;
348                                         }
349                                 }
350                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
351                                 {
352                                         if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
353                                         {
354                                                 log << TestLog::Message << "limit validation failed,  " << featureLimitTable[ndx].name
355                                                         << " not valid-limit type MAX - actual is "
356                                                         << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
357                                                 limitsOk = false;
358                                         }
359                                 }
360                                 break;
361                         }
362
363                         case LIMIT_FORMAT_FLOAT:
364                         {
365                                 float limitToCheck = featureLimitTable[ndx].floatVal;
366                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
367                                 {
368                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
369                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal;
370                                 }
371
372                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
373                                 {
374                                         if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
375                                         {
376                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
377                                                         << " not valid-limit type MIN - actual is "
378                                                         << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
379                                                 limitsOk = false;
380                                         }
381                                 }
382                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
383                                 {
384                                         if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
385                                         {
386                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
387                                                         << " not valid-limit type MAX actual is "
388                                                         << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
389                                                 limitsOk = false;
390                                         }
391                                 }
392                                 break;
393                         }
394
395                         case LIMIT_FORMAT_SIGNED_INT:
396                         {
397                                 deInt32 limitToCheck = featureLimitTable[ndx].intVal;
398                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
399                                 {
400                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
401                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal;
402                                 }
403                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
404                                 {
405                                         if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
406                                         {
407                                                 log << TestLog::Message <<  "limit validation failed, " << featureLimitTable[ndx].name
408                                                         << " not valid-limit type MIN actual is "
409                                                         << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
410                                                 limitsOk = false;
411                                         }
412                                 }
413                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
414                                 {
415                                         if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
416                                         {
417                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
418                                                         << " not valid-limit type MAX actual is "
419                                                         << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
420                                                 limitsOk = false;
421                                         }
422                                 }
423                                 break;
424                         }
425
426                         case LIMIT_FORMAT_DEVICE_SIZE:
427                         {
428                                 deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal;
429                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
430                                 {
431                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
432                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal;
433                                 }
434
435                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
436                                 {
437                                         if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
438                                         {
439                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
440                                                         << " not valid-limit type MIN actual is "
441                                                         << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
442                                                 limitsOk = false;
443                                         }
444                                 }
445                                 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
446                                 {
447                                         if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
448                                         {
449                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
450                                                         << " not valid-limit type MAX actual is "
451                                                         << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
452                                                 limitsOk = false;
453                                         }
454                                 }
455                                 break;
456                         }
457
458                         case LIMIT_FORMAT_BITMASK:
459                         {
460                                 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
461                                 if (featureLimitTable[ndx].unsuppTableNdx != -1)
462                                 {
463                                         if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
464                                                 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
465                                 }
466
467                                 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
468                                 {
469                                         if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck)
470                                         {
471                                                 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
472                                                         << " not valid-limit type bitmask actual is "
473                                                         << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
474                                                 limitsOk = false;
475                                         }
476                                 }
477                                 break;
478                         }
479
480                         default:
481                                 DE_ASSERT(0);
482                                 limitsOk = false;
483                 }
484         }
485
486         if (limits->maxFramebufferWidth > limits->maxViewportDimensions[0] ||
487                 limits->maxFramebufferHeight > limits->maxViewportDimensions[1])
488         {
489                 log << TestLog::Message << "limit validation failed, maxFramebufferDimension of "
490                         << "[" << limits->maxFramebufferWidth << ", " << limits->maxFramebufferHeight << "] "
491                         << "is larger than maxViewportDimension of "
492                         << "[" << limits->maxViewportDimensions[0] << ", " << limits->maxViewportDimensions[1] << "]" << TestLog::EndMessage;
493                 limitsOk = false;
494         }
495
496         if (limits->viewportBoundsRange[0] > float(-2 * limits->maxViewportDimensions[0]))
497         {
498                 log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0]
499                         << "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage;
500                 limitsOk = false;
501         }
502
503         if (limits->viewportBoundsRange[1] < float(2 * limits->maxViewportDimensions[1] - 1))
504         {
505                 log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1]
506                         << "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage;
507                 limitsOk = false;
508         }
509
510         return limitsOk;
511 }
512
513 void validateLimitsCheckSupport (Context& context)
514 {
515         if (!context.contextSupports(vk::ApiVersion(1, 2, 0)))
516                 TCU_THROW(NotSupportedError, "At least Vulkan 1.2 required to run test");
517 }
518
519 typedef struct FeatureLimitTableItem_
520 {
521         const void*             cond;
522         const char*             condName;
523         const void*             ptr;
524         const char*             name;
525         deUint32                uintVal;                        //!< Format is UNSIGNED_INT
526         deInt32                 intVal;                         //!< Format is SIGNED_INT
527         deUint64                deviceSizeVal;          //!< Format is DEVICE_SIZE
528         float                   floatVal;                       //!< Format is FLOAT
529         LimitFormat             format;
530         LimitType               type;
531 } FeatureLimitTableItem;
532
533 template<typename T>
534 bool validateNumericLimit (const T limitToCheck, const T reportedValue, const LimitType limitType, const char* limitName, TestLog& log)
535 {
536         if (limitType == LIMIT_TYPE_MIN)
537         {
538                 if (reportedValue < limitToCheck)
539                 {
540                         log << TestLog::Message << "Limit validation failed " << limitName
541                                 << " reported value is " << reportedValue
542                                 << " expected MIN " << limitToCheck
543                                 << TestLog::EndMessage;
544
545                         return false;
546                 }
547
548                 log << TestLog::Message << limitName
549                         << "=" << reportedValue
550                         << " (>=" << limitToCheck << ")"
551                         << TestLog::EndMessage;
552         }
553         else if (limitType == LIMIT_TYPE_MAX)
554         {
555                 if (reportedValue > limitToCheck)
556                 {
557                         log << TestLog::Message << "Limit validation failed " << limitName
558                                 << " reported value is " << reportedValue
559                                 << " expected MAX " << limitToCheck
560                                 << TestLog::EndMessage;
561
562                         return false;
563                 }
564
565                 log << TestLog::Message << limitName
566                         << "=" << reportedValue
567                         << " (<=" << limitToCheck << ")"
568                         << TestLog::EndMessage;
569         }
570
571         return true;
572 }
573
574 template<typename T>
575 bool validateBitmaskLimit (const T limitToCheck, const T reportedValue, const LimitType limitType, const char* limitName, TestLog& log)
576 {
577         if (limitType == LIMIT_TYPE_MIN)
578         {
579                 if ((reportedValue & limitToCheck) != limitToCheck)
580                 {
581                         log << TestLog::Message << "Limit validation failed " << limitName
582                                 << " reported value is " << reportedValue
583                                 << " expected MIN " << limitToCheck
584                                 << TestLog::EndMessage;
585
586                         return false;
587                 }
588
589                 log << TestLog::Message << limitName
590                         << "=" << tcu::toHex(reportedValue)
591                         << " (contains " << tcu::toHex(limitToCheck) << ")"
592                         << TestLog::EndMessage;
593         }
594
595         return true;
596 }
597
598 bool validateLimit (FeatureLimitTableItem limit, TestLog& log)
599 {
600         if (*((VkBool32*)limit.cond) == DE_FALSE)
601         {
602                 log << TestLog::Message
603                         << "Limit validation skipped '" << limit.name << "' due to "
604                         << limit.condName << " == false'"
605                         << TestLog::EndMessage;
606
607                 return true;
608         }
609
610         switch (limit.format)
611         {
612                 case LIMIT_FORMAT_UNSIGNED_INT:
613                 {
614                         const deUint32  limitToCheck    = limit.uintVal;
615                         const deUint32  reportedValue   = *(deUint32*)limit.ptr;
616
617                         return validateNumericLimit(limitToCheck, reportedValue, limit.type, limit.name, log);
618                 }
619
620                 case LIMIT_FORMAT_FLOAT:
621                 {
622                         const float             limitToCheck    = limit.floatVal;
623                         const float             reportedValue   = *(float*)limit.ptr;
624
625                         return validateNumericLimit(limitToCheck, reportedValue, limit.type, limit.name, log);
626                 }
627
628                 case LIMIT_FORMAT_SIGNED_INT:
629                 {
630                         const deInt32   limitToCheck    = limit.intVal;
631                         const deInt32   reportedValue   = *(deInt32*)limit.ptr;
632
633                         return validateNumericLimit(limitToCheck, reportedValue, limit.type, limit.name, log);
634                 }
635
636                 case LIMIT_FORMAT_DEVICE_SIZE:
637                 {
638                         const deUint64  limitToCheck    = limit.deviceSizeVal;
639                         const deUint64  reportedValue   = *(deUint64*)limit.ptr;
640
641                         return validateNumericLimit(limitToCheck, reportedValue, limit.type, limit.name, log);
642                 }
643
644                 case LIMIT_FORMAT_BITMASK:
645                 {
646                         const deUint32  limitToCheck    = limit.uintVal;
647                         const deUint32  reportedValue   = *(deUint32*)limit.ptr;
648
649                         return validateBitmaskLimit(limitToCheck, reportedValue, limit.type, limit.name, log);
650                 }
651
652                 default:
653                         TCU_THROW(InternalError, "Unknown LimitFormat specified");
654         }
655 }
656
657 #ifdef PN
658 #error PN defined
659 #else
660 #define PN(_X_) &(_X_), (const char*)(#_X_)
661 #endif
662
663 #define LIM_MIN_UINT32(X)       deUint32(X),          0,               0,     0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN
664 #define LIM_MAX_UINT32(X)       deUint32(X),          0,               0,     0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX
665 #define LIM_NONE_UINT32                   0,          0,               0,     0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE
666 #define LIM_MIN_INT32(X)                  0, deInt32(X),               0,     0.0f, LIMIT_FORMAT_SIGNED_INT,   LIMIT_TYPE_MIN
667 #define LIM_MAX_INT32(X)                  0, deInt32(X),               0,     0.0f, LIMIT_FORMAT_SIGNED_INT,   LIMIT_TYPE_MAX
668 #define LIM_NONE_INT32                    0,          0,               0,     0.0f, LIMIT_FORMAT_SIGNED_INT,   LIMIT_TYPE_NONE
669 #define LIM_MIN_DEVSIZE(X)                0,          0, VkDeviceSize(X),     0.0f, LIMIT_FORMAT_DEVICE_SIZE,  LIMIT_TYPE_MIN
670 #define LIM_MAX_DEVSIZE(X)                0,          0, VkDeviceSize(X),     0.0f, LIMIT_FORMAT_DEVICE_SIZE,  LIMIT_TYPE_MAX
671 #define LIM_NONE_DEVSIZE                  0,          0,               0,     0.0f, LIMIT_FORMAT_DEVICE_SIZE,  LIMIT_TYPE_NONE
672 #define LIM_MIN_FLOAT(X)                  0,          0,               0, float(X), LIMIT_FORMAT_FLOAT,        LIMIT_TYPE_MIN
673 #define LIM_MAX_FLOAT(X)                  0,          0,               0, float(X), LIMIT_FORMAT_FLOAT,        LIMIT_TYPE_MAX
674 #define LIM_NONE_FLOAT                    0,          0,               0,     0.0f, LIMIT_FORMAT_FLOAT,        LIMIT_TYPE_NONE
675 #define LIM_MIN_BITI32(X)       deUint32(X),          0,               0,     0.0f, LIMIT_FORMAT_BITMASK,      LIMIT_TYPE_MIN
676 #define LIM_MAX_BITI32(X)       deUint32(X),          0,               0,     0.0f, LIMIT_FORMAT_BITMASK,      LIMIT_TYPE_MAX
677 #define LIM_NONE_BITI32                   0,          0,               0,     0.0f, LIMIT_FORMAT_BITMASK,      LIMIT_TYPE_NONE
678
679 tcu::TestStatus validateLimits12 (Context& context)
680 {
681         const VkPhysicalDevice                                          physicalDevice                  = context.getPhysicalDevice();
682         const InstanceInterface&                                        vki                                             = context.getInstanceInterface();
683         TestLog&                                                                        log                                             = context.getTestContext().getLog();
684         bool                                                                            limitsOk                                = true;
685
686         const VkPhysicalDeviceFeatures2&                        features2                               = context.getDeviceFeatures2();
687         const VkPhysicalDeviceFeatures&                         features                                = features2.features;
688         const VkPhysicalDeviceVulkan12Features          features12                              = getPhysicalDeviceVulkan12Features(vki, physicalDevice);
689
690         const VkPhysicalDeviceProperties2&                      properties2                             = context.getDeviceProperties2();
691         const VkPhysicalDeviceVulkan12Properties        vulkan12Properties              = getPhysicalDeviceVulkan12Properties(vki, physicalDevice);
692         const VkPhysicalDeviceVulkan11Properties        vulkan11Properties              = getPhysicalDeviceVulkan11Properties(vki, physicalDevice);
693         const VkPhysicalDeviceLimits&                           limits                                  = properties2.properties.limits;
694
695         const VkBool32                                                          checkAlways                             = VK_TRUE;
696         const VkBool32                                                          checkVulkan12Limit              = VK_TRUE;
697
698         deUint32                                                                        shaderStages                    = 3;
699         deUint32                                                                        maxPerStageResourcesMin = deMin32(128,  limits.maxPerStageDescriptorUniformBuffers              +
700                                                                                                                                                                                 limits.maxPerStageDescriptorStorageBuffers              +
701                                                                                                                                                                                 limits.maxPerStageDescriptorSampledImages               +
702                                                                                                                                                                                 limits.maxPerStageDescriptorStorageImages               +
703                                                                                                                                                                                 limits.maxPerStageDescriptorInputAttachments    +
704                                                                                                                                                                                 limits.maxColorAttachments);
705
706         if (features.tessellationShader)
707         {
708                 shaderStages += 2;
709         }
710
711         if (features.geometryShader)
712         {
713                 shaderStages++;
714         }
715
716         FeatureLimitTableItem featureLimitTable[] =
717         {
718                 { PN(checkAlways),                                                              PN(limits.maxImageDimension1D),                                                                                                                                 LIM_MIN_UINT32(4096) },
719                 { PN(checkAlways),                                                              PN(limits.maxImageDimension2D),                                                                                                                                 LIM_MIN_UINT32(4096) },
720                 { PN(checkAlways),                                                              PN(limits.maxImageDimension3D),                                                                                                                                 LIM_MIN_UINT32(256) },
721                 { PN(checkAlways),                                                              PN(limits.maxImageDimensionCube),                                                                                                                               LIM_MIN_UINT32(4096) },
722                 { PN(checkAlways),                                                              PN(limits.maxImageArrayLayers),                                                                                                                                 LIM_MIN_UINT32(256) },
723                 { PN(checkAlways),                                                              PN(limits.maxTexelBufferElements),                                                                                                                              LIM_MIN_UINT32(65536) },
724                 { PN(checkAlways),                                                              PN(limits.maxUniformBufferRange),                                                                                                                               LIM_MIN_UINT32(16384) },
725                 { PN(checkAlways),                                                              PN(limits.maxStorageBufferRange),                                                                                                                               LIM_MIN_UINT32((1<<27)) },
726                 { PN(checkAlways),                                                              PN(limits.maxPushConstantsSize),                                                                                                                                LIM_MIN_UINT32(128) },
727                 { PN(checkAlways),                                                              PN(limits.maxMemoryAllocationCount),                                                                                                                    LIM_MIN_UINT32(4096) },
728                 { PN(checkAlways),                                                              PN(limits.maxSamplerAllocationCount),                                                                                                                   LIM_MIN_UINT32(4000) },
729                 { PN(checkAlways),                                                              PN(limits.bufferImageGranularity),                                                                                                                              LIM_MIN_DEVSIZE(1) },
730                 { PN(checkAlways),                                                              PN(limits.bufferImageGranularity),                                                                                                                              LIM_MAX_DEVSIZE(131072) },
731                 { PN(features.sparseBinding),                                   PN(limits.sparseAddressSpaceSize),                                                                                                                              LIM_MIN_DEVSIZE((1ull<<31)) },
732                 { PN(checkAlways),                                                              PN(limits.maxBoundDescriptorSets),                                                                                                                              LIM_MIN_UINT32(4) },
733                 { PN(checkAlways),                                                              PN(limits.maxPerStageDescriptorSamplers),                                                                                                               LIM_MIN_UINT32(16) },
734                 { PN(checkAlways),                                                              PN(limits.maxPerStageDescriptorUniformBuffers),                                                                                                 LIM_MIN_UINT32(12) },
735                 { PN(checkAlways),                                                              PN(limits.maxPerStageDescriptorStorageBuffers),                                                                                                 LIM_MIN_UINT32(4) },
736                 { PN(checkAlways),                                                              PN(limits.maxPerStageDescriptorSampledImages),                                                                                                  LIM_MIN_UINT32(16) },
737                 { PN(checkAlways),                                                              PN(limits.maxPerStageDescriptorStorageImages),                                                                                                  LIM_MIN_UINT32(4) },
738                 { PN(checkAlways),                                                              PN(limits.maxPerStageDescriptorInputAttachments),                                                                                               LIM_MIN_UINT32(4) },
739                 { PN(checkAlways),                                                              PN(limits.maxPerStageResources),                                                                                                                                LIM_MIN_UINT32(maxPerStageResourcesMin) },
740                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetSamplers),                                                                                                                    LIM_MIN_UINT32(shaderStages * 16) },
741                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetUniformBuffers),                                                                                                              LIM_MIN_UINT32(shaderStages * 12) },
742                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetUniformBuffersDynamic),                                                                                               LIM_MIN_UINT32(8) },
743                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetStorageBuffers),                                                                                                              LIM_MIN_UINT32(shaderStages * 4) },
744                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetStorageBuffersDynamic),                                                                                               LIM_MIN_UINT32(4) },
745                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetSampledImages),                                                                                                               LIM_MIN_UINT32(shaderStages * 16) },
746                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetStorageImages),                                                                                                               LIM_MIN_UINT32(shaderStages * 4) },
747                 { PN(checkAlways),                                                              PN(limits.maxDescriptorSetInputAttachments),                                                                                                    LIM_MIN_UINT32(4) },
748                 { PN(checkAlways),                                                              PN(limits.maxVertexInputAttributes),                                                                                                                    LIM_MIN_UINT32(16) },
749                 { PN(checkAlways),                                                              PN(limits.maxVertexInputBindings),                                                                                                                              LIM_MIN_UINT32(16) },
750                 { PN(checkAlways),                                                              PN(limits.maxVertexInputAttributeOffset),                                                                                                               LIM_MIN_UINT32(2047) },
751                 { PN(checkAlways),                                                              PN(limits.maxVertexInputBindingStride),                                                                                                                 LIM_MIN_UINT32(2048) },
752                 { PN(checkAlways),                                                              PN(limits.maxVertexOutputComponents),                                                                                                                   LIM_MIN_UINT32(64) },
753                 { PN(features.tessellationShader),                              PN(limits.maxTessellationGenerationLevel),                                                                                                              LIM_MIN_UINT32(64) },
754                 { PN(features.tessellationShader),                              PN(limits.maxTessellationPatchSize),                                                                                                                    LIM_MIN_UINT32(32) },
755                 { PN(features.tessellationShader),                              PN(limits.maxTessellationControlPerVertexInputComponents),                                                                              LIM_MIN_UINT32(64) },
756                 { PN(features.tessellationShader),                              PN(limits.maxTessellationControlPerVertexOutputComponents),                                                                             LIM_MIN_UINT32(64) },
757                 { PN(features.tessellationShader),                              PN(limits.maxTessellationControlPerPatchOutputComponents),                                                                              LIM_MIN_UINT32(120) },
758                 { PN(features.tessellationShader),                              PN(limits.maxTessellationControlTotalOutputComponents),                                                                                 LIM_MIN_UINT32(2048) },
759                 { PN(features.tessellationShader),                              PN(limits.maxTessellationEvaluationInputComponents),                                                                                    LIM_MIN_UINT32(64) },
760                 { PN(features.tessellationShader),                              PN(limits.maxTessellationEvaluationOutputComponents),                                                                                   LIM_MIN_UINT32(64) },
761                 { PN(features.geometryShader),                                  PN(limits.maxGeometryShaderInvocations),                                                                                                                LIM_MIN_UINT32(32) },
762                 { PN(features.geometryShader),                                  PN(limits.maxGeometryInputComponents),                                                                                                                  LIM_MIN_UINT32(64) },
763                 { PN(features.geometryShader),                                  PN(limits.maxGeometryOutputComponents),                                                                                                                 LIM_MIN_UINT32(64) },
764                 { PN(features.geometryShader),                                  PN(limits.maxGeometryOutputVertices),                                                                                                                   LIM_MIN_UINT32(256) },
765                 { PN(features.geometryShader),                                  PN(limits.maxGeometryTotalOutputComponents),                                                                                                    LIM_MIN_UINT32(1024) },
766                 { PN(checkAlways),                                                              PN(limits.maxFragmentInputComponents),                                                                                                                  LIM_MIN_UINT32(64) },
767                 { PN(checkAlways),                                                              PN(limits.maxFragmentOutputAttachments),                                                                                                                LIM_MIN_UINT32(4) },
768                 { PN(features.dualSrcBlend),                                    PN(limits.maxFragmentDualSrcAttachments),                                                                                                               LIM_MIN_UINT32(1) },
769                 { PN(checkAlways),                                                              PN(limits.maxFragmentCombinedOutputResources),                                                                                                  LIM_MIN_UINT32(4) },
770                 { PN(checkAlways),                                                              PN(limits.maxComputeSharedMemorySize),                                                                                                                  LIM_MIN_UINT32(16384) },
771                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupCount[0]),                                                                                                                 LIM_MIN_UINT32(65535) },
772                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupCount[1]),                                                                                                                 LIM_MIN_UINT32(65535) },
773                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupCount[2]),                                                                                                                 LIM_MIN_UINT32(65535) },
774                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupInvocations),                                                                                                              LIM_MIN_UINT32(128) },
775                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupSize[0]),                                                                                                                  LIM_MIN_UINT32(128) },
776                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupSize[1]),                                                                                                                  LIM_MIN_UINT32(128) },
777                 { PN(checkAlways),                                                              PN(limits.maxComputeWorkGroupSize[2]),                                                                                                                  LIM_MIN_UINT32(64) },
778                 { PN(checkAlways),                                                              PN(limits.subPixelPrecisionBits),                                                                                                                               LIM_MIN_UINT32(4) },
779                 { PN(checkAlways),                                                              PN(limits.subTexelPrecisionBits),                                                                                                                               LIM_MIN_UINT32(4) },
780                 { PN(checkAlways),                                                              PN(limits.mipmapPrecisionBits),                                                                                                                                 LIM_MIN_UINT32(4) },
781                 { PN(features.fullDrawIndexUint32),                             PN(limits.maxDrawIndexedIndexValue),                                                                                                                    LIM_MIN_UINT32((deUint32)~0) },
782                 { PN(features.multiDrawIndirect),                               PN(limits.maxDrawIndirectCount),                                                                                                                                LIM_MIN_UINT32(65535) },
783                 { PN(checkAlways),                                                              PN(limits.maxSamplerLodBias),                                                                                                                                   LIM_MIN_FLOAT(2.0f) },
784                 { PN(features.samplerAnisotropy),                               PN(limits.maxSamplerAnisotropy),                                                                                                                                LIM_MIN_FLOAT(16.0f) },
785                 { PN(features.multiViewport),                                   PN(limits.maxViewports),                                                                                                                                                LIM_MIN_UINT32(16) },
786                 { PN(checkAlways),                                                              PN(limits.maxViewportDimensions[0]),                                                                                                                    LIM_MIN_UINT32(4096) },
787                 { PN(checkAlways),                                                              PN(limits.maxViewportDimensions[1]),                                                                                                                    LIM_MIN_UINT32(4096) },
788                 { PN(checkAlways),                                                              PN(limits.viewportBoundsRange[0]),                                                                                                                              LIM_MAX_FLOAT(-8192.0f) },
789                 { PN(checkAlways),                                                              PN(limits.viewportBoundsRange[1]),                                                                                                                              LIM_MIN_FLOAT(8191.0f) },
790                 { PN(checkAlways),                                                              PN(limits.viewportSubPixelBits),                                                                                                                                LIM_MIN_UINT32(0) },
791                 { PN(checkAlways),                                                              PN(limits.minMemoryMapAlignment),                                                                                                                               LIM_MIN_UINT32(64) },
792                 { PN(checkAlways),                                                              PN(limits.minTexelBufferOffsetAlignment),                                                                                                               LIM_MIN_DEVSIZE(1) },
793                 { PN(checkAlways),                                                              PN(limits.minTexelBufferOffsetAlignment),                                                                                                               LIM_MAX_DEVSIZE(256) },
794                 { PN(checkAlways),                                                              PN(limits.minUniformBufferOffsetAlignment),                                                                                                             LIM_MIN_DEVSIZE(1) },
795                 { PN(checkAlways),                                                              PN(limits.minUniformBufferOffsetAlignment),                                                                                                             LIM_MAX_DEVSIZE(256) },
796                 { PN(checkAlways),                                                              PN(limits.minStorageBufferOffsetAlignment),                                                                                                             LIM_MIN_DEVSIZE(1) },
797                 { PN(checkAlways),                                                              PN(limits.minStorageBufferOffsetAlignment),                                                                                                             LIM_MAX_DEVSIZE(256) },
798                 { PN(checkAlways),                                                              PN(limits.minTexelOffset),                                                                                                                                              LIM_MAX_INT32(-8) },
799                 { PN(checkAlways),                                                              PN(limits.maxTexelOffset),                                                                                                                                              LIM_MIN_INT32(7) },
800                 { PN(features.shaderImageGatherExtended),               PN(limits.minTexelGatherOffset),                                                                                                                                LIM_MAX_INT32(-8) },
801                 { PN(features.shaderImageGatherExtended),               PN(limits.maxTexelGatherOffset),                                                                                                                                LIM_MIN_INT32(7) },
802                 { PN(features.sampleRateShading),                               PN(limits.minInterpolationOffset),                                                                                                                              LIM_MAX_FLOAT(-0.5f) },
803                 { PN(features.sampleRateShading),                               PN(limits.maxInterpolationOffset),                                                                                                                              LIM_MIN_FLOAT(0.5f - (1.0f/deFloatPow(2.0f, (float)limits.subPixelInterpolationOffsetBits))) },
804                 { PN(features.sampleRateShading),                               PN(limits.subPixelInterpolationOffsetBits),                                                                                                             LIM_MIN_UINT32(4) },
805                 { PN(checkAlways),                                                              PN(limits.maxFramebufferWidth),                                                                                                                                 LIM_MIN_UINT32(4096) },
806                 { PN(checkAlways),                                                              PN(limits.maxFramebufferHeight),                                                                                                                                LIM_MIN_UINT32(4096) },
807                 { PN(checkAlways),                                                              PN(limits.maxFramebufferLayers),                                                                                                                                LIM_MIN_UINT32(256) },
808                 { PN(checkAlways),                                                              PN(limits.framebufferColorSampleCounts),                                                                                                                LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
809                 { PN(checkVulkan12Limit),                                               PN(vulkan12Properties.framebufferIntegerColorSampleCounts),                                                                             LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT) },
810                 { PN(checkAlways),                                                              PN(limits.framebufferDepthSampleCounts),                                                                                                                LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
811                 { PN(checkAlways),                                                              PN(limits.framebufferStencilSampleCounts),                                                                                                              LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
812                 { PN(checkAlways),                                                              PN(limits.framebufferNoAttachmentsSampleCounts),                                                                                                LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
813                 { PN(checkAlways),                                                              PN(limits.maxColorAttachments),                                                                                                                                 LIM_MIN_UINT32(4) },
814                 { PN(checkAlways),                                                              PN(limits.sampledImageColorSampleCounts),                                                                                                               LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
815                 { PN(checkAlways),                                                              PN(limits.sampledImageIntegerSampleCounts),                                                                                                             LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT) },
816                 { PN(checkAlways),                                                              PN(limits.sampledImageDepthSampleCounts),                                                                                                               LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
817                 { PN(checkAlways),                                                              PN(limits.sampledImageStencilSampleCounts),                                                                                                             LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
818                 { PN(features.shaderStorageImageMultisample),   PN(limits.storageImageSampleCounts),                                                                                                                    LIM_MIN_BITI32(VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT) },
819                 { PN(checkAlways),                                                              PN(limits.maxSampleMaskWords),                                                                                                                                  LIM_MIN_UINT32(1) },
820                 { PN(checkAlways),                                                              PN(limits.timestampComputeAndGraphics),                                                                                                                 LIM_NONE_UINT32 },
821                 { PN(checkAlways),                                                              PN(limits.timestampPeriod),                                                                                                                                             LIM_NONE_UINT32 },
822                 { PN(features.shaderClipDistance),                              PN(limits.maxClipDistances),                                                                                                                                    LIM_MIN_UINT32(8) },
823                 { PN(features.shaderCullDistance),                              PN(limits.maxCullDistances),                                                                                                                                    LIM_MIN_UINT32(8) },
824                 { PN(features.shaderClipDistance),                              PN(limits.maxCombinedClipAndCullDistances),                                                                                                             LIM_MIN_UINT32(8) },
825                 { PN(checkAlways),                                                              PN(limits.discreteQueuePriorities),                                                                                                                             LIM_MIN_UINT32(2) },
826                 { PN(features.largePoints),                                             PN(limits.pointSizeRange[0]),                                                                                                                                   LIM_MIN_FLOAT(0.0f) },
827                 { PN(features.largePoints),                                             PN(limits.pointSizeRange[0]),                                                                                                                                   LIM_MAX_FLOAT(1.0f) },
828                 { PN(features.largePoints),                                             PN(limits.pointSizeRange[1]),                                                                                                                                   LIM_MIN_FLOAT(64.0f - limits.pointSizeGranularity) },
829                 { PN(features.wideLines),                                               PN(limits.lineWidthRange[0]),                                                                                                                                   LIM_MIN_FLOAT(0.0f) },
830                 { PN(features.wideLines),                                               PN(limits.lineWidthRange[0]),                                                                                                                                   LIM_MAX_FLOAT(1.0f) },
831                 { PN(features.wideLines),                                               PN(limits.lineWidthRange[1]),                                                                                                                                   LIM_MIN_FLOAT(8.0f - limits.lineWidthGranularity) },
832                 { PN(features.largePoints),                                             PN(limits.pointSizeGranularity),                                                                                                                                LIM_MIN_FLOAT(0.0f) },
833                 { PN(features.largePoints),                                             PN(limits.pointSizeGranularity),                                                                                                                                LIM_MAX_FLOAT(1.0f) },
834                 { PN(features.wideLines),                                               PN(limits.lineWidthGranularity),                                                                                                                                LIM_MIN_FLOAT(0.0f) },
835                 { PN(features.wideLines),                                               PN(limits.lineWidthGranularity),                                                                                                                                LIM_MAX_FLOAT(1.0f) },
836                 { PN(checkAlways),                                                              PN(limits.strictLines),                                                                                                                                                 LIM_NONE_UINT32 },
837                 { PN(checkAlways),                                                              PN(limits.standardSampleLocations),                                                                                                                             LIM_NONE_UINT32 },
838                 { PN(checkAlways),                                                              PN(limits.optimalBufferCopyOffsetAlignment),                                                                                                    LIM_NONE_DEVSIZE },
839                 { PN(checkAlways),                                                              PN(limits.optimalBufferCopyRowPitchAlignment),                                                                                                  LIM_NONE_DEVSIZE },
840                 { PN(checkAlways),                                                              PN(limits.nonCoherentAtomSize),                                                                                                                                 LIM_MIN_DEVSIZE(1) },
841                 { PN(checkAlways),                                                              PN(limits.nonCoherentAtomSize),                                                                                                                                 LIM_MAX_DEVSIZE(256) },
842
843                 // VK_KHR_multiview
844                 { PN(checkVulkan12Limit),                                               PN(vulkan11Properties.maxMultiviewViewCount),                                                                                                   LIM_MIN_UINT32(6) },
845                 { PN(checkVulkan12Limit),                                               PN(vulkan11Properties.maxMultiviewInstanceIndex),                                                                                               LIM_MIN_UINT32((1<<27) - 1) },
846
847                 // VK_KHR_maintenance3
848                 { PN(checkVulkan12Limit),                                               PN(vulkan11Properties.maxPerSetDescriptors),                                                                                                    LIM_MIN_UINT32(1024) },
849                 { PN(checkVulkan12Limit),                                               PN(vulkan11Properties.maxMemoryAllocationSize),                                                                                                 LIM_MIN_DEVSIZE(1<<30) },
850
851                 // VK_EXT_descriptor_indexing
852                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxUpdateAfterBindDescriptorsInAllPools),                                                                 LIM_MIN_UINT32(500000) },
853                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSamplers),                                                    LIM_MIN_UINT32(500000) },
854                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindUniformBuffers),                                              LIM_MIN_UINT32(12) },
855                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageBuffers),                                              LIM_MIN_UINT32(500000) },
856                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSampledImages),                                               LIM_MIN_UINT32(500000) },
857                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageImages),                                               LIM_MIN_UINT32(500000) },
858                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindInputAttachments),                                    LIM_MIN_UINT32(4) },
859                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageUpdateAfterBindResources),                                                                             LIM_MIN_UINT32(500000) },
860                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindSamplers),                                                                 LIM_MIN_UINT32(500000) },
861                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffers),                                                   LIM_MIN_UINT32(shaderStages * 12) },
862                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic),                                    LIM_MIN_UINT32(8) },
863                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffers),                                                   LIM_MIN_UINT32(500000) },
864                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic),                                    LIM_MIN_UINT32(4) },
865                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindSampledImages),                                                    LIM_MIN_UINT32(500000) },
866                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageImages),                                                    LIM_MIN_UINT32(500000) },
867                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindInputAttachments),                                                 LIM_MIN_UINT32(4) },
868                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSamplers),                                                    LIM_MIN_UINT32(limits.maxPerStageDescriptorSamplers) },
869                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindUniformBuffers),                                              LIM_MIN_UINT32(limits.maxPerStageDescriptorUniformBuffers) },
870                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageBuffers),                                              LIM_MIN_UINT32(limits.maxPerStageDescriptorStorageBuffers) },
871                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSampledImages),                                               LIM_MIN_UINT32(limits.maxPerStageDescriptorSampledImages) },
872                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageImages),                                               LIM_MIN_UINT32(limits.maxPerStageDescriptorStorageImages) },
873                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageDescriptorUpdateAfterBindInputAttachments),                                    LIM_MIN_UINT32(limits.maxPerStageDescriptorInputAttachments) },
874                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxPerStageUpdateAfterBindResources),                                                                             LIM_MIN_UINT32(limits.maxPerStageResources) },
875                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindSamplers),                                                                 LIM_MIN_UINT32(limits.maxDescriptorSetSamplers) },
876                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffers),                                                   LIM_MIN_UINT32(limits.maxDescriptorSetUniformBuffers) },
877                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic),                                    LIM_MIN_UINT32(limits.maxDescriptorSetUniformBuffersDynamic) },
878                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffers),                                                   LIM_MIN_UINT32(limits.maxDescriptorSetStorageBuffers) },
879                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic),                                    LIM_MIN_UINT32(limits.maxDescriptorSetStorageBuffersDynamic) },
880                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindSampledImages),                                                    LIM_MIN_UINT32(limits.maxDescriptorSetSampledImages) },
881                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageImages),                                                    LIM_MIN_UINT32(limits.maxDescriptorSetStorageImages) },
882                 { PN(features12.descriptorIndexing),                    PN(vulkan12Properties.maxDescriptorSetUpdateAfterBindInputAttachments),                                                 LIM_MIN_UINT32(limits.maxDescriptorSetInputAttachments) },
883
884                 // timelineSemaphore
885                 { PN(checkVulkan12Limit),                                               PN(vulkan12Properties.maxTimelineSemaphoreValueDifference),                                                                             LIM_MIN_DEVSIZE((1ull<<31) - 1) },
886         };
887
888         log << TestLog::Message << limits << TestLog::EndMessage;
889
890         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
891                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
892
893         if (limits.maxFramebufferWidth > limits.maxViewportDimensions[0] ||
894                 limits.maxFramebufferHeight > limits.maxViewportDimensions[1])
895         {
896                 log << TestLog::Message << "limit validation failed, maxFramebufferDimension of "
897                         << "[" << limits.maxFramebufferWidth << ", " << limits.maxFramebufferHeight << "] "
898                         << "is larger than maxViewportDimension of "
899                         << "[" << limits.maxViewportDimensions[0] << ", " << limits.maxViewportDimensions[1] << "]" << TestLog::EndMessage;
900                 limitsOk = false;
901         }
902
903         if (limits.viewportBoundsRange[0] > float(-2 * limits.maxViewportDimensions[0]))
904         {
905                 log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits.viewportBoundsRange[0]
906                         << "is larger than -2*maxViewportDimension[0] of " << -2*limits.maxViewportDimensions[0] << TestLog::EndMessage;
907                 limitsOk = false;
908         }
909
910         if (limits.viewportBoundsRange[1] < float(2 * limits.maxViewportDimensions[1] - 1))
911         {
912                 log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits.viewportBoundsRange[1]
913                         << "is less than 2*maxViewportDimension[1] of " << 2*limits.maxViewportDimensions[1] << TestLog::EndMessage;
914                 limitsOk = false;
915         }
916
917         if (limitsOk)
918                 return tcu::TestStatus::pass("pass");
919         else
920                 return tcu::TestStatus::fail("fail");
921 }
922
923 void checkSupportKhrPushDescriptor (Context& context)
924 {
925         context.requireDeviceFunctionality("VK_KHR_push_descriptor");
926 }
927
928 tcu::TestStatus validateLimitsKhrPushDescriptor (Context& context)
929 {
930         const VkBool32                                                                          checkAlways                                     = VK_TRUE;
931         const VkPhysicalDevicePushDescriptorPropertiesKHR&      pushDescriptorPropertiesKHR     = context.getPushDescriptorProperties();
932         TestLog&                                                                                        log                                                     = context.getTestContext().getLog();
933         bool                                                                                            limitsOk                                        = true;
934
935         FeatureLimitTableItem featureLimitTable[] =
936         {
937                 { PN(checkAlways),      PN(pushDescriptorPropertiesKHR.maxPushDescriptors),     LIM_MIN_UINT32(32) },
938         };
939
940         log << TestLog::Message << pushDescriptorPropertiesKHR << TestLog::EndMessage;
941
942         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
943                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
944
945         if (limitsOk)
946                 return tcu::TestStatus::pass("pass");
947         else
948                 return tcu::TestStatus::fail("fail");
949 }
950
951 void checkSupportKhrMultiview (Context& context)
952 {
953         context.requireDeviceFunctionality("VK_KHR_multiview");
954 }
955
956 tcu::TestStatus validateLimitsKhrMultiview (Context& context)
957 {
958         const VkBool32                                                          checkAlways                     = VK_TRUE;
959         const VkPhysicalDeviceMultiviewProperties&      multiviewProperties     = context.getMultiviewProperties();
960         TestLog&                                                                        log                                     = context.getTestContext().getLog();
961         bool                                                                            limitsOk                        = true;
962
963         FeatureLimitTableItem featureLimitTable[] =
964         {
965                 // VK_KHR_multiview
966                 { PN(checkAlways),      PN(multiviewProperties.maxMultiviewViewCount),          LIM_MIN_UINT32(6) },
967                 { PN(checkAlways),      PN(multiviewProperties.maxMultiviewInstanceIndex),      LIM_MIN_UINT32((1<<27) - 1) },
968         };
969
970         log << TestLog::Message << multiviewProperties << TestLog::EndMessage;
971
972         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
973                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
974
975         if (limitsOk)
976                 return tcu::TestStatus::pass("pass");
977         else
978                 return tcu::TestStatus::fail("fail");
979 }
980
981 void checkSupportExtDiscardRectangles (Context& context)
982 {
983         context.requireDeviceFunctionality("VK_EXT_discard_rectangles");
984 }
985
986 tcu::TestStatus validateLimitsExtDiscardRectangles (Context& context)
987 {
988         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
989         const VkPhysicalDeviceDiscardRectanglePropertiesEXT&    discardRectanglePropertiesEXT   = context.getDiscardRectanglePropertiesEXT();
990         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
991         bool                                                                                                    limitsOk                                                = true;
992
993         FeatureLimitTableItem featureLimitTable[] =
994         {
995                 { PN(checkAlways),      PN(discardRectanglePropertiesEXT.maxDiscardRectangles), LIM_MIN_UINT32(4) },
996         };
997
998         log << TestLog::Message << discardRectanglePropertiesEXT << TestLog::EndMessage;
999
1000         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1001                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1002
1003         if (limitsOk)
1004                 return tcu::TestStatus::pass("pass");
1005         else
1006                 return tcu::TestStatus::fail("fail");
1007 }
1008
1009 void checkSupportExtSampleLocations (Context& context)
1010 {
1011         context.requireDeviceFunctionality("VK_EXT_sample_locations");
1012 }
1013
1014 tcu::TestStatus validateLimitsExtSampleLocations (Context& context)
1015 {
1016         const VkBool32                                                                          checkAlways                                             = VK_TRUE;
1017         const VkPhysicalDeviceSampleLocationsPropertiesEXT&     sampleLocationsPropertiesEXT    = context.getSampleLocationsPropertiesEXT();
1018         TestLog&                                                                                        log                                                             = context.getTestContext().getLog();
1019         bool                                                                                            limitsOk                                                = true;
1020
1021         FeatureLimitTableItem featureLimitTable[] =
1022         {
1023                 { PN(checkAlways),      PN(sampleLocationsPropertiesEXT.sampleLocationSampleCounts),            LIM_MIN_BITI32(VK_SAMPLE_COUNT_4_BIT) },
1024                 { PN(checkAlways),      PN(sampleLocationsPropertiesEXT.maxSampleLocationGridSize.width),       LIM_MIN_FLOAT(0.0f) },
1025                 { PN(checkAlways),      PN(sampleLocationsPropertiesEXT.maxSampleLocationGridSize.height),      LIM_MIN_FLOAT(0.0f) },
1026                 { PN(checkAlways),      PN(sampleLocationsPropertiesEXT.sampleLocationCoordinateRange[0]),      LIM_MAX_FLOAT(0.0f) },
1027                 { PN(checkAlways),      PN(sampleLocationsPropertiesEXT.sampleLocationCoordinateRange[1]),      LIM_MIN_FLOAT(0.9375f) },
1028                 { PN(checkAlways),      PN(sampleLocationsPropertiesEXT.sampleLocationSubPixelBits),            LIM_MIN_UINT32(4) },
1029         };
1030
1031         log << TestLog::Message << sampleLocationsPropertiesEXT << TestLog::EndMessage;
1032
1033         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1034                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1035
1036         if (limitsOk)
1037                 return tcu::TestStatus::pass("pass");
1038         else
1039                 return tcu::TestStatus::fail("fail");
1040 }
1041
1042 void checkSupportExtExternalMemoryHost (Context& context)
1043 {
1044         context.requireDeviceFunctionality("VK_EXT_external_memory_host");
1045 }
1046
1047 tcu::TestStatus validateLimitsExtExternalMemoryHost (Context& context)
1048 {
1049         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1050         const VkPhysicalDeviceExternalMemoryHostPropertiesEXT&  externalMemoryHostPropertiesEXT = context.getExternalMemoryHostPropertiesEXT();
1051         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1052         bool                                                                                                    limitsOk                                                = true;
1053
1054         FeatureLimitTableItem featureLimitTable[] =
1055         {
1056                 { PN(checkAlways),      PN(externalMemoryHostPropertiesEXT.minImportedHostPointerAlignment),    LIM_MAX_DEVSIZE(65536) },
1057         };
1058
1059         log << TestLog::Message << externalMemoryHostPropertiesEXT << TestLog::EndMessage;
1060
1061         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1062                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1063
1064         if (limitsOk)
1065                 return tcu::TestStatus::pass("pass");
1066         else
1067                 return tcu::TestStatus::fail("fail");
1068 }
1069
1070 void checkSupportExtBlendOperationAdvanced (Context& context)
1071 {
1072         context.requireDeviceFunctionality("VK_EXT_blend_operation_advanced");
1073 }
1074
1075 tcu::TestStatus validateLimitsExtBlendOperationAdvanced (Context& context)
1076 {
1077         const VkBool32                                                                                          checkAlways                                                     = VK_TRUE;
1078         const VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT&      blendOperationAdvancedPropertiesEXT     = context.getBlendOperationAdvancedPropertiesEXT();
1079         TestLog&                                                                                                        log                                                                     = context.getTestContext().getLog();
1080         bool                                                                                                            limitsOk                                                        = true;
1081
1082         FeatureLimitTableItem featureLimitTable[] =
1083         {
1084                 { PN(checkAlways),      PN(blendOperationAdvancedPropertiesEXT.advancedBlendMaxColorAttachments),       LIM_MIN_UINT32(1) },
1085         };
1086
1087         log << TestLog::Message << blendOperationAdvancedPropertiesEXT << TestLog::EndMessage;
1088
1089         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1090                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1091
1092         if (limitsOk)
1093                 return tcu::TestStatus::pass("pass");
1094         else
1095                 return tcu::TestStatus::fail("fail");
1096 }
1097
1098 void checkSupportKhrMaintenance3 (Context& context)
1099 {
1100         context.requireDeviceFunctionality("VK_KHR_maintenance3");
1101 }
1102
1103 tcu::TestStatus validateLimitsKhrMaintenance3 (Context& context)
1104 {
1105         const VkBool32                                                                  checkAlways                             = VK_TRUE;
1106         const VkPhysicalDeviceMaintenance3Properties&   maintenance3Properties  = context.getMaintenance3Properties();
1107         TestLog&                                                                                log                                             = context.getTestContext().getLog();
1108         bool                                                                                    limitsOk                                = true;
1109
1110         FeatureLimitTableItem featureLimitTable[] =
1111         {
1112                 { PN(checkAlways),      PN(maintenance3Properties.maxPerSetDescriptors),        LIM_MIN_UINT32(1024) },
1113                 { PN(checkAlways),      PN(maintenance3Properties.maxMemoryAllocationSize),     LIM_MIN_DEVSIZE(1<<30) },
1114         };
1115
1116         log << TestLog::Message << maintenance3Properties << TestLog::EndMessage;
1117
1118         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1119                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1120
1121         if (limitsOk)
1122                 return tcu::TestStatus::pass("pass");
1123         else
1124                 return tcu::TestStatus::fail("fail");
1125 }
1126
1127 void checkSupportExtConservativeRasterization (Context& context)
1128 {
1129         context.requireDeviceFunctionality("VK_EXT_conservative_rasterization");
1130 }
1131
1132 tcu::TestStatus validateLimitsExtConservativeRasterization (Context& context)
1133 {
1134         const VkBool32                                                                                                  checkAlways                                                             = VK_TRUE;
1135         const VkPhysicalDeviceConservativeRasterizationPropertiesEXT&   conservativeRasterizationPropertiesEXT  = context.getConservativeRasterizationPropertiesEXT();
1136         TestLog&                                                                                                                log                                                                             = context.getTestContext().getLog();
1137         bool                                                                                                                    limitsOk                                                                = true;
1138
1139         FeatureLimitTableItem featureLimitTable[] =
1140         {
1141                 { PN(checkAlways),      PN(conservativeRasterizationPropertiesEXT.primitiveOverestimationSize),                                 LIM_MIN_FLOAT(0.0f) },
1142                 { PN(checkAlways),      PN(conservativeRasterizationPropertiesEXT.maxExtraPrimitiveOverestimationSize),                 LIM_MIN_FLOAT(0.0f) },
1143                 { PN(checkAlways),      PN(conservativeRasterizationPropertiesEXT.extraPrimitiveOverestimationSizeGranularity), LIM_MIN_FLOAT(0.0f) },
1144         };
1145
1146         log << TestLog::Message << conservativeRasterizationPropertiesEXT << TestLog::EndMessage;
1147
1148         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1149                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1150
1151         if (limitsOk)
1152                 return tcu::TestStatus::pass("pass");
1153         else
1154                 return tcu::TestStatus::fail("fail");
1155 }
1156
1157 void checkSupportExtDescriptorIndexing (Context& context)
1158 {
1159         const std::string&                                                      requiredDeviceExtension         = "VK_EXT_descriptor_indexing";
1160         const VkPhysicalDevice                                          physicalDevice                          = context.getPhysicalDevice();
1161         const InstanceInterface&                                        vki                                                     = context.getInstanceInterface();
1162         const std::vector<VkExtensionProperties>        deviceExtensionProperties       = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
1163
1164         if (!isExtensionSupported(deviceExtensionProperties, RequiredExtension(requiredDeviceExtension)))
1165                 TCU_THROW(NotSupportedError, requiredDeviceExtension + " is not supported");
1166
1167         // Extension string is present, then extension is really supported and should have been added into chain in DefaultDevice properties and features
1168 }
1169
1170 tcu::TestStatus validateLimitsExtDescriptorIndexing (Context& context)
1171 {
1172         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1173         const VkPhysicalDeviceProperties2&                                              properties2                                             = context.getDeviceProperties2();
1174         const VkPhysicalDeviceLimits&                                                   limits                                                  = properties2.properties.limits;
1175         const VkPhysicalDeviceDescriptorIndexingPropertiesEXT&  descriptorIndexingPropertiesEXT = context.getDescriptorIndexingProperties();
1176         const VkPhysicalDeviceFeatures&                                                 features                                                = context.getDeviceFeatures();
1177         const deUint32                                                                                  tessellationShaderCount                 = (features.tessellationShader) ? 2 : 0;
1178         const deUint32                                                                                  geometryShaderCount                             = (features.geometryShader) ? 1 : 0;
1179         const deUint32                                                                                  shaderStages                                    = 3 + tessellationShaderCount + geometryShaderCount;
1180         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1181         bool                                                                                                    limitsOk                                                = true;
1182
1183         FeatureLimitTableItem featureLimitTable[] =
1184         {
1185                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxUpdateAfterBindDescriptorsInAllPools),                            LIM_MIN_UINT32(500000) },
1186                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindSamplers),                       LIM_MIN_UINT32(500000) },
1187                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindUniformBuffers),         LIM_MIN_UINT32(12) },
1188                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindStorageBuffers),         LIM_MIN_UINT32(500000) },
1189                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindSampledImages),          LIM_MIN_UINT32(500000) },
1190                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindStorageImages),          LIM_MIN_UINT32(500000) },
1191                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindInputAttachments),       LIM_MIN_UINT32(4) },
1192                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageUpdateAfterBindResources),                                        LIM_MIN_UINT32(500000) },
1193                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindSamplers),                            LIM_MIN_UINT32(500000) },
1194                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindUniformBuffers),                      LIM_MIN_UINT32(shaderStages * 12) },
1195                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic),       LIM_MIN_UINT32(8) },
1196                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindStorageBuffers),                      LIM_MIN_UINT32(500000) },
1197                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic),       LIM_MIN_UINT32(4) },
1198                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindSampledImages),                       LIM_MIN_UINT32(500000) },
1199                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindStorageImages),                       LIM_MIN_UINT32(500000) },
1200                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindInputAttachments),            LIM_MIN_UINT32(4) },
1201                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindSamplers),                       LIM_MIN_UINT32(limits.maxPerStageDescriptorSamplers) },
1202                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindUniformBuffers),         LIM_MIN_UINT32(limits.maxPerStageDescriptorUniformBuffers) },
1203                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindStorageBuffers),         LIM_MIN_UINT32(limits.maxPerStageDescriptorStorageBuffers) },
1204                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindSampledImages),          LIM_MIN_UINT32(limits.maxPerStageDescriptorSampledImages) },
1205                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindStorageImages),          LIM_MIN_UINT32(limits.maxPerStageDescriptorStorageImages) },
1206                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageDescriptorUpdateAfterBindInputAttachments),       LIM_MIN_UINT32(limits.maxPerStageDescriptorInputAttachments) },
1207                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxPerStageUpdateAfterBindResources),                                        LIM_MIN_UINT32(limits.maxPerStageResources) },
1208                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindSamplers),                            LIM_MIN_UINT32(limits.maxDescriptorSetSamplers) },
1209                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindUniformBuffers),                      LIM_MIN_UINT32(limits.maxDescriptorSetUniformBuffers) },
1210                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic),       LIM_MIN_UINT32(limits.maxDescriptorSetUniformBuffersDynamic) },
1211                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindStorageBuffers),                      LIM_MIN_UINT32(limits.maxDescriptorSetStorageBuffers) },
1212                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic),       LIM_MIN_UINT32(limits.maxDescriptorSetStorageBuffersDynamic) },
1213                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindSampledImages),                       LIM_MIN_UINT32(limits.maxDescriptorSetSampledImages) },
1214                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindStorageImages),                       LIM_MIN_UINT32(limits.maxDescriptorSetStorageImages) },
1215                 { PN(checkAlways),      PN(descriptorIndexingPropertiesEXT.maxDescriptorSetUpdateAfterBindInputAttachments),            LIM_MIN_UINT32(limits.maxDescriptorSetInputAttachments) },
1216         };
1217
1218         log << TestLog::Message << descriptorIndexingPropertiesEXT << TestLog::EndMessage;
1219
1220         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1221                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1222
1223         if (limitsOk)
1224                 return tcu::TestStatus::pass("pass");
1225         else
1226                 return tcu::TestStatus::fail("fail");
1227 }
1228
1229 void checkSupportExtInlineUniformBlock (Context& context)
1230 {
1231         context.requireDeviceFunctionality("VK_EXT_inline_uniform_block");
1232 }
1233
1234 tcu::TestStatus validateLimitsExtInlineUniformBlock (Context& context)
1235 {
1236         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1237         const VkPhysicalDeviceInlineUniformBlockPropertiesEXT&  inlineUniformBlockPropertiesEXT = context.getInlineUniformBlockPropertiesEXT();
1238         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1239         bool                                                                                                    limitsOk                                                = true;
1240
1241         FeatureLimitTableItem featureLimitTable[] =
1242         {
1243                 { PN(checkAlways),      PN(inlineUniformBlockPropertiesEXT.maxInlineUniformBlockSize),                                                                  LIM_MIN_UINT32(256) },
1244                 { PN(checkAlways),      PN(inlineUniformBlockPropertiesEXT.maxPerStageDescriptorInlineUniformBlocks),                                   LIM_MIN_UINT32(4) },
1245                 { PN(checkAlways),      PN(inlineUniformBlockPropertiesEXT.maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks),    LIM_MIN_UINT32(4) },
1246                 { PN(checkAlways),      PN(inlineUniformBlockPropertiesEXT.maxDescriptorSetInlineUniformBlocks),                                                LIM_MIN_UINT32(4) },
1247                 { PN(checkAlways),      PN(inlineUniformBlockPropertiesEXT.maxDescriptorSetUpdateAfterBindInlineUniformBlocks),                 LIM_MIN_UINT32(4) },
1248         };
1249
1250         log << TestLog::Message << inlineUniformBlockPropertiesEXT << TestLog::EndMessage;
1251
1252         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1253                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1254
1255         if (limitsOk)
1256                 return tcu::TestStatus::pass("pass");
1257         else
1258                 return tcu::TestStatus::fail("fail");
1259 }
1260
1261 void checkSupportExtVertexAttributeDivisor (Context& context)
1262 {
1263         context.requireDeviceFunctionality("VK_EXT_vertex_attribute_divisor");
1264 }
1265
1266 tcu::TestStatus validateLimitsExtVertexAttributeDivisor (Context& context)
1267 {
1268         const VkBool32                                                                                          checkAlways                                                     = VK_TRUE;
1269         const VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT&      vertexAttributeDivisorPropertiesEXT     = context.getVertexAttributeDivisorPropertiesEXT();
1270         TestLog&                                                                                                        log                                                                     = context.getTestContext().getLog();
1271         bool                                                                                                            limitsOk                                                        = true;
1272
1273         FeatureLimitTableItem featureLimitTable[] =
1274         {
1275                 { PN(checkAlways),      PN(vertexAttributeDivisorPropertiesEXT.maxVertexAttribDivisor), LIM_MIN_UINT32((1<<16) - 1) },
1276         };
1277
1278         log << TestLog::Message << vertexAttributeDivisorPropertiesEXT << TestLog::EndMessage;
1279
1280         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1281                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1282
1283         if (limitsOk)
1284                 return tcu::TestStatus::pass("pass");
1285         else
1286                 return tcu::TestStatus::fail("fail");
1287 }
1288
1289 void checkSupportNvMeshShader (Context& context)
1290 {
1291         const std::string&                                                      requiredDeviceExtension         = "VK_NV_mesh_shader";
1292         const VkPhysicalDevice                                          physicalDevice                          = context.getPhysicalDevice();
1293         const InstanceInterface&                                        vki                                                     = context.getInstanceInterface();
1294         const std::vector<VkExtensionProperties>        deviceExtensionProperties       = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
1295
1296         if (!isExtensionSupported(deviceExtensionProperties, RequiredExtension(requiredDeviceExtension)))
1297                 TCU_THROW(NotSupportedError, requiredDeviceExtension + " is not supported");
1298 }
1299
1300 tcu::TestStatus validateLimitsNvMeshShader (Context& context)
1301 {
1302         const VkBool32                                                  checkAlways                             = VK_TRUE;
1303         const VkPhysicalDevice                                  physicalDevice                  = context.getPhysicalDevice();
1304         const InstanceInterface&                                vki                                             = context.getInstanceInterface();
1305         TestLog&                                                                log                                             = context.getTestContext().getLog();
1306         bool                                                                    limitsOk                                = true;
1307         VkPhysicalDeviceMeshShaderPropertiesNV  meshShaderPropertiesNV  = initVulkanStructure();
1308         VkPhysicalDeviceProperties2                             properties2                             = initVulkanStructure(&meshShaderPropertiesNV);
1309
1310         vki.getPhysicalDeviceProperties2(physicalDevice, &properties2);
1311
1312         FeatureLimitTableItem featureLimitTable[] =
1313         {
1314                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxDrawMeshTasksCount),               LIM_MIN_UINT32(deUint32((1ull<<16) - 1)) },
1315                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxTaskWorkGroupInvocations), LIM_MIN_UINT32(32) },
1316                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxTaskWorkGroupSize[0]),             LIM_MIN_UINT32(32) },
1317                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxTaskWorkGroupSize[1]),             LIM_MIN_UINT32(1) },
1318                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxTaskWorkGroupSize[2]),             LIM_MIN_UINT32(1) },
1319                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxTaskTotalMemorySize),              LIM_MIN_UINT32(16384) },
1320                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxTaskOutputCount),                  LIM_MIN_UINT32((1<<16) - 1) },
1321                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshWorkGroupInvocations), LIM_MIN_UINT32(32) },
1322                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshWorkGroupSize[0]),             LIM_MIN_UINT32(32) },
1323                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshWorkGroupSize[1]),             LIM_MIN_UINT32(1) },
1324                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshWorkGroupSize[2]),             LIM_MIN_UINT32(1) },
1325                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshTotalMemorySize),              LIM_MIN_UINT32(16384) },
1326                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshOutputVertices),               LIM_MIN_UINT32(256) },
1327                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshOutputPrimitives),             LIM_MIN_UINT32(256) },
1328                 { PN(checkAlways),      PN(meshShaderPropertiesNV.maxMeshMultiviewViewCount),   LIM_MIN_UINT32(1) },
1329         };
1330
1331         log << TestLog::Message << meshShaderPropertiesNV << TestLog::EndMessage;
1332
1333         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1334                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1335
1336         if (limitsOk)
1337                 return tcu::TestStatus::pass("pass");
1338         else
1339                 return tcu::TestStatus::fail("fail");
1340 }
1341
1342 void checkSupportExtTransformFeedback (Context& context)
1343 {
1344         context.requireDeviceFunctionality("VK_EXT_transform_feedback");
1345 }
1346
1347 tcu::TestStatus validateLimitsExtTransformFeedback (Context& context)
1348 {
1349         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1350         const VkPhysicalDeviceTransformFeedbackPropertiesEXT&   transformFeedbackPropertiesEXT  = context.getTransformFeedbackPropertiesEXT();
1351         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1352         bool                                                                                                    limitsOk                                                = true;
1353
1354         FeatureLimitTableItem featureLimitTable[] =
1355         {
1356                 { PN(checkAlways),      PN(transformFeedbackPropertiesEXT.maxTransformFeedbackStreams),                         LIM_MIN_UINT32(1) },
1357                 { PN(checkAlways),      PN(transformFeedbackPropertiesEXT.maxTransformFeedbackBuffers),                         LIM_MIN_UINT32(1) },
1358                 { PN(checkAlways),      PN(transformFeedbackPropertiesEXT.maxTransformFeedbackBufferSize),                      LIM_MIN_DEVSIZE(1ull<<27) },
1359                 { PN(checkAlways),      PN(transformFeedbackPropertiesEXT.maxTransformFeedbackStreamDataSize),          LIM_MIN_UINT32(512) },
1360                 { PN(checkAlways),      PN(transformFeedbackPropertiesEXT.maxTransformFeedbackBufferDataSize),          LIM_MIN_UINT32(512) },
1361                 { PN(checkAlways),      PN(transformFeedbackPropertiesEXT.maxTransformFeedbackBufferDataStride),        LIM_MIN_UINT32(512) },
1362         };
1363
1364         log << TestLog::Message << transformFeedbackPropertiesEXT << TestLog::EndMessage;
1365
1366         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1367                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1368
1369         if (limitsOk)
1370                 return tcu::TestStatus::pass("pass");
1371         else
1372                 return tcu::TestStatus::fail("fail");
1373 }
1374
1375 void checkSupportExtFragmentDensityMap (Context& context)
1376 {
1377         context.requireDeviceFunctionality("VK_EXT_fragment_density_map");
1378 }
1379
1380 tcu::TestStatus validateLimitsExtFragmentDensityMap (Context& context)
1381 {
1382         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1383         const VkPhysicalDeviceFragmentDensityMapPropertiesEXT&  fragmentDensityMapPropertiesEXT = context.getFragmentDensityMapPropertiesEXT();
1384         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1385         bool                                                                                                    limitsOk                                                = true;
1386
1387         FeatureLimitTableItem featureLimitTable[] =
1388         {
1389                 { PN(checkAlways),      PN(fragmentDensityMapPropertiesEXT.minFragmentDensityTexelSize.width),                                                  LIM_MIN_UINT32(1) },
1390                 { PN(checkAlways),      PN(fragmentDensityMapPropertiesEXT.minFragmentDensityTexelSize.height),                                                 LIM_MIN_UINT32(1) },
1391                 { PN(checkAlways),      PN(fragmentDensityMapPropertiesEXT.maxFragmentDensityTexelSize.width),                                                  LIM_MIN_UINT32(1) },
1392                 { PN(checkAlways),      PN(fragmentDensityMapPropertiesEXT.maxFragmentDensityTexelSize.height),                                                 LIM_MIN_UINT32(1) },
1393         };
1394
1395         log << TestLog::Message << fragmentDensityMapPropertiesEXT << TestLog::EndMessage;
1396
1397         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1398                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1399
1400         if (limitsOk)
1401                 return tcu::TestStatus::pass("pass");
1402         else
1403                 return tcu::TestStatus::fail("fail");
1404 }
1405
1406 void checkSupportNvRayTracing (Context& context)
1407 {
1408         const std::string&                                                      requiredDeviceExtension         = "VK_NV_ray_tracing";
1409         const VkPhysicalDevice                                          physicalDevice                          = context.getPhysicalDevice();
1410         const InstanceInterface&                                        vki                                                     = context.getInstanceInterface();
1411         const std::vector<VkExtensionProperties>        deviceExtensionProperties       = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
1412
1413         if (!isExtensionSupported(deviceExtensionProperties, RequiredExtension(requiredDeviceExtension)))
1414                 TCU_THROW(NotSupportedError, requiredDeviceExtension + " is not supported");
1415 }
1416
1417 tcu::TestStatus validateLimitsNvRayTracing (Context& context)
1418 {
1419         const VkBool32                                                  checkAlways                             = VK_TRUE;
1420         const VkPhysicalDevice                                  physicalDevice                  = context.getPhysicalDevice();
1421         const InstanceInterface&                                vki                                             = context.getInstanceInterface();
1422         TestLog&                                                                log                                             = context.getTestContext().getLog();
1423         bool                                                                    limitsOk                                = true;
1424         VkPhysicalDeviceRayTracingPropertiesNV  rayTracingPropertiesNV  = initVulkanStructure();
1425         VkPhysicalDeviceProperties2                             properties2                             = initVulkanStructure(&rayTracingPropertiesNV);
1426
1427         vki.getPhysicalDeviceProperties2(physicalDevice, &properties2);
1428
1429         FeatureLimitTableItem featureLimitTable[] =
1430         {
1431                 { PN(checkAlways),      PN(rayTracingPropertiesNV.shaderGroupHandleSize),                                       LIM_MIN_UINT32(16) },
1432                 { PN(checkAlways),      PN(rayTracingPropertiesNV.maxRecursionDepth),                                           LIM_MIN_UINT32(31) },
1433                 { PN(checkAlways),      PN(rayTracingPropertiesNV.shaderGroupBaseAlignment),                            LIM_MIN_UINT32(64) },
1434                 { PN(checkAlways),      PN(rayTracingPropertiesNV.maxGeometryCount),                                            LIM_MIN_UINT32((1<<24) - 1) },
1435                 { PN(checkAlways),      PN(rayTracingPropertiesNV.maxInstanceCount),                                            LIM_MIN_UINT32((1<<24) - 1) },
1436                 { PN(checkAlways),      PN(rayTracingPropertiesNV.maxTriangleCount),                                            LIM_MIN_UINT32((1<<29) - 1) },
1437                 { PN(checkAlways),      PN(rayTracingPropertiesNV.maxDescriptorSetAccelerationStructures),      LIM_MIN_UINT32(16) },
1438         };
1439
1440         log << TestLog::Message << rayTracingPropertiesNV << TestLog::EndMessage;
1441
1442         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1443                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1444
1445         if (limitsOk)
1446                 return tcu::TestStatus::pass("pass");
1447         else
1448                 return tcu::TestStatus::fail("fail");
1449 }
1450
1451 void checkSupportKhrTimelineSemaphore (Context& context)
1452 {
1453         context.requireDeviceFunctionality("VK_KHR_timeline_semaphore");
1454 }
1455
1456 tcu::TestStatus validateLimitsKhrTimelineSemaphore (Context& context)
1457 {
1458         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1459         const VkPhysicalDeviceTimelineSemaphorePropertiesKHR&   timelineSemaphorePropertiesKHR  = context.getTimelineSemaphoreProperties();
1460         bool                                                                                                    limitsOk                                                = true;
1461         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1462
1463         FeatureLimitTableItem featureLimitTable[] =
1464         {
1465                 { PN(checkAlways),      PN(timelineSemaphorePropertiesKHR.maxTimelineSemaphoreValueDifference), LIM_MIN_DEVSIZE((1ull<<31) - 1) },
1466         };
1467
1468         log << TestLog::Message << timelineSemaphorePropertiesKHR << TestLog::EndMessage;
1469
1470         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1471                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1472
1473         if (limitsOk)
1474                 return tcu::TestStatus::pass("pass");
1475         else
1476                 return tcu::TestStatus::fail("fail");
1477 }
1478
1479 void checkSupportExtLineRasterization (Context& context)
1480 {
1481         context.requireDeviceFunctionality("VK_EXT_line_rasterization");
1482 }
1483
1484 tcu::TestStatus validateLimitsExtLineRasterization (Context& context)
1485 {
1486         const VkBool32                                                                                  checkAlways                                             = VK_TRUE;
1487         const VkPhysicalDeviceLineRasterizationPropertiesEXT&   lineRasterizationPropertiesEXT  = context.getLineRasterizationPropertiesEXT();
1488         TestLog&                                                                                                log                                                             = context.getTestContext().getLog();
1489         bool                                                                                                    limitsOk                                                = true;
1490
1491         FeatureLimitTableItem featureLimitTable[] =
1492         {
1493                 { PN(checkAlways),      PN(lineRasterizationPropertiesEXT.lineSubPixelPrecisionBits),   LIM_MIN_UINT32(4) },
1494         };
1495
1496         log << TestLog::Message << lineRasterizationPropertiesEXT << TestLog::EndMessage;
1497
1498         for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
1499                 limitsOk = validateLimit(featureLimitTable[ndx], log) && limitsOk;
1500
1501         if (limitsOk)
1502                 return tcu::TestStatus::pass("pass");
1503         else
1504                 return tcu::TestStatus::fail("fail");
1505 }
1506
1507 void checkSupportFeatureBitInfluence (Context& context)
1508 {
1509         if (!context.contextSupports(vk::ApiVersion(1, 2, 0)))
1510                 TCU_THROW(NotSupportedError, "At least Vulkan 1.2 required to run test");
1511 }
1512
1513 void createTestDevice (Context& context, void* pNext, const char* const* ppEnabledExtensionNames, deUint32 enabledExtensionCount)
1514 {
1515         const PlatformInterface&                                platformInterface               = context.getPlatformInterface();
1516         const auto                                                              validationEnabled               = context.getTestContext().getCommandLine().isValidationEnabled();
1517         const Unique<VkInstance>                                instance                                (createDefaultInstance(platformInterface, context.getUsedApiVersion()));
1518         const InstanceDriver                                    instanceDriver                  (platformInterface, instance.get());
1519         const VkPhysicalDevice                                  physicalDevice                  = chooseDevice(instanceDriver, instance.get(), context.getTestContext().getCommandLine());
1520         const deUint32                                                  queueFamilyIndex                = 0;
1521         const deUint32                                                  queueCount                              = 1;
1522         const deUint32                                                  queueIndex                              = 0;
1523         const float                                                             queuePriority                   = 1.0f;
1524         const vector<VkQueueFamilyProperties>   queueFamilyProperties   = getPhysicalDeviceQueueFamilyProperties(instanceDriver, physicalDevice);
1525         const VkDeviceQueueCreateInfo                   deviceQueueCreateInfo   =
1526         {
1527                 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,     //  VkStructureType                             sType;
1528                 DE_NULL,                                                                        //  const void*                                 pNext;
1529                 (VkDeviceQueueCreateFlags)0u,                           //  VkDeviceQueueCreateFlags    flags;
1530                 queueFamilyIndex,                                                       //  deUint32                                    queueFamilyIndex;
1531                 queueCount,                                                                     //  deUint32                                    queueCount;
1532                 &queuePriority,                                                         //  const float*                                pQueuePriorities;
1533         };
1534         const VkDeviceCreateInfo                                deviceCreateInfo                =
1535         {
1536                 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,           //  VkStructureType                                     sType;
1537                 pNext,                                                                          //  const void*                                         pNext;
1538                 (VkDeviceCreateFlags)0u,                                        //  VkDeviceCreateFlags                         flags;
1539                 1,                                                                                      //  deUint32                                            queueCreateInfoCount;
1540                 &deviceQueueCreateInfo,                                         //  const VkDeviceQueueCreateInfo*      pQueueCreateInfos;
1541                 0,                                                                                      //  deUint32                                            enabledLayerCount;
1542                 DE_NULL,                                                                        //  const char* const*                          ppEnabledLayerNames;
1543                 enabledExtensionCount,                                          //  deUint32                                            enabledExtensionCount;
1544                 ppEnabledExtensionNames,                                        //  const char* const*                          ppEnabledExtensionNames;
1545                 DE_NULL,                                                                        //  const VkPhysicalDeviceFeatures*     pEnabledFeatures;
1546         };
1547         const Unique<VkDevice>                                  device                                  (createCustomDevice(validationEnabled, platformInterface, *instance, instanceDriver, physicalDevice, &deviceCreateInfo));
1548         const DeviceDriver                                              deviceDriver                    (platformInterface, instance.get(), device.get());
1549         const VkQueue                                                   queue                                   = getDeviceQueue(deviceDriver, *device,  queueFamilyIndex, queueIndex);
1550
1551         VK_CHECK(deviceDriver.queueWaitIdle(queue));
1552 }
1553
1554 void cleanVulkanStruct (void* structPtr, size_t structSize)
1555 {
1556         struct StructureBase
1557         {
1558                 VkStructureType         sType;
1559                 void*                           pNext;
1560         };
1561
1562         VkStructureType         sType = ((StructureBase*)structPtr)->sType;
1563
1564         deMemset(structPtr, 0, structSize);
1565
1566         ((StructureBase*)structPtr)->sType = sType;
1567 }
1568
1569 tcu::TestStatus featureBitInfluenceOnDeviceCreate (Context& context)
1570 {
1571 #define FEATURE_TABLE_ITEM(CORE, EXT, FIELD, STR) { &(CORE), sizeof(CORE), &(CORE.FIELD), #CORE "." #FIELD, &(EXT), sizeof(EXT), &(EXT.FIELD), #EXT "." #FIELD, STR }
1572 #define DEPENDENCY_DUAL_ITEM(CORE, EXT, FIELD, PARENT) { &(CORE.FIELD), &(CORE.PARENT) }, { &(EXT.FIELD), &(EXT.PARENT) }
1573 #define DEPENDENCY_SINGLE_ITEM(CORE, FIELD, PARENT) { &(CORE.FIELD), &(CORE.PARENT) }
1574
1575         const VkPhysicalDevice                                                          physicalDevice                                          = context.getPhysicalDevice();
1576         const InstanceInterface&                                                        vki                                                                     = context.getInstanceInterface();
1577         TestLog&                                                                                        log                                                                     = context.getTestContext().getLog();
1578         const std::vector<VkExtensionProperties>                        deviceExtensionProperties                       = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
1579
1580         VkPhysicalDeviceFeatures2                                                       features2                                                       = initVulkanStructure();
1581         VkPhysicalDeviceVulkan11Features                                        vulkan11Features                                        = initVulkanStructure();
1582         VkPhysicalDeviceVulkan12Features                                        vulkan12Features                                        = initVulkanStructure();
1583         VkPhysicalDevice16BitStorageFeaturesKHR                         sixteenBitStorageFeatures                       = initVulkanStructure();
1584         VkPhysicalDeviceMultiviewFeatures                                       multiviewFeatures                                       = initVulkanStructure();
1585         VkPhysicalDeviceVariablePointersFeatures                        variablePointersFeatures                        = initVulkanStructure();
1586         VkPhysicalDeviceProtectedMemoryFeatures                         protectedMemoryFeatures                         = initVulkanStructure();
1587         VkPhysicalDeviceSamplerYcbcrConversionFeatures          samplerYcbcrConversionFeatures          = initVulkanStructure();
1588         VkPhysicalDeviceShaderDrawParametersFeatures            shaderDrawParametersFeatures            = initVulkanStructure();
1589         VkPhysicalDevice8BitStorageFeatures                                     eightBitStorageFeatures                         = initVulkanStructure();
1590         VkPhysicalDeviceShaderAtomicInt64Features                       shaderAtomicInt64Features                       = initVulkanStructure();
1591         VkPhysicalDeviceShaderFloat16Int8Features                       shaderFloat16Int8Features                       = initVulkanStructure();
1592         VkPhysicalDeviceDescriptorIndexingFeatures                      descriptorIndexingFeatures                      = initVulkanStructure();
1593         VkPhysicalDeviceScalarBlockLayoutFeatures                       scalarBlockLayoutFeatures                       = initVulkanStructure();
1594         VkPhysicalDeviceImagelessFramebufferFeatures            imagelessFramebufferFeatures            = initVulkanStructure();
1595         VkPhysicalDeviceUniformBufferStandardLayoutFeatures     uniformBufferStandardLayoutFeatures     = initVulkanStructure();
1596         VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures     shaderSubgroupExtendedTypesFeatures     = initVulkanStructure();
1597         VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures     separateDepthStencilLayoutsFeatures     = initVulkanStructure();
1598         VkPhysicalDeviceHostQueryResetFeatures                          hostQueryResetFeatures                          = initVulkanStructure();
1599         VkPhysicalDeviceTimelineSemaphoreFeatures                       timelineSemaphoreFeatures                       = initVulkanStructure();
1600         VkPhysicalDeviceBufferDeviceAddressFeatures                     bufferDeviceAddressFeatures                     = initVulkanStructure();
1601         VkPhysicalDeviceVulkanMemoryModelFeatures                       vulkanMemoryModelFeatures                       = initVulkanStructure();
1602
1603         struct UnusedExtensionFeatures
1604         {
1605                 VkStructureType         sType;
1606                 void*                           pNext;
1607                 VkBool32                        descriptorIndexing;
1608                 VkBool32                        samplerFilterMinmax;
1609         } unusedExtensionFeatures;
1610
1611         struct FeatureTable
1612         {
1613                 void*           coreStructPtr;
1614                 size_t          coreStructSize;
1615                 VkBool32*       coreFieldPtr;
1616                 const char*     coreFieldName;
1617                 void*           extStructPtr;
1618                 size_t          extStructSize;
1619                 VkBool32*       extFieldPtr;
1620                 const char*     extFieldName;
1621                 const char*     extString;
1622         }
1623         featureTable[] =
1624         {
1625                 FEATURE_TABLE_ITEM(vulkan11Features,    sixteenBitStorageFeatures,                              storageBuffer16BitAccess,                                                       "VK_KHR_16bit_storage"),
1626                 FEATURE_TABLE_ITEM(vulkan11Features,    sixteenBitStorageFeatures,                              uniformAndStorageBuffer16BitAccess,                                     "VK_KHR_16bit_storage"),
1627                 FEATURE_TABLE_ITEM(vulkan11Features,    sixteenBitStorageFeatures,                              storagePushConstant16,                                                          "VK_KHR_16bit_storage"),
1628                 FEATURE_TABLE_ITEM(vulkan11Features,    sixteenBitStorageFeatures,                              storageInputOutput16,                                                           "VK_KHR_16bit_storage"),
1629                 FEATURE_TABLE_ITEM(vulkan11Features,    multiviewFeatures,                                              multiview,                                                                                      "VK_KHR_multiview"),
1630                 FEATURE_TABLE_ITEM(vulkan11Features,    multiviewFeatures,                                              multiviewGeometryShader,                                                        "VK_KHR_multiview"),
1631                 FEATURE_TABLE_ITEM(vulkan11Features,    multiviewFeatures,                                              multiviewTessellationShader,                                            "VK_KHR_multiview"),
1632                 FEATURE_TABLE_ITEM(vulkan11Features,    variablePointersFeatures,                               variablePointersStorageBuffer,                                          "VK_KHR_variable_pointers"),
1633                 FEATURE_TABLE_ITEM(vulkan11Features,    variablePointersFeatures,                               variablePointers,                                                                       "VK_KHR_variable_pointers"),
1634                 FEATURE_TABLE_ITEM(vulkan11Features,    protectedMemoryFeatures,                                protectedMemory,                                                                        DE_NULL),
1635                 FEATURE_TABLE_ITEM(vulkan11Features,    samplerYcbcrConversionFeatures,                 samplerYcbcrConversion,                                                         "VK_KHR_sampler_ycbcr_conversion"),
1636                 FEATURE_TABLE_ITEM(vulkan11Features,    shaderDrawParametersFeatures,                   shaderDrawParameters,                                                           DE_NULL),
1637                 FEATURE_TABLE_ITEM(vulkan12Features,    eightBitStorageFeatures,                                storageBuffer8BitAccess,                                                        "VK_KHR_8bit_storage"),
1638                 FEATURE_TABLE_ITEM(vulkan12Features,    eightBitStorageFeatures,                                uniformAndStorageBuffer8BitAccess,                                      "VK_KHR_8bit_storage"),
1639                 FEATURE_TABLE_ITEM(vulkan12Features,    eightBitStorageFeatures,                                storagePushConstant8,                                                           "VK_KHR_8bit_storage"),
1640                 FEATURE_TABLE_ITEM(vulkan12Features,    shaderAtomicInt64Features,                              shaderBufferInt64Atomics,                                                       "VK_KHR_shader_atomic_int64"),
1641                 FEATURE_TABLE_ITEM(vulkan12Features,    shaderAtomicInt64Features,                              shaderSharedInt64Atomics,                                                       "VK_KHR_shader_atomic_int64"),
1642                 FEATURE_TABLE_ITEM(vulkan12Features,    shaderFloat16Int8Features,                              shaderFloat16,                                                                          "VK_KHR_shader_float16_int8"),
1643                 FEATURE_TABLE_ITEM(vulkan12Features,    shaderFloat16Int8Features,                              shaderInt8,                                                                                     "VK_KHR_shader_float16_int8"),
1644                 FEATURE_TABLE_ITEM(vulkan12Features,    unusedExtensionFeatures,                                descriptorIndexing,                                                                     DE_NULL),
1645                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderInputAttachmentArrayDynamicIndexing,                      "VK_EXT_descriptor_indexing"),
1646                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderUniformTexelBufferArrayDynamicIndexing,           "VK_EXT_descriptor_indexing"),
1647                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderStorageTexelBufferArrayDynamicIndexing,           "VK_EXT_descriptor_indexing"),
1648                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderUniformBufferArrayNonUniformIndexing,                     "VK_EXT_descriptor_indexing"),
1649                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderSampledImageArrayNonUniformIndexing,                      "VK_EXT_descriptor_indexing"),
1650                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderStorageBufferArrayNonUniformIndexing,                     "VK_EXT_descriptor_indexing"),
1651                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderStorageImageArrayNonUniformIndexing,                      "VK_EXT_descriptor_indexing"),
1652                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderInputAttachmentArrayNonUniformIndexing,           "VK_EXT_descriptor_indexing"),
1653                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderUniformTexelBufferArrayNonUniformIndexing,        "VK_EXT_descriptor_indexing"),
1654                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             shaderStorageTexelBufferArrayNonUniformIndexing,        "VK_EXT_descriptor_indexing"),
1655                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingUniformBufferUpdateAfterBind,          "VK_EXT_descriptor_indexing"),
1656                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingSampledImageUpdateAfterBind,           "VK_EXT_descriptor_indexing"),
1657                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingStorageImageUpdateAfterBind,           "VK_EXT_descriptor_indexing"),
1658                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingStorageBufferUpdateAfterBind,          "VK_EXT_descriptor_indexing"),
1659                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingUniformTexelBufferUpdateAfterBind,     "VK_EXT_descriptor_indexing"),
1660                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingStorageTexelBufferUpdateAfterBind,     "VK_EXT_descriptor_indexing"),
1661                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingUpdateUnusedWhilePending,                      "VK_EXT_descriptor_indexing"),
1662                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingPartiallyBound,                                        "VK_EXT_descriptor_indexing"),
1663                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             descriptorBindingVariableDescriptorCount,                       "VK_EXT_descriptor_indexing"),
1664                 FEATURE_TABLE_ITEM(vulkan12Features,    descriptorIndexingFeatures,                             runtimeDescriptorArray,                                                         "VK_EXT_descriptor_indexing"),
1665                 FEATURE_TABLE_ITEM(vulkan12Features,    unusedExtensionFeatures,                                samplerFilterMinmax,                                                            "VK_EXT_sampler_filter_minmax"),
1666                 FEATURE_TABLE_ITEM(vulkan12Features,    scalarBlockLayoutFeatures,                              scalarBlockLayout,                                                                      "VK_EXT_scalar_block_layout"),
1667                 FEATURE_TABLE_ITEM(vulkan12Features,    imagelessFramebufferFeatures,                   imagelessFramebuffer,                                                           "VK_KHR_imageless_framebuffer"),
1668                 FEATURE_TABLE_ITEM(vulkan12Features,    uniformBufferStandardLayoutFeatures,    uniformBufferStandardLayout,                                            "VK_KHR_uniform_buffer_standard_layout"),
1669                 FEATURE_TABLE_ITEM(vulkan12Features,    shaderSubgroupExtendedTypesFeatures,    shaderSubgroupExtendedTypes,                                            "VK_KHR_shader_subgroup_extended_types"),
1670                 FEATURE_TABLE_ITEM(vulkan12Features,    separateDepthStencilLayoutsFeatures,    separateDepthStencilLayouts,                                            "VK_KHR_separate_depth_stencil_layouts"),
1671                 FEATURE_TABLE_ITEM(vulkan12Features,    hostQueryResetFeatures,                                 hostQueryReset,                                                                         "VK_EXT_host_query_reset"),
1672                 FEATURE_TABLE_ITEM(vulkan12Features,    timelineSemaphoreFeatures,                              timelineSemaphore,                                                                      "VK_KHR_timeline_semaphore"),
1673                 FEATURE_TABLE_ITEM(vulkan12Features,    bufferDeviceAddressFeatures,                    bufferDeviceAddress,                                                            "VK_EXT_buffer_device_address"),
1674                 FEATURE_TABLE_ITEM(vulkan12Features,    bufferDeviceAddressFeatures,                    bufferDeviceAddressCaptureReplay,                                       "VK_EXT_buffer_device_address"),
1675                 FEATURE_TABLE_ITEM(vulkan12Features,    bufferDeviceAddressFeatures,                    bufferDeviceAddressMultiDevice,                                         "VK_EXT_buffer_device_address"),
1676                 FEATURE_TABLE_ITEM(vulkan12Features,    vulkanMemoryModelFeatures,                              vulkanMemoryModel,                                                                      "VK_KHR_vulkan_memory_model"),
1677                 FEATURE_TABLE_ITEM(vulkan12Features,    vulkanMemoryModelFeatures,                              vulkanMemoryModelDeviceScope,                                           "VK_KHR_vulkan_memory_model"),
1678                 FEATURE_TABLE_ITEM(vulkan12Features,    vulkanMemoryModelFeatures,                              vulkanMemoryModelAvailabilityVisibilityChains,          "VK_KHR_vulkan_memory_model"),
1679         };
1680         struct FeatureDependencyTable
1681         {
1682                 VkBool32*       featurePtr;
1683                 VkBool32*       dependOnPtr;
1684         }
1685         featureDependencyTable[] =
1686         {
1687                 DEPENDENCY_DUAL_ITEM    (vulkan11Features,      multiviewFeatures,                              multiviewGeometryShader,                                                        multiview),
1688                 DEPENDENCY_DUAL_ITEM    (vulkan11Features,      multiviewFeatures,                              multiviewTessellationShader,                                            multiview),
1689                 DEPENDENCY_DUAL_ITEM    (vulkan11Features,      variablePointersFeatures,               variablePointers,                                                                       variablePointersStorageBuffer),
1690                 DEPENDENCY_DUAL_ITEM    (vulkan12Features,      bufferDeviceAddressFeatures,    bufferDeviceAddressCaptureReplay,                                       bufferDeviceAddress),
1691                 DEPENDENCY_DUAL_ITEM    (vulkan12Features,      bufferDeviceAddressFeatures,    bufferDeviceAddressMultiDevice,                                         bufferDeviceAddress),
1692                 DEPENDENCY_DUAL_ITEM    (vulkan12Features,      vulkanMemoryModelFeatures,              vulkanMemoryModelDeviceScope,                                           vulkanMemoryModel),
1693                 DEPENDENCY_DUAL_ITEM    (vulkan12Features,      vulkanMemoryModelFeatures,              vulkanMemoryModelAvailabilityVisibilityChains,          vulkanMemoryModel),
1694         };
1695
1696         deMemset(&unusedExtensionFeatures, 0, sizeof(unusedExtensionFeatures));
1697
1698         for (size_t featureTableNdx = 0; featureTableNdx < DE_LENGTH_OF_ARRAY(featureTable); ++featureTableNdx)
1699         {
1700                 FeatureTable&   testedFeature   = featureTable[featureTableNdx];
1701                 VkBool32                coreFeatureState= DE_FALSE;
1702                 VkBool32                extFeatureState = DE_FALSE;
1703
1704                 // Core test
1705                 {
1706                         void*           structPtr       = testedFeature.coreStructPtr;
1707                         size_t          structSize      = testedFeature.coreStructSize;
1708                         VkBool32*       featurePtr      = testedFeature.coreFieldPtr;
1709
1710                         if (structPtr != &unusedExtensionFeatures)
1711                                 features2.pNext = structPtr;
1712
1713                         vki.getPhysicalDeviceFeatures2(physicalDevice, &features2);
1714
1715                         coreFeatureState = featurePtr[0];
1716
1717                         log << TestLog::Message
1718                                 << "Feature status "
1719                                 << testedFeature.coreFieldName << "=" << coreFeatureState
1720                                 << TestLog::EndMessage;
1721
1722                         if (coreFeatureState)
1723                         {
1724                                 cleanVulkanStruct(structPtr, structSize);
1725
1726                                 featurePtr[0] = DE_TRUE;
1727
1728                                 for (size_t featureDependencyTableNdx = 0; featureDependencyTableNdx < DE_LENGTH_OF_ARRAY(featureDependencyTable); ++featureDependencyTableNdx)
1729                                         if (featureDependencyTable[featureDependencyTableNdx].featurePtr == featurePtr)
1730                                                 featureDependencyTable[featureDependencyTableNdx].dependOnPtr[0] = DE_TRUE;
1731
1732                                 createTestDevice(context, &features2, DE_NULL, 0u);
1733                         }
1734                 }
1735
1736                 // ext test
1737                 {
1738                         void*           structPtr               = testedFeature.extStructPtr;
1739                         size_t          structSize              = testedFeature.extStructSize;
1740                         VkBool32*       featurePtr              = testedFeature.extFieldPtr;
1741                         const char*     extStringPtr    = testedFeature.extString;
1742
1743                         if (structPtr != &unusedExtensionFeatures)
1744                                 features2.pNext = structPtr;
1745
1746                         if (extStringPtr == DE_NULL || isExtensionSupported(deviceExtensionProperties, RequiredExtension(extStringPtr)))
1747                         {
1748                                 vki.getPhysicalDeviceFeatures2(physicalDevice, &features2);
1749
1750                                 extFeatureState = *featurePtr;
1751
1752                                 log << TestLog::Message
1753                                         << "Feature status "
1754                                         << testedFeature.extFieldName << "=" << extFeatureState
1755                                         << TestLog::EndMessage;
1756
1757                                 if (extFeatureState)
1758                                 {
1759                                         cleanVulkanStruct(structPtr, structSize);
1760
1761                                         featurePtr[0] = DE_TRUE;
1762
1763                                         for (size_t featureDependencyTableNdx = 0; featureDependencyTableNdx < DE_LENGTH_OF_ARRAY(featureDependencyTable); ++featureDependencyTableNdx)
1764                                                 if (featureDependencyTable[featureDependencyTableNdx].featurePtr == featurePtr)
1765                                                         featureDependencyTable[featureDependencyTableNdx].dependOnPtr[0] = DE_TRUE;
1766
1767                                         createTestDevice(context, &features2, &extStringPtr, (extStringPtr == DE_NULL) ? 0u : 1u );
1768                                 }
1769                         }
1770                 }
1771         }
1772
1773         return tcu::TestStatus::pass("pass");
1774 }
1775
1776 template<typename T>
1777 class CheckIncompleteResult
1778 {
1779 public:
1780         virtual                 ~CheckIncompleteResult  (void) {}
1781         virtual void    getResult                               (Context& context, T* data) = 0;
1782
1783         void operator() (Context& context, tcu::ResultCollector& results, const std::size_t expectedCompleteSize)
1784         {
1785                 if (expectedCompleteSize == 0)
1786                         return;
1787
1788                 vector<T>               outputData      (expectedCompleteSize);
1789                 const deUint32  usedSize        = static_cast<deUint32>(expectedCompleteSize / 3);
1790
1791                 ValidateQueryBits::fillBits(outputData.begin(), outputData.end());      // unused entries should have this pattern intact
1792                 m_count         = usedSize;
1793                 m_result        = VK_SUCCESS;
1794
1795                 getResult(context, &outputData[0]);                                                                     // update m_count and m_result
1796
1797                 if (m_count != usedSize || m_result != VK_INCOMPLETE || !ValidateQueryBits::checkBits(outputData.begin() + m_count, outputData.end()))
1798                         results.fail("Query didn't return VK_INCOMPLETE");
1799         }
1800
1801 protected:
1802         deUint32        m_count;
1803         VkResult        m_result;
1804 };
1805
1806 struct CheckEnumeratePhysicalDevicesIncompleteResult : public CheckIncompleteResult<VkPhysicalDevice>
1807 {
1808         void getResult (Context& context, VkPhysicalDevice* data)
1809         {
1810                 m_result = context.getInstanceInterface().enumeratePhysicalDevices(context.getInstance(), &m_count, data);
1811         }
1812 };
1813
1814 struct CheckEnumeratePhysicalDeviceGroupsIncompleteResult : public CheckIncompleteResult<VkPhysicalDeviceGroupProperties>
1815 {
1816         void getResult (Context& context, VkPhysicalDeviceGroupProperties* data)
1817         {
1818                 m_result = context.getInstanceInterface().enumeratePhysicalDeviceGroups(context.getInstance(), &m_count, data);
1819         }
1820 };
1821
1822 struct CheckEnumerateInstanceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
1823 {
1824         void getResult (Context& context, VkLayerProperties* data)
1825         {
1826                 m_result = context.getPlatformInterface().enumerateInstanceLayerProperties(&m_count, data);
1827         }
1828 };
1829
1830 struct CheckEnumerateDeviceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
1831 {
1832         void getResult (Context& context, VkLayerProperties* data)
1833         {
1834                 m_result = context.getInstanceInterface().enumerateDeviceLayerProperties(context.getPhysicalDevice(), &m_count, data);
1835         }
1836 };
1837
1838 struct CheckEnumerateInstanceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
1839 {
1840         CheckEnumerateInstanceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
1841
1842         void getResult (Context& context, VkExtensionProperties* data)
1843         {
1844                 const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
1845                 m_result = context.getPlatformInterface().enumerateInstanceExtensionProperties(pLayerName, &m_count, data);
1846         }
1847
1848 private:
1849         const std::string       m_layerName;
1850 };
1851
1852 struct CheckEnumerateDeviceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
1853 {
1854         CheckEnumerateDeviceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
1855
1856         void getResult (Context& context, VkExtensionProperties* data)
1857         {
1858                 const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
1859                 m_result = context.getInstanceInterface().enumerateDeviceExtensionProperties(context.getPhysicalDevice(), pLayerName, &m_count, data);
1860         }
1861
1862 private:
1863         const std::string       m_layerName;
1864 };
1865
1866 tcu::TestStatus enumeratePhysicalDevices (Context& context)
1867 {
1868         TestLog&                                                log             = context.getTestContext().getLog();
1869         tcu::ResultCollector                    results (log);
1870         const vector<VkPhysicalDevice>  devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
1871
1872         log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
1873
1874         for (size_t ndx = 0; ndx < devices.size(); ndx++)
1875                 log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage;
1876
1877         CheckEnumeratePhysicalDevicesIncompleteResult()(context, results, devices.size());
1878
1879         return tcu::TestStatus(results.getResult(), results.getMessage());
1880 }
1881
1882 tcu::TestStatus enumeratePhysicalDeviceGroups (Context& context)
1883 {
1884         TestLog&                                                                                        log                             = context.getTestContext().getLog();
1885         tcu::ResultCollector                                                            results                 (log);
1886         const CustomInstance                                                            instance                (createCustomInstanceWithExtension(context, "VK_KHR_device_group_creation"));
1887         const InstanceDriver&                                                           vki                             (instance.getDriver());
1888         const vector<VkPhysicalDeviceGroupProperties>           devicegroups    = enumeratePhysicalDeviceGroups(vki, instance);
1889
1890         log << TestLog::Integer("NumDevices", "Number of device groups", "", QP_KEY_TAG_NONE, deInt64(devicegroups.size()));
1891
1892         for (size_t ndx = 0; ndx < devicegroups.size(); ndx++)
1893                 log << TestLog::Message << ndx << ": " << devicegroups[ndx] << TestLog::EndMessage;
1894
1895         CheckEnumeratePhysicalDeviceGroupsIncompleteResult()(context, results, devicegroups.size());
1896
1897         return tcu::TestStatus(results.getResult(), results.getMessage());
1898 }
1899
1900 template<typename T>
1901 void collectDuplicates (set<T>& duplicates, const vector<T>& values)
1902 {
1903         set<T> seen;
1904
1905         for (size_t ndx = 0; ndx < values.size(); ndx++)
1906         {
1907                 const T& value = values[ndx];
1908
1909                 if (!seen.insert(value).second)
1910                         duplicates.insert(value);
1911         }
1912 }
1913
1914 void checkDuplicates (tcu::ResultCollector& results, const char* what, const vector<string>& values)
1915 {
1916         set<string> duplicates;
1917
1918         collectDuplicates(duplicates, values);
1919
1920         for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter)
1921         {
1922                 std::ostringstream msg;
1923                 msg << "Duplicate " << what << ": " << *iter;
1924                 results.fail(msg.str());
1925         }
1926 }
1927
1928 void checkDuplicateExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
1929 {
1930         checkDuplicates(results, "extension", extensions);
1931 }
1932
1933 void checkDuplicateLayers (tcu::ResultCollector& results, const vector<string>& layers)
1934 {
1935         checkDuplicates(results, "layer", layers);
1936 }
1937
1938 void checkKhrExtensions (tcu::ResultCollector&          results,
1939                                                  const vector<string>&          extensions,
1940                                                  const int                                      numAllowedKhrExtensions,
1941                                                  const char* const*                     allowedKhrExtensions)
1942 {
1943         const set<string>       allowedExtSet           (allowedKhrExtensions, allowedKhrExtensions+numAllowedKhrExtensions);
1944
1945         for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter)
1946         {
1947                 // Only Khronos-controlled extensions are checked
1948                 if (de::beginsWith(*extIter, "VK_KHR_") &&
1949                         !de::contains(allowedExtSet, *extIter))
1950                 {
1951                         results.fail("Unknown extension " + *extIter);
1952                 }
1953         }
1954 }
1955
1956 void checkInstanceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
1957 {
1958 #include "vkInstanceExtensions.inl"
1959
1960         checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
1961         checkDuplicateExtensions(results, extensions);
1962 }
1963
1964 void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
1965 {
1966 #include "vkDeviceExtensions.inl"
1967
1968         checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedDeviceKhrExtensions), s_allowedDeviceKhrExtensions);
1969         checkDuplicateExtensions(results, extensions);
1970 }
1971
1972 void checkInstanceExtensionDependencies(tcu::ResultCollector&                                                                                   results,
1973                                                                                 int                                                                                                                             dependencyLength,
1974                                                                                 const std::tuple<deUint32, deUint32, const char*, const char*>* dependencies,
1975                                                                                 deUint32                                                                                                                versionMajor,
1976                                                                                 deUint32                                                                                                                versionMinor,
1977                                                                                 const vector<VkExtensionProperties>&                                                    extensionProperties)
1978 {
1979         for (int ndx = 0; ndx < dependencyLength; ndx++)
1980         {
1981                 deUint32 currentVersionMajor, currentVersionMinor;
1982                 const char* extensionFirst;
1983                 const char* extensionSecond;
1984                 std::tie(currentVersionMajor, currentVersionMinor, extensionFirst, extensionSecond) = dependencies[ndx];
1985                 if (currentVersionMajor != versionMajor || currentVersionMinor != versionMinor)
1986                         continue;
1987                 if (isExtensionSupported(extensionProperties, RequiredExtension(extensionFirst)) &&
1988                         !isExtensionSupported(extensionProperties, RequiredExtension(extensionSecond)))
1989                 {
1990                         results.fail("Extension " + string(extensionFirst) + " is missing dependency: " + string(extensionSecond));
1991                 }
1992         }
1993 }
1994
1995 void checkDeviceExtensionDependencies(tcu::ResultCollector&                                                                                             results,
1996                                                                           int                                                                                                                           dependencyLength,
1997                                                                           const std::tuple<deUint32, deUint32, const char*, const char*>*       dependencies,
1998                                                                           deUint32                                                                                                                      versionMajor,
1999                                                                           deUint32                                                                                                                      versionMinor,
2000                                                                           const vector<VkExtensionProperties>&                                                          instanceExtensionProperties,
2001                                                                           const vector<VkExtensionProperties>&                                                          deviceExtensionProperties)
2002 {
2003         for (int ndx = 0; ndx < dependencyLength; ndx++)
2004         {
2005                 deUint32 currentVersionMajor, currentVersionMinor;
2006                 const char* extensionFirst;
2007                 const char* extensionSecond;
2008                 std::tie(currentVersionMajor, currentVersionMinor, extensionFirst, extensionSecond) = dependencies[ndx];
2009                 if (currentVersionMajor != versionMajor || currentVersionMinor != versionMinor)
2010                         continue;
2011                 if (isExtensionSupported(deviceExtensionProperties, RequiredExtension(extensionFirst)) &&
2012                         !isExtensionSupported(deviceExtensionProperties, RequiredExtension(extensionSecond)) &&
2013                         !isExtensionSupported(instanceExtensionProperties, RequiredExtension(extensionSecond)))
2014                 {
2015                         results.fail("Extension " + string(extensionFirst) + " is missing dependency: " + string(extensionSecond));
2016                 }
2017         }
2018 }
2019
2020 tcu::TestStatus enumerateInstanceLayers (Context& context)
2021 {
2022         TestLog&                                                log                                     = context.getTestContext().getLog();
2023         tcu::ResultCollector                    results                         (log);
2024         const vector<VkLayerProperties> properties                      = enumerateInstanceLayerProperties(context.getPlatformInterface());
2025         vector<string>                                  layerNames;
2026
2027         for (size_t ndx = 0; ndx < properties.size(); ndx++)
2028         {
2029                 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
2030
2031                 layerNames.push_back(properties[ndx].layerName);
2032         }
2033
2034         checkDuplicateLayers(results, layerNames);
2035         CheckEnumerateInstanceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
2036
2037         return tcu::TestStatus(results.getResult(), results.getMessage());
2038 }
2039
2040 tcu::TestStatus enumerateInstanceExtensions (Context& context)
2041 {
2042         TestLog&                                log             = context.getTestContext().getLog();
2043         tcu::ResultCollector    results (log);
2044
2045         {
2046                 const ScopedLogSection                          section         (log, "Global", "Global Extensions");
2047                 const vector<VkExtensionProperties>     properties      = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
2048                 vector<string>                                          extensionNames;
2049
2050                 for (size_t ndx = 0; ndx < properties.size(); ndx++)
2051                 {
2052                         log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
2053
2054                         extensionNames.push_back(properties[ndx].extensionName);
2055                 }
2056
2057                 checkInstanceExtensions(results, extensionNames);
2058                 CheckEnumerateInstanceExtensionPropertiesIncompleteResult()(context, results, properties.size());
2059
2060                 for (const auto& version : releasedApiVersions)
2061                 {
2062                         deUint32 versionMajor, versionMinor;
2063                         std::tie(std::ignore, versionMajor, versionMinor) = version;
2064                         if (context.contextSupports(vk::ApiVersion(versionMajor, versionMinor, 0)))
2065                         {
2066                                 checkInstanceExtensionDependencies(results,
2067                                         DE_LENGTH_OF_ARRAY(instanceExtensionDependencies),
2068                                         instanceExtensionDependencies,
2069                                         versionMajor,
2070                                         versionMinor,
2071                                         properties);
2072                                 break;
2073                         }
2074                 }
2075         }
2076
2077         {
2078                 const vector<VkLayerProperties> layers  = enumerateInstanceLayerProperties(context.getPlatformInterface());
2079
2080                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
2081                 {
2082                         const ScopedLogSection                          section                         (log, layer->layerName, string("Layer: ") + layer->layerName);
2083                         const vector<VkExtensionProperties>     properties                      = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
2084                         vector<string>                                          extensionNames;
2085
2086                         for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
2087                         {
2088                                 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
2089
2090                                 extensionNames.push_back(properties[extNdx].extensionName);
2091                         }
2092
2093                         checkInstanceExtensions(results, extensionNames);
2094                         CheckEnumerateInstanceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
2095                 }
2096         }
2097
2098         return tcu::TestStatus(results.getResult(), results.getMessage());
2099 }
2100
2101 tcu::TestStatus testNoKhxExtensions (Context& context)
2102 {
2103         VkPhysicalDevice                        physicalDevice  = context.getPhysicalDevice();
2104         const PlatformInterface&        vkp                             = context.getPlatformInterface();
2105         const InstanceInterface&        vki                             = context.getInstanceInterface();
2106
2107         tcu::ResultCollector            results(context.getTestContext().getLog());
2108         bool                                            testSucceeded = true;
2109         deUint32                                        instanceExtensionsCount;
2110         deUint32                                        deviceExtensionsCount;
2111
2112         // grab number of instance and device extensions
2113         vkp.enumerateInstanceExtensionProperties(DE_NULL, &instanceExtensionsCount, DE_NULL);
2114         vki.enumerateDeviceExtensionProperties(physicalDevice, DE_NULL, &deviceExtensionsCount, DE_NULL);
2115         vector<VkExtensionProperties> extensionsProperties(instanceExtensionsCount + deviceExtensionsCount);
2116
2117         // grab instance and device extensions into single vector
2118         if (instanceExtensionsCount)
2119                 vkp.enumerateInstanceExtensionProperties(DE_NULL, &instanceExtensionsCount, &extensionsProperties[0]);
2120         if (deviceExtensionsCount)
2121                 vki.enumerateDeviceExtensionProperties(physicalDevice, DE_NULL, &deviceExtensionsCount, &extensionsProperties[instanceExtensionsCount]);
2122
2123         // iterate over all extensions and verify their names
2124         vector<VkExtensionProperties>::const_iterator extension = extensionsProperties.begin();
2125         while (extension != extensionsProperties.end())
2126         {
2127                 // KHX author ID is no longer used, all KHX extensions have been promoted to KHR status
2128                 std::string extensionName(extension->extensionName);
2129                 bool caseFailed = de::beginsWith(extensionName, "VK_KHX_");
2130                 if (caseFailed)
2131                 {
2132                         results.fail("Invalid extension name " + extensionName);
2133                         testSucceeded = false;
2134                 }
2135                 ++extension;
2136         }
2137
2138         if (testSucceeded)
2139                 return tcu::TestStatus::pass("No extensions begining with \"VK_KHX\"");
2140         return tcu::TestStatus::fail("One or more extensions begins with \"VK_KHX\"");
2141 }
2142
2143 tcu::TestStatus enumerateDeviceLayers (Context& context)
2144 {
2145         TestLog&                                                log                     = context.getTestContext().getLog();
2146         tcu::ResultCollector                    results         (log);
2147         const vector<VkLayerProperties> properties      = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2148         vector<string>                                  layerNames;
2149
2150         for (size_t ndx = 0; ndx < properties.size(); ndx++)
2151         {
2152                 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
2153
2154                 layerNames.push_back(properties[ndx].layerName);
2155         }
2156
2157         checkDuplicateLayers(results, layerNames);
2158         CheckEnumerateDeviceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
2159
2160         return tcu::TestStatus(results.getResult(), results.getMessage());
2161 }
2162
2163 tcu::TestStatus enumerateDeviceExtensions (Context& context)
2164 {
2165         TestLog&                                log             = context.getTestContext().getLog();
2166         tcu::ResultCollector    results (log);
2167
2168         {
2169                 const ScopedLogSection                          section                                         (log, "Global", "Global Extensions");
2170                 const vector<VkExtensionProperties>     instanceExtensionProperties     = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
2171                 const vector<VkExtensionProperties>     deviceExtensionProperties       = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
2172                 vector<string>                                          deviceExtensionNames;
2173
2174                 for (size_t ndx = 0; ndx < deviceExtensionProperties.size(); ndx++)
2175                 {
2176                         log << TestLog::Message << ndx << ": " << deviceExtensionProperties[ndx] << TestLog::EndMessage;
2177
2178                         deviceExtensionNames.push_back(deviceExtensionProperties[ndx].extensionName);
2179                 }
2180
2181                 checkDeviceExtensions(results, deviceExtensionNames);
2182                 CheckEnumerateDeviceExtensionPropertiesIncompleteResult()(context, results, deviceExtensionProperties.size());
2183
2184                 for (const auto& version : releasedApiVersions)
2185                 {
2186                         deUint32 versionMajor, versionMinor;
2187                         std::tie(std::ignore, versionMajor, versionMinor) = version;
2188                         if (context.contextSupports(vk::ApiVersion(versionMajor, versionMinor, 0)))
2189                         {
2190                                 checkDeviceExtensionDependencies(results,
2191                                         DE_LENGTH_OF_ARRAY(deviceExtensionDependencies),
2192                                         deviceExtensionDependencies,
2193                                         versionMajor,
2194                                         versionMinor,
2195                                         instanceExtensionProperties,
2196                                         deviceExtensionProperties);
2197                                 break;
2198                         }
2199                 }
2200         }
2201
2202         {
2203                 const vector<VkLayerProperties> layers  = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2204
2205                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
2206                 {
2207                         const ScopedLogSection                          section         (log, layer->layerName, string("Layer: ") + layer->layerName);
2208                         const vector<VkExtensionProperties>     properties      = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
2209                         vector<string>                                          extensionNames;
2210
2211                         for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
2212                         {
2213                                 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
2214
2215
2216                                 extensionNames.push_back(properties[extNdx].extensionName);
2217                         }
2218
2219                         checkDeviceExtensions(results, extensionNames);
2220                         CheckEnumerateDeviceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
2221                 }
2222         }
2223
2224         return tcu::TestStatus(results.getResult(), results.getMessage());
2225 }
2226
2227 tcu::TestStatus extensionCoreVersions (Context& context)
2228 {
2229         deUint32        major;
2230         deUint32        minor;
2231         const char*     extName;
2232
2233         auto&                                   log             = context.getTestContext().getLog();
2234         tcu::ResultCollector    results (log);
2235
2236         const auto instanceExtensionProperties  = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
2237         const auto deviceExtensionProperties    = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
2238
2239         for (const auto& majorMinorName : extensionRequiredCoreVersion)
2240         {
2241                 std::tie(major, minor, extName) = majorMinorName;
2242                 const RequiredExtension reqExt (extName);
2243
2244                 if ((isExtensionSupported(instanceExtensionProperties, reqExt) || isExtensionSupported(deviceExtensionProperties, reqExt)) &&
2245                     !context.contextSupports(vk::ApiVersion(major, minor, 0u)))
2246                 {
2247                         results.fail("Required core version for " + std::string(extName) + " not met (" + de::toString(major) + "." + de::toString(minor) + ")");
2248                 }
2249         }
2250
2251         return tcu::TestStatus(results.getResult(), results.getMessage());
2252 }
2253
2254 #define VK_SIZE_OF(STRUCT, MEMBER)                                      (sizeof(((STRUCT*)0)->MEMBER))
2255 #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER)                      { (size_t)DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) }
2256
2257 tcu::TestStatus deviceFeatures (Context& context)
2258 {
2259         using namespace ValidateQueryBits;
2260
2261         TestLog&                                                log                     = context.getTestContext().getLog();
2262         VkPhysicalDeviceFeatures*               features;
2263         deUint8                                                 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE];
2264
2265         const QueryMemberTableEntry featureOffsetTable[] =
2266         {
2267                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess),
2268                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32),
2269                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray),
2270                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend),
2271                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader),
2272                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader),
2273                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading),
2274                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend),
2275                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp),
2276                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect),
2277                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance),
2278                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp),
2279                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp),
2280                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid),
2281                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds),
2282                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines),
2283                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints),
2284                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne),
2285                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport),
2286                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy),
2287                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2),
2288                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR),
2289                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC),
2290                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise),
2291                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery),
2292                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics),
2293                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics),
2294                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize),
2295                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended),
2296                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats),
2297                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample),
2298                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat),
2299                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat),
2300                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing),
2301                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing),
2302                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing),
2303                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing),
2304                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance),
2305                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance),
2306                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64),
2307                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64),
2308                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16),
2309                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency),
2310                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod),
2311                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding),
2312                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer),
2313                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D),
2314                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D),
2315                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples),
2316                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples),
2317                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples),
2318                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples),
2319                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased),
2320                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate),
2321                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries),
2322                 { 0, 0 }
2323         };
2324
2325         deMemset(buffer, GUARD_VALUE, sizeof(buffer));
2326         features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer);
2327
2328         context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features);
2329
2330         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
2331                 << TestLog::Message << *features << TestLog::EndMessage;
2332
2333         // Requirements and dependencies
2334         {
2335                 if (!features->robustBufferAccess)
2336                         return tcu::TestStatus::fail("robustBufferAccess is not supported");
2337
2338                 // multiViewport requires MultiViewport (SPIR-V capability) support, which depends on Geometry
2339                 if (features->multiViewport && !features->geometryShader)
2340                         return tcu::TestStatus::fail("multiViewport is supported but geometryShader is not");
2341         }
2342
2343         for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
2344         {
2345                 if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE)
2346                 {
2347                         log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
2348                         return tcu::TestStatus::fail("deviceFeatures buffer overflow");
2349                 }
2350         }
2351
2352         if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable))
2353         {
2354                 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage;
2355                 return tcu::TestStatus::fail("deviceFeatures incomplete initialization");
2356         }
2357
2358         return tcu::TestStatus::pass("Query succeeded");
2359 }
2360
2361 static const ValidateQueryBits::QueryMemberTableEntry s_physicalDevicePropertiesOffsetTable[] =
2362 {
2363         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion),
2364         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion),
2365         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID),
2366         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID),
2367         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType),
2368         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID),
2369         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D),
2370         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D),
2371         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D),
2372         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube),
2373         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers),
2374         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements),
2375         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange),
2376         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange),
2377         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize),
2378         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount),
2379         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount),
2380         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity),
2381         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize),
2382         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets),
2383         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers),
2384         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers),
2385         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers),
2386         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages),
2387         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages),
2388         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments),
2389         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources),
2390         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers),
2391         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers),
2392         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic),
2393         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers),
2394         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic),
2395         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages),
2396         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages),
2397         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments),
2398         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes),
2399         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings),
2400         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset),
2401         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride),
2402         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents),
2403         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel),
2404         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize),
2405         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents),
2406         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents),
2407         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents),
2408         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents),
2409         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents),
2410         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents),
2411         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations),
2412         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents),
2413         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents),
2414         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices),
2415         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents),
2416         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents),
2417         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments),
2418         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments),
2419         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources),
2420         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize),
2421         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]),
2422         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations),
2423         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]),
2424         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits),
2425         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits),
2426         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits),
2427         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue),
2428         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount),
2429         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias),
2430         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy),
2431         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports),
2432         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]),
2433         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]),
2434         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits),
2435         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment),
2436         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment),
2437         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment),
2438         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment),
2439         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset),
2440         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset),
2441         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset),
2442         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset),
2443         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset),
2444         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset),
2445         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits),
2446         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth),
2447         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight),
2448         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers),
2449         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts),
2450         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts),
2451         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts),
2452         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts),
2453         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments),
2454         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts),
2455         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts),
2456         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts),
2457         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts),
2458         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts),
2459         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords),
2460         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics),
2461         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod),
2462         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances),
2463         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances),
2464         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances),
2465         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities),
2466         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]),
2467         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]),
2468         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity),
2469         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity),
2470         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines),
2471         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations),
2472         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment),
2473         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment),
2474         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize),
2475         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape),
2476         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape),
2477         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape),
2478         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize),
2479         OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict),
2480         { 0, 0 }
2481 };
2482
2483 tcu::TestStatus deviceProperties (Context& context)
2484 {
2485         using namespace ValidateQueryBits;
2486
2487         TestLog&                                                log                     = context.getTestContext().getLog();
2488         VkPhysicalDeviceProperties*             props;
2489         VkPhysicalDeviceFeatures                features;
2490         deUint8                                                 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE];
2491
2492         props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer);
2493         deMemset(props, GUARD_VALUE, sizeof(buffer));
2494
2495         context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props);
2496         context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features);
2497
2498         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
2499                 << TestLog::Message << *props << TestLog::EndMessage;
2500
2501         if (!validateFeatureLimits(props, &features, log))
2502                 return tcu::TestStatus::fail("deviceProperties - feature limits failed");
2503
2504         for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
2505         {
2506                 if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE)
2507                 {
2508                         log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
2509                         return tcu::TestStatus::fail("deviceProperties buffer overflow");
2510                 }
2511         }
2512
2513         if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), s_physicalDevicePropertiesOffsetTable))
2514         {
2515                 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage;
2516                 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
2517         }
2518
2519         // Check if deviceName string is properly terminated.
2520         if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE)
2521         {
2522                 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage;
2523                 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
2524         }
2525
2526         {
2527                 const ApiVersion deviceVersion = unpackVersion(props->apiVersion);
2528                 const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION_1_2);
2529
2530                 if (deviceVersion.majorNum != deqpVersion.majorNum)
2531                 {
2532                         log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage;
2533                         return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
2534                 }
2535
2536                 if (deviceVersion.minorNum > deqpVersion.minorNum)
2537                 {
2538                         log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage;
2539                         return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
2540                 }
2541         }
2542
2543         return tcu::TestStatus::pass("DeviceProperites query succeeded");
2544 }
2545
2546 tcu::TestStatus deviceQueueFamilyProperties (Context& context)
2547 {
2548         TestLog&                                                                log                                     = context.getTestContext().getLog();
2549         const vector<VkQueueFamilyProperties>   queueProperties         = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2550
2551         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage;
2552
2553         for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++)
2554                 log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage;
2555
2556         return tcu::TestStatus::pass("Querying queue properties succeeded");
2557 }
2558
2559 tcu::TestStatus deviceMemoryProperties (Context& context)
2560 {
2561         TestLog&                                                        log                     = context.getTestContext().getLog();
2562         VkPhysicalDeviceMemoryProperties*       memProps;
2563         deUint8                                                         buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE];
2564
2565         memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer);
2566         deMemset(buffer, GUARD_VALUE, sizeof(buffer));
2567
2568         context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps);
2569
2570         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
2571                 << TestLog::Message << *memProps << TestLog::EndMessage;
2572
2573         for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
2574         {
2575                 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE)
2576                 {
2577                         log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
2578                         return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow");
2579                 }
2580         }
2581
2582         if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS)
2583         {
2584                 log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage;
2585                 return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large");
2586         }
2587
2588         if (memProps->memoryHeapCount == 1)
2589         {
2590                 if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
2591                 {
2592                         log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage;
2593                         return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags");
2594                 }
2595         }
2596
2597         const VkMemoryPropertyFlags validPropertyFlags[] =
2598         {
2599                 0,
2600                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
2601                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
2602                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
2603                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
2604                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
2605                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
2606                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
2607                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
2608         };
2609
2610         const VkMemoryPropertyFlags requiredPropertyFlags[] =
2611         {
2612                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
2613         };
2614
2615         bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)];
2616         std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
2617
2618         for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++)
2619         {
2620                 bool validPropTypeFound = false;
2621
2622                 if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount)
2623                 {
2624                         log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage;
2625                         return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex");
2626                 }
2627
2628                 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;
2629
2630                 for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++)
2631                         if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator)
2632                                 requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true;
2633
2634                 if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck))
2635                         validPropTypeFound = true;
2636
2637                 if (!validPropTypeFound)
2638                 {
2639                         log << TestLog::Message << "deviceMemoryProperties - propertyFlags "
2640                                 << memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage;
2641                         return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
2642                 }
2643
2644                 if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
2645                 {
2646                         if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
2647                         {
2648                                 log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage;
2649                                 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
2650                         }
2651                 }
2652                 else
2653                 {
2654                         if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
2655                         {
2656                                 log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage;
2657                                 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
2658                         }
2659                 }
2660         }
2661
2662         bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
2663         if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound))
2664         {
2665                 DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags));
2666                 log << TestLog::Message << "deviceMemoryProperties - required property flags "
2667                         << getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage;
2668
2669                 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
2670         }
2671
2672         return tcu::TestStatus::pass("Querying memory properties succeeded");
2673 }
2674
2675 tcu::TestStatus deviceGroupPeerMemoryFeatures (Context& context)
2676 {
2677         TestLog&                                                        log                                             = context.getTestContext().getLog();
2678         const PlatformInterface&                        vkp                                             = context.getPlatformInterface();
2679         const CustomInstance                            instance                                (createCustomInstanceWithExtension(context, "VK_KHR_device_group_creation"));
2680         const InstanceDriver&                           vki                                             (instance.getDriver());
2681         const tcu::CommandLine&                         cmdLine                                 = context.getTestContext().getCommandLine();
2682         const deUint32                                          devGroupIdx                             = cmdLine.getVKDeviceGroupId() - 1;
2683         const deUint32                                          deviceIdx                               = vk::chooseDeviceIndex(context.getInstanceInterface(), instance, cmdLine);
2684         const float                                                     queuePriority                   = 1.0f;
2685         VkPhysicalDeviceMemoryProperties        memProps;
2686         VkPeerMemoryFeatureFlags*                       peerMemFeatures;
2687         deUint8                                                         buffer                                  [sizeof(VkPeerMemoryFeatureFlags) + GUARD_SIZE];
2688         deUint32                                                        numPhysicalDevices              = 0;
2689         deUint32                                                        queueFamilyIndex                = 0;
2690
2691         const vector<VkPhysicalDeviceGroupProperties>           deviceGroupProps = enumeratePhysicalDeviceGroups(vki, instance);
2692         std::vector<const char*>                                                        deviceExtensions;
2693         deviceExtensions.push_back("VK_KHR_device_group");
2694
2695         if (!isCoreDeviceExtension(context.getUsedApiVersion(), "VK_KHR_device_group"))
2696                 deviceExtensions.push_back("VK_KHR_device_group");
2697
2698         const std::vector<VkQueueFamilyProperties>      queueProps              = getPhysicalDeviceQueueFamilyProperties(vki, deviceGroupProps[devGroupIdx].physicalDevices[deviceIdx]);
2699         for (size_t queueNdx = 0; queueNdx < queueProps.size(); queueNdx++)
2700         {
2701                 if (queueProps[queueNdx].queueFlags & VK_QUEUE_GRAPHICS_BIT)
2702                         queueFamilyIndex = (deUint32)queueNdx;
2703         }
2704         const VkDeviceQueueCreateInfo           deviceQueueCreateInfo   =
2705         {
2706                 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,                     //type
2707                 DE_NULL,                                                                                        //pNext
2708                 (VkDeviceQueueCreateFlags)0u,                                           //flags
2709                 queueFamilyIndex,                                                                       //queueFamilyIndex;
2710                 1u,                                                                                                     //queueCount;
2711                 &queuePriority,                                                                         //pQueuePriorities;
2712         };
2713
2714         // Need atleast 2 devices for peer memory features
2715         numPhysicalDevices = deviceGroupProps[devGroupIdx].physicalDeviceCount;
2716         if (numPhysicalDevices < 2)
2717                 TCU_THROW(NotSupportedError, "Need a device Group with at least 2 physical devices.");
2718
2719         // Create device groups
2720         const VkDeviceGroupDeviceCreateInfo                                             deviceGroupInfo =
2721         {
2722                 VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO,      //stype
2723                 DE_NULL,                                                                                        //pNext
2724                 deviceGroupProps[devGroupIdx].physicalDeviceCount,      //physicalDeviceCount
2725                 deviceGroupProps[devGroupIdx].physicalDevices           //physicalDevices
2726         };
2727
2728         const VkDeviceCreateInfo                                                                deviceCreateInfo =
2729         {
2730                 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,                                                   //sType;
2731                 &deviceGroupInfo,                                                                                               //pNext;
2732                 (VkDeviceCreateFlags)0u,                                                                                //flags
2733                 1,                                                                                                                              //queueRecordCount;
2734                 &deviceQueueCreateInfo,                                                                                 //pRequestedQueues;
2735                 0,                                                                                                                              //layerCount;
2736                 DE_NULL,                                                                                                                //ppEnabledLayerNames;
2737                 deUint32(deviceExtensions.size()),                                                              //extensionCount;
2738                 (deviceExtensions.empty() ? DE_NULL : &deviceExtensions[0]),    //ppEnabledExtensionNames;
2739                 DE_NULL,                                                                                                                //pEnabledFeatures;
2740         };
2741
2742         Move<VkDevice>          deviceGroup = createCustomDevice(context.getTestContext().getCommandLine().isValidationEnabled(), vkp, instance, vki, deviceGroupProps[devGroupIdx].physicalDevices[deviceIdx], &deviceCreateInfo);
2743         const DeviceDriver      vk      (vkp, instance, *deviceGroup);
2744         context.getInstanceInterface().getPhysicalDeviceMemoryProperties(deviceGroupProps[devGroupIdx].physicalDevices[deviceIdx], &memProps);
2745
2746         peerMemFeatures = reinterpret_cast<VkPeerMemoryFeatureFlags*>(buffer);
2747         deMemset(buffer, GUARD_VALUE, sizeof(buffer));
2748
2749         for (deUint32 heapIndex = 0; heapIndex < memProps.memoryHeapCount; heapIndex++)
2750         {
2751                 for (deUint32 localDeviceIndex = 0; localDeviceIndex < numPhysicalDevices; localDeviceIndex++)
2752                 {
2753                         for (deUint32 remoteDeviceIndex = 0; remoteDeviceIndex < numPhysicalDevices; remoteDeviceIndex++)
2754                         {
2755                                 if (localDeviceIndex != remoteDeviceIndex)
2756                                 {
2757                                         vk.getDeviceGroupPeerMemoryFeatures(deviceGroup.get(), heapIndex, localDeviceIndex, remoteDeviceIndex, peerMemFeatures);
2758
2759                                         // Check guard
2760                                         for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
2761                                         {
2762                                                 if (buffer[ndx + sizeof(VkPeerMemoryFeatureFlags)] != GUARD_VALUE)
2763                                                 {
2764                                                         log << TestLog::Message << "deviceGroupPeerMemoryFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
2765                                                         return tcu::TestStatus::fail("deviceGroupPeerMemoryFeatures buffer overflow");
2766                                                 }
2767                                         }
2768
2769                                         VkPeerMemoryFeatureFlags requiredFlag = VK_PEER_MEMORY_FEATURE_COPY_DST_BIT;
2770                                         VkPeerMemoryFeatureFlags maxValidFlag = VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT|VK_PEER_MEMORY_FEATURE_COPY_DST_BIT|
2771                                                                                                                                 VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT|VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT;
2772                                         if ((!(*peerMemFeatures & requiredFlag)) ||
2773                                                 *peerMemFeatures > maxValidFlag)
2774                                                 return tcu::TestStatus::fail("deviceGroupPeerMemoryFeatures invalid flag");
2775
2776                                         log << TestLog::Message << "deviceGroup = " << deviceGroup.get() << TestLog::EndMessage
2777                                                 << TestLog::Message << "heapIndex = " << heapIndex << TestLog::EndMessage
2778                                                 << TestLog::Message << "localDeviceIndex = " << localDeviceIndex << TestLog::EndMessage
2779                                                 << TestLog::Message << "remoteDeviceIndex = " << remoteDeviceIndex << TestLog::EndMessage
2780                                                 << TestLog::Message << "PeerMemoryFeatureFlags = " << *peerMemFeatures << TestLog::EndMessage;
2781                                 }
2782                         } // remote device
2783                 } // local device
2784         } // heap Index
2785
2786         return tcu::TestStatus::pass("Querying deviceGroup peer memory features succeeded");
2787 }
2788
2789 tcu::TestStatus deviceMemoryBudgetProperties (Context& context)
2790 {
2791         TestLog&                                                        log                     = context.getTestContext().getLog();
2792         deUint8                                                         buffer[sizeof(VkPhysicalDeviceMemoryBudgetPropertiesEXT) + GUARD_SIZE];
2793
2794         if (!context.isDeviceFunctionalitySupported("VK_EXT_memory_budget"))
2795                 TCU_THROW(NotSupportedError, "VK_EXT_memory_budget is not supported");
2796
2797         VkPhysicalDeviceMemoryBudgetPropertiesEXT *budgetProps = reinterpret_cast<VkPhysicalDeviceMemoryBudgetPropertiesEXT *>(buffer);
2798         deMemset(buffer, GUARD_VALUE, sizeof(buffer));
2799
2800         budgetProps->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
2801         budgetProps->pNext = DE_NULL;
2802
2803         VkPhysicalDeviceMemoryProperties2       memProps;
2804         deMemset(&memProps, 0, sizeof(memProps));
2805         memProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
2806         memProps.pNext = budgetProps;
2807
2808         context.getInstanceInterface().getPhysicalDeviceMemoryProperties2(context.getPhysicalDevice(), &memProps);
2809
2810         log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
2811                 << TestLog::Message << *budgetProps << TestLog::EndMessage;
2812
2813         for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
2814         {
2815                 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryBudgetPropertiesEXT)] != GUARD_VALUE)
2816                 {
2817                         log << TestLog::Message << "deviceMemoryBudgetProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
2818                         return tcu::TestStatus::fail("deviceMemoryBudgetProperties buffer overflow");
2819                 }
2820         }
2821
2822         for (deUint32 i = 0; i < memProps.memoryProperties.memoryHeapCount; ++i)
2823         {
2824                 if (budgetProps->heapBudget[i] == 0)
2825                 {
2826                         log << TestLog::Message << "deviceMemoryBudgetProperties - Supported heaps must report nonzero budget" << TestLog::EndMessage;
2827                         return tcu::TestStatus::fail("deviceMemoryBudgetProperties invalid heap budget (zero)");
2828                 }
2829                 if (budgetProps->heapBudget[i] > memProps.memoryProperties.memoryHeaps[i].size)
2830                 {
2831                         log << TestLog::Message << "deviceMemoryBudgetProperties - Heap budget must be less than or equal to heap size" << TestLog::EndMessage;
2832                         return tcu::TestStatus::fail("deviceMemoryBudgetProperties invalid heap budget (too large)");
2833                 }
2834         }
2835
2836         for (deUint32 i = memProps.memoryProperties.memoryHeapCount; i < VK_MAX_MEMORY_HEAPS; ++i)
2837         {
2838                 if (budgetProps->heapBudget[i] != 0 || budgetProps->heapUsage[i] != 0)
2839                 {
2840                         log << TestLog::Message << "deviceMemoryBudgetProperties - Unused heaps must report budget/usage of zero" << TestLog::EndMessage;
2841                         return tcu::TestStatus::fail("deviceMemoryBudgetProperties invalid unused heaps");
2842                 }
2843         }
2844
2845         return tcu::TestStatus::pass("Querying memory budget properties succeeded");
2846 }
2847
2848 namespace
2849 {
2850
2851 #include "vkMandatoryFeatures.inl"
2852
2853 }
2854
2855 tcu::TestStatus deviceMandatoryFeatures(Context& context)
2856 {
2857         if ( checkMandatoryFeatures(context) )
2858                 return tcu::TestStatus::pass("Passed");
2859         return tcu::TestStatus::fail("Not all mandatory features are supported ( see: vkspec.html#features-requirements )");
2860 }
2861
2862 VkFormatFeatureFlags getBaseRequiredOptimalTilingFeatures (VkFormat format)
2863 {
2864         struct Formatpair
2865         {
2866                 VkFormat                                format;
2867                 VkFormatFeatureFlags    flags;
2868         };
2869
2870         enum
2871         {
2872                 SAIM = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT,
2873                 BLSR = VK_FORMAT_FEATURE_BLIT_SRC_BIT,
2874                 SIFL = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT,
2875                 COAT = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT,
2876                 BLDS = VK_FORMAT_FEATURE_BLIT_DST_BIT,
2877                 CABL = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT,
2878                 STIM = VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT,
2879                 STIA = VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT,
2880                 DSAT = VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT,
2881                 TRSR = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT,
2882                 TRDS = VK_FORMAT_FEATURE_TRANSFER_DST_BIT
2883         };
2884
2885         static const Formatpair formatflags[] =
2886         {
2887                 { VK_FORMAT_B4G4R4A4_UNORM_PACK16,              SAIM | BLSR | TRSR | TRDS |               SIFL },
2888                 { VK_FORMAT_R5G6B5_UNORM_PACK16,                SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2889                 { VK_FORMAT_A1R5G5B5_UNORM_PACK16,              SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2890                 { VK_FORMAT_R8_UNORM,                                   SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2891                 { VK_FORMAT_R8_SNORM,                                   SAIM | BLSR | TRSR | TRDS |               SIFL },
2892                 { VK_FORMAT_R8_UINT,                                    SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2893                 { VK_FORMAT_R8_SINT,                                    SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2894                 { VK_FORMAT_R8G8_UNORM,                                 SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2895                 { VK_FORMAT_R8G8_SNORM,                                 SAIM | BLSR | TRSR | TRDS |               SIFL },
2896                 { VK_FORMAT_R8G8_UINT,                                  SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2897                 { VK_FORMAT_R8G8_SINT,                                  SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2898                 { VK_FORMAT_R8G8B8A8_UNORM,                             SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL | STIM | CABL },
2899                 { VK_FORMAT_R8G8B8A8_SNORM,                             SAIM | BLSR | TRSR | TRDS |               SIFL | STIM },
2900                 { VK_FORMAT_R8G8B8A8_UINT,                              SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2901                 { VK_FORMAT_R8G8B8A8_SINT,                              SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2902                 { VK_FORMAT_R8G8B8A8_SRGB,                              SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2903                 { VK_FORMAT_B8G8R8A8_UNORM,                             SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2904                 { VK_FORMAT_B8G8R8A8_SRGB,                              SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2905                 { VK_FORMAT_A8B8G8R8_UNORM_PACK32,              SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2906                 { VK_FORMAT_A8B8G8R8_SNORM_PACK32,              SAIM | BLSR | TRSR | TRDS |               SIFL },
2907                 { VK_FORMAT_A8B8G8R8_UINT_PACK32,               SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2908                 { VK_FORMAT_A8B8G8R8_SINT_PACK32,               SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2909                 { VK_FORMAT_A8B8G8R8_SRGB_PACK32,               SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2910                 { VK_FORMAT_A2B10G10R10_UNORM_PACK32,   SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2911                 { VK_FORMAT_A2B10G10R10_UINT_PACK32,    SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2912                 { VK_FORMAT_R16_UINT,                                   SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2913                 { VK_FORMAT_R16_SINT,                                   SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2914                 { VK_FORMAT_R16_SFLOAT,                                 SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2915                 { VK_FORMAT_R16G16_UINT,                                SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2916                 { VK_FORMAT_R16G16_SINT,                                SAIM | BLSR | TRSR | TRDS | COAT | BLDS },
2917                 { VK_FORMAT_R16G16_SFLOAT,                              SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL |        CABL },
2918                 { VK_FORMAT_R16G16B16A16_UINT,                  SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2919                 { VK_FORMAT_R16G16B16A16_SINT,                  SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2920                 { VK_FORMAT_R16G16B16A16_SFLOAT,                SAIM | BLSR | TRSR | TRDS | COAT | BLDS | SIFL | STIM | CABL },
2921                 { VK_FORMAT_R32_UINT,                                   SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM |        STIA },
2922                 { VK_FORMAT_R32_SINT,                                   SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM |        STIA },
2923                 { VK_FORMAT_R32_SFLOAT,                                 SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2924                 { VK_FORMAT_R32G32_UINT,                                SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2925                 { VK_FORMAT_R32G32_SINT,                                SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2926                 { VK_FORMAT_R32G32_SFLOAT,                              SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2927                 { VK_FORMAT_R32G32B32A32_UINT,                  SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2928                 { VK_FORMAT_R32G32B32A32_SINT,                  SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2929                 { VK_FORMAT_R32G32B32A32_SFLOAT,                SAIM | BLSR | TRSR | TRDS | COAT | BLDS |        STIM },
2930                 { VK_FORMAT_B10G11R11_UFLOAT_PACK32,    SAIM | BLSR | TRSR | TRDS |               SIFL },
2931                 { VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,             SAIM | BLSR | TRSR | TRDS |               SIFL },
2932                 { VK_FORMAT_D16_UNORM,                                  SAIM | BLSR | TRSR | TRDS |                                           DSAT },
2933         };
2934
2935         size_t formatpairs = sizeof(formatflags) / sizeof(Formatpair);
2936
2937         for (unsigned int i = 0; i < formatpairs; i++)
2938                 if (formatflags[i].format == format)
2939                         return formatflags[i].flags;
2940         return 0;
2941 }
2942
2943 VkFormatFeatureFlags getRequiredOptimalExtendedTilingFeatures (Context& context, VkFormat format, VkFormatFeatureFlags queriedFlags)
2944 {
2945         VkFormatFeatureFlags    flags   = (VkFormatFeatureFlags)0;
2946
2947         // VK_EXT_sampler_filter_minmax:
2948         //      If filterMinmaxSingleComponentFormats is VK_TRUE, the following formats must
2949         //      support the VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT feature with
2950         //      VK_IMAGE_TILING_OPTIMAL, if they support VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT.
2951
2952         static const VkFormat s_requiredSampledImageFilterMinMaxFormats[] =
2953         {
2954                 VK_FORMAT_R8_UNORM,
2955                 VK_FORMAT_R8_SNORM,
2956                 VK_FORMAT_R16_UNORM,
2957                 VK_FORMAT_R16_SNORM,
2958                 VK_FORMAT_R16_SFLOAT,
2959                 VK_FORMAT_R32_SFLOAT,
2960                 VK_FORMAT_D16_UNORM,
2961                 VK_FORMAT_X8_D24_UNORM_PACK32,
2962                 VK_FORMAT_D32_SFLOAT,
2963                 VK_FORMAT_D16_UNORM_S8_UINT,
2964                 VK_FORMAT_D24_UNORM_S8_UINT,
2965                 VK_FORMAT_D32_SFLOAT_S8_UINT,
2966         };
2967
2968         if ((queriedFlags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
2969         {
2970                 if (de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_EXT_sampler_filter_minmax"))
2971                 {
2972                         if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterMinMaxFormats), DE_ARRAY_END(s_requiredSampledImageFilterMinMaxFormats), format))
2973                         {
2974                                 VkPhysicalDeviceSamplerFilterMinmaxProperties           physicalDeviceSamplerMinMaxProperties =
2975                                 {
2976                                         VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT,
2977                                         DE_NULL,
2978                                         DE_FALSE,
2979                                         DE_FALSE
2980                                 };
2981
2982                                 {
2983                                         VkPhysicalDeviceProperties2             physicalDeviceProperties;
2984                                         physicalDeviceProperties.sType  = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
2985                                         physicalDeviceProperties.pNext  = &physicalDeviceSamplerMinMaxProperties;
2986
2987                                         const InstanceInterface&                vk = context.getInstanceInterface();
2988                                         vk.getPhysicalDeviceProperties2(context.getPhysicalDevice(), &physicalDeviceProperties);
2989                                 }
2990
2991                                 if (physicalDeviceSamplerMinMaxProperties.filterMinmaxSingleComponentFormats)
2992                                 {
2993                                         flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
2994                                 }
2995                         }
2996                 }
2997         }
2998
2999         // VK_EXT_filter_cubic:
3000         // If cubic filtering is supported, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT must be supported for the following image view types:
3001         // VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_VIEW_TYPE_2D_ARRAY
3002         static const VkFormat s_requiredSampledImageFilterCubicFormats[] =
3003         {
3004                 VK_FORMAT_R4G4_UNORM_PACK8,
3005                 VK_FORMAT_R4G4B4A4_UNORM_PACK16,
3006                 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
3007                 VK_FORMAT_R5G6B5_UNORM_PACK16,
3008                 VK_FORMAT_B5G6R5_UNORM_PACK16,
3009                 VK_FORMAT_R5G5B5A1_UNORM_PACK16,
3010                 VK_FORMAT_B5G5R5A1_UNORM_PACK16,
3011                 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
3012                 VK_FORMAT_R8_UNORM,
3013                 VK_FORMAT_R8_SNORM,
3014                 VK_FORMAT_R8_SRGB,
3015                 VK_FORMAT_R8G8_UNORM,
3016                 VK_FORMAT_R8G8_SNORM,
3017                 VK_FORMAT_R8G8_SRGB,
3018                 VK_FORMAT_R8G8B8_UNORM,
3019                 VK_FORMAT_R8G8B8_SNORM,
3020                 VK_FORMAT_R8G8B8_SRGB,
3021                 VK_FORMAT_B8G8R8_UNORM,
3022                 VK_FORMAT_B8G8R8_SNORM,
3023                 VK_FORMAT_B8G8R8_SRGB,
3024                 VK_FORMAT_R8G8B8A8_UNORM,
3025                 VK_FORMAT_R8G8B8A8_SNORM,
3026                 VK_FORMAT_R8G8B8A8_SRGB,
3027                 VK_FORMAT_B8G8R8A8_UNORM,
3028                 VK_FORMAT_B8G8R8A8_SNORM,
3029                 VK_FORMAT_B8G8R8A8_SRGB,
3030                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3031                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3032                 VK_FORMAT_A8B8G8R8_SRGB_PACK32
3033         };
3034
3035         static const VkFormat s_requiredSampledImageFilterCubicFormatsETC2[] =
3036         {
3037                 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
3038                 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
3039                 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
3040                 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
3041                 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
3042                 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK
3043         };
3044
3045         if ( (queriedFlags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0 && de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_EXT_filter_cubic") )
3046         {
3047                 if ( de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterCubicFormats), DE_ARRAY_END(s_requiredSampledImageFilterCubicFormats), format) )
3048                         flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT;
3049
3050                 VkPhysicalDeviceFeatures2                                               coreFeatures;
3051                 deMemset(&coreFeatures, 0, sizeof(coreFeatures));
3052
3053                 coreFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
3054                 coreFeatures.pNext = DE_NULL;
3055                 context.getInstanceInterface().getPhysicalDeviceFeatures2(context.getPhysicalDevice(), &coreFeatures);
3056                 if ( coreFeatures.features.textureCompressionETC2 && de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterCubicFormatsETC2), DE_ARRAY_END(s_requiredSampledImageFilterCubicFormatsETC2), format) )
3057                         flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT;
3058         }
3059
3060         return flags;
3061 }
3062
3063 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format)
3064 {
3065         static const VkFormat s_requiredVertexBufferFormats[] =
3066         {
3067                 VK_FORMAT_R8_UNORM,
3068                 VK_FORMAT_R8_SNORM,
3069                 VK_FORMAT_R8_UINT,
3070                 VK_FORMAT_R8_SINT,
3071                 VK_FORMAT_R8G8_UNORM,
3072                 VK_FORMAT_R8G8_SNORM,
3073                 VK_FORMAT_R8G8_UINT,
3074                 VK_FORMAT_R8G8_SINT,
3075                 VK_FORMAT_R8G8B8A8_UNORM,
3076                 VK_FORMAT_R8G8B8A8_SNORM,
3077                 VK_FORMAT_R8G8B8A8_UINT,
3078                 VK_FORMAT_R8G8B8A8_SINT,
3079                 VK_FORMAT_B8G8R8A8_UNORM,
3080                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3081                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3082                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3083                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3084                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3085                 VK_FORMAT_R16_UNORM,
3086                 VK_FORMAT_R16_SNORM,
3087                 VK_FORMAT_R16_UINT,
3088                 VK_FORMAT_R16_SINT,
3089                 VK_FORMAT_R16_SFLOAT,
3090                 VK_FORMAT_R16G16_UNORM,
3091                 VK_FORMAT_R16G16_SNORM,
3092                 VK_FORMAT_R16G16_UINT,
3093                 VK_FORMAT_R16G16_SINT,
3094                 VK_FORMAT_R16G16_SFLOAT,
3095                 VK_FORMAT_R16G16B16A16_UNORM,
3096                 VK_FORMAT_R16G16B16A16_SNORM,
3097                 VK_FORMAT_R16G16B16A16_UINT,
3098                 VK_FORMAT_R16G16B16A16_SINT,
3099                 VK_FORMAT_R16G16B16A16_SFLOAT,
3100                 VK_FORMAT_R32_UINT,
3101                 VK_FORMAT_R32_SINT,
3102                 VK_FORMAT_R32_SFLOAT,
3103                 VK_FORMAT_R32G32_UINT,
3104                 VK_FORMAT_R32G32_SINT,
3105                 VK_FORMAT_R32G32_SFLOAT,
3106                 VK_FORMAT_R32G32B32_UINT,
3107                 VK_FORMAT_R32G32B32_SINT,
3108                 VK_FORMAT_R32G32B32_SFLOAT,
3109                 VK_FORMAT_R32G32B32A32_UINT,
3110                 VK_FORMAT_R32G32B32A32_SINT,
3111                 VK_FORMAT_R32G32B32A32_SFLOAT
3112         };
3113         static const VkFormat s_requiredUniformTexelBufferFormats[] =
3114         {
3115                 VK_FORMAT_R8_UNORM,
3116                 VK_FORMAT_R8_SNORM,
3117                 VK_FORMAT_R8_UINT,
3118                 VK_FORMAT_R8_SINT,
3119                 VK_FORMAT_R8G8_UNORM,
3120                 VK_FORMAT_R8G8_SNORM,
3121                 VK_FORMAT_R8G8_UINT,
3122                 VK_FORMAT_R8G8_SINT,
3123                 VK_FORMAT_R8G8B8A8_UNORM,
3124                 VK_FORMAT_R8G8B8A8_SNORM,
3125                 VK_FORMAT_R8G8B8A8_UINT,
3126                 VK_FORMAT_R8G8B8A8_SINT,
3127                 VK_FORMAT_B8G8R8A8_UNORM,
3128                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3129                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3130                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3131                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3132                 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
3133                 VK_FORMAT_A2B10G10R10_UINT_PACK32,
3134                 VK_FORMAT_R16_UINT,
3135                 VK_FORMAT_R16_SINT,
3136                 VK_FORMAT_R16_SFLOAT,
3137                 VK_FORMAT_R16G16_UINT,
3138                 VK_FORMAT_R16G16_SINT,
3139                 VK_FORMAT_R16G16_SFLOAT,
3140                 VK_FORMAT_R16G16B16A16_UINT,
3141                 VK_FORMAT_R16G16B16A16_SINT,
3142                 VK_FORMAT_R16G16B16A16_SFLOAT,
3143                 VK_FORMAT_R32_UINT,
3144                 VK_FORMAT_R32_SINT,
3145                 VK_FORMAT_R32_SFLOAT,
3146                 VK_FORMAT_R32G32_UINT,
3147                 VK_FORMAT_R32G32_SINT,
3148                 VK_FORMAT_R32G32_SFLOAT,
3149                 VK_FORMAT_R32G32B32A32_UINT,
3150                 VK_FORMAT_R32G32B32A32_SINT,
3151                 VK_FORMAT_R32G32B32A32_SFLOAT,
3152                 VK_FORMAT_B10G11R11_UFLOAT_PACK32
3153         };
3154         static const VkFormat s_requiredStorageTexelBufferFormats[] =
3155         {
3156                 VK_FORMAT_R8G8B8A8_UNORM,
3157                 VK_FORMAT_R8G8B8A8_SNORM,
3158                 VK_FORMAT_R8G8B8A8_UINT,
3159                 VK_FORMAT_R8G8B8A8_SINT,
3160                 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
3161                 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
3162                 VK_FORMAT_A8B8G8R8_UINT_PACK32,
3163                 VK_FORMAT_A8B8G8R8_SINT_PACK32,
3164                 VK_FORMAT_R16G16B16A16_UINT,
3165                 VK_FORMAT_R16G16B16A16_SINT,
3166                 VK_FORMAT_R16G16B16A16_SFLOAT,
3167                 VK_FORMAT_R32_UINT,
3168                 VK_FORMAT_R32_SINT,
3169                 VK_FORMAT_R32_SFLOAT,
3170                 VK_FORMAT_R32G32_UINT,
3171                 VK_FORMAT_R32G32_SINT,
3172                 VK_FORMAT_R32G32_SFLOAT,
3173                 VK_FORMAT_R32G32B32A32_UINT,
3174                 VK_FORMAT_R32G32B32A32_SINT,
3175                 VK_FORMAT_R32G32B32A32_SFLOAT
3176         };
3177         static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] =
3178         {
3179                 VK_FORMAT_R32_UINT,
3180                 VK_FORMAT_R32_SINT
3181         };
3182
3183         VkFormatFeatureFlags    flags   = (VkFormatFeatureFlags)0;
3184
3185         if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format))
3186                 flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
3187
3188         if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format))
3189                 flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
3190
3191         if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format))
3192                 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
3193
3194         if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format))
3195                 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
3196
3197         return flags;
3198 }
3199
3200 VkPhysicalDeviceSamplerYcbcrConversionFeatures getPhysicalDeviceSamplerYcbcrConversionFeatures (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
3201 {
3202         VkPhysicalDeviceFeatures2                                               coreFeatures;
3203         VkPhysicalDeviceSamplerYcbcrConversionFeatures  ycbcrFeatures;
3204
3205         deMemset(&coreFeatures, 0, sizeof(coreFeatures));
3206         deMemset(&ycbcrFeatures, 0, sizeof(ycbcrFeatures));
3207
3208         coreFeatures.sType              = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
3209         coreFeatures.pNext              = &ycbcrFeatures;
3210         ycbcrFeatures.sType             = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
3211
3212         vk.getPhysicalDeviceFeatures2(physicalDevice, &coreFeatures);
3213
3214         return ycbcrFeatures;
3215 }
3216
3217 void checkYcbcrApiSupport (Context& context)
3218 {
3219         // check if YCbcr API and are supported by implementation
3220
3221         // the support for formats and YCbCr may still be optional - see isYcbcrConversionSupported below
3222
3223         if (!vk::isCoreDeviceExtension(context.getUsedApiVersion(), "VK_KHR_sampler_ycbcr_conversion"))
3224         {
3225                 if (!context.isDeviceFunctionalitySupported("VK_KHR_sampler_ycbcr_conversion"))
3226                         TCU_THROW(NotSupportedError, "VK_KHR_sampler_ycbcr_conversion is not supported");
3227
3228                 // Hard dependency for ycbcr
3229                 TCU_CHECK(de::contains(context.getInstanceExtensions().begin(), context.getInstanceExtensions().end(), "VK_KHR_get_physical_device_properties2"));
3230         }
3231 }
3232
3233 bool isYcbcrConversionSupported (Context& context)
3234 {
3235         checkYcbcrApiSupport(context);
3236
3237         const VkPhysicalDeviceSamplerYcbcrConversionFeatures    ycbcrFeatures   = getPhysicalDeviceSamplerYcbcrConversionFeatures(context.getInstanceInterface(), context.getPhysicalDevice());
3238
3239         return (ycbcrFeatures.samplerYcbcrConversion == VK_TRUE);
3240 }
3241
3242 VkFormatFeatureFlags getRequiredYcbcrFormatFeatures (Context& context, VkFormat format)
3243 {
3244         bool req = isYcbcrConversionSupported(context) && (     format == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM ||
3245                                                                                                                 format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM);
3246
3247         const VkFormatFeatureFlags      required        = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
3248                                                                                         | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT
3249                                                                                         | VK_FORMAT_FEATURE_TRANSFER_DST_BIT
3250                                                                                         | VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT;
3251         return req ? required : (VkFormatFeatureFlags)0;
3252 }
3253
3254 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (Context& context, VkFormat format)
3255 {
3256         if (isYCbCrFormat(format))
3257                 return getRequiredYcbcrFormatFeatures(context, format);
3258         else
3259         {
3260                 VkFormatFeatureFlags ret = getBaseRequiredOptimalTilingFeatures(format);
3261
3262                 // \todo [2017-05-16 pyry] This should be extended to cover for example COLOR_ATTACHMENT for depth formats etc.
3263                 // \todo [2017-05-18 pyry] Any other color conversion related features that can't be supported by regular formats?
3264                 ret |= getRequiredOptimalExtendedTilingFeatures(context, format, ret);
3265
3266                 // Compressed formats have optional support for some features
3267                 // TODO: Is this really correct? It looks like it should be checking the different compressed features
3268                 if (isCompressedFormat(format) && (ret & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT))
3269                         ret |=  VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
3270                                         VK_FORMAT_FEATURE_TRANSFER_DST_BIT |
3271                                         VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
3272                                         VK_FORMAT_FEATURE_BLIT_SRC_BIT;
3273
3274                 return ret;
3275         }
3276 }
3277
3278 bool requiresYCbCrConversion(Context& context, VkFormat format)
3279 {
3280         if (format == VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16)
3281         {
3282                 if (!context.isDeviceFunctionalitySupported("VK_EXT_rgba10x6_formats"))
3283                         return true;
3284                 VkPhysicalDeviceFeatures2                                               coreFeatures;
3285                 VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT      rgba10x6features;
3286
3287                 deMemset(&coreFeatures, 0, sizeof(coreFeatures));
3288                 deMemset(&rgba10x6features, 0, sizeof(rgba10x6features));
3289
3290                 coreFeatures.sType              = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
3291                 coreFeatures.pNext              = &rgba10x6features;
3292                 rgba10x6features.sType          = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT;
3293
3294                 const InstanceInterface &vk = context.getInstanceInterface();
3295                 vk.getPhysicalDeviceFeatures2(context.getPhysicalDevice(), &coreFeatures);
3296
3297                 return !rgba10x6features.formatRgba10x6WithoutYCbCrSampler;
3298         }
3299
3300         return isYCbCrFormat(format) &&
3301                         format != VK_FORMAT_R10X6_UNORM_PACK16 && format != VK_FORMAT_R10X6G10X6_UNORM_2PACK16 &&
3302                         format != VK_FORMAT_R12X4_UNORM_PACK16 && format != VK_FORMAT_R12X4G12X4_UNORM_2PACK16;
3303 }
3304
3305 VkFormatFeatureFlags getAllowedOptimalTilingFeatures (Context &context, VkFormat format)
3306 {
3307         // YCbCr formats only support a subset of format feature flags
3308         const VkFormatFeatureFlags ycbcrAllows =
3309                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
3310                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT |
3311                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG |
3312                 VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
3313                 VK_FORMAT_FEATURE_TRANSFER_DST_BIT |
3314                 VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT |
3315                 VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT |
3316                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT |
3317                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT |
3318                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT |
3319                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT |
3320                 VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT |
3321                 VK_FORMAT_FEATURE_DISJOINT_BIT;
3322
3323         // By default everything is allowed.
3324         VkFormatFeatureFlags allow = (VkFormatFeatureFlags)~0u;
3325         // Formats for which SamplerYCbCrConversion is required may not support certain features.
3326         if (requiresYCbCrConversion(context, format))
3327                 allow &= ycbcrAllows;
3328         // single-plane formats *may not* support DISJOINT_BIT
3329         if (!isYCbCrFormat(format) || getPlaneCount(format) == 1)
3330                 allow &= ~VK_FORMAT_FEATURE_DISJOINT_BIT;
3331
3332         return allow;
3333 }
3334
3335 VkFormatFeatureFlags getAllowedBufferFeatures (Context &context, VkFormat format)
3336 {
3337         // TODO: Do we allow non-buffer flags in the bufferFeatures?
3338         return requiresYCbCrConversion(context, format) ? (VkFormatFeatureFlags)0 : (VkFormatFeatureFlags)(~VK_FORMAT_FEATURE_DISJOINT_BIT);
3339 }
3340
3341 tcu::TestStatus formatProperties (Context& context, VkFormat format)
3342 {
3343         // check if Ycbcr format enums are valid given the version and extensions
3344         if (isYCbCrFormat(format))
3345                 checkYcbcrApiSupport(context);
3346
3347         TestLog&                                        log                     = context.getTestContext().getLog();
3348         const VkFormatProperties        properties      = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
3349         bool                                            allOk           = true;
3350
3351         const VkFormatFeatureFlags reqImg       = getRequiredOptimalTilingFeatures(context, format);
3352         const VkFormatFeatureFlags reqBuf       = getRequiredBufferFeatures(format);
3353         const VkFormatFeatureFlags allowImg     = getAllowedOptimalTilingFeatures(context, format);
3354         const VkFormatFeatureFlags allowBuf     = getAllowedBufferFeatures(context, format);
3355
3356         const struct feature_req
3357         {
3358                 const char*                             fieldName;
3359                 VkFormatFeatureFlags    supportedFeatures;
3360                 VkFormatFeatureFlags    requiredFeatures;
3361                 VkFormatFeatureFlags    allowedFeatures;
3362         } fields[] =
3363         {
3364                 { "linearTilingFeatures",       properties.linearTilingFeatures,        (VkFormatFeatureFlags)0,        allowImg },
3365                 { "optimalTilingFeatures",      properties.optimalTilingFeatures,       reqImg,                                         allowImg },
3366                 { "bufferFeatures",                     properties.bufferFeatures,                      reqBuf,                                         allowBuf }
3367         };
3368
3369         log << TestLog::Message << properties << TestLog::EndMessage;
3370
3371         for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
3372         {
3373                 const char* const                       fieldName       = fields[fieldNdx].fieldName;
3374                 const VkFormatFeatureFlags      supported       = fields[fieldNdx].supportedFeatures;
3375                 const VkFormatFeatureFlags      required        = fields[fieldNdx].requiredFeatures;
3376                 const VkFormatFeatureFlags      allowed         = fields[fieldNdx].allowedFeatures;
3377
3378                 if ((supported & required) != required)
3379                 {
3380                         log << TestLog::Message << "ERROR in " << fieldName << ":\n"
3381                                                                         << "  required: " << getFormatFeatureFlagsStr(required) << "\n  "
3382                                                                         << "  missing: " << getFormatFeatureFlagsStr(~supported & required)
3383                                 << TestLog::EndMessage;
3384                         allOk = false;
3385                 }
3386
3387                 if ((supported & ~allowed) != 0)
3388                 {
3389                         log << TestLog::Message << "ERROR in " << fieldName << ":\n"
3390                                                                         << "  has: " << getFormatFeatureFlagsStr(supported & ~allowed)
3391                                 << TestLog::EndMessage;
3392                         allOk = false;
3393                 }
3394
3395                 if (((supported & VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT) != 0) &&
3396                         ((supported & VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT) == 0))
3397                 {
3398                         log << TestLog::Message << "ERROR in " << fieldName << ":\n"
3399                                                                         << " supports VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT"
3400                                                                         << " but not VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT"
3401                                 << TestLog::EndMessage;
3402                         allOk = false;
3403                 }
3404         }
3405
3406         if (allOk)
3407                 return tcu::TestStatus::pass("Query and validation passed");
3408         else
3409                 return tcu::TestStatus::fail("Required features not supported");
3410 }
3411
3412 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features)
3413 {
3414         const VkFormatProperties        properties      = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
3415
3416         return (properties.optimalTilingFeatures & features) == features;
3417 }
3418
3419 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features)
3420 {
3421         for (const VkFormat* cur = begin; cur != end; ++cur)
3422         {
3423                 if (!optimalTilingFeaturesSupported(context, *cur, features))
3424                         return false;
3425         }
3426
3427         return true;
3428 }
3429
3430 tcu::TestStatus testDepthStencilSupported (Context& context)
3431 {
3432         if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
3433                 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
3434                 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT");
3435
3436         if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
3437                 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
3438                 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT");
3439
3440         return tcu::TestStatus::pass("Required depth/stencil formats supported");
3441 }
3442
3443 tcu::TestStatus testCompressedFormatsSupported (Context& context)
3444 {
3445         static const VkFormat s_allBcFormats[] =
3446         {
3447                 VK_FORMAT_BC1_RGB_UNORM_BLOCK,
3448                 VK_FORMAT_BC1_RGB_SRGB_BLOCK,
3449                 VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
3450                 VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
3451                 VK_FORMAT_BC2_UNORM_BLOCK,
3452                 VK_FORMAT_BC2_SRGB_BLOCK,
3453                 VK_FORMAT_BC3_UNORM_BLOCK,
3454                 VK_FORMAT_BC3_SRGB_BLOCK,
3455                 VK_FORMAT_BC4_UNORM_BLOCK,
3456                 VK_FORMAT_BC4_SNORM_BLOCK,
3457                 VK_FORMAT_BC5_UNORM_BLOCK,
3458                 VK_FORMAT_BC5_SNORM_BLOCK,
3459                 VK_FORMAT_BC6H_UFLOAT_BLOCK,
3460                 VK_FORMAT_BC6H_SFLOAT_BLOCK,
3461                 VK_FORMAT_BC7_UNORM_BLOCK,
3462                 VK_FORMAT_BC7_SRGB_BLOCK,
3463         };
3464         static const VkFormat s_allEtc2Formats[] =
3465         {
3466                 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
3467                 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
3468                 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
3469                 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
3470                 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
3471                 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
3472                 VK_FORMAT_EAC_R11_UNORM_BLOCK,
3473                 VK_FORMAT_EAC_R11_SNORM_BLOCK,
3474                 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
3475                 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
3476         };
3477         static const VkFormat s_allAstcLdrFormats[] =
3478         {
3479                 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
3480                 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
3481                 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
3482                 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
3483                 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
3484                 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
3485                 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
3486                 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
3487                 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
3488                 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
3489                 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
3490                 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
3491                 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
3492                 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
3493                 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
3494                 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
3495                 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
3496                 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
3497                 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
3498                 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
3499                 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
3500                 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
3501                 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
3502                 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
3503                 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
3504                 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
3505                 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
3506                 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
3507         };
3508
3509         static const struct
3510         {
3511                 const char*                                                                     setName;
3512                 const char*                                                                     featureName;
3513                 const VkBool32 VkPhysicalDeviceFeatures::*      feature;
3514                 const VkFormat*                                                         formatsBegin;
3515                 const VkFormat*                                                         formatsEnd;
3516         } s_compressedFormatSets[] =
3517         {
3518                 { "BC",                 "textureCompressionBC",                 &VkPhysicalDeviceFeatures::textureCompressionBC,                DE_ARRAY_BEGIN(s_allBcFormats),                 DE_ARRAY_END(s_allBcFormats)            },
3519                 { "ETC2",               "textureCompressionETC2",               &VkPhysicalDeviceFeatures::textureCompressionETC2,              DE_ARRAY_BEGIN(s_allEtc2Formats),               DE_ARRAY_END(s_allEtc2Formats)          },
3520                 { "ASTC LDR",   "textureCompressionASTC_LDR",   &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR,  DE_ARRAY_BEGIN(s_allAstcLdrFormats),    DE_ARRAY_END(s_allAstcLdrFormats)       },
3521         };
3522
3523         TestLog&                                                log                                     = context.getTestContext().getLog();
3524         const VkPhysicalDeviceFeatures& features                        = context.getDeviceFeatures();
3525         int                                                             numSupportedSets        = 0;
3526         int                                                             numErrors                       = 0;
3527         int                                                             numWarnings                     = 0;
3528
3529         for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx)
3530         {
3531                 const char* const                       setName                         = s_compressedFormatSets[setNdx].setName;
3532                 const char* const                       featureName                     = s_compressedFormatSets[setNdx].featureName;
3533                 const bool                                      featureBitSet           = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE;
3534                 const VkFormatFeatureFlags      requiredFeatures        =
3535                         VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT |
3536                         VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
3537                 const bool                      allSupported    = optimalTilingFeaturesSupportedForAll(context,
3538                                                                                                                                                                    s_compressedFormatSets[setNdx].formatsBegin,
3539                                                                                                                                                                    s_compressedFormatSets[setNdx].formatsEnd,
3540                                                                                                                                                                    requiredFeatures);
3541
3542                 if (featureBitSet && !allSupported)
3543                 {
3544                         log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage;
3545                         numErrors += 1;
3546                 }
3547                 else if (allSupported && !featureBitSet)
3548                 {
3549                         log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage;
3550                         numWarnings += 1;
3551                 }
3552
3553                 if (featureBitSet)
3554                 {
3555                         log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage;
3556                         numSupportedSets += 1;
3557                 }
3558                 else
3559                         log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage;
3560         }
3561
3562         if (numSupportedSets == 0)
3563         {
3564                 log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage;
3565                 numErrors += 1;
3566         }
3567
3568         if (numErrors > 0)
3569                 return tcu::TestStatus::fail("Compressed format support not valid");
3570         else if (numWarnings > 0)
3571                 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support");
3572         else
3573                 return tcu::TestStatus::pass("Compressed texture format support is valid");
3574 }
3575
3576 void createFormatTests (tcu::TestCaseGroup* testGroup)
3577 {
3578         DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0);
3579
3580         static const struct
3581         {
3582                 VkFormat        begin;
3583                 VkFormat        end;
3584         } s_formatRanges[] =
3585         {
3586                 // core formats
3587                 { (VkFormat)(VK_FORMAT_UNDEFINED+1),            VK_CORE_FORMAT_LAST                                                                             },
3588
3589                 // YCbCr formats
3590                 { VK_FORMAT_G8B8G8R8_422_UNORM,                         (VkFormat)(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM+1)    },
3591
3592                 // YCbCr extended formats
3593                 { VK_FORMAT_G8_B8R8_2PLANE_444_UNORM_EXT,       (VkFormat)(VK_FORMAT_G16_B16R16_2PLANE_444_UNORM_EXT+1) },
3594         };
3595
3596         for (int rangeNdx = 0; rangeNdx < DE_LENGTH_OF_ARRAY(s_formatRanges); ++rangeNdx)
3597         {
3598                 const VkFormat                                                          rangeBegin              = s_formatRanges[rangeNdx].begin;
3599                 const VkFormat                                                          rangeEnd                = s_formatRanges[rangeNdx].end;
3600
3601                 for (VkFormat format = rangeBegin; format != rangeEnd; format = (VkFormat)(format+1))
3602                 {
3603                         const char* const       enumName        = getFormatName(format);
3604                         const string            caseName        = de::toLower(string(enumName).substr(10));
3605
3606                         addFunctionCase(testGroup, caseName, enumName, formatProperties, format);
3607                 }
3608         }
3609
3610         addFunctionCase(testGroup, "depth_stencil",                     "",     testDepthStencilSupported);
3611         addFunctionCase(testGroup, "compressed_formats",        "",     testCompressedFormatsSupported);
3612 }
3613
3614 VkImageUsageFlags getValidImageUsageFlags (const VkFormatFeatureFlags supportedFeatures, const bool useKhrMaintenance1Semantics)
3615 {
3616         VkImageUsageFlags       flags   = (VkImageUsageFlags)0;
3617
3618         if (useKhrMaintenance1Semantics)
3619         {
3620                 if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) != 0)
3621                         flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
3622
3623                 if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) != 0)
3624                         flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
3625         }
3626         else
3627         {
3628                 // If format is supported at all, it must be valid transfer src+dst
3629                 if (supportedFeatures != 0)
3630                         flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
3631         }
3632
3633         if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
3634                 flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
3635
3636         if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0)
3637                 flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
3638
3639         if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
3640                 flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
3641
3642         if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
3643                 flags |= VK_IMAGE_USAGE_STORAGE_BIT;
3644
3645         return flags;
3646 }
3647
3648 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
3649 {
3650         if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)
3651         {
3652                 const VkImageUsageFlags         allowedFlags    = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
3653                                                                                                         | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
3654                                                                                                         | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
3655                                                                                                         | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
3656
3657                 // Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT
3658                 if ((usage & ~allowedFlags) != 0)
3659                         return false;
3660
3661                 // TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT
3662                 if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
3663                         return false;
3664         }
3665
3666         return usage != 0;
3667 }
3668
3669 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat format, VkFormatFeatureFlags formatFeatures, VkImageType type, VkImageUsageFlags usage)
3670 {
3671         VkImageCreateFlags      flags   = (VkImageCreateFlags)0;
3672
3673         if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
3674         {
3675                 flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
3676
3677                 if (type == VK_IMAGE_TYPE_2D && !isYCbCrFormat(format))
3678                 {
3679                         flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
3680                 }
3681         }
3682
3683         if (isYCbCrFormat(format) && getPlaneCount(format) > 1)
3684         {
3685                 if (formatFeatures & VK_FORMAT_FEATURE_DISJOINT_BIT_KHR)
3686                         flags |= VK_IMAGE_CREATE_DISJOINT_BIT_KHR;
3687         }
3688
3689         if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 &&
3690                 (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
3691         {
3692                 if (deviceFeatures.sparseBinding)
3693                         flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
3694
3695                 if (deviceFeatures.sparseResidencyAliased)
3696                         flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
3697         }
3698
3699         return flags;
3700 }
3701
3702 bool isValidImageCreateFlagCombination (VkImageCreateFlags)
3703 {
3704         return true;
3705 }
3706
3707 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures&       deviceFeatures,
3708                                                                                   const VkFormat                                        format,
3709                                                                                   const VkFormatProperties&                     formatProperties,
3710                                                                                   const VkImageType                                     imageType,
3711                                                                                   const VkImageTiling                           imageTiling,
3712                                                                                   const VkImageUsageFlags                       usageFlags,
3713                                                                                   const VkImageCreateFlags                      createFlags)
3714 {
3715         DE_UNREF(deviceFeatures);
3716         DE_UNREF(formatProperties);
3717         DE_UNREF(createFlags);
3718
3719         // Linear images can have arbitrary limitations
3720         if (imageTiling == VK_IMAGE_TILING_LINEAR)
3721                 return false;
3722
3723         // Support for other usages for compressed formats is optional
3724         if (isCompressedFormat(format) &&
3725                 (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0)
3726                 return false;
3727
3728         // Support for 1D, and sliced 3D compressed formats is optional
3729         if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
3730                 return false;
3731
3732         // Support for 1D and 3D depth/stencil textures is optional
3733         if (isDepthStencilFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
3734                 return false;
3735
3736         DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
3737         DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
3738
3739         if (isYCbCrFormat(format) && (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)))
3740                 return false;
3741
3742         if (createFlags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)
3743         {
3744                 if (isCompressedFormat(format))
3745                         return false;
3746
3747                 if (isDepthStencilFormat(format))
3748                         return false;
3749
3750                 if (!deIsPowerOfTwo32(mapVkFormat(format).getPixelSize()))
3751                         return false;
3752
3753                 switch (imageType)
3754                 {
3755                         case VK_IMAGE_TYPE_2D:
3756                                 return (deviceFeatures.sparseResidencyImage2D == VK_TRUE);
3757                         case VK_IMAGE_TYPE_3D:
3758                                 return (deviceFeatures.sparseResidencyImage3D == VK_TRUE);
3759                         default:
3760                                 return false;
3761                 }
3762         }
3763
3764         return true;
3765 }
3766
3767 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits&  deviceLimits,
3768                                                                                                                  const VkFormat                                 format,
3769                                                                                                                  const VkImageUsageFlags                usageFlags)
3770 {
3771         if (isCompressedFormat(format))
3772                 return VK_SAMPLE_COUNT_1_BIT;
3773
3774         bool            hasDepthComp    = false;
3775         bool            hasStencilComp  = false;
3776         const bool      isYCbCr                 = isYCbCrFormat(format);
3777         if (!isYCbCr)
3778         {
3779                 const tcu::TextureFormat        tcuFormat               = mapVkFormat(format);
3780                 hasDepthComp    = (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS);
3781                 hasStencilComp  = (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS);
3782         }
3783
3784         const bool                                              isColorFormat   = !hasDepthComp && !hasStencilComp;
3785         VkSampleCountFlags                              sampleCounts    = ~(VkSampleCountFlags)0;
3786
3787         DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat);
3788
3789         if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0)
3790                 sampleCounts &= deviceLimits.storageImageSampleCounts;
3791
3792         if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
3793         {
3794                 if (hasDepthComp)
3795                         sampleCounts &= deviceLimits.sampledImageDepthSampleCounts;
3796
3797                 if (hasStencilComp)
3798                         sampleCounts &= deviceLimits.sampledImageStencilSampleCounts;
3799
3800                 if (isColorFormat)
3801                 {
3802                         if (isYCbCr)
3803                                 sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
3804                         else
3805                         {
3806                                 const tcu::TextureFormat                tcuFormat       = mapVkFormat(format);
3807                                 const tcu::TextureChannelClass  chnClass        = tcu::getTextureChannelClass(tcuFormat.type);
3808
3809                                 if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
3810                                         chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
3811                                         sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts;
3812                                 else
3813                                         sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
3814                         }
3815                 }
3816         }
3817
3818         if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
3819                 sampleCounts &= deviceLimits.framebufferColorSampleCounts;
3820
3821         if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
3822         {
3823                 if (hasDepthComp)
3824                         sampleCounts &= deviceLimits.framebufferDepthSampleCounts;
3825
3826                 if (hasStencilComp)
3827                         sampleCounts &= deviceLimits.framebufferStencilSampleCounts;
3828         }
3829
3830         // If there is no usage flag set that would have corresponding device limit,
3831         // only VK_SAMPLE_COUNT_1_BIT is required.
3832         if (sampleCounts == ~(VkSampleCountFlags)0)
3833                 sampleCounts &= VK_SAMPLE_COUNT_1_BIT;
3834
3835         return sampleCounts;
3836 }
3837
3838 struct ImageFormatPropertyCase
3839 {
3840         typedef tcu::TestStatus (*Function) (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling);
3841
3842         Function                testFunction;
3843         VkFormat                format;
3844         VkImageType             imageType;
3845         VkImageTiling   tiling;
3846
3847         ImageFormatPropertyCase (Function testFunction_, VkFormat format_, VkImageType imageType_, VkImageTiling tiling_)
3848                 : testFunction  (testFunction_)
3849                 , format                (format_)
3850                 , imageType             (imageType_)
3851                 , tiling                (tiling_)
3852         {}
3853
3854         ImageFormatPropertyCase (void)
3855                 : testFunction  ((Function)DE_NULL)
3856                 , format                (VK_FORMAT_UNDEFINED)
3857                 , imageType             (VK_CORE_IMAGE_TYPE_LAST)
3858                 , tiling                (VK_CORE_IMAGE_TILING_LAST)
3859         {}
3860 };
3861
3862 tcu::TestStatus imageFormatProperties (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
3863 {
3864         if (isYCbCrFormat(format))
3865                 // check if Ycbcr format enums are valid given the version and extensions
3866                 checkYcbcrApiSupport(context);
3867
3868         TestLog&                                                log                                     = context.getTestContext().getLog();
3869         const VkPhysicalDeviceFeatures& deviceFeatures          = context.getDeviceFeatures();
3870         const VkPhysicalDeviceLimits&   deviceLimits            = context.getDeviceProperties().limits;
3871         const VkFormatProperties                formatProperties        = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
3872         const bool                                              hasKhrMaintenance1      = context.isDeviceFunctionalitySupported("VK_KHR_maintenance1");
3873
3874         const VkFormatFeatureFlags              supportedFeatures       = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
3875         const VkImageUsageFlags                 usageFlagSet            = getValidImageUsageFlags(supportedFeatures, hasKhrMaintenance1);
3876
3877         tcu::ResultCollector                    results                         (log, "ERROR: ");
3878
3879         if (hasKhrMaintenance1 && (supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
3880         {
3881                 results.check((supportedFeatures & (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT|VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) != 0,
3882                                           "A sampled image format must have VK_FORMAT_FEATURE_TRANSFER_SRC_BIT and VK_FORMAT_FEATURE_TRANSFER_DST_BIT format feature flags set");
3883         }
3884
3885         if (isYcbcrConversionSupported(context) && (format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR || format == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR))
3886         {
3887                 VkFormatFeatureFlags requiredFeatures = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR;
3888                 if (tiling == VK_IMAGE_TILING_OPTIMAL)
3889                         requiredFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR;
3890
3891                 results.check((supportedFeatures & requiredFeatures) == requiredFeatures,
3892                                           getFormatName(format) + string(" must support ") + de::toString(getFormatFeatureFlagsStr(requiredFeatures)));
3893         }
3894
3895         for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
3896         {
3897                 if ((curUsageFlags & ~usageFlagSet) != 0 ||
3898                         !isValidImageUsageFlagCombination(curUsageFlags))
3899                         continue;
3900
3901                 const VkImageCreateFlags        createFlagSet           = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags);
3902
3903                 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++)
3904                 {
3905                         if ((curCreateFlags & ~createFlagSet) != 0 ||
3906                                 !isValidImageCreateFlagCombination(curCreateFlags))
3907                                 continue;
3908
3909                         const bool                              isRequiredCombination   = isRequiredImageParameterCombination(deviceFeatures,
3910                                                                                                                                                                                                   format,
3911                                                                                                                                                                                                   formatProperties,
3912                                                                                                                                                                                                   imageType,
3913                                                                                                                                                                                                   tiling,
3914                                                                                                                                                                                                   curUsageFlags,
3915                                                                                                                                                                                                   curCreateFlags);
3916                         VkImageFormatProperties properties;
3917                         VkResult                                queryResult;
3918
3919                         log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", "
3920                                                                         << getImageTilingStr(tiling) << ", "
3921                                                                         << getImageUsageFlagsStr(curUsageFlags) << ", "
3922                                                                         << getImageCreateFlagsStr(curCreateFlags)
3923                                 << TestLog::EndMessage;
3924
3925                         // Set return value to known garbage
3926                         deMemset(&properties, 0xcd, sizeof(properties));
3927
3928                         queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(),
3929                                                                                                                                                                                                 format,
3930                                                                                                                                                                                                 imageType,
3931                                                                                                                                                                                                 tiling,
3932                                                                                                                                                                                                 curUsageFlags,
3933                                                                                                                                                                                                 curCreateFlags,
3934                                                                                                                                                                                                 &properties);
3935
3936                         if (queryResult == VK_SUCCESS)
3937                         {
3938                                 const deUint32  fullMipPyramidSize      = de::max(de::max(deLog2Floor32(properties.maxExtent.width),
3939                                                                                                                                           deLog2Floor32(properties.maxExtent.height)),
3940                                                                                                                           deLog2Floor32(properties.maxExtent.depth)) + 1;
3941
3942                                 log << TestLog::Message << properties << "\n" << TestLog::EndMessage;
3943
3944                                 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image");
3945                                 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image");
3946                                 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image");
3947                                 results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image");
3948
3949                                 if (tiling == VK_IMAGE_TILING_OPTIMAL && imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
3950                                          (supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)))
3951                                 {
3952                                         const VkSampleCountFlags        requiredSampleCounts    = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
3953                                         results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
3954                                 }
3955                                 else
3956                                         results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT");
3957
3958                                 if (isRequiredCombination)
3959                                 {
3960                                         results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width      >= deviceLimits.maxImageDimension1D),
3961                                                                   "Reported dimensions smaller than device limits");
3962                                         results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width      >= deviceLimits.maxImageDimension2D &&
3963                                                                                                                                         properties.maxExtent.height     >= deviceLimits.maxImageDimension2D),
3964                                                                   "Reported dimensions smaller than device limits");
3965                                         results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width      >= deviceLimits.maxImageDimension3D &&
3966                                                                                                                                         properties.maxExtent.height     >= deviceLimits.maxImageDimension3D &&
3967                                                                                                                                         properties.maxExtent.depth      >= deviceLimits.maxImageDimension3D),
3968                                                                   "Reported dimensions smaller than device limits");
3969                                         results.check((isYCbCrFormat(format) && (properties.maxMipLevels == 1)) || properties.maxMipLevels == fullMipPyramidSize,
3970                                                       "Invalid mip pyramid size");
3971                                         results.check((isYCbCrFormat(format) && (properties.maxArrayLayers == 1)) || imageType == VK_IMAGE_TYPE_3D ||
3972                                                       properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers, "Invalid maxArrayLayers");
3973                                 }
3974                                 else
3975                                 {
3976                                         results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size");
3977                                         results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers");
3978                                 }
3979
3980                                 results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE,
3981                                                           "maxResourceSize smaller than minimum required size");
3982                         }
3983                         else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED)
3984                         {
3985                                 log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage;
3986
3987                                 if (isRequiredCombination)
3988                                         results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination");
3989
3990                                 // Specification requires that all fields are set to 0
3991                                 results.check(properties.maxExtent.width        == 0, "maxExtent.width != 0");
3992                                 results.check(properties.maxExtent.height       == 0, "maxExtent.height != 0");
3993                                 results.check(properties.maxExtent.depth        == 0, "maxExtent.depth != 0");
3994                                 results.check(properties.maxMipLevels           == 0, "maxMipLevels != 0");
3995                                 results.check(properties.maxArrayLayers         == 0, "maxArrayLayers != 0");
3996                                 results.check(properties.sampleCounts           == 0, "sampleCounts != 0");
3997                                 results.check(properties.maxResourceSize        == 0, "maxResourceSize != 0");
3998                         }
3999                         else
4000                         {
4001                                 results.fail("Got unexpected error" + de::toString(queryResult));
4002                         }
4003                 }
4004         }
4005
4006         return tcu::TestStatus(results.getResult(), results.getMessage());
4007 }
4008
4009 // VK_KHR_get_physical_device_properties2
4010
4011 string toString(const VkPhysicalDevicePCIBusInfoPropertiesEXT& value)
4012 {
4013         std::ostringstream  s;
4014         s << "VkPhysicalDevicePCIBusInfoPropertiesEXT = {\n";
4015         s << "\tsType = " << value.sType << '\n';
4016         s << "\tpciDomain = " << value.pciDomain << '\n';
4017         s << "\tpciBus = " << value.pciBus << '\n';
4018         s << "\tpciDevice = " << value.pciDevice << '\n';
4019         s << "\tpciFunction = " << value.pciFunction << '\n';
4020         s << '}';
4021         return s.str();
4022 }
4023
4024 bool checkExtension (vector<VkExtensionProperties>& properties, const char* extension)
4025 {
4026         for (size_t ndx = 0; ndx < properties.size(); ++ndx)
4027         {
4028                 if (strncmp(properties[ndx].extensionName, extension, VK_MAX_EXTENSION_NAME_SIZE) == 0)
4029                         return true;
4030         }
4031         return false;
4032 }
4033
4034 tcu::TestStatus deviceFeatures2 (Context& context)
4035 {
4036         const CustomInstance            instance                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4037         const InstanceDriver&           vki                             (instance.getDriver());
4038         const VkPhysicalDevice          physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4039         const int                                       count                   = 2u;
4040         TestLog&                                        log                             = context.getTestContext().getLog();
4041         VkPhysicalDeviceFeatures        coreFeatures;
4042         VkPhysicalDeviceFeatures2       extFeatures;
4043
4044         deMemset(&coreFeatures, 0xcd, sizeof(coreFeatures));
4045         deMemset(&extFeatures.features, 0xcd, sizeof(extFeatures.features));
4046         std::vector<std::string> instExtensions = context.getInstanceExtensions();
4047
4048         extFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
4049         extFeatures.pNext = DE_NULL;
4050
4051         vki.getPhysicalDeviceFeatures(physicalDevice, &coreFeatures);
4052         vki.getPhysicalDeviceFeatures2(physicalDevice, &extFeatures);
4053
4054         TCU_CHECK(extFeatures.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2);
4055         TCU_CHECK(extFeatures.pNext == DE_NULL);
4056
4057         if (deMemCmp(&coreFeatures, &extFeatures.features, sizeof(VkPhysicalDeviceFeatures)) != 0)
4058                 TCU_FAIL("Mismatch between features reported by vkGetPhysicalDeviceFeatures and vkGetPhysicalDeviceFeatures2");
4059
4060         log << TestLog::Message << extFeatures << TestLog::EndMessage;
4061
4062         vector<VkExtensionProperties> properties        = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
4063
4064 #include "vkDeviceFeatures2.inl"
4065
4066         return tcu::TestStatus::pass("Querying device features succeeded");
4067 }
4068
4069 tcu::TestStatus deviceProperties2 (Context& context)
4070 {
4071         const CustomInstance                    instance                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4072         const InstanceDriver&                   vki                             (instance.getDriver());
4073         const VkPhysicalDevice                  physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4074         TestLog&                                                log                             = context.getTestContext().getLog();
4075         VkPhysicalDeviceProperties              coreProperties;
4076         VkPhysicalDeviceProperties2             extProperties;
4077
4078         extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
4079         extProperties.pNext = DE_NULL;
4080
4081         vki.getPhysicalDeviceProperties(physicalDevice, &coreProperties);
4082         vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4083
4084         TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2);
4085         TCU_CHECK(extProperties.pNext == DE_NULL);
4086
4087         // We can't use memcmp() here because the structs may contain padding bytes that drivers may or may not
4088         // have written while writing the data and memcmp will compare them anyway, so we iterate through the
4089         // valid bytes for each field in the struct and compare only the valid bytes for each one.
4090         for (int propNdx = 0; propNdx < DE_LENGTH_OF_ARRAY(s_physicalDevicePropertiesOffsetTable); propNdx++)
4091         {
4092                 const size_t offset                                     = s_physicalDevicePropertiesOffsetTable[propNdx].offset;
4093                 const size_t size                                       = s_physicalDevicePropertiesOffsetTable[propNdx].size;
4094
4095                 const deUint8* corePropertyBytes        = reinterpret_cast<deUint8*>(&coreProperties) + offset;
4096                 const deUint8* extPropertyBytes         = reinterpret_cast<deUint8*>(&extProperties.properties) + offset;
4097
4098                 if (deMemCmp(corePropertyBytes, extPropertyBytes, size) != 0)
4099                         TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceProperties and vkGetPhysicalDeviceProperties2");
4100         }
4101
4102         log << TestLog::Message << extProperties.properties << TestLog::EndMessage;
4103
4104         const int count = 2u;
4105
4106         vector<VkExtensionProperties> properties                = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
4107         const bool khr_external_fence_capabilities              = checkExtension(properties, "VK_KHR_external_fence_capabilities")              ||      context.contextSupports(vk::ApiVersion(1, 1, 0));
4108         const bool khr_external_memory_capabilities             = checkExtension(properties, "VK_KHR_external_memory_capabilities")             ||      context.contextSupports(vk::ApiVersion(1, 1, 0));
4109         const bool khr_external_semaphore_capabilities  = checkExtension(properties, "VK_KHR_external_semaphore_capabilities")  ||      context.contextSupports(vk::ApiVersion(1, 1, 0));
4110         const bool khr_multiview                                                = checkExtension(properties, "VK_KHR_multiview")                                                ||      context.contextSupports(vk::ApiVersion(1, 1, 0));
4111         const bool khr_device_protected_memory                  =                                                                                                                                                       context.contextSupports(vk::ApiVersion(1, 1, 0));
4112         const bool khr_device_subgroup                                  =                                                                                                                                                       context.contextSupports(vk::ApiVersion(1, 1, 0));
4113         const bool khr_maintenance2                                             = checkExtension(properties, "VK_KHR_maintenance2")                                             ||      context.contextSupports(vk::ApiVersion(1, 1, 0));
4114         const bool khr_maintenance3                                             = checkExtension(properties, "VK_KHR_maintenance3")                                             ||      context.contextSupports(vk::ApiVersion(1, 1, 0));
4115         const bool khr_depth_stencil_resolve                    = checkExtension(properties, "VK_KHR_depth_stencil_resolve")                    ||      context.contextSupports(vk::ApiVersion(1, 2, 0));
4116         const bool khr_driver_properties                                = checkExtension(properties, "VK_KHR_driver_properties")                                ||      context.contextSupports(vk::ApiVersion(1, 2, 0));
4117         const bool khr_shader_float_controls                    = checkExtension(properties, "VK_KHR_shader_float_controls")                    ||      context.contextSupports(vk::ApiVersion(1, 2, 0));
4118         const bool khr_descriptor_indexing                              = checkExtension(properties, "VK_EXT_descriptor_indexing")                              ||      context.contextSupports(vk::ApiVersion(1, 2, 0));
4119         const bool khr_sampler_filter_minmax                    = checkExtension(properties, "VK_EXT_sampler_filter_minmax")                    ||      context.contextSupports(vk::ApiVersion(1, 2, 0));
4120         const bool khr_integer_dot_product                              = checkExtension(properties, "VK_KHR_shader_integer_dot_product");
4121
4122         VkPhysicalDeviceIDProperties                                                    idProperties[count];
4123         VkPhysicalDeviceMultiviewProperties                                             multiviewProperties[count];
4124         VkPhysicalDeviceProtectedMemoryProperties                               protectedMemoryPropertiesKHR[count];
4125         VkPhysicalDeviceSubgroupProperties                                              subgroupProperties[count];
4126         VkPhysicalDevicePointClippingProperties                                 pointClippingProperties[count];
4127         VkPhysicalDeviceMaintenance3Properties                                  maintenance3Properties[count];
4128         VkPhysicalDeviceDepthStencilResolveProperties                   depthStencilResolveProperties[count];
4129         VkPhysicalDeviceDriverProperties                                                driverProperties[count];
4130         VkPhysicalDeviceFloatControlsProperties                                 floatControlsProperties[count];
4131         VkPhysicalDeviceDescriptorIndexingProperties                    descriptorIndexingProperties[count];
4132         VkPhysicalDeviceSamplerFilterMinmaxProperties                   samplerFilterMinmaxProperties[count];
4133         VkPhysicalDeviceShaderIntegerDotProductPropertiesKHR    integerDotProductProperties[count];
4134
4135         for (int ndx = 0; ndx < count; ++ndx)
4136         {
4137                 deMemset(&idProperties[ndx],                                    0xFF*ndx, sizeof(VkPhysicalDeviceIDProperties                                   ));
4138                 deMemset(&multiviewProperties[ndx],                             0xFF*ndx, sizeof(VkPhysicalDeviceMultiviewProperties                    ));
4139                 deMemset(&protectedMemoryPropertiesKHR[ndx],    0xFF*ndx, sizeof(VkPhysicalDeviceProtectedMemoryProperties              ));
4140                 deMemset(&subgroupProperties[ndx],                              0xFF*ndx, sizeof(VkPhysicalDeviceSubgroupProperties                             ));
4141                 deMemset(&pointClippingProperties[ndx],                 0xFF*ndx, sizeof(VkPhysicalDevicePointClippingProperties                ));
4142                 deMemset(&maintenance3Properties[ndx],                  0xFF*ndx, sizeof(VkPhysicalDeviceMaintenance3Properties                 ));
4143                 deMemset(&depthStencilResolveProperties[ndx],   0xFF*ndx, sizeof(VkPhysicalDeviceDepthStencilResolveProperties  ));
4144                 deMemset(&driverProperties[ndx],                                0xFF*ndx, sizeof(VkPhysicalDeviceDriverProperties                               ));
4145                 deMemset(&floatControlsProperties[ndx],                 0xFF*ndx, sizeof(VkPhysicalDeviceFloatControlsProperties                ));
4146                 deMemset(&descriptorIndexingProperties[ndx],    0xFF*ndx, sizeof(VkPhysicalDeviceDescriptorIndexingProperties   ));
4147                 deMemset(&samplerFilterMinmaxProperties[ndx],   0xFF*ndx, sizeof(VkPhysicalDeviceSamplerFilterMinmaxProperties  ));
4148                 deMemset(&integerDotProductProperties[ndx],             0xFF*ndx, sizeof(VkPhysicalDeviceShaderIntegerDotProductPropertiesKHR   ));
4149
4150                 idProperties[ndx].sType                                         = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES;
4151                 idProperties[ndx].pNext                                         = &multiviewProperties[ndx];
4152
4153                 multiviewProperties[ndx].sType                          = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES;
4154                 multiviewProperties[ndx].pNext                          = &protectedMemoryPropertiesKHR[ndx];
4155
4156                 protectedMemoryPropertiesKHR[ndx].sType         = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES;
4157                 protectedMemoryPropertiesKHR[ndx].pNext         = &subgroupProperties[ndx];
4158
4159                 subgroupProperties[ndx].sType                           = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
4160                 subgroupProperties[ndx].pNext                           = &pointClippingProperties[ndx];
4161
4162                 pointClippingProperties[ndx].sType                      = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES;
4163                 pointClippingProperties[ndx].pNext                      = &maintenance3Properties[ndx];
4164
4165                 maintenance3Properties[ndx].sType                       = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES;
4166                 maintenance3Properties[ndx].pNext                       = &depthStencilResolveProperties[ndx];
4167
4168                 depthStencilResolveProperties[ndx].sType        = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES;
4169                 depthStencilResolveProperties[ndx].pNext        = &driverProperties[ndx];
4170
4171                 driverProperties[ndx].sType                                     = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
4172                 driverProperties[ndx].pNext                                     = &floatControlsProperties[ndx];
4173
4174                 floatControlsProperties[ndx].sType                      = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR;
4175                 floatControlsProperties[ndx].pNext                      = &descriptorIndexingProperties[ndx];
4176
4177                 descriptorIndexingProperties[ndx].sType         = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES;
4178                 descriptorIndexingProperties[ndx].pNext         = &samplerFilterMinmaxProperties[ndx];
4179
4180                 samplerFilterMinmaxProperties[ndx].sType        = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES;
4181                 samplerFilterMinmaxProperties[ndx].pNext        = &integerDotProductProperties[ndx];
4182
4183                 integerDotProductProperties[ndx].sType          = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR;
4184                 integerDotProductProperties[ndx].pNext          = DE_NULL;
4185
4186                 extProperties.pNext                                                     = &idProperties[ndx];
4187
4188                 vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4189         }
4190
4191         if ( khr_external_fence_capabilities || khr_external_memory_capabilities || khr_external_semaphore_capabilities )
4192                 log << TestLog::Message << idProperties[0]                                      << TestLog::EndMessage;
4193         if (khr_multiview)
4194                 log << TestLog::Message << multiviewProperties[0]                       << TestLog::EndMessage;
4195         if (khr_device_protected_memory)
4196                 log << TestLog::Message << protectedMemoryPropertiesKHR[0]      << TestLog::EndMessage;
4197         if (khr_device_subgroup)
4198                 log << TestLog::Message << subgroupProperties[0]                        << TestLog::EndMessage;
4199         if (khr_maintenance2)
4200                 log << TestLog::Message << pointClippingProperties[0]           << TestLog::EndMessage;
4201         if (khr_maintenance3)
4202                 log << TestLog::Message << maintenance3Properties[0]            << TestLog::EndMessage;
4203         if (khr_depth_stencil_resolve)
4204                 log << TestLog::Message << depthStencilResolveProperties[0] << TestLog::EndMessage;
4205         if (khr_driver_properties)
4206                 log << TestLog::Message << driverProperties[0]                          << TestLog::EndMessage;
4207         if (khr_shader_float_controls)
4208                 log << TestLog::Message << floatControlsProperties[0]           << TestLog::EndMessage;
4209         if (khr_descriptor_indexing)
4210                 log << TestLog::Message << descriptorIndexingProperties[0] << TestLog::EndMessage;
4211         if (khr_sampler_filter_minmax)
4212                 log << TestLog::Message << samplerFilterMinmaxProperties[0] << TestLog::EndMessage;
4213         if (khr_integer_dot_product)
4214                 log << TestLog::Message << integerDotProductProperties[0] << TestLog::EndMessage;
4215
4216         if ( khr_external_fence_capabilities || khr_external_memory_capabilities || khr_external_semaphore_capabilities )
4217         {
4218                 if ((deMemCmp(idProperties[0].deviceUUID, idProperties[1].deviceUUID, VK_UUID_SIZE) != 0) ||
4219                         (deMemCmp(idProperties[0].driverUUID, idProperties[1].driverUUID, VK_UUID_SIZE) != 0) ||
4220                         (idProperties[0].deviceLUIDValid        != idProperties[1].deviceLUIDValid))
4221                 {
4222                         TCU_FAIL("Mismatch between VkPhysicalDeviceIDProperties");
4223                 }
4224                 else if (idProperties[0].deviceLUIDValid)
4225                 {
4226                         // If deviceLUIDValid is VK_FALSE, the contents of deviceLUID and deviceNodeMask are undefined
4227                         // so thay can only be compared when deviceLUIDValid is VK_TRUE.
4228                         if ((deMemCmp(idProperties[0].deviceLUID, idProperties[1].deviceLUID, VK_LUID_SIZE) != 0) ||
4229                                 (idProperties[0].deviceNodeMask         != idProperties[1].deviceNodeMask))
4230                         {
4231                                 TCU_FAIL("Mismatch between VkPhysicalDeviceIDProperties");
4232                         }
4233                 }
4234         }
4235         if (khr_multiview &&
4236                 (multiviewProperties[0].maxMultiviewViewCount           != multiviewProperties[1].maxMultiviewViewCount ||
4237                  multiviewProperties[0].maxMultiviewInstanceIndex       != multiviewProperties[1].maxMultiviewInstanceIndex))
4238         {
4239                 TCU_FAIL("Mismatch between VkPhysicalDeviceMultiviewProperties");
4240         }
4241         if (khr_device_protected_memory &&
4242                 (protectedMemoryPropertiesKHR[0].protectedNoFault       != protectedMemoryPropertiesKHR[1].protectedNoFault))
4243         {
4244                 TCU_FAIL("Mismatch between VkPhysicalDeviceProtectedMemoryProperties");
4245         }
4246         if (khr_device_subgroup &&
4247                 (subgroupProperties[0].subgroupSize                                     != subgroupProperties[1].subgroupSize ||
4248                  subgroupProperties[0].supportedStages                          != subgroupProperties[1].supportedStages ||
4249                  subgroupProperties[0].supportedOperations                      != subgroupProperties[1].supportedOperations ||
4250                  subgroupProperties[0].quadOperationsInAllStages        != subgroupProperties[1].quadOperationsInAllStages ))
4251         {
4252                 TCU_FAIL("Mismatch between VkPhysicalDeviceSubgroupProperties");
4253         }
4254         if (khr_maintenance2 &&
4255                 (pointClippingProperties[0].pointClippingBehavior       != pointClippingProperties[1].pointClippingBehavior))
4256         {
4257                 TCU_FAIL("Mismatch between VkPhysicalDevicePointClippingProperties");
4258         }
4259         if (khr_maintenance3 &&
4260                 (maintenance3Properties[0].maxPerSetDescriptors         != maintenance3Properties[1].maxPerSetDescriptors ||
4261                  maintenance3Properties[0].maxMemoryAllocationSize      != maintenance3Properties[1].maxMemoryAllocationSize))
4262         {
4263                 if (protectedMemoryPropertiesKHR[0].protectedNoFault != protectedMemoryPropertiesKHR[1].protectedNoFault)
4264                 {
4265                         TCU_FAIL("Mismatch between VkPhysicalDeviceProtectedMemoryProperties");
4266                 }
4267                 if ((subgroupProperties[0].subgroupSize                                 != subgroupProperties[1].subgroupSize) ||
4268                         (subgroupProperties[0].supportedStages                          != subgroupProperties[1].supportedStages) ||
4269                         (subgroupProperties[0].supportedOperations                      != subgroupProperties[1].supportedOperations) ||
4270                         (subgroupProperties[0].quadOperationsInAllStages        != subgroupProperties[1].quadOperationsInAllStages))
4271                 {
4272                         TCU_FAIL("Mismatch between VkPhysicalDeviceSubgroupProperties");
4273                 }
4274                 TCU_FAIL("Mismatch between VkPhysicalDeviceMaintenance3Properties");
4275         }
4276         if (khr_depth_stencil_resolve &&
4277                 (depthStencilResolveProperties[0].supportedDepthResolveModes    != depthStencilResolveProperties[1].supportedDepthResolveModes ||
4278                  depthStencilResolveProperties[0].supportedStencilResolveModes  != depthStencilResolveProperties[1].supportedStencilResolveModes ||
4279                  depthStencilResolveProperties[0].independentResolveNone                != depthStencilResolveProperties[1].independentResolveNone ||
4280                  depthStencilResolveProperties[0].independentResolve                    != depthStencilResolveProperties[1].independentResolve))
4281         {
4282                 TCU_FAIL("Mismatch between VkPhysicalDeviceDepthStencilResolveProperties");
4283         }
4284         if (khr_driver_properties &&
4285                 (driverProperties[0].driverID                                                                                           != driverProperties[1].driverID ||
4286                  strncmp(driverProperties[0].driverName, driverProperties[1].driverName, VK_MAX_DRIVER_NAME_SIZE)       != 0 ||
4287                  strncmp(driverProperties[0].driverInfo, driverProperties[1].driverInfo, VK_MAX_DRIVER_INFO_SIZE)               != 0 ||
4288                  driverProperties[0].conformanceVersion.major                                                           != driverProperties[1].conformanceVersion.major ||
4289                  driverProperties[0].conformanceVersion.minor                                                           != driverProperties[1].conformanceVersion.minor ||
4290                  driverProperties[0].conformanceVersion.subminor                                                        != driverProperties[1].conformanceVersion.subminor ||
4291                  driverProperties[0].conformanceVersion.patch                                                           != driverProperties[1].conformanceVersion.patch))
4292         {
4293                 TCU_FAIL("Mismatch between VkPhysicalDeviceDriverProperties");
4294         }
4295         if (khr_shader_float_controls &&
4296                 (floatControlsProperties[0].denormBehaviorIndependence                          != floatControlsProperties[1].denormBehaviorIndependence ||
4297                  floatControlsProperties[0].roundingModeIndependence                            != floatControlsProperties[1].roundingModeIndependence ||
4298                  floatControlsProperties[0].shaderSignedZeroInfNanPreserveFloat16       != floatControlsProperties[1].shaderSignedZeroInfNanPreserveFloat16 ||
4299                  floatControlsProperties[0].shaderSignedZeroInfNanPreserveFloat32       != floatControlsProperties[1].shaderSignedZeroInfNanPreserveFloat32 ||
4300                  floatControlsProperties[0].shaderSignedZeroInfNanPreserveFloat64       != floatControlsProperties[1].shaderSignedZeroInfNanPreserveFloat64 ||
4301                  floatControlsProperties[0].shaderDenormPreserveFloat16                         != floatControlsProperties[1].shaderDenormPreserveFloat16 ||
4302                  floatControlsProperties[0].shaderDenormPreserveFloat32                         != floatControlsProperties[1].shaderDenormPreserveFloat32 ||
4303                  floatControlsProperties[0].shaderDenormPreserveFloat64                         != floatControlsProperties[1].shaderDenormPreserveFloat64 ||
4304                  floatControlsProperties[0].shaderDenormFlushToZeroFloat16                      != floatControlsProperties[1].shaderDenormFlushToZeroFloat16 ||
4305                  floatControlsProperties[0].shaderDenormFlushToZeroFloat32                      != floatControlsProperties[1].shaderDenormFlushToZeroFloat32 ||
4306                  floatControlsProperties[0].shaderDenormFlushToZeroFloat64                      != floatControlsProperties[1].shaderDenormFlushToZeroFloat64 ||
4307                  floatControlsProperties[0].shaderRoundingModeRTEFloat16                        != floatControlsProperties[1].shaderRoundingModeRTEFloat16 ||
4308                  floatControlsProperties[0].shaderRoundingModeRTEFloat32                        != floatControlsProperties[1].shaderRoundingModeRTEFloat32 ||
4309                  floatControlsProperties[0].shaderRoundingModeRTEFloat64                        != floatControlsProperties[1].shaderRoundingModeRTEFloat64 ||
4310                  floatControlsProperties[0].shaderRoundingModeRTZFloat16                        != floatControlsProperties[1].shaderRoundingModeRTZFloat16 ||
4311                  floatControlsProperties[0].shaderRoundingModeRTZFloat32                        != floatControlsProperties[1].shaderRoundingModeRTZFloat32 ||
4312                  floatControlsProperties[0].shaderRoundingModeRTZFloat64                        != floatControlsProperties[1].shaderRoundingModeRTZFloat64 ))
4313         {
4314                 TCU_FAIL("Mismatch between VkPhysicalDeviceFloatControlsProperties");
4315         }
4316         if (khr_descriptor_indexing &&
4317                 (descriptorIndexingProperties[0].maxUpdateAfterBindDescriptorsInAllPools                                != descriptorIndexingProperties[1].maxUpdateAfterBindDescriptorsInAllPools ||
4318                  descriptorIndexingProperties[0].shaderUniformBufferArrayNonUniformIndexingNative               != descriptorIndexingProperties[1].shaderUniformBufferArrayNonUniformIndexingNative ||
4319                  descriptorIndexingProperties[0].shaderSampledImageArrayNonUniformIndexingNative                != descriptorIndexingProperties[1].shaderSampledImageArrayNonUniformIndexingNative ||
4320                  descriptorIndexingProperties[0].shaderStorageBufferArrayNonUniformIndexingNative               != descriptorIndexingProperties[1].shaderStorageBufferArrayNonUniformIndexingNative ||
4321                  descriptorIndexingProperties[0].shaderStorageImageArrayNonUniformIndexingNative                != descriptorIndexingProperties[1].shaderStorageImageArrayNonUniformIndexingNative ||
4322                  descriptorIndexingProperties[0].shaderInputAttachmentArrayNonUniformIndexingNative             != descriptorIndexingProperties[1].shaderInputAttachmentArrayNonUniformIndexingNative ||
4323                  descriptorIndexingProperties[0].robustBufferAccessUpdateAfterBind                                              != descriptorIndexingProperties[1].robustBufferAccessUpdateAfterBind ||
4324                  descriptorIndexingProperties[0].quadDivergentImplicitLod                                                               != descriptorIndexingProperties[1].quadDivergentImplicitLod ||
4325                  descriptorIndexingProperties[0].maxPerStageDescriptorUpdateAfterBindSamplers                   != descriptorIndexingProperties[1].maxPerStageDescriptorUpdateAfterBindSamplers ||
4326                  descriptorIndexingProperties[0].maxPerStageDescriptorUpdateAfterBindUniformBuffers             != descriptorIndexingProperties[1].maxPerStageDescriptorUpdateAfterBindUniformBuffers ||
4327                  descriptorIndexingProperties[0].maxPerStageDescriptorUpdateAfterBindStorageBuffers             != descriptorIndexingProperties[1].maxPerStageDescriptorUpdateAfterBindStorageBuffers ||
4328                  descriptorIndexingProperties[0].maxPerStageDescriptorUpdateAfterBindSampledImages              != descriptorIndexingProperties[1].maxPerStageDescriptorUpdateAfterBindSampledImages ||
4329                  descriptorIndexingProperties[0].maxPerStageDescriptorUpdateAfterBindStorageImages              != descriptorIndexingProperties[1].maxPerStageDescriptorUpdateAfterBindStorageImages ||
4330                  descriptorIndexingProperties[0].maxPerStageDescriptorUpdateAfterBindInputAttachments   != descriptorIndexingProperties[1].maxPerStageDescriptorUpdateAfterBindInputAttachments ||
4331                  descriptorIndexingProperties[0].maxPerStageUpdateAfterBindResources                                    != descriptorIndexingProperties[1].maxPerStageUpdateAfterBindResources ||
4332                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindSamplers                                != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindSamplers ||
4333                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindUniformBuffers                  != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindUniformBuffers ||
4334                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindUniformBuffersDynamic   != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindUniformBuffersDynamic ||
4335                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindStorageBuffers                  != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindStorageBuffers ||
4336                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindStorageBuffersDynamic   != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindStorageBuffersDynamic ||
4337                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindSampledImages                   != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindSampledImages ||
4338                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindStorageImages                   != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindStorageImages ||
4339                  descriptorIndexingProperties[0].maxDescriptorSetUpdateAfterBindInputAttachments                != descriptorIndexingProperties[1].maxDescriptorSetUpdateAfterBindInputAttachments ))
4340         {
4341                 TCU_FAIL("Mismatch between VkPhysicalDeviceDescriptorIndexingProperties");
4342         }
4343         if (khr_sampler_filter_minmax &&
4344                 (samplerFilterMinmaxProperties[0].filterMinmaxSingleComponentFormats    != samplerFilterMinmaxProperties[1].filterMinmaxSingleComponentFormats ||
4345                  samplerFilterMinmaxProperties[0].filterMinmaxImageComponentMapping             != samplerFilterMinmaxProperties[1].filterMinmaxImageComponentMapping))
4346         {
4347                 TCU_FAIL("Mismatch between VkPhysicalDeviceSamplerFilterMinmaxProperties");
4348         }
4349
4350         if (khr_integer_dot_product &&
4351                 (integerDotProductProperties[0].integerDotProduct8BitUnsignedAccelerated                                                                                != integerDotProductProperties[1].integerDotProduct8BitUnsignedAccelerated ||
4352                  integerDotProductProperties[0].integerDotProduct8BitSignedAccelerated                                                                                  != integerDotProductProperties[1].integerDotProduct8BitSignedAccelerated ||
4353                  integerDotProductProperties[0].integerDotProduct8BitMixedSignednessAccelerated                                                                 != integerDotProductProperties[1].integerDotProduct8BitMixedSignednessAccelerated ||
4354                  integerDotProductProperties[0].integerDotProduct4x8BitPackedUnsignedAccelerated                                                                != integerDotProductProperties[1].integerDotProduct4x8BitPackedUnsignedAccelerated ||
4355                  integerDotProductProperties[0].integerDotProduct4x8BitPackedSignedAccelerated                                                                  != integerDotProductProperties[1].integerDotProduct4x8BitPackedSignedAccelerated ||
4356                  integerDotProductProperties[0].integerDotProduct4x8BitPackedMixedSignednessAccelerated                                                 != integerDotProductProperties[1].integerDotProduct4x8BitPackedMixedSignednessAccelerated ||
4357                  integerDotProductProperties[0].integerDotProduct16BitUnsignedAccelerated                                                                               != integerDotProductProperties[1].integerDotProduct16BitUnsignedAccelerated ||
4358                  integerDotProductProperties[0].integerDotProduct16BitSignedAccelerated                                                                                 != integerDotProductProperties[1].integerDotProduct16BitSignedAccelerated ||
4359                  integerDotProductProperties[0].integerDotProduct16BitMixedSignednessAccelerated                                                                != integerDotProductProperties[1].integerDotProduct16BitMixedSignednessAccelerated ||
4360                  integerDotProductProperties[0].integerDotProduct32BitUnsignedAccelerated                                                                               != integerDotProductProperties[1].integerDotProduct32BitUnsignedAccelerated ||
4361                  integerDotProductProperties[0].integerDotProduct32BitSignedAccelerated                                                                                 != integerDotProductProperties[1].integerDotProduct32BitSignedAccelerated ||
4362                  integerDotProductProperties[0].integerDotProduct32BitMixedSignednessAccelerated                                                                != integerDotProductProperties[1].integerDotProduct32BitMixedSignednessAccelerated ||
4363                  integerDotProductProperties[0].integerDotProduct64BitUnsignedAccelerated                                                                               != integerDotProductProperties[1].integerDotProduct64BitUnsignedAccelerated ||
4364                  integerDotProductProperties[0].integerDotProduct64BitSignedAccelerated                                                                                 != integerDotProductProperties[1].integerDotProduct64BitSignedAccelerated ||
4365                  integerDotProductProperties[0].integerDotProduct64BitMixedSignednessAccelerated                                                                != integerDotProductProperties[1].integerDotProduct64BitMixedSignednessAccelerated ||
4366                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating8BitUnsignedAccelerated                                  != integerDotProductProperties[1].integerDotProductAccumulatingSaturating8BitUnsignedAccelerated ||
4367                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating8BitSignedAccelerated                                    != integerDotProductProperties[1].integerDotProductAccumulatingSaturating8BitSignedAccelerated ||
4368                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated                   != integerDotProductProperties[1].integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated ||
4369                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated                  != integerDotProductProperties[1].integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated ||
4370                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated                    != integerDotProductProperties[1].integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated ||
4371                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated   != integerDotProductProperties[1].integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated ||
4372                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating16BitUnsignedAccelerated                                 != integerDotProductProperties[1].integerDotProductAccumulatingSaturating16BitUnsignedAccelerated ||
4373                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating16BitSignedAccelerated                                   != integerDotProductProperties[1].integerDotProductAccumulatingSaturating16BitSignedAccelerated ||
4374                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated                  != integerDotProductProperties[1].integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated ||
4375                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating32BitUnsignedAccelerated                                 != integerDotProductProperties[1].integerDotProductAccumulatingSaturating32BitUnsignedAccelerated ||
4376                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating32BitSignedAccelerated                                   != integerDotProductProperties[1].integerDotProductAccumulatingSaturating32BitSignedAccelerated ||
4377                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated                  != integerDotProductProperties[1].integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated ||
4378                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating64BitUnsignedAccelerated                                 != integerDotProductProperties[1].integerDotProductAccumulatingSaturating64BitUnsignedAccelerated ||
4379                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating64BitSignedAccelerated                                   != integerDotProductProperties[1].integerDotProductAccumulatingSaturating64BitSignedAccelerated ||
4380                  integerDotProductProperties[0].integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated                  != integerDotProductProperties[1].integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated))
4381         {
4382                 TCU_FAIL("Mismatch between VkPhysicalDeviceShaderIntegerDotProductPropertiesKHR");
4383         }
4384
4385         if (isExtensionSupported(properties, RequiredExtension("VK_KHR_push_descriptor")))
4386         {
4387                 VkPhysicalDevicePushDescriptorPropertiesKHR             pushDescriptorProperties[count];
4388
4389                 for (int ndx = 0; ndx < count; ++ndx)
4390                 {
4391                         deMemset(&pushDescriptorProperties[ndx], 0xFF * ndx, sizeof(VkPhysicalDevicePushDescriptorPropertiesKHR));
4392
4393                         pushDescriptorProperties[ndx].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR;
4394                         pushDescriptorProperties[ndx].pNext     = DE_NULL;
4395
4396                         extProperties.pNext = &pushDescriptorProperties[ndx];
4397
4398                         vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4399
4400                         pushDescriptorProperties[ndx].pNext = DE_NULL;
4401                 }
4402
4403                 log << TestLog::Message << pushDescriptorProperties[0] << TestLog::EndMessage;
4404
4405                 if ( pushDescriptorProperties[0].maxPushDescriptors != pushDescriptorProperties[1].maxPushDescriptors )
4406                 {
4407                         TCU_FAIL("Mismatch between VkPhysicalDevicePushDescriptorPropertiesKHR ");
4408                 }
4409                 if (pushDescriptorProperties[0].maxPushDescriptors < 32)
4410                 {
4411                         TCU_FAIL("VkPhysicalDevicePushDescriptorPropertiesKHR.maxPushDescriptors must be at least 32");
4412                 }
4413         }
4414
4415         if (isExtensionSupported(properties, RequiredExtension("VK_KHR_performance_query")))
4416         {
4417                 VkPhysicalDevicePerformanceQueryPropertiesKHR performanceQueryProperties[count];
4418
4419                 for (int ndx = 0; ndx < count; ++ndx)
4420                 {
4421                         deMemset(&performanceQueryProperties[ndx], 0xFF * ndx, sizeof(VkPhysicalDevicePerformanceQueryPropertiesKHR));
4422                         performanceQueryProperties[ndx].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR;
4423                         performanceQueryProperties[ndx].pNext = DE_NULL;
4424
4425                         extProperties.pNext = &performanceQueryProperties[ndx];
4426
4427                         vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4428                 }
4429
4430                 log << TestLog::Message << performanceQueryProperties[0] << TestLog::EndMessage;
4431
4432                 if (performanceQueryProperties[0].allowCommandBufferQueryCopies != performanceQueryProperties[1].allowCommandBufferQueryCopies)
4433                 {
4434                         TCU_FAIL("Mismatch between VkPhysicalDevicePerformanceQueryPropertiesKHR");
4435                 }
4436         }
4437
4438         if (isExtensionSupported(properties, RequiredExtension("VK_EXT_pci_bus_info", 2, 2)))
4439         {
4440                 VkPhysicalDevicePCIBusInfoPropertiesEXT pciBusInfoProperties[count];
4441
4442                 for (int ndx = 0; ndx < count; ++ndx)
4443                 {
4444                         // Each PCI device is identified by an 8-bit domain number, 5-bit
4445                         // device number and 3-bit function number[1][2].
4446                         //
4447                         // In addition, because PCI systems can be interconnected and
4448                         // divided in segments, Linux assigns a 16-bit number to the device
4449                         // as the "domain". In Windows, the segment or domain is stored in
4450                         // the higher 24-bit section of the bus number.
4451                         //
4452                         // This means the maximum unsigned 32-bit integer for these members
4453                         // are invalid values and should change after querying properties.
4454                         //
4455                         // [1] https://en.wikipedia.org/wiki/PCI_configuration_space
4456                         // [2] PCI Express Base Specification Revision 3.0, section 2.2.4.2.
4457                         deMemset(pciBusInfoProperties + ndx, 0xFF * ndx, sizeof(pciBusInfoProperties[ndx]));
4458                         pciBusInfoProperties[ndx].pciDomain   = DEUINT32_MAX;
4459                         pciBusInfoProperties[ndx].pciBus      = DEUINT32_MAX;
4460                         pciBusInfoProperties[ndx].pciDevice   = DEUINT32_MAX;
4461                         pciBusInfoProperties[ndx].pciFunction = DEUINT32_MAX;
4462
4463                         pciBusInfoProperties[ndx].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT;
4464                         pciBusInfoProperties[ndx].pNext = DE_NULL;
4465
4466                         extProperties.pNext = pciBusInfoProperties + ndx;
4467                         vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4468                 }
4469
4470                 log << TestLog::Message << toString(pciBusInfoProperties[0]) << TestLog::EndMessage;
4471
4472                 if (pciBusInfoProperties[0].pciDomain   != pciBusInfoProperties[1].pciDomain ||
4473                         pciBusInfoProperties[0].pciBus          != pciBusInfoProperties[1].pciBus ||
4474                         pciBusInfoProperties[0].pciDevice       != pciBusInfoProperties[1].pciDevice ||
4475                         pciBusInfoProperties[0].pciFunction     != pciBusInfoProperties[1].pciFunction)
4476                 {
4477                         TCU_FAIL("Mismatch between VkPhysicalDevicePCIBusInfoPropertiesEXT");
4478                 }
4479                 if (pciBusInfoProperties[0].pciDomain   == DEUINT32_MAX ||
4480                     pciBusInfoProperties[0].pciBus      == DEUINT32_MAX ||
4481                     pciBusInfoProperties[0].pciDevice   == DEUINT32_MAX ||
4482                     pciBusInfoProperties[0].pciFunction == DEUINT32_MAX)
4483                 {
4484                         TCU_FAIL("Invalid information in VkPhysicalDevicePCIBusInfoPropertiesEXT");
4485                 }
4486         }
4487
4488         if (isExtensionSupported(properties, RequiredExtension("VK_KHR_portability_subset")))
4489         {
4490                 VkPhysicalDevicePortabilitySubsetPropertiesKHR portabilitySubsetProperties[count];
4491
4492                 for (int ndx = 0; ndx < count; ++ndx)
4493                 {
4494                         deMemset(&portabilitySubsetProperties[ndx], 0xFF * ndx, sizeof(VkPhysicalDevicePortabilitySubsetPropertiesKHR));
4495                         portabilitySubsetProperties[ndx].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR;
4496                         portabilitySubsetProperties[ndx].pNext = DE_NULL;
4497
4498                         extProperties.pNext = &portabilitySubsetProperties[ndx];
4499
4500                         vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4501                 }
4502
4503                 log << TestLog::Message << portabilitySubsetProperties[0] << TestLog::EndMessage;
4504
4505                 if (portabilitySubsetProperties[0].minVertexInputBindingStrideAlignment != portabilitySubsetProperties[1].minVertexInputBindingStrideAlignment)
4506                 {
4507                         TCU_FAIL("Mismatch between VkPhysicalDevicePortabilitySubsetPropertiesKHR");
4508                 }
4509         }
4510
4511         return tcu::TestStatus::pass("Querying device properties succeeded");
4512 }
4513
4514 string toString (const VkFormatProperties2& value)
4515 {
4516         std::ostringstream      s;
4517         s << "VkFormatProperties2 = {\n";
4518         s << "\tsType = " << value.sType << '\n';
4519         s << "\tformatProperties = {\n";
4520         s << "\tlinearTilingFeatures = " << getFormatFeatureFlagsStr(value.formatProperties.linearTilingFeatures) << '\n';
4521         s << "\toptimalTilingFeatures = " << getFormatFeatureFlagsStr(value.formatProperties.optimalTilingFeatures) << '\n';
4522         s << "\tbufferFeatures = " << getFormatFeatureFlagsStr(value.formatProperties.bufferFeatures) << '\n';
4523         s << "\t}";
4524         s << "}";
4525         return s.str();
4526 }
4527
4528 tcu::TestStatus deviceFormatProperties2 (Context& context)
4529 {
4530         const CustomInstance                    instance                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4531         const InstanceDriver&                   vki                             (instance.getDriver());
4532         const VkPhysicalDevice                  physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4533         TestLog&                                                log                             = context.getTestContext().getLog();
4534
4535         for (int formatNdx = 0; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
4536         {
4537                 const VkFormat                  format                  = (VkFormat)formatNdx;
4538                 VkFormatProperties              coreProperties;
4539                 VkFormatProperties2             extProperties;
4540
4541                 deMemset(&coreProperties, 0xcd, sizeof(VkFormatProperties));
4542                 deMemset(&extProperties, 0xcd, sizeof(VkFormatProperties2));
4543
4544                 extProperties.sType     = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
4545                 extProperties.pNext = DE_NULL;
4546
4547                 vki.getPhysicalDeviceFormatProperties(physicalDevice, format, &coreProperties);
4548                 vki.getPhysicalDeviceFormatProperties2(physicalDevice, format, &extProperties);
4549
4550                 TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
4551                 TCU_CHECK(extProperties.pNext == DE_NULL);
4552
4553                 if (deMemCmp(&coreProperties, &extProperties.formatProperties, sizeof(VkFormatProperties)) != 0)
4554                         TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceFormatProperties and vkGetPhysicalDeviceFormatProperties2");
4555
4556                 log << TestLog::Message << toString (extProperties) << TestLog::EndMessage;
4557         }
4558
4559         return tcu::TestStatus::pass("Querying device format properties succeeded");
4560 }
4561
4562 tcu::TestStatus deviceQueueFamilyProperties2 (Context& context)
4563 {
4564         const CustomInstance                    instance                                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4565         const InstanceDriver&                   vki                                             (instance.getDriver());
4566         const VkPhysicalDevice                  physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4567         TestLog&                                                log                                             = context.getTestContext().getLog();
4568         deUint32                                                numCoreQueueFamilies    = ~0u;
4569         deUint32                                                numExtQueueFamilies             = ~0u;
4570
4571         vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, DE_NULL);
4572         vki.getPhysicalDeviceQueueFamilyProperties2(physicalDevice, &numExtQueueFamilies, DE_NULL);
4573
4574         TCU_CHECK_MSG(numCoreQueueFamilies == numExtQueueFamilies, "Different number of queue family properties reported");
4575         TCU_CHECK(numCoreQueueFamilies > 0);
4576
4577         {
4578                 std::vector<VkQueueFamilyProperties>            coreProperties  (numCoreQueueFamilies);
4579                 std::vector<VkQueueFamilyProperties2>           extProperties   (numExtQueueFamilies);
4580
4581                 deMemset(&coreProperties[0], 0xcd, sizeof(VkQueueFamilyProperties)*numCoreQueueFamilies);
4582                 deMemset(&extProperties[0], 0xcd, sizeof(VkQueueFamilyProperties2)*numExtQueueFamilies);
4583
4584                 for (size_t ndx = 0; ndx < extProperties.size(); ++ndx)
4585                 {
4586                         extProperties[ndx].sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2;
4587                         extProperties[ndx].pNext = DE_NULL;
4588                 }
4589
4590                 vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, &coreProperties[0]);
4591                 vki.getPhysicalDeviceQueueFamilyProperties2(physicalDevice, &numExtQueueFamilies, &extProperties[0]);
4592
4593                 TCU_CHECK((size_t)numCoreQueueFamilies == coreProperties.size());
4594                 TCU_CHECK((size_t)numExtQueueFamilies == extProperties.size());
4595                 DE_ASSERT(numCoreQueueFamilies == numExtQueueFamilies);
4596
4597                 for (size_t ndx = 0; ndx < extProperties.size(); ++ndx)
4598                 {
4599                         TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2);
4600                         TCU_CHECK(extProperties[ndx].pNext == DE_NULL);
4601
4602                         if (deMemCmp(&coreProperties[ndx], &extProperties[ndx].queueFamilyProperties, sizeof(VkQueueFamilyProperties)) != 0)
4603                                 TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceQueueFamilyProperties and vkGetPhysicalDeviceQueueFamilyProperties2");
4604
4605                         log << TestLog::Message << " queueFamilyNdx = " << ndx <<TestLog::EndMessage
4606                         << TestLog::Message << extProperties[ndx] << TestLog::EndMessage;
4607                 }
4608         }
4609
4610         return tcu::TestStatus::pass("Querying device queue family properties succeeded");
4611 }
4612
4613 tcu::TestStatus deviceMemoryProperties2 (Context& context)
4614 {
4615         const CustomInstance                            instance                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4616         const InstanceDriver&                           vki                             (instance.getDriver());
4617         const VkPhysicalDevice                          physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4618         TestLog&                                                        log                             = context.getTestContext().getLog();
4619         VkPhysicalDeviceMemoryProperties        coreProperties;
4620         VkPhysicalDeviceMemoryProperties2       extProperties;
4621
4622         deMemset(&coreProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties));
4623         deMemset(&extProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties2));
4624
4625         extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
4626         extProperties.pNext = DE_NULL;
4627
4628         vki.getPhysicalDeviceMemoryProperties(physicalDevice, &coreProperties);
4629         vki.getPhysicalDeviceMemoryProperties2(physicalDevice, &extProperties);
4630
4631         TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2);
4632         TCU_CHECK(extProperties.pNext == DE_NULL);
4633
4634         if (coreProperties.memoryTypeCount != extProperties.memoryProperties.memoryTypeCount)
4635                 TCU_FAIL("Mismatch between memoryTypeCount reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2");
4636         if (coreProperties.memoryHeapCount != extProperties.memoryProperties.memoryHeapCount)
4637                 TCU_FAIL("Mismatch between memoryHeapCount reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2");
4638         for (deUint32 i = 0; i < coreProperties.memoryTypeCount; i++)
4639                 if (deMemCmp(&coreProperties.memoryTypes[i], &extProperties.memoryProperties.memoryTypes[i], sizeof(VkMemoryType)) != 0)
4640                         TCU_FAIL("Mismatch between memoryTypes reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2");
4641         for (deUint32 i = 0; i < coreProperties.memoryHeapCount; i++)
4642                 if (deMemCmp(&coreProperties.memoryHeaps[i], &extProperties.memoryProperties.memoryHeaps[i], sizeof(VkMemoryHeap)) != 0)
4643                         TCU_FAIL("Mismatch between memoryHeaps reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2");
4644
4645         log << TestLog::Message << extProperties << TestLog::EndMessage;
4646
4647         return tcu::TestStatus::pass("Querying device memory properties succeeded");
4648 }
4649
4650 tcu::TestStatus deviceFeaturesVulkan12 (Context& context)
4651 {
4652         using namespace ValidateQueryBits;
4653
4654         const QueryMemberTableEntry                     feature11OffsetTable[] =
4655         {
4656                 // VkPhysicalDevice16BitStorageFeatures
4657                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, storageBuffer16BitAccess),
4658                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, uniformAndStorageBuffer16BitAccess),
4659                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, storagePushConstant16),
4660                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, storageInputOutput16),
4661
4662                 // VkPhysicalDeviceMultiviewFeatures
4663                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, multiview),
4664                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, multiviewGeometryShader),
4665                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, multiviewTessellationShader),
4666
4667                 // VkPhysicalDeviceVariablePointersFeatures
4668                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, variablePointersStorageBuffer),
4669                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, variablePointers),
4670
4671                 // VkPhysicalDeviceProtectedMemoryFeatures
4672                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, protectedMemory),
4673
4674                 // VkPhysicalDeviceSamplerYcbcrConversionFeatures
4675                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, samplerYcbcrConversion),
4676
4677                 // VkPhysicalDeviceShaderDrawParametersFeatures
4678                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Features, shaderDrawParameters),
4679                 { 0, 0 }
4680         };
4681         const QueryMemberTableEntry                     feature12OffsetTable[] =
4682         {
4683                 // None
4684                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, samplerMirrorClampToEdge),
4685                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, drawIndirectCount),
4686
4687                 // VkPhysicalDevice8BitStorageFeatures
4688                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, storageBuffer8BitAccess),
4689                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, uniformAndStorageBuffer8BitAccess),
4690                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, storagePushConstant8),
4691
4692                 // VkPhysicalDeviceShaderAtomicInt64Features
4693                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderBufferInt64Atomics),
4694                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderSharedInt64Atomics),
4695
4696                 // VkPhysicalDeviceShaderFloat16Int8Features
4697                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderFloat16),
4698                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderInt8),
4699
4700                 // VkPhysicalDeviceDescriptorIndexingFeatures
4701                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorIndexing),
4702                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderInputAttachmentArrayDynamicIndexing),
4703                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderUniformTexelBufferArrayDynamicIndexing),
4704                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderStorageTexelBufferArrayDynamicIndexing),
4705                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderUniformBufferArrayNonUniformIndexing),
4706                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderSampledImageArrayNonUniformIndexing),
4707                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderStorageBufferArrayNonUniformIndexing),
4708                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderStorageImageArrayNonUniformIndexing),
4709                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderInputAttachmentArrayNonUniformIndexing),
4710                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderUniformTexelBufferArrayNonUniformIndexing),
4711                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderStorageTexelBufferArrayNonUniformIndexing),
4712                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingUniformBufferUpdateAfterBind),
4713                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingSampledImageUpdateAfterBind),
4714                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingStorageImageUpdateAfterBind),
4715                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingStorageBufferUpdateAfterBind),
4716                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingUniformTexelBufferUpdateAfterBind),
4717                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingStorageTexelBufferUpdateAfterBind),
4718                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingUpdateUnusedWhilePending),
4719                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingPartiallyBound),
4720                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, descriptorBindingVariableDescriptorCount),
4721                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, runtimeDescriptorArray),
4722
4723                 // None
4724                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, samplerFilterMinmax),
4725
4726                 // VkPhysicalDeviceScalarBlockLayoutFeatures
4727                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, scalarBlockLayout),
4728
4729                 // VkPhysicalDeviceImagelessFramebufferFeatures
4730                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, imagelessFramebuffer),
4731
4732                 // VkPhysicalDeviceUniformBufferStandardLayoutFeatures
4733                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, uniformBufferStandardLayout),
4734
4735                 // VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures
4736                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderSubgroupExtendedTypes),
4737
4738                 // VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures
4739                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, separateDepthStencilLayouts),
4740
4741                 // VkPhysicalDeviceHostQueryResetFeatures
4742                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, hostQueryReset),
4743
4744                 // VkPhysicalDeviceTimelineSemaphoreFeatures
4745                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, timelineSemaphore),
4746
4747                 // VkPhysicalDeviceBufferDeviceAddressFeatures
4748                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, bufferDeviceAddress),
4749                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, bufferDeviceAddressCaptureReplay),
4750                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, bufferDeviceAddressMultiDevice),
4751
4752                 // VkPhysicalDeviceVulkanMemoryModelFeatures
4753                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, vulkanMemoryModel),
4754                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, vulkanMemoryModelDeviceScope),
4755                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, vulkanMemoryModelAvailabilityVisibilityChains),
4756
4757                 // None
4758                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderOutputViewportIndex),
4759                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, shaderOutputLayer),
4760                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Features, subgroupBroadcastDynamicId),
4761                 { 0, 0 }
4762         };
4763         TestLog&                                                                                        log                                                                             = context.getTestContext().getLog();
4764         const CustomInstance                                                            instance                                                                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4765         const InstanceDriver&                                                           vki                                                                             = instance.getDriver();
4766         const VkPhysicalDevice                                                          physicalDevice                                                  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4767         const deUint32                                                                          vulkan11FeaturesBufferSize                              = sizeof(VkPhysicalDeviceVulkan11Features) + GUARD_SIZE;
4768         const deUint32                                                                          vulkan12FeaturesBufferSize                              = sizeof(VkPhysicalDeviceVulkan12Features) + GUARD_SIZE;
4769         VkPhysicalDeviceFeatures2                                                       extFeatures;
4770         deUint8                                                                                         buffer11a[vulkan11FeaturesBufferSize];
4771         deUint8                                                                                         buffer11b[vulkan11FeaturesBufferSize];
4772         deUint8                                                                                         buffer12a[vulkan12FeaturesBufferSize];
4773         deUint8                                                                                         buffer12b[vulkan12FeaturesBufferSize];
4774         const int                                                                                       count                                                                   = 2u;
4775         VkPhysicalDeviceVulkan11Features*                                       vulkan11Features[count]                                 = { (VkPhysicalDeviceVulkan11Features*)(buffer11a), (VkPhysicalDeviceVulkan11Features*)(buffer11b)};
4776         VkPhysicalDeviceVulkan12Features*                                       vulkan12Features[count]                                 = { (VkPhysicalDeviceVulkan12Features*)(buffer12a), (VkPhysicalDeviceVulkan12Features*)(buffer12b)};
4777
4778         if (!context.contextSupports(vk::ApiVersion(1, 2, 0)))
4779                 TCU_THROW(NotSupportedError, "At least Vulkan 1.2 required to run test");
4780
4781         deMemset(buffer11b, GUARD_VALUE, sizeof(buffer11b));
4782         deMemset(buffer12a, GUARD_VALUE, sizeof(buffer12a));
4783         deMemset(buffer12b, GUARD_VALUE, sizeof(buffer12b));
4784         deMemset(buffer11a, GUARD_VALUE, sizeof(buffer11a));
4785
4786         // Validate all fields initialized
4787         for (int ndx = 0; ndx < count; ++ndx)
4788         {
4789                 deMemset(&extFeatures.features, 0x00, sizeof(extFeatures.features));
4790                 extFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
4791                 extFeatures.pNext = vulkan11Features[ndx];
4792
4793                 deMemset(vulkan11Features[ndx], 0xFF * ndx, sizeof(VkPhysicalDeviceVulkan11Features));
4794                 vulkan11Features[ndx]->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
4795                 vulkan11Features[ndx]->pNext = vulkan12Features[ndx];
4796
4797                 deMemset(vulkan12Features[ndx], 0xFF * ndx, sizeof(VkPhysicalDeviceVulkan12Features));
4798                 vulkan12Features[ndx]->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
4799                 vulkan12Features[ndx]->pNext = DE_NULL;
4800
4801                 vki.getPhysicalDeviceFeatures2(physicalDevice, &extFeatures);
4802         }
4803
4804         log << TestLog::Message << *vulkan11Features[0] << TestLog::EndMessage;
4805         log << TestLog::Message << *vulkan12Features[0] << TestLog::EndMessage;
4806
4807         if (!validateStructsWithGuard(feature11OffsetTable, vulkan11Features, GUARD_VALUE, GUARD_SIZE))
4808         {
4809                 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceVulkan11Features initialization failure" << TestLog::EndMessage;
4810
4811                 return tcu::TestStatus::fail("VkPhysicalDeviceVulkan11Features initialization failure");
4812         }
4813
4814         if (!validateStructsWithGuard(feature12OffsetTable, vulkan12Features, GUARD_VALUE, GUARD_SIZE))
4815         {
4816                 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceVulkan12Features initialization failure" << TestLog::EndMessage;
4817
4818                 return tcu::TestStatus::fail("VkPhysicalDeviceVulkan12Features initialization failure");
4819         }
4820
4821         return tcu::TestStatus::pass("Querying Vulkan 1.2 device features succeeded");
4822 }
4823
4824 tcu::TestStatus devicePropertiesVulkan12 (Context& context)
4825 {
4826         using namespace ValidateQueryBits;
4827
4828         const QueryMemberTableEntry                     properties11OffsetTable[] =
4829         {
4830                 // VkPhysicalDeviceIDProperties
4831                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, deviceUUID),
4832                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, driverUUID),
4833                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, deviceLUID),
4834                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, deviceNodeMask),
4835                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, deviceLUIDValid),
4836
4837                 // VkPhysicalDeviceSubgroupProperties
4838                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, subgroupSize),
4839                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, subgroupSupportedStages),
4840                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, subgroupSupportedOperations),
4841                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, subgroupQuadOperationsInAllStages),
4842
4843                 // VkPhysicalDevicePointClippingProperties
4844                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, pointClippingBehavior),
4845
4846                 // VkPhysicalDeviceMultiviewProperties
4847                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, maxMultiviewViewCount),
4848                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, maxMultiviewInstanceIndex),
4849
4850                 // VkPhysicalDeviceProtectedMemoryProperties
4851                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, protectedNoFault),
4852
4853                 // VkPhysicalDeviceMaintenance3Properties
4854                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, maxPerSetDescriptors),
4855                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan11Properties, maxMemoryAllocationSize),
4856                 { 0, 0 }
4857         };
4858         const QueryMemberTableEntry                     properties12OffsetTable[] =
4859         {
4860                 // VkPhysicalDeviceDriverProperties
4861                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, driverID),
4862                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, conformanceVersion),
4863
4864                 // VkPhysicalDeviceFloatControlsProperties
4865                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, denormBehaviorIndependence),
4866                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, roundingModeIndependence),
4867                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderSignedZeroInfNanPreserveFloat16),
4868                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderSignedZeroInfNanPreserveFloat32),
4869                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderSignedZeroInfNanPreserveFloat64),
4870                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderDenormPreserveFloat16),
4871                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderDenormPreserveFloat32),
4872                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderDenormPreserveFloat64),
4873                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderDenormFlushToZeroFloat16),
4874                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderDenormFlushToZeroFloat32),
4875                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderDenormFlushToZeroFloat64),
4876                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderRoundingModeRTEFloat16),
4877                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderRoundingModeRTEFloat32),
4878                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderRoundingModeRTEFloat64),
4879                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderRoundingModeRTZFloat16),
4880                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderRoundingModeRTZFloat32),
4881                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderRoundingModeRTZFloat64),
4882
4883                 // VkPhysicalDeviceDescriptorIndexingProperties
4884                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxUpdateAfterBindDescriptorsInAllPools),
4885                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderUniformBufferArrayNonUniformIndexingNative),
4886                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderSampledImageArrayNonUniformIndexingNative),
4887                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderStorageBufferArrayNonUniformIndexingNative),
4888                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderStorageImageArrayNonUniformIndexingNative),
4889                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, shaderInputAttachmentArrayNonUniformIndexingNative),
4890                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, robustBufferAccessUpdateAfterBind),
4891                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, quadDivergentImplicitLod),
4892                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageDescriptorUpdateAfterBindSamplers),
4893                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageDescriptorUpdateAfterBindUniformBuffers),
4894                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageDescriptorUpdateAfterBindStorageBuffers),
4895                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageDescriptorUpdateAfterBindSampledImages),
4896                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageDescriptorUpdateAfterBindStorageImages),
4897                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageDescriptorUpdateAfterBindInputAttachments),
4898                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxPerStageUpdateAfterBindResources),
4899                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindSamplers),
4900                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindUniformBuffers),
4901                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindUniformBuffersDynamic),
4902                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindStorageBuffers),
4903                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindStorageBuffersDynamic),
4904                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindSampledImages),
4905                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindStorageImages),
4906                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxDescriptorSetUpdateAfterBindInputAttachments),
4907
4908                 // VkPhysicalDeviceDepthStencilResolveProperties
4909                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, supportedDepthResolveModes),
4910                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, supportedStencilResolveModes),
4911                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, independentResolveNone),
4912                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, independentResolve),
4913
4914                 // VkPhysicalDeviceSamplerFilterMinmaxProperties
4915                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, filterMinmaxSingleComponentFormats),
4916                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, filterMinmaxImageComponentMapping),
4917
4918                 // VkPhysicalDeviceTimelineSemaphoreProperties
4919                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, maxTimelineSemaphoreValueDifference),
4920
4921                 // None
4922                 OFFSET_TABLE_ENTRY(VkPhysicalDeviceVulkan12Properties, framebufferIntegerColorSampleCounts),
4923                 { 0, 0 }
4924         };
4925         TestLog&                                                                                log                                                                                     = context.getTestContext().getLog();
4926         const CustomInstance                                                    instance                                                                        (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4927         const InstanceDriver&                                                   vki                                                                                     = instance.getDriver();
4928         const VkPhysicalDevice                                                  physicalDevice                                                          (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4929         const deUint32                                                                  vulkan11PropertiesBufferSize                            = sizeof(VkPhysicalDeviceVulkan11Properties) + GUARD_SIZE;
4930         const deUint32                                                                  vulkan12PropertiesBufferSize                            = sizeof(VkPhysicalDeviceVulkan12Properties) + GUARD_SIZE;
4931         VkPhysicalDeviceProperties2                                             extProperties;
4932         deUint8                                                                                 buffer11a[vulkan11PropertiesBufferSize];
4933         deUint8                                                                                 buffer11b[vulkan11PropertiesBufferSize];
4934         deUint8                                                                                 buffer12a[vulkan12PropertiesBufferSize];
4935         deUint8                                                                                 buffer12b[vulkan12PropertiesBufferSize];
4936         const int                                                                               count                                                                           = 2u;
4937         VkPhysicalDeviceVulkan11Properties*                             vulkan11Properties[count]                                       = { (VkPhysicalDeviceVulkan11Properties*)(buffer11a), (VkPhysicalDeviceVulkan11Properties*)(buffer11b)};
4938         VkPhysicalDeviceVulkan12Properties*                             vulkan12Properties[count]                                       = { (VkPhysicalDeviceVulkan12Properties*)(buffer12a), (VkPhysicalDeviceVulkan12Properties*)(buffer12b)};
4939
4940         if (!context.contextSupports(vk::ApiVersion(1, 2, 0)))
4941                 TCU_THROW(NotSupportedError, "At least Vulkan 1.2 required to run test");
4942
4943         deMemset(buffer11a, GUARD_VALUE, sizeof(buffer11a));
4944         deMemset(buffer11b, GUARD_VALUE, sizeof(buffer11b));
4945         deMemset(buffer12a, GUARD_VALUE, sizeof(buffer12a));
4946         deMemset(buffer12b, GUARD_VALUE, sizeof(buffer12b));
4947
4948         for (int ndx = 0; ndx < count; ++ndx)
4949         {
4950                 deMemset(&extProperties.properties, 0x00, sizeof(extProperties.properties));
4951                 extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
4952                 extProperties.pNext = vulkan11Properties[ndx];
4953
4954                 deMemset(vulkan11Properties[ndx], 0xFF * ndx, sizeof(VkPhysicalDeviceVulkan11Properties));
4955                 vulkan11Properties[ndx]->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES;
4956                 vulkan11Properties[ndx]->pNext = vulkan12Properties[ndx];
4957
4958                 deMemset(vulkan12Properties[ndx], 0xFF * ndx, sizeof(VkPhysicalDeviceVulkan12Properties));
4959                 vulkan12Properties[ndx]->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES;
4960                 vulkan12Properties[ndx]->pNext = DE_NULL;
4961
4962                 vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
4963         }
4964
4965         log << TestLog::Message << *vulkan11Properties[0] << TestLog::EndMessage;
4966         log << TestLog::Message << *vulkan12Properties[0] << TestLog::EndMessage;
4967
4968         if (!validateStructsWithGuard(properties11OffsetTable, vulkan11Properties, GUARD_VALUE, GUARD_SIZE))
4969         {
4970                 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceVulkan11Properties initialization failure" << TestLog::EndMessage;
4971
4972                 return tcu::TestStatus::fail("VkPhysicalDeviceVulkan11Properties initialization failure");
4973         }
4974
4975         if (!validateStructsWithGuard(properties12OffsetTable, vulkan12Properties, GUARD_VALUE, GUARD_SIZE) ||
4976                 strncmp(vulkan12Properties[0]->driverName, vulkan12Properties[1]->driverName, VK_MAX_DRIVER_NAME_SIZE) != 0 ||
4977                 strncmp(vulkan12Properties[0]->driverInfo, vulkan12Properties[1]->driverInfo, VK_MAX_DRIVER_INFO_SIZE) != 0 )
4978         {
4979                 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceVulkan12Properties initialization failure" << TestLog::EndMessage;
4980
4981                 return tcu::TestStatus::fail("VkPhysicalDeviceVulkan12Properties initialization failure");
4982         }
4983
4984         return tcu::TestStatus::pass("Querying Vulkan 1.2 device properties succeeded");
4985 }
4986
4987 tcu::TestStatus deviceFeatureExtensionsConsistencyVulkan12(Context& context)
4988 {
4989         TestLog&                                                                                        log                                                                             = context.getTestContext().getLog();
4990         const CustomInstance                                                            instance                                                                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
4991         const InstanceDriver&                                                           vki                                                                             = instance.getDriver();
4992         const VkPhysicalDevice                                                          physicalDevice                                                  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
4993
4994         if (!context.contextSupports(vk::ApiVersion(1, 2, 0)))
4995                 TCU_THROW(NotSupportedError, "At least Vulkan 1.2 required to run test");
4996
4997         VkPhysicalDeviceVulkan12Features                                        vulkan12Features                                                = initVulkanStructure();
4998         VkPhysicalDeviceVulkan11Features                                        vulkan11Features                                                = initVulkanStructure(&vulkan12Features);
4999         VkPhysicalDeviceFeatures2                                                       extFeatures                                                             = initVulkanStructure(&vulkan11Features);
5000
5001         vki.getPhysicalDeviceFeatures2(physicalDevice, &extFeatures);
5002
5003         log << TestLog::Message << vulkan11Features << TestLog::EndMessage;
5004         log << TestLog::Message << vulkan12Features << TestLog::EndMessage;
5005
5006         // Validate if proper VkPhysicalDeviceVulkanXXFeatures fields are set when corresponding extensions are present
5007         std::pair<std::pair<const char*,const char*>, VkBool32> extensions2validate[] =
5008         {
5009                 { { "VK_KHR_sampler_mirror_clamp_to_edge",      "VkPhysicalDeviceVulkan12Features.samplerMirrorClampToEdge" },  vulkan12Features.samplerMirrorClampToEdge },
5010                 { { "VK_KHR_draw_indirect_count",                       "VkPhysicalDeviceVulkan12Features.drawIndirectCount" },                 vulkan12Features.drawIndirectCount },
5011                 { { "VK_EXT_descriptor_indexing",                       "VkPhysicalDeviceVulkan12Features.descriptorIndexing" },                vulkan12Features.descriptorIndexing },
5012                 { { "VK_EXT_sampler_filter_minmax",                     "VkPhysicalDeviceVulkan12Features.samplerFilterMinmax" },               vulkan12Features.samplerFilterMinmax },
5013                 { { "VK_EXT_shader_viewport_index_layer",       "VkPhysicalDeviceVulkan12Features.shaderOutputViewportIndex" }, vulkan12Features.shaderOutputViewportIndex },
5014                 { { "VK_EXT_shader_viewport_index_layer",       "VkPhysicalDeviceVulkan12Features.shaderOutputLayer" },                 vulkan12Features.shaderOutputLayer }
5015         };
5016         vector<VkExtensionProperties> extensionProperties = enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
5017         for (const auto& ext : extensions2validate)
5018                 if (checkExtension(extensionProperties, ext.first.first) && !ext.second)
5019                         TCU_FAIL(string("Mismatch between extension ") + ext.first.first + " and " + ext.first.second);
5020
5021         // collect all extension features
5022         {
5023                 VkPhysicalDevice16BitStorageFeatures                            device16BitStorageFeatures                              = initVulkanStructure();
5024                 VkPhysicalDeviceMultiviewFeatures                                       deviceMultiviewFeatures                                 = initVulkanStructure(&device16BitStorageFeatures);
5025                 VkPhysicalDeviceProtectedMemoryFeatures                         protectedMemoryFeatures                                 = initVulkanStructure(&deviceMultiviewFeatures);
5026                 VkPhysicalDeviceSamplerYcbcrConversionFeatures          samplerYcbcrConversionFeatures                  = initVulkanStructure(&protectedMemoryFeatures);
5027                 VkPhysicalDeviceShaderDrawParametersFeatures            shaderDrawParametersFeatures                    = initVulkanStructure(&samplerYcbcrConversionFeatures);
5028                 VkPhysicalDeviceVariablePointersFeatures                        variablePointerFeatures                                 = initVulkanStructure(&shaderDrawParametersFeatures);
5029                 VkPhysicalDevice8BitStorageFeatures                                     device8BitStorageFeatures                               = initVulkanStructure(&variablePointerFeatures);
5030                 VkPhysicalDeviceShaderAtomicInt64Features                       shaderAtomicInt64Features                               = initVulkanStructure(&device8BitStorageFeatures);
5031                 VkPhysicalDeviceShaderFloat16Int8Features                       shaderFloat16Int8Features                               = initVulkanStructure(&shaderAtomicInt64Features);
5032                 VkPhysicalDeviceDescriptorIndexingFeatures                      descriptorIndexingFeatures                              = initVulkanStructure(&shaderFloat16Int8Features);
5033                 VkPhysicalDeviceScalarBlockLayoutFeatures                       scalarBlockLayoutFeatures                               = initVulkanStructure(&descriptorIndexingFeatures);
5034                 VkPhysicalDeviceImagelessFramebufferFeatures            imagelessFramebufferFeatures                    = initVulkanStructure(&scalarBlockLayoutFeatures);
5035                 VkPhysicalDeviceUniformBufferStandardLayoutFeatures     uniformBufferStandardLayoutFeatures             = initVulkanStructure(&imagelessFramebufferFeatures);
5036                 VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures     shaderSubgroupExtendedTypesFeatures             = initVulkanStructure(&uniformBufferStandardLayoutFeatures);
5037                 VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures     separateDepthStencilLayoutsFeatures             = initVulkanStructure(&shaderSubgroupExtendedTypesFeatures);
5038                 VkPhysicalDeviceHostQueryResetFeatures                          hostQueryResetFeatures                                  = initVulkanStructure(&separateDepthStencilLayoutsFeatures);
5039                 VkPhysicalDeviceTimelineSemaphoreFeatures                       timelineSemaphoreFeatures                               = initVulkanStructure(&hostQueryResetFeatures);
5040                 VkPhysicalDeviceBufferDeviceAddressFeatures                     bufferDeviceAddressFeatures                             = initVulkanStructure(&timelineSemaphoreFeatures);
5041                 VkPhysicalDeviceVulkanMemoryModelFeatures                       vulkanMemoryModelFeatures                               = initVulkanStructure(&bufferDeviceAddressFeatures);
5042                 extFeatures = initVulkanStructure(&vulkanMemoryModelFeatures);
5043
5044                 vki.getPhysicalDeviceFeatures2(physicalDevice, &extFeatures);
5045
5046                 log << TestLog::Message << extFeatures << TestLog::EndMessage;
5047                 log << TestLog::Message << device16BitStorageFeatures << TestLog::EndMessage;
5048                 log << TestLog::Message << deviceMultiviewFeatures << TestLog::EndMessage;
5049                 log << TestLog::Message << protectedMemoryFeatures << TestLog::EndMessage;
5050                 log << TestLog::Message << samplerYcbcrConversionFeatures << TestLog::EndMessage;
5051                 log << TestLog::Message << shaderDrawParametersFeatures << TestLog::EndMessage;
5052                 log << TestLog::Message << variablePointerFeatures << TestLog::EndMessage;
5053                 log << TestLog::Message << device8BitStorageFeatures << TestLog::EndMessage;
5054                 log << TestLog::Message << shaderAtomicInt64Features << TestLog::EndMessage;
5055                 log << TestLog::Message << shaderFloat16Int8Features << TestLog::EndMessage;
5056                 log << TestLog::Message << descriptorIndexingFeatures << TestLog::EndMessage;
5057                 log << TestLog::Message << scalarBlockLayoutFeatures << TestLog::EndMessage;
5058                 log << TestLog::Message << imagelessFramebufferFeatures << TestLog::EndMessage;
5059                 log << TestLog::Message << uniformBufferStandardLayoutFeatures << TestLog::EndMessage;
5060                 log << TestLog::Message << shaderSubgroupExtendedTypesFeatures << TestLog::EndMessage;
5061                 log << TestLog::Message << separateDepthStencilLayoutsFeatures << TestLog::EndMessage;
5062                 log << TestLog::Message << hostQueryResetFeatures << TestLog::EndMessage;
5063                 log << TestLog::Message << timelineSemaphoreFeatures << TestLog::EndMessage;
5064                 log << TestLog::Message << bufferDeviceAddressFeatures << TestLog::EndMessage;
5065                 log << TestLog::Message << vulkanMemoryModelFeatures << TestLog::EndMessage;
5066
5067                 if ((   device16BitStorageFeatures.storageBuffer16BitAccess                             != vulkan11Features.storageBuffer16BitAccess ||
5068                                 device16BitStorageFeatures.uniformAndStorageBuffer16BitAccess   != vulkan11Features.uniformAndStorageBuffer16BitAccess ||
5069                                 device16BitStorageFeatures.storagePushConstant16                                != vulkan11Features.storagePushConstant16 ||
5070                                 device16BitStorageFeatures.storageInputOutput16                                 != vulkan11Features.storageInputOutput16 ))
5071                 {
5072                         TCU_FAIL("Mismatch between VkPhysicalDevice16BitStorageFeatures and VkPhysicalDeviceVulkan11Features");
5073                 }
5074
5075                 if ((   deviceMultiviewFeatures.multiview                                       != vulkan11Features.multiview ||
5076                                 deviceMultiviewFeatures.multiviewGeometryShader         != vulkan11Features.multiviewGeometryShader ||
5077                                 deviceMultiviewFeatures.multiviewTessellationShader     != vulkan11Features.multiviewTessellationShader ))
5078                 {
5079                         TCU_FAIL("Mismatch between VkPhysicalDeviceMultiviewFeatures and VkPhysicalDeviceVulkan11Features");
5080                 }
5081
5082                 if (    (protectedMemoryFeatures.protectedMemory        != vulkan11Features.protectedMemory ))
5083                 {
5084                         TCU_FAIL("Mismatch between VkPhysicalDeviceProtectedMemoryFeatures and VkPhysicalDeviceVulkan11Features");
5085                 }
5086
5087                 if (    (samplerYcbcrConversionFeatures.samplerYcbcrConversion  != vulkan11Features.samplerYcbcrConversion ))
5088                 {
5089                         TCU_FAIL("Mismatch between VkPhysicalDeviceSamplerYcbcrConversionFeatures and VkPhysicalDeviceVulkan11Features");
5090                 }
5091
5092                 if (    (shaderDrawParametersFeatures.shaderDrawParameters      != vulkan11Features.shaderDrawParameters ))
5093                 {
5094                         TCU_FAIL("Mismatch between VkPhysicalDeviceShaderDrawParametersFeatures and VkPhysicalDeviceVulkan11Features");
5095                 }
5096
5097                 if ((   variablePointerFeatures.variablePointersStorageBuffer   != vulkan11Features.variablePointersStorageBuffer ||
5098                                 variablePointerFeatures.variablePointers                                != vulkan11Features.variablePointers))
5099                 {
5100                         TCU_FAIL("Mismatch between VkPhysicalDeviceVariablePointersFeatures and VkPhysicalDeviceVulkan11Features");
5101                 }
5102
5103                 if ((   device8BitStorageFeatures.storageBuffer8BitAccess                       != vulkan12Features.storageBuffer8BitAccess ||
5104                                 device8BitStorageFeatures.uniformAndStorageBuffer8BitAccess     != vulkan12Features.uniformAndStorageBuffer8BitAccess ||
5105                                 device8BitStorageFeatures.storagePushConstant8                          != vulkan12Features.storagePushConstant8 ))
5106                 {
5107                         TCU_FAIL("Mismatch between VkPhysicalDevice8BitStorageFeatures and VkPhysicalDeviceVulkan12Features");
5108                 }
5109
5110                 if ((   shaderAtomicInt64Features.shaderBufferInt64Atomics != vulkan12Features.shaderBufferInt64Atomics ||
5111                                 shaderAtomicInt64Features.shaderSharedInt64Atomics != vulkan12Features.shaderSharedInt64Atomics ))
5112                 {
5113                         TCU_FAIL("Mismatch between VkPhysicalDeviceShaderAtomicInt64Features and VkPhysicalDeviceVulkan12Features");
5114                 }
5115
5116                 if ((   shaderFloat16Int8Features.shaderFloat16 != vulkan12Features.shaderFloat16 ||
5117                                 shaderFloat16Int8Features.shaderInt8            != vulkan12Features.shaderInt8 ))
5118                 {
5119                         TCU_FAIL("Mismatch between VkPhysicalDeviceShaderFloat16Int8Features and VkPhysicalDeviceVulkan12Features");
5120                 }
5121
5122                 if ((vulkan12Features.descriptorIndexing) &&
5123                         (       descriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing                    != vulkan12Features.shaderInputAttachmentArrayDynamicIndexing ||
5124                                 descriptorIndexingFeatures.shaderUniformTexelBufferArrayDynamicIndexing                 != vulkan12Features.shaderUniformTexelBufferArrayDynamicIndexing ||
5125                                 descriptorIndexingFeatures.shaderStorageTexelBufferArrayDynamicIndexing                 != vulkan12Features.shaderStorageTexelBufferArrayDynamicIndexing ||
5126                                 descriptorIndexingFeatures.shaderUniformBufferArrayNonUniformIndexing                   != vulkan12Features.shaderUniformBufferArrayNonUniformIndexing ||
5127                                 descriptorIndexingFeatures.shaderSampledImageArrayNonUniformIndexing                    != vulkan12Features.shaderSampledImageArrayNonUniformIndexing ||
5128                                 descriptorIndexingFeatures.shaderStorageBufferArrayNonUniformIndexing                   != vulkan12Features.shaderStorageBufferArrayNonUniformIndexing ||
5129                                 descriptorIndexingFeatures.shaderStorageImageArrayNonUniformIndexing                    != vulkan12Features.shaderStorageImageArrayNonUniformIndexing ||
5130                                 descriptorIndexingFeatures.shaderInputAttachmentArrayNonUniformIndexing                 != vulkan12Features.shaderInputAttachmentArrayNonUniformIndexing ||
5131                                 descriptorIndexingFeatures.shaderUniformTexelBufferArrayNonUniformIndexing              != vulkan12Features.shaderUniformTexelBufferArrayNonUniformIndexing ||
5132                                 descriptorIndexingFeatures.shaderStorageTexelBufferArrayNonUniformIndexing              != vulkan12Features.shaderStorageTexelBufferArrayNonUniformIndexing ||
5133                                 descriptorIndexingFeatures.descriptorBindingUniformBufferUpdateAfterBind                != vulkan12Features.descriptorBindingUniformBufferUpdateAfterBind ||
5134                                 descriptorIndexingFeatures.descriptorBindingSampledImageUpdateAfterBind                 != vulkan12Features.descriptorBindingSampledImageUpdateAfterBind ||
5135                                 descriptorIndexingFeatures.descriptorBindingStorageImageUpdateAfterBind                 != vulkan12Features.descriptorBindingStorageImageUpdateAfterBind ||
5136                                 descriptorIndexingFeatures.descriptorBindingStorageBufferUpdateAfterBind                != vulkan12Features.descriptorBindingStorageBufferUpdateAfterBind ||
5137                                 descriptorIndexingFeatures.descriptorBindingUniformTexelBufferUpdateAfterBind   != vulkan12Features.descriptorBindingUniformTexelBufferUpdateAfterBind ||
5138                                 descriptorIndexingFeatures.descriptorBindingStorageTexelBufferUpdateAfterBind   != vulkan12Features.descriptorBindingStorageTexelBufferUpdateAfterBind ||
5139                                 descriptorIndexingFeatures.descriptorBindingUpdateUnusedWhilePending                    != vulkan12Features.descriptorBindingUpdateUnusedWhilePending ||
5140                                 descriptorIndexingFeatures.descriptorBindingPartiallyBound                                              != vulkan12Features.descriptorBindingPartiallyBound ||
5141                                 descriptorIndexingFeatures.descriptorBindingVariableDescriptorCount                             != vulkan12Features.descriptorBindingVariableDescriptorCount ||
5142                                 descriptorIndexingFeatures.runtimeDescriptorArray                                                               != vulkan12Features.runtimeDescriptorArray ))
5143                 {
5144                         TCU_FAIL("Mismatch between VkPhysicalDeviceDescriptorIndexingFeatures and VkPhysicalDeviceVulkan12Features");
5145                 }
5146
5147                 if ((   scalarBlockLayoutFeatures.scalarBlockLayout != vulkan12Features.scalarBlockLayout ))
5148                 {
5149                         TCU_FAIL("Mismatch between VkPhysicalDeviceScalarBlockLayoutFeatures and VkPhysicalDeviceVulkan12Features");
5150                 }
5151
5152                 if ((   imagelessFramebufferFeatures.imagelessFramebuffer != vulkan12Features.imagelessFramebuffer ))
5153                 {
5154                         TCU_FAIL("Mismatch between VkPhysicalDeviceImagelessFramebufferFeatures and VkPhysicalDeviceVulkan12Features");
5155                 }
5156
5157                 if ((   uniformBufferStandardLayoutFeatures.uniformBufferStandardLayout != vulkan12Features.uniformBufferStandardLayout ))
5158                 {
5159                         TCU_FAIL("Mismatch between VkPhysicalDeviceUniformBufferStandardLayoutFeatures and VkPhysicalDeviceVulkan12Features");
5160                 }
5161
5162                 if ((   shaderSubgroupExtendedTypesFeatures.shaderSubgroupExtendedTypes != vulkan12Features.shaderSubgroupExtendedTypes ))
5163                 {
5164                         TCU_FAIL("Mismatch between VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures and VkPhysicalDeviceVulkan12Features");
5165                 }
5166
5167                 if ((   separateDepthStencilLayoutsFeatures.separateDepthStencilLayouts != vulkan12Features.separateDepthStencilLayouts ))
5168                 {
5169                         TCU_FAIL("Mismatch between VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures and VkPhysicalDeviceVulkan12Features");
5170                 }
5171
5172                 if ((   hostQueryResetFeatures.hostQueryReset != vulkan12Features.hostQueryReset ))
5173                 {
5174                         TCU_FAIL("Mismatch between VkPhysicalDeviceHostQueryResetFeatures and VkPhysicalDeviceVulkan12Features");
5175                 }
5176
5177                 if ((   timelineSemaphoreFeatures.timelineSemaphore != vulkan12Features.timelineSemaphore ))
5178                 {
5179                         TCU_FAIL("Mismatch between VkPhysicalDeviceTimelineSemaphoreFeatures and VkPhysicalDeviceVulkan12Features");
5180                 }
5181
5182                 if ((   bufferDeviceAddressFeatures.bufferDeviceAddress                                 != vulkan12Features.bufferDeviceAddress ||
5183                                 bufferDeviceAddressFeatures.bufferDeviceAddressCaptureReplay    != vulkan12Features.bufferDeviceAddressCaptureReplay ||
5184                                 bufferDeviceAddressFeatures.bufferDeviceAddressMultiDevice              != vulkan12Features.bufferDeviceAddressMultiDevice ))
5185                 {
5186                         TCU_FAIL("Mismatch between VkPhysicalDeviceBufferDeviceAddressFeatures and VkPhysicalDeviceVulkan12Features");
5187                 }
5188
5189                 if ((   vulkanMemoryModelFeatures.vulkanMemoryModel                                                             != vulkan12Features.vulkanMemoryModel ||
5190                                 vulkanMemoryModelFeatures.vulkanMemoryModelDeviceScope                                  != vulkan12Features.vulkanMemoryModelDeviceScope ||
5191                                 vulkanMemoryModelFeatures.vulkanMemoryModelAvailabilityVisibilityChains != vulkan12Features.vulkanMemoryModelAvailabilityVisibilityChains ))
5192                 {
5193                         TCU_FAIL("Mismatch between VkPhysicalDeviceVulkanMemoryModelFeatures and VkPhysicalDeviceVulkan12Features");
5194                 }
5195         }
5196
5197         return tcu::TestStatus::pass("Vulkan 1.2 device features are consistent with extensions");
5198 }
5199
5200 tcu::TestStatus devicePropertyExtensionsConsistencyVulkan12(Context& context)
5201 {
5202         TestLog&                                                                                log                                                                                     = context.getTestContext().getLog();
5203         const CustomInstance                                                    instance                                                                        (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
5204         const InstanceDriver&                                                   vki                                                                                     = instance.getDriver();
5205         const VkPhysicalDevice                                                  physicalDevice                                                          (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
5206
5207         if (!context.contextSupports(vk::ApiVersion(1, 2, 0)))
5208                 TCU_THROW(NotSupportedError, "At least Vulkan 1.2 required to run test");
5209
5210         VkPhysicalDeviceVulkan12Properties                              vulkan12Properties                                                      = initVulkanStructure();
5211         VkPhysicalDeviceVulkan11Properties                              vulkan11Properties                                                      = initVulkanStructure(&vulkan12Properties);
5212         VkPhysicalDeviceProperties2                                             extProperties                                                           = initVulkanStructure(&vulkan11Properties);
5213
5214         vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
5215
5216         log << TestLog::Message << vulkan11Properties << TestLog::EndMessage;
5217         log << TestLog::Message << vulkan12Properties << TestLog::EndMessage;
5218
5219         // Validate all fields initialized matching to extension structures
5220         {
5221                 VkPhysicalDeviceIDProperties                                    idProperties                                                            = initVulkanStructure();
5222                 VkPhysicalDeviceSubgroupProperties                              subgroupProperties                                                      = initVulkanStructure(&idProperties);
5223                 VkPhysicalDevicePointClippingProperties                 pointClippingProperties                                         = initVulkanStructure(&subgroupProperties);
5224                 VkPhysicalDeviceMultiviewProperties                             multiviewProperties                                                     = initVulkanStructure(&pointClippingProperties);
5225                 VkPhysicalDeviceProtectedMemoryProperties               protectedMemoryPropertiesKHR                            = initVulkanStructure(&multiviewProperties);
5226                 VkPhysicalDeviceMaintenance3Properties                  maintenance3Properties                                          = initVulkanStructure(&protectedMemoryPropertiesKHR);
5227                 VkPhysicalDeviceDriverProperties                                driverProperties                                                        = initVulkanStructure(&maintenance3Properties);
5228                 VkPhysicalDeviceFloatControlsProperties                 floatControlsProperties                                         = initVulkanStructure(&driverProperties);
5229                 VkPhysicalDeviceDescriptorIndexingProperties    descriptorIndexingProperties                            = initVulkanStructure(&floatControlsProperties);
5230                 VkPhysicalDeviceDepthStencilResolveProperties   depthStencilResolveProperties                           = initVulkanStructure(&descriptorIndexingProperties);
5231                 VkPhysicalDeviceSamplerFilterMinmaxProperties   samplerFilterMinmaxProperties                           = initVulkanStructure(&depthStencilResolveProperties);
5232                 VkPhysicalDeviceTimelineSemaphoreProperties             timelineSemaphoreProperties                                     = initVulkanStructure(&samplerFilterMinmaxProperties);
5233                 extProperties = initVulkanStructure(&timelineSemaphoreProperties);
5234
5235                 vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
5236
5237                 if ((deMemCmp(idProperties.deviceUUID, vulkan11Properties.deviceUUID, VK_UUID_SIZE) != 0) ||
5238                         (deMemCmp(idProperties.driverUUID, vulkan11Properties.driverUUID, VK_UUID_SIZE) != 0) ||
5239                         (idProperties.deviceLUIDValid != vulkan11Properties.deviceLUIDValid))
5240                 {
5241                         TCU_FAIL("Mismatch between VkPhysicalDeviceIDProperties and VkPhysicalDeviceVulkan11Properties");
5242                 }
5243                 else if (idProperties.deviceLUIDValid)
5244                 {
5245                         // If deviceLUIDValid is VK_FALSE, the contents of deviceLUID and deviceNodeMask are undefined
5246                         // so thay can only be compared when deviceLUIDValid is VK_TRUE.
5247                         if ((deMemCmp(idProperties.deviceLUID, vulkan11Properties.deviceLUID, VK_LUID_SIZE) != 0) ||
5248                                 (idProperties.deviceNodeMask != vulkan11Properties.deviceNodeMask))
5249                         {
5250                                 TCU_FAIL("Mismatch between VkPhysicalDeviceIDProperties and VkPhysicalDeviceVulkan11Properties");
5251                         }
5252                 }
5253
5254                 if ((subgroupProperties.subgroupSize                            != vulkan11Properties.subgroupSize ||
5255                          subgroupProperties.supportedStages                             != vulkan11Properties.subgroupSupportedStages ||
5256                          subgroupProperties.supportedOperations                 != vulkan11Properties.subgroupSupportedOperations ||
5257                          subgroupProperties.quadOperationsInAllStages   != vulkan11Properties.subgroupQuadOperationsInAllStages))
5258                 {
5259                         TCU_FAIL("Mismatch between VkPhysicalDeviceSubgroupProperties and VkPhysicalDeviceVulkan11Properties");
5260                 }
5261
5262                 if ((pointClippingProperties.pointClippingBehavior      != vulkan11Properties.pointClippingBehavior))
5263                 {
5264                         TCU_FAIL("Mismatch between VkPhysicalDevicePointClippingProperties and VkPhysicalDeviceVulkan11Properties");
5265                 }
5266
5267                 if ((multiviewProperties.maxMultiviewViewCount          != vulkan11Properties.maxMultiviewViewCount ||
5268                          multiviewProperties.maxMultiviewInstanceIndex  != vulkan11Properties.maxMultiviewInstanceIndex))
5269                 {
5270                         TCU_FAIL("Mismatch between VkPhysicalDeviceMultiviewProperties and VkPhysicalDeviceVulkan11Properties");
5271                 }
5272
5273                 if ((protectedMemoryPropertiesKHR.protectedNoFault      != vulkan11Properties.protectedNoFault))
5274                 {
5275                         TCU_FAIL("Mismatch between VkPhysicalDeviceProtectedMemoryProperties and VkPhysicalDeviceVulkan11Properties");
5276                 }
5277
5278                 if ((maintenance3Properties.maxPerSetDescriptors        != vulkan11Properties.maxPerSetDescriptors ||
5279                          maintenance3Properties.maxMemoryAllocationSize != vulkan11Properties.maxMemoryAllocationSize))
5280                 {
5281                         TCU_FAIL("Mismatch between VkPhysicalDeviceMaintenance3Properties and VkPhysicalDeviceVulkan11Properties");
5282                 }
5283
5284                 if ((driverProperties.driverID                                                                                          != vulkan12Properties.driverID ||
5285                          strncmp(driverProperties.driverName, vulkan12Properties.driverName, VK_MAX_DRIVER_NAME_SIZE)   != 0 ||
5286                          strncmp(driverProperties.driverInfo, vulkan12Properties.driverInfo, VK_MAX_DRIVER_INFO_SIZE)   != 0 ||
5287                          driverProperties.conformanceVersion.major                                                              != vulkan12Properties.conformanceVersion.major ||
5288                          driverProperties.conformanceVersion.minor                                                              != vulkan12Properties.conformanceVersion.minor ||
5289                          driverProperties.conformanceVersion.subminor                                                   != vulkan12Properties.conformanceVersion.subminor ||
5290                          driverProperties.conformanceVersion.patch                                                              != vulkan12Properties.conformanceVersion.patch))
5291                 {
5292                         TCU_FAIL("Mismatch between VkPhysicalDeviceDriverProperties and VkPhysicalDeviceVulkan12Properties");
5293                 }
5294
5295                 if ((floatControlsProperties.denormBehaviorIndependence                         != vulkan12Properties.denormBehaviorIndependence ||
5296                          floatControlsProperties.roundingModeIndependence                               != vulkan12Properties.roundingModeIndependence ||
5297                          floatControlsProperties.shaderSignedZeroInfNanPreserveFloat16  != vulkan12Properties.shaderSignedZeroInfNanPreserveFloat16 ||
5298                          floatControlsProperties.shaderSignedZeroInfNanPreserveFloat32  != vulkan12Properties.shaderSignedZeroInfNanPreserveFloat32 ||
5299                          floatControlsProperties.shaderSignedZeroInfNanPreserveFloat64  != vulkan12Properties.shaderSignedZeroInfNanPreserveFloat64 ||
5300                          floatControlsProperties.shaderDenormPreserveFloat16                    != vulkan12Properties.shaderDenormPreserveFloat16 ||
5301                          floatControlsProperties.shaderDenormPreserveFloat32                    != vulkan12Properties.shaderDenormPreserveFloat32 ||
5302                          floatControlsProperties.shaderDenormPreserveFloat64                    != vulkan12Properties.shaderDenormPreserveFloat64 ||
5303                          floatControlsProperties.shaderDenormFlushToZeroFloat16                 != vulkan12Properties.shaderDenormFlushToZeroFloat16 ||
5304                          floatControlsProperties.shaderDenormFlushToZeroFloat32                 != vulkan12Properties.shaderDenormFlushToZeroFloat32 ||
5305                          floatControlsProperties.shaderDenormFlushToZeroFloat64                 != vulkan12Properties.shaderDenormFlushToZeroFloat64 ||
5306                          floatControlsProperties.shaderRoundingModeRTEFloat16                   != vulkan12Properties.shaderRoundingModeRTEFloat16 ||
5307                          floatControlsProperties.shaderRoundingModeRTEFloat32                   != vulkan12Properties.shaderRoundingModeRTEFloat32 ||
5308                          floatControlsProperties.shaderRoundingModeRTEFloat64                   != vulkan12Properties.shaderRoundingModeRTEFloat64 ||
5309                          floatControlsProperties.shaderRoundingModeRTZFloat16                   != vulkan12Properties.shaderRoundingModeRTZFloat16 ||
5310                          floatControlsProperties.shaderRoundingModeRTZFloat32                   != vulkan12Properties.shaderRoundingModeRTZFloat32 ||
5311                          floatControlsProperties.shaderRoundingModeRTZFloat64                   != vulkan12Properties.shaderRoundingModeRTZFloat64 ))
5312                 {
5313                         TCU_FAIL("Mismatch between VkPhysicalDeviceFloatControlsProperties and VkPhysicalDeviceVulkan12Properties");
5314                 }
5315
5316                 if ((descriptorIndexingProperties.maxUpdateAfterBindDescriptorsInAllPools                               != vulkan12Properties.maxUpdateAfterBindDescriptorsInAllPools ||
5317                          descriptorIndexingProperties.shaderUniformBufferArrayNonUniformIndexingNative          != vulkan12Properties.shaderUniformBufferArrayNonUniformIndexingNative ||
5318                          descriptorIndexingProperties.shaderSampledImageArrayNonUniformIndexingNative           != vulkan12Properties.shaderSampledImageArrayNonUniformIndexingNative ||
5319                          descriptorIndexingProperties.shaderStorageBufferArrayNonUniformIndexingNative          != vulkan12Properties.shaderStorageBufferArrayNonUniformIndexingNative ||
5320                          descriptorIndexingProperties.shaderStorageImageArrayNonUniformIndexingNative           != vulkan12Properties.shaderStorageImageArrayNonUniformIndexingNative ||
5321                          descriptorIndexingProperties.shaderInputAttachmentArrayNonUniformIndexingNative        != vulkan12Properties.shaderInputAttachmentArrayNonUniformIndexingNative ||
5322                          descriptorIndexingProperties.robustBufferAccessUpdateAfterBind                                         != vulkan12Properties.robustBufferAccessUpdateAfterBind ||
5323                          descriptorIndexingProperties.quadDivergentImplicitLod                                                          != vulkan12Properties.quadDivergentImplicitLod ||
5324                          descriptorIndexingProperties.maxPerStageDescriptorUpdateAfterBindSamplers                      != vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSamplers ||
5325                          descriptorIndexingProperties.maxPerStageDescriptorUpdateAfterBindUniformBuffers        != vulkan12Properties.maxPerStageDescriptorUpdateAfterBindUniformBuffers ||
5326                          descriptorIndexingProperties.maxPerStageDescriptorUpdateAfterBindStorageBuffers        != vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageBuffers ||
5327                          descriptorIndexingProperties.maxPerStageDescriptorUpdateAfterBindSampledImages         != vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSampledImages ||
5328                          descriptorIndexingProperties.maxPerStageDescriptorUpdateAfterBindStorageImages         != vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageImages ||
5329                          descriptorIndexingProperties.maxPerStageDescriptorUpdateAfterBindInputAttachments      != vulkan12Properties.maxPerStageDescriptorUpdateAfterBindInputAttachments ||
5330                          descriptorIndexingProperties.maxPerStageUpdateAfterBindResources                                       != vulkan12Properties.maxPerStageUpdateAfterBindResources ||
5331                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindSamplers                           != vulkan12Properties.maxDescriptorSetUpdateAfterBindSamplers ||
5332                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindUniformBuffers                     != vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffers ||
5333                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic      != vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic ||
5334                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindStorageBuffers                     != vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffers ||
5335                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic      != vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic ||
5336                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindSampledImages                      != vulkan12Properties.maxDescriptorSetUpdateAfterBindSampledImages ||
5337                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindStorageImages                      != vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageImages ||
5338                          descriptorIndexingProperties.maxDescriptorSetUpdateAfterBindInputAttachments           != vulkan12Properties.maxDescriptorSetUpdateAfterBindInputAttachments ))
5339                 {
5340                         TCU_FAIL("Mismatch between VkPhysicalDeviceDescriptorIndexingProperties and VkPhysicalDeviceVulkan12Properties");
5341                 }
5342
5343                 if ((depthStencilResolveProperties.supportedDepthResolveModes   != vulkan12Properties.supportedDepthResolveModes ||
5344                          depthStencilResolveProperties.supportedStencilResolveModes     != vulkan12Properties.supportedStencilResolveModes ||
5345                          depthStencilResolveProperties.independentResolveNone           != vulkan12Properties.independentResolveNone ||
5346                          depthStencilResolveProperties.independentResolve                       != vulkan12Properties.independentResolve))
5347                 {
5348                         TCU_FAIL("Mismatch between VkPhysicalDeviceDepthStencilResolveProperties and VkPhysicalDeviceVulkan12Properties");
5349                 }
5350
5351                 if ((samplerFilterMinmaxProperties.filterMinmaxSingleComponentFormats   != vulkan12Properties.filterMinmaxSingleComponentFormats ||
5352                          samplerFilterMinmaxProperties.filterMinmaxImageComponentMapping        != vulkan12Properties.filterMinmaxImageComponentMapping))
5353                 {
5354                         TCU_FAIL("Mismatch between VkPhysicalDeviceSamplerFilterMinmaxProperties and VkPhysicalDeviceVulkan12Properties");
5355                 }
5356
5357                 if ((timelineSemaphoreProperties.maxTimelineSemaphoreValueDifference    != vulkan12Properties.maxTimelineSemaphoreValueDifference))
5358                 {
5359                         TCU_FAIL("Mismatch between VkPhysicalDeviceTimelineSemaphoreProperties and VkPhysicalDeviceVulkan12Properties");
5360                 }
5361         }
5362
5363         return tcu::TestStatus::pass("Vulkan 1.2 device properties are consistent with extension properties");
5364 }
5365
5366 tcu::TestStatus imageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
5367 {
5368         if (isYCbCrFormat(format))
5369                 // check if Ycbcr format enums are valid given the version and extensions
5370                 checkYcbcrApiSupport(context);
5371
5372         TestLog&                                                log                             = context.getTestContext().getLog();
5373
5374         const CustomInstance                    instance                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
5375         const InstanceDriver&                   vki                             (instance.getDriver());
5376         const VkPhysicalDevice                  physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
5377
5378         const VkImageCreateFlags                ycbcrFlags              = isYCbCrFormat(format) ? (VkImageCreateFlags)VK_IMAGE_CREATE_DISJOINT_BIT_KHR : (VkImageCreateFlags)0u;
5379         const VkImageUsageFlags                 allUsageFlags   = VK_IMAGE_USAGE_TRANSFER_SRC_BIT
5380                                                                                                         | VK_IMAGE_USAGE_TRANSFER_DST_BIT
5381                                                                                                         | VK_IMAGE_USAGE_SAMPLED_BIT
5382                                                                                                         | VK_IMAGE_USAGE_STORAGE_BIT
5383                                                                                                         | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
5384                                                                                                         | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
5385                                                                                                         | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
5386                                                                                                         | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
5387         const VkImageCreateFlags                allCreateFlags  = VK_IMAGE_CREATE_SPARSE_BINDING_BIT
5388                                                                                                         | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT
5389                                                                                                         | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT
5390                                                                                                         | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
5391                                                                                                         | VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
5392                                                                                                         | ycbcrFlags;
5393
5394         for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++)
5395         {
5396                 if (!isValidImageUsageFlagCombination(curUsageFlags))
5397                         continue;
5398
5399                 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= allCreateFlags; curCreateFlags++)
5400                 {
5401                         const VkPhysicalDeviceImageFormatInfo2  imageFormatInfo =
5402                         {
5403                                 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
5404                                 DE_NULL,
5405                                 format,
5406                                 imageType,
5407                                 tiling,
5408                                 curUsageFlags,
5409                                 curCreateFlags
5410                         };
5411
5412                         VkImageFormatProperties                                         coreProperties;
5413                         VkImageFormatProperties2                                        extProperties;
5414                         VkResult                                                                        coreResult;
5415                         VkResult                                                                        extResult;
5416
5417                         deMemset(&coreProperties, 0xcd, sizeof(VkImageFormatProperties));
5418                         deMemset(&extProperties, 0xcd, sizeof(VkImageFormatProperties2));
5419
5420                         extProperties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
5421                         extProperties.pNext = DE_NULL;
5422
5423                         coreResult      = vki.getPhysicalDeviceImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.tiling, imageFormatInfo.usage, imageFormatInfo.flags, &coreProperties);
5424                         extResult       = vki.getPhysicalDeviceImageFormatProperties2(physicalDevice, &imageFormatInfo, &extProperties);
5425
5426                         TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2);
5427                         TCU_CHECK(extProperties.pNext == DE_NULL);
5428
5429                         if ((coreResult != extResult) ||
5430                                 (deMemCmp(&coreProperties, &extProperties.imageFormatProperties, sizeof(VkImageFormatProperties)) != 0))
5431                         {
5432                                 log << TestLog::Message << "ERROR: device mismatch with query " << imageFormatInfo << TestLog::EndMessage
5433                                         << TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties() returned " << coreResult << ", " << coreProperties << TestLog::EndMessage
5434                                         << TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties2() returned " << extResult << ", " << extProperties << TestLog::EndMessage;
5435                                 TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceImageFormatProperties and vkGetPhysicalDeviceImageFormatProperties2");
5436                         }
5437                 }
5438         }
5439
5440         return tcu::TestStatus::pass("Querying image format properties succeeded");
5441 }
5442
5443 tcu::TestStatus sparseImageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
5444 {
5445         TestLog&                                                log                             = context.getTestContext().getLog();
5446
5447         const CustomInstance                    instance                (createCustomInstanceWithExtension(context, "VK_KHR_get_physical_device_properties2"));
5448         const InstanceDriver&                   vki                             (instance.getDriver());
5449         const VkPhysicalDevice                  physicalDevice  (chooseDevice(vki, instance, context.getTestContext().getCommandLine()));
5450
5451         const VkImageUsageFlags                 allUsageFlags   = VK_IMAGE_USAGE_TRANSFER_SRC_BIT
5452                                                                                                         | VK_IMAGE_USAGE_TRANSFER_DST_BIT
5453                                                                                                         | VK_IMAGE_USAGE_SAMPLED_BIT
5454                                                                                                         | VK_IMAGE_USAGE_STORAGE_BIT
5455                                                                                                         | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
5456                                                                                                         | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
5457                                                                                                         | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
5458                                                                                                         | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
5459
5460         for (deUint32 sampleCountBit = VK_SAMPLE_COUNT_1_BIT; sampleCountBit <= VK_SAMPLE_COUNT_64_BIT; sampleCountBit = (sampleCountBit << 1u))
5461         {
5462                 for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++)
5463                 {
5464                         if (!isValidImageUsageFlagCombination(curUsageFlags))
5465                                 continue;
5466
5467                         const VkPhysicalDeviceSparseImageFormatInfo2    imageFormatInfo =
5468                         {
5469                                 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2,
5470                                 DE_NULL,
5471                                 format,
5472                                 imageType,
5473                                 (VkSampleCountFlagBits)sampleCountBit,
5474                                 curUsageFlags,
5475                                 tiling,
5476                         };
5477
5478                         deUint32        numCoreProperties       = 0u;
5479                         deUint32        numExtProperties        = 0u;
5480
5481                         // Query count
5482                         vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, DE_NULL);
5483                         vki.getPhysicalDeviceSparseImageFormatProperties2(physicalDevice, &imageFormatInfo, &numExtProperties, DE_NULL);
5484
5485                         if (numCoreProperties != numExtProperties)
5486                         {
5487                                 log << TestLog::Message << "ERROR: different number of properties reported for " << imageFormatInfo << TestLog::EndMessage;
5488                                 TCU_FAIL("Mismatch in reported property count");
5489                         }
5490
5491                         if (!context.getDeviceFeatures().sparseBinding)
5492                         {
5493                                 // There is no support for sparse binding, getPhysicalDeviceSparseImageFormatProperties* MUST report no properties
5494                                 // Only have to check one of the entrypoints as a mismatch in count is already caught.
5495                                 if (numCoreProperties > 0)
5496                                 {
5497                                         log << TestLog::Message << "ERROR: device does not support sparse binding but claims support for " << numCoreProperties << " properties in vkGetPhysicalDeviceSparseImageFormatProperties with parameters " << imageFormatInfo << TestLog::EndMessage;
5498                                         TCU_FAIL("Claimed format properties inconsistent with overall sparseBinding feature");
5499                                 }
5500                         }
5501
5502                         if (numCoreProperties > 0)
5503                         {
5504                                 std::vector<VkSparseImageFormatProperties>              coreProperties  (numCoreProperties);
5505                                 std::vector<VkSparseImageFormatProperties2>             extProperties   (numExtProperties);
5506
5507                                 deMemset(&coreProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties)*numCoreProperties);
5508                                 deMemset(&extProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties2)*numExtProperties);
5509
5510                                 for (deUint32 ndx = 0; ndx < numExtProperties; ++ndx)
5511                                 {
5512                                         extProperties[ndx].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2;
5513                                         extProperties[ndx].pNext = DE_NULL;
5514                                 }
5515
5516                                 vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, &coreProperties[0]);
5517                                 vki.getPhysicalDeviceSparseImageFormatProperties2(physicalDevice, &imageFormatInfo, &numExtProperties, &extProperties[0]);
5518
5519                                 TCU_CHECK((size_t)numCoreProperties == coreProperties.size());
5520                                 TCU_CHECK((size_t)numExtProperties == extProperties.size());
5521
5522                                 for (deUint32 ndx = 0; ndx < numCoreProperties; ++ndx)
5523                                 {
5524                                         TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2);
5525                                         TCU_CHECK(extProperties[ndx].pNext == DE_NULL);
5526
5527                                         if ((deMemCmp(&coreProperties[ndx], &extProperties[ndx].properties, sizeof(VkSparseImageFormatProperties)) != 0))
5528                                         {
5529                                                 log << TestLog::Message << "ERROR: device mismatch with query " << imageFormatInfo << " property " << ndx << TestLog::EndMessage
5530                                                         << TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties() returned " << coreProperties[ndx] << TestLog::EndMessage
5531                                                         << TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties2() returned " << extProperties[ndx] << TestLog::EndMessage;
5532                                                 TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceSparseImageFormatProperties and vkGetPhysicalDeviceSparseImageFormatProperties2");
5533                                         }
5534                                 }
5535                         }
5536                 }
5537         }
5538
5539         return tcu::TestStatus::pass("Querying sparse image format properties succeeded");
5540 }
5541
5542 tcu::TestStatus execImageFormatTest (Context& context, ImageFormatPropertyCase testCase)
5543 {
5544         return testCase.testFunction(context, testCase.format, testCase.imageType, testCase.tiling);
5545 }
5546
5547 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
5548 {
5549         DE_ASSERT(params.format == VK_FORMAT_UNDEFINED);
5550
5551         static const struct
5552         {
5553                 VkFormat                                                                begin;
5554                 VkFormat                                                                end;
5555                 ImageFormatPropertyCase                                 params;
5556         } s_formatRanges[] =
5557         {
5558                 // core formats
5559                 { (VkFormat)(VK_FORMAT_UNDEFINED + 1),          VK_CORE_FORMAT_LAST,                                                                            params },
5560
5561                 // YCbCr formats
5562                 { VK_FORMAT_G8B8G8R8_422_UNORM_KHR,                     (VkFormat)(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR + 1),     params },
5563
5564                 // YCbCr extended formats
5565                 { VK_FORMAT_G8_B8R8_2PLANE_444_UNORM_EXT,       (VkFormat)(VK_FORMAT_G16_B16R16_2PLANE_444_UNORM_EXT+1),        params },
5566         };
5567
5568         for (int rangeNdx = 0; rangeNdx < DE_LENGTH_OF_ARRAY(s_formatRanges); ++rangeNdx)
5569         {
5570                 const VkFormat                                                          rangeBegin              = s_formatRanges[rangeNdx].begin;
5571                 const VkFormat                                                          rangeEnd                = s_formatRanges[rangeNdx].end;
5572
5573                 for (VkFormat format = rangeBegin; format != rangeEnd; format = (VkFormat)(format+1))
5574                 {
5575                         const bool                      isYCbCr         = isYCbCrFormat(format);
5576                         const bool                      isSparse        = (params.testFunction == sparseImageFormatProperties2);
5577
5578                         if (isYCbCr && isSparse)
5579                                 continue;
5580
5581                         if (isYCbCr && params.imageType != VK_IMAGE_TYPE_2D)
5582                                 continue;
5583
5584                         const char* const       enumName        = getFormatName(format);
5585                         const string            caseName        = de::toLower(string(enumName).substr(10));
5586
5587                         params.format = format;
5588
5589                         addFunctionCase(testGroup, caseName, enumName, execImageFormatTest, params);
5590                 }
5591         }
5592 }
5593
5594 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
5595 {
5596         DE_ASSERT(params.tiling == VK_CORE_IMAGE_TILING_LAST);
5597
5598         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal",     "",     createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_OPTIMAL)));
5599         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear",      "",     createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_LINEAR)));
5600 }
5601
5602 void createImageFormatTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase::Function testFunction)
5603 {
5604         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_1D, VK_CORE_IMAGE_TILING_LAST)));
5605         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_2D, VK_CORE_IMAGE_TILING_LAST)));
5606         testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_3D, VK_CORE_IMAGE_TILING_LAST)));
5607 }
5608
5609
5610 // Android CTS -specific tests
5611
5612 namespace android
5613 {
5614
5615 void checkExtensions (tcu::ResultCollector& results, const set<string>& allowedExtensions, const vector<VkExtensionProperties>& reportedExtensions)
5616 {
5617         for (vector<VkExtensionProperties>::const_iterator extension = reportedExtensions.begin(); extension != reportedExtensions.end(); ++extension)
5618         {
5619                 const string    extensionName   (extension->extensionName);
5620                 const bool              mustBeKnown             = de::beginsWith(extensionName, "VK_GOOGLE_")   ||
5621                                                                                   de::beginsWith(extensionName, "VK_ANDROID_");
5622
5623                 if (mustBeKnown && !de::contains(allowedExtensions, extensionName))
5624                         results.fail("Unknown extension: " + extensionName);
5625         }
5626 }
5627
5628 tcu::TestStatus testNoUnknownExtensions (Context& context)
5629 {
5630         TestLog&                                log                                     = context.getTestContext().getLog();
5631         tcu::ResultCollector    results                         (log);
5632         set<string>                             allowedInstanceExtensions;
5633         set<string>                             allowedDeviceExtensions;
5634
5635         // All known extensions should be added to allowedExtensions:
5636         // allowedExtensions.insert("VK_GOOGLE_extension1");
5637         allowedDeviceExtensions.insert("VK_ANDROID_external_memory_android_hardware_buffer");
5638         allowedDeviceExtensions.insert("VK_GOOGLE_display_timing");
5639         allowedDeviceExtensions.insert("VK_GOOGLE_decorate_string");
5640         allowedDeviceExtensions.insert("VK_GOOGLE_hlsl_functionality1");
5641
5642         // Instance extensions
5643         checkExtensions(results,
5644                                         allowedInstanceExtensions,
5645                                         enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL));
5646
5647         // Extensions exposed by instance layers
5648         {
5649                 const vector<VkLayerProperties> layers  = enumerateInstanceLayerProperties(context.getPlatformInterface());
5650
5651                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
5652                 {
5653                         checkExtensions(results,
5654                                                         allowedInstanceExtensions,
5655                                                         enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName));
5656                 }
5657         }
5658
5659         // Device extensions
5660         checkExtensions(results,
5661                                         allowedDeviceExtensions,
5662                                         enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL));
5663
5664         // Extensions exposed by device layers
5665         {
5666                 const vector<VkLayerProperties> layers  = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5667
5668                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
5669                 {
5670                         checkExtensions(results,
5671                                                         allowedDeviceExtensions,
5672                                                         enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName));
5673                 }
5674         }
5675
5676         return tcu::TestStatus(results.getResult(), results.getMessage());
5677 }
5678
5679 tcu::TestStatus testNoLayers (Context& context)
5680 {
5681         TestLog&                                log             = context.getTestContext().getLog();
5682         tcu::ResultCollector    results (log);
5683
5684         {
5685                 const vector<VkLayerProperties> layers  = enumerateInstanceLayerProperties(context.getPlatformInterface());
5686
5687                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
5688                         results.fail(string("Instance layer enumerated: ") + layer->layerName);
5689         }
5690
5691         {
5692                 const vector<VkLayerProperties> layers  = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
5693
5694                 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
5695                         results.fail(string("Device layer enumerated: ") + layer->layerName);
5696         }
5697
5698         return tcu::TestStatus(results.getResult(), results.getMessage());
5699 }
5700
5701 tcu::TestStatus testMandatoryExtensions (Context& context)
5702 {
5703         TestLog&                                log             = context.getTestContext().getLog();
5704         tcu::ResultCollector    results (log);
5705
5706         // Instance extensions
5707         {
5708                 static const string mandatoryExtensions[]       =
5709                 {
5710                         "VK_KHR_get_physical_device_properties2",
5711                 };
5712
5713                 for (const auto &ext : mandatoryExtensions)
5714                 {
5715                         if (!context.isInstanceFunctionalitySupported(ext))
5716                                 results.fail(ext + " is not supported");
5717                 }
5718         }
5719
5720         // Device extensions
5721         {
5722                 static const string mandatoryExtensions[] =
5723                 {
5724                         "VK_KHR_maintenance1",
5725                 };
5726
5727                 for (const auto &ext : mandatoryExtensions)
5728                 {
5729                         if (!context.isDeviceFunctionalitySupported(ext))
5730                                 results.fail(ext + " is not supported");
5731                 }
5732         }
5733
5734         return tcu::TestStatus(results.getResult(), results.getMessage());
5735 }
5736
5737 } // android
5738
5739 } // anonymous
5740
5741 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx)
5742 {
5743         de::MovePtr<tcu::TestCaseGroup> infoTests       (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
5744
5745         infoTests->addChild(createTestGroup(testCtx, "format_properties",               "VkGetPhysicalDeviceFormatProperties() Tests",          createFormatTests));
5746         infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests",     createImageFormatTests, imageFormatProperties));
5747
5748         {
5749                 de::MovePtr<tcu::TestCaseGroup> extCoreVersionGrp (new tcu::TestCaseGroup(testCtx, "extension_core_versions", "Tests checking extension required core versions"));
5750
5751                 addFunctionCase(extCoreVersionGrp.get(), "extension_core_versions", "", extensionCoreVersions);
5752
5753                 infoTests->addChild(extCoreVersionGrp.release());
5754         }
5755
5756         {
5757                 de::MovePtr<tcu::TestCaseGroup> extendedPropertiesTests (new tcu::TestCaseGroup(testCtx, "get_physical_device_properties2", "VK_KHR_get_physical_device_properties2"));
5758
5759                 addFunctionCase(extendedPropertiesTests.get(), "features",                                      "Extended Device Features",                                     deviceFeatures2);
5760                 addFunctionCase(extendedPropertiesTests.get(), "properties",                            "Extended Device Properties",                           deviceProperties2);
5761                 addFunctionCase(extendedPropertiesTests.get(), "format_properties",                     "Extended Device Format Properties",            deviceFormatProperties2);
5762                 addFunctionCase(extendedPropertiesTests.get(), "queue_family_properties",       "Extended Device Queue Family Properties",      deviceQueueFamilyProperties2);
5763                 addFunctionCase(extendedPropertiesTests.get(), "memory_properties",                     "Extended Device Memory Properties",            deviceMemoryProperties2);
5764
5765                 infoTests->addChild(extendedPropertiesTests.release());
5766         }
5767
5768         {
5769                 de::MovePtr<tcu::TestCaseGroup> extendedPropertiesTests (new tcu::TestCaseGroup(testCtx, "vulkan1p2", "Vulkan 1.2 related tests"));
5770
5771                 addFunctionCase(extendedPropertiesTests.get(), "features",                                                      "Extended Vulkan 1.2 Device Features",                                          deviceFeaturesVulkan12);
5772                 addFunctionCase(extendedPropertiesTests.get(), "properties",                                            "Extended Vulkan 1.2 Device Properties",                                        devicePropertiesVulkan12);
5773                 addFunctionCase(extendedPropertiesTests.get(), "feature_extensions_consistency",        "Vulkan 1.2 consistency between Features and Extensions",       deviceFeatureExtensionsConsistencyVulkan12);
5774                 addFunctionCase(extendedPropertiesTests.get(), "property_extensions_consistency",       "Vulkan 1.2 consistency between Properties and Extensions", devicePropertyExtensionsConsistencyVulkan12);
5775                 addFunctionCase(extendedPropertiesTests.get(), "feature_bits_influence",                        "Validate feature bits influence on feature activation",        checkSupportFeatureBitInfluence, featureBitInfluenceOnDeviceCreate);
5776
5777                 infoTests->addChild(extendedPropertiesTests.release());
5778         }
5779
5780         {
5781                 de::MovePtr<tcu::TestCaseGroup> limitsValidationTests (new tcu::TestCaseGroup(testCtx, "vulkan1p2_limits_validation", "Vulkan 1.2 and core extensions limits validation"));
5782
5783                 addFunctionCase(limitsValidationTests.get(), "general",                                                 "Vulkan 1.2 Limit validation",                                                  validateLimitsCheckSupport,                                     validateLimits12);
5784                 addFunctionCase(limitsValidationTests.get(), "khr_push_descriptor",                             "VK_KHR_push_descriptor limit validation",                              checkSupportKhrPushDescriptor,                          validateLimitsKhrPushDescriptor);
5785                 addFunctionCase(limitsValidationTests.get(), "khr_multiview",                                   "VK_KHR_multiview limit validation",                                    checkSupportKhrMultiview,                                       validateLimitsKhrMultiview);
5786                 addFunctionCase(limitsValidationTests.get(), "ext_discard_rectangles",                  "VK_EXT_discard_rectangles limit validation",                   checkSupportExtDiscardRectangles,                       validateLimitsExtDiscardRectangles);
5787                 addFunctionCase(limitsValidationTests.get(), "ext_sample_locations",                    "VK_EXT_sample_locations limit validation",                             checkSupportExtSampleLocations,                         validateLimitsExtSampleLocations);
5788                 addFunctionCase(limitsValidationTests.get(), "ext_external_memory_host",                "VK_EXT_external_memory_host limit validation",                 checkSupportExtExternalMemoryHost,                      validateLimitsExtExternalMemoryHost);
5789                 addFunctionCase(limitsValidationTests.get(), "ext_blend_operation_advanced",    "VK_EXT_blend_operation_advanced limit validation",             checkSupportExtBlendOperationAdvanced,          validateLimitsExtBlendOperationAdvanced);
5790                 addFunctionCase(limitsValidationTests.get(), "khr_maintenance_3",                               "VK_KHR_maintenance3 limit validation",                                 checkSupportKhrMaintenance3,                            validateLimitsKhrMaintenance3);
5791                 addFunctionCase(limitsValidationTests.get(), "ext_conservative_rasterization",  "VK_EXT_conservative_rasterization limit validation",   checkSupportExtConservativeRasterization,       validateLimitsExtConservativeRasterization);
5792                 addFunctionCase(limitsValidationTests.get(), "ext_descriptor_indexing",                 "VK_EXT_descriptor_indexing limit validation",                  checkSupportExtDescriptorIndexing,                      validateLimitsExtDescriptorIndexing);
5793                 addFunctionCase(limitsValidationTests.get(), "ext_inline_uniform_block",                "VK_EXT_inline_uniform_block limit validation",                 checkSupportExtInlineUniformBlock,                      validateLimitsExtInlineUniformBlock);
5794                 addFunctionCase(limitsValidationTests.get(), "ext_vertex_attribute_divisor",    "VK_EXT_vertex_attribute_divisor limit validation",             checkSupportExtVertexAttributeDivisor,          validateLimitsExtVertexAttributeDivisor);
5795                 addFunctionCase(limitsValidationTests.get(), "nv_mesh_shader",                                  "VK_NV_mesh_shader limit validation",                                   checkSupportNvMeshShader,                                       validateLimitsNvMeshShader);
5796                 addFunctionCase(limitsValidationTests.get(), "ext_transform_feedback",                  "VK_EXT_transform_feedback limit validation",                   checkSupportExtTransformFeedback,                       validateLimitsExtTransformFeedback);
5797                 addFunctionCase(limitsValidationTests.get(), "fragment_density_map",                    "VK_EXT_fragment_density_map limit validation",                 checkSupportExtFragmentDensityMap,                      validateLimitsExtFragmentDensityMap);
5798                 addFunctionCase(limitsValidationTests.get(), "nv_ray_tracing",                                  "VK_NV_ray_tracing limit validation",                                   checkSupportNvRayTracing,                                       validateLimitsNvRayTracing);
5799                 addFunctionCase(limitsValidationTests.get(), "timeline_semaphore",                              "VK_KHR_timeline_semaphore limit validation",                   checkSupportKhrTimelineSemaphore,                       validateLimitsKhrTimelineSemaphore);
5800                 addFunctionCase(limitsValidationTests.get(), "ext_line_rasterization",                  "VK_EXT_line_rasterization limit validation",                   checkSupportExtLineRasterization,                       validateLimitsExtLineRasterization);
5801
5802                 infoTests->addChild(limitsValidationTests.release());
5803         }
5804
5805         infoTests->addChild(createTestGroup(testCtx, "image_format_properties2",                "VkGetPhysicalDeviceImageFormatProperties2() Tests",            createImageFormatTests, imageFormatProperties2));
5806         infoTests->addChild(createTestGroup(testCtx, "sparse_image_format_properties2", "VkGetPhysicalDeviceSparseImageFormatProperties2() Tests",      createImageFormatTests, sparseImageFormatProperties2));
5807
5808         {
5809                 de::MovePtr<tcu::TestCaseGroup> androidTests    (new tcu::TestCaseGroup(testCtx, "android", "Android CTS Tests"));
5810
5811                 addFunctionCase(androidTests.get(),     "mandatory_extensions",         "Test that all mandatory extensions are supported",     android::testMandatoryExtensions);
5812                 addFunctionCase(androidTests.get(), "no_unknown_extensions",    "Test for unknown device or instance extensions",       android::testNoUnknownExtensions);
5813                 addFunctionCase(androidTests.get(), "no_layers",                                "Test that no layers are enumerated",                           android::testNoLayers);
5814
5815                 infoTests->addChild(androidTests.release());
5816         }
5817
5818         return infoTests.release();
5819 }
5820
5821 void createFeatureInfoInstanceTests(tcu::TestCaseGroup* testGroup)
5822 {
5823         addFunctionCase(testGroup, "physical_devices",                                  "Physical devices",                                             enumeratePhysicalDevices);
5824         addFunctionCase(testGroup, "physical_device_groups",                    "Physical devices Groups",                              enumeratePhysicalDeviceGroups);
5825         addFunctionCase(testGroup, "instance_layers",                                   "Layers",                                                               enumerateInstanceLayers);
5826         addFunctionCase(testGroup, "instance_extensions",                               "Extensions",                                                   enumerateInstanceExtensions);
5827 }
5828
5829 void createFeatureInfoDeviceTests(tcu::TestCaseGroup* testGroup)
5830 {
5831         addFunctionCase(testGroup, "device_features",                                   "Device Features",                                              deviceFeatures);
5832         addFunctionCase(testGroup, "device_properties",                                 "Device Properties",                                    deviceProperties);
5833         addFunctionCase(testGroup, "device_queue_family_properties",    "Queue family properties",                              deviceQueueFamilyProperties);
5834         addFunctionCase(testGroup, "device_memory_properties",                  "Memory properties",                                    deviceMemoryProperties);
5835         addFunctionCase(testGroup, "device_layers",                                             "Layers",                                                               enumerateDeviceLayers);
5836         addFunctionCase(testGroup, "device_extensions",                                 "Extensions",                                                   enumerateDeviceExtensions);
5837         addFunctionCase(testGroup, "device_no_khx_extensions",                  "KHX extensions",                                               testNoKhxExtensions);
5838         addFunctionCase(testGroup, "device_memory_budget",                              "Memory budget",                                                deviceMemoryBudgetProperties);
5839         addFunctionCase(testGroup, "device_mandatory_features",                 "Mandatory features",                                   deviceMandatoryFeatures);
5840 }
5841
5842 void createFeatureInfoDeviceGroupTests(tcu::TestCaseGroup* testGroup)
5843 {
5844         addFunctionCase(testGroup, "device_group_peer_memory_features", "Device Group peer memory features",    deviceGroupPeerMemoryFeatures);
5845 }
5846
5847 } // api
5848 } // vkt