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