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