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