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