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