1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Api Feature Query tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktApiFeatureInfo.hpp"
26 #include "vktTestCaseUtil.hpp"
27 #include "vktTestGroupUtil.hpp"
29 #include "vkPlatform.hpp"
30 #include "vkStrUtil.hpp"
32 #include "vkDeviceUtil.hpp"
33 #include "vkQueryUtil.hpp"
34 #include "vkImageUtil.hpp"
35 #include "vkApiVersion.hpp"
37 #include "tcuTestLog.hpp"
38 #include "tcuFormatUtil.hpp"
39 #include "tcuTextureUtil.hpp"
40 #include "tcuResultCollector.hpp"
42 #include "deUniquePtr.hpp"
44 #include "deStringUtil.hpp"
45 #include "deSTLUtil.hpp"
65 using tcu::ScopedLogSection;
69 GUARD_SIZE = 0x20, //!< Number of bytes to check
70 GUARD_VALUE = 0xcd, //!< Data pattern
73 static const VkDeviceSize MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE = (1LLU<<31); //!< Minimum value for VkImageFormatProperties::maxResourceSize (2GiB)
77 LIMIT_FORMAT_SIGNED_INT,
78 LIMIT_FORMAT_UNSIGNED_INT,
80 LIMIT_FORMAT_DEVICE_SIZE,
95 #define LIMIT(_X_) DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_), (const char*)(#_X_)
96 #define FEATURE(_X_) DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_)
98 inline bool isExtensionSupported (const vector<string>& extensionStrings, const string& extensionName)
100 return de::contains(extensionStrings.begin(), extensionStrings.end(), extensionName);
103 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
105 bool limitsOk = true;
106 VkPhysicalDeviceLimits* limits = &properties->limits;
107 struct FeatureLimitTable
111 deUint32 uintVal; //!< Format is UNSIGNED_INT
112 deInt32 intVal; //!< Format is SIGNED_INT
113 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE
114 float floatVal; //!< Format is FLOAT
117 deInt32 unsuppTableNdx;
118 } featureLimitTable[] = //!< Based on 1.0.28 Vulkan spec
120 { LIMIT(maxImageDimension1D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
121 { LIMIT(maxImageDimension2D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
122 { LIMIT(maxImageDimension3D), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
123 { LIMIT(maxImageDimensionCube), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
124 { LIMIT(maxImageArrayLayers), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
125 { LIMIT(maxTexelBufferElements), 65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
126 { LIMIT(maxUniformBufferRange), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
127 { LIMIT(maxStorageBufferRange), 0, 0, 0, 0, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
128 { LIMIT(maxPushConstantsSize), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
129 { LIMIT(maxMemoryAllocationCount), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
130 { LIMIT(maxSamplerAllocationCount), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
131 { LIMIT(bufferImageGranularity), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
132 { LIMIT(bufferImageGranularity), 0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
133 { LIMIT(sparseAddressSpaceSize), 0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
134 { LIMIT(maxBoundDescriptorSets), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
135 { LIMIT(maxPerStageDescriptorSamplers), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
136 { LIMIT(maxPerStageDescriptorUniformBuffers), 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
137 { LIMIT(maxPerStageDescriptorStorageBuffers), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
138 { LIMIT(maxPerStageDescriptorSampledImages), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
139 { LIMIT(maxPerStageDescriptorStorageImages), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
140 { LIMIT(maxPerStageDescriptorInputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
141 { LIMIT(maxPerStageResources), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
142 { LIMIT(maxDescriptorSetSamplers), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
143 { LIMIT(maxDescriptorSetUniformBuffers), 72, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
144 { LIMIT(maxDescriptorSetUniformBuffersDynamic), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
145 { LIMIT(maxDescriptorSetStorageBuffers), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
146 { LIMIT(maxDescriptorSetStorageBuffersDynamic), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
147 { LIMIT(maxDescriptorSetSampledImages), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
148 { LIMIT(maxDescriptorSetStorageImages), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
149 { LIMIT(maxDescriptorSetInputAttachments), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
150 { LIMIT(maxVertexInputAttributes), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
151 { LIMIT(maxVertexInputBindings), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
152 { LIMIT(maxVertexInputAttributeOffset), 2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
153 { LIMIT(maxVertexInputBindingStride), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
154 { LIMIT(maxVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
155 { LIMIT(maxTessellationGenerationLevel), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
156 { LIMIT(maxTessellationPatchSize), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
157 { LIMIT(maxTessellationControlPerVertexInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
158 { LIMIT(maxTessellationControlPerVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
159 { LIMIT(maxTessellationControlPerPatchOutputComponents), 120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
160 { LIMIT(maxTessellationControlTotalOutputComponents), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
161 { LIMIT(maxTessellationEvaluationInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
162 { LIMIT(maxTessellationEvaluationOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
163 { LIMIT(maxGeometryShaderInvocations), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
164 { LIMIT(maxGeometryInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
165 { LIMIT(maxGeometryOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
166 { LIMIT(maxGeometryOutputVertices), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
167 { LIMIT(maxGeometryTotalOutputComponents), 1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
168 { LIMIT(maxFragmentInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
169 { LIMIT(maxFragmentOutputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
170 { LIMIT(maxFragmentDualSrcAttachments), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
171 { LIMIT(maxFragmentCombinedOutputResources), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
172 { LIMIT(maxComputeSharedMemorySize), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
173 { LIMIT(maxComputeWorkGroupCount[0]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
174 { LIMIT(maxComputeWorkGroupCount[1]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
175 { LIMIT(maxComputeWorkGroupCount[2]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
176 { LIMIT(maxComputeWorkGroupInvocations), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
177 { LIMIT(maxComputeWorkGroupSize[0]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
178 { LIMIT(maxComputeWorkGroupSize[1]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
179 { LIMIT(maxComputeWorkGroupSize[2]), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
180 { LIMIT(subPixelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
181 { LIMIT(subTexelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
182 { LIMIT(mipmapPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
183 { LIMIT(maxDrawIndexedIndexValue), (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
184 { LIMIT(maxDrawIndirectCount), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
185 { LIMIT(maxSamplerLodBias), 0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
186 { LIMIT(maxSamplerAnisotropy), 0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
187 { LIMIT(maxViewports), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
188 { LIMIT(maxViewportDimensions[0]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
189 { LIMIT(maxViewportDimensions[1]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
190 { LIMIT(viewportBoundsRange[0]), 0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
191 { LIMIT(viewportBoundsRange[1]), 0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
192 { LIMIT(viewportSubPixelBits), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
193 { LIMIT(minMemoryMapAlignment), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
194 { LIMIT(minTexelBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
195 { LIMIT(minTexelBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
196 { LIMIT(minUniformBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
197 { LIMIT(minUniformBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
198 { LIMIT(minStorageBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
199 { LIMIT(minStorageBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
200 { LIMIT(minTexelOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
201 { LIMIT(maxTexelOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
202 { LIMIT(minTexelGatherOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
203 { LIMIT(maxTexelGatherOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
204 { LIMIT(minInterpolationOffset), 0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
205 { LIMIT(maxInterpolationOffset), 0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
206 { LIMIT(subPixelInterpolationOffsetBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
207 { LIMIT(maxFramebufferWidth), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
208 { LIMIT(maxFramebufferHeight), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
209 { LIMIT(maxFramebufferLayers), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
210 { LIMIT(framebufferColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
211 { LIMIT(framebufferDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
212 { LIMIT(framebufferStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
213 { LIMIT(framebufferNoAttachmentsSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
214 { LIMIT(maxColorAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
215 { LIMIT(sampledImageColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
216 { LIMIT(sampledImageIntegerSampleCounts), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
217 { LIMIT(sampledImageDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
218 { LIMIT(sampledImageStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
219 { LIMIT(storageImageSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
220 { LIMIT(maxSampleMaskWords), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
221 { LIMIT(timestampComputeAndGraphics), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
222 { LIMIT(timestampPeriod), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
223 { LIMIT(maxClipDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
224 { LIMIT(maxCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
225 { LIMIT(maxCombinedClipAndCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
226 { LIMIT(discreteQueuePriorities), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
227 { LIMIT(pointSizeRange[0]), 0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
228 { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
229 { LIMIT(pointSizeRange[1]), 0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
230 { LIMIT(lineWidthRange[0]), 0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
231 { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
232 { LIMIT(lineWidthRange[1]), 0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
233 { LIMIT(pointSizeGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
234 { LIMIT(lineWidthGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
235 { LIMIT(strictLines), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
236 { LIMIT(standardSampleLocations), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
237 { LIMIT(optimalBufferCopyOffsetAlignment), 0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
238 { LIMIT(optimalBufferCopyRowPitchAlignment), 0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
239 { LIMIT(nonCoherentAtomSize), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
240 { LIMIT(nonCoherentAtomSize), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
243 const struct UnsupportedFeatureLimitTable
245 deUint32 limitOffset;
247 deUint32 featureOffset;
248 deUint32 uintVal; //!< Format is UNSIGNED_INT
249 deInt32 intVal; //!< Format is SIGNED_INT
250 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE
251 float floatVal; //!< Format is FLOAT
252 } unsupportedFeatureTable[] =
254 { LIMIT(sparseAddressSpaceSize), FEATURE(sparseBinding), 0, 0, 0, 0.0f },
255 { LIMIT(maxTessellationGenerationLevel), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
256 { LIMIT(maxTessellationPatchSize), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
257 { LIMIT(maxTessellationControlPerVertexInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
258 { LIMIT(maxTessellationControlPerVertexOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
259 { LIMIT(maxTessellationControlPerPatchOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
260 { LIMIT(maxTessellationControlTotalOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
261 { LIMIT(maxTessellationEvaluationInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
262 { LIMIT(maxTessellationEvaluationOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
263 { LIMIT(maxGeometryShaderInvocations), FEATURE(geometryShader), 0, 0, 0, 0.0f },
264 { LIMIT(maxGeometryInputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
265 { LIMIT(maxGeometryOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
266 { LIMIT(maxGeometryOutputVertices), FEATURE(geometryShader), 0, 0, 0, 0.0f },
267 { LIMIT(maxGeometryTotalOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
268 { LIMIT(maxFragmentDualSrcAttachments), FEATURE(dualSrcBlend), 0, 0, 0, 0.0f },
269 { LIMIT(maxDrawIndexedIndexValue), FEATURE(fullDrawIndexUint32), (1<<24)-1, 0, 0, 0.0f },
270 { LIMIT(maxDrawIndirectCount), FEATURE(multiDrawIndirect), 1, 0, 0, 0.0f },
271 { LIMIT(maxSamplerAnisotropy), FEATURE(samplerAnisotropy), 1, 0, 0, 0.0f },
272 { LIMIT(maxViewports), FEATURE(multiViewport), 1, 0, 0, 0.0f },
273 { LIMIT(minTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f },
274 { LIMIT(maxTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f },
275 { LIMIT(minInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
276 { LIMIT(maxInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
277 { LIMIT(subPixelInterpolationOffsetBits), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
278 { LIMIT(storageImageSampleCounts), FEATURE(shaderStorageImageMultisample), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f },
279 { LIMIT(maxClipDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
280 { LIMIT(maxCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
281 { LIMIT(maxCombinedClipAndCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
282 { LIMIT(pointSizeRange[0]), FEATURE(largePoints), 0, 0, 0, 1.0f },
283 { LIMIT(pointSizeRange[1]), FEATURE(largePoints), 0, 0, 0, 1.0f },
284 { LIMIT(lineWidthRange[0]), FEATURE(wideLines), 0, 0, 0, 1.0f },
285 { LIMIT(lineWidthRange[1]), FEATURE(wideLines), 0, 0, 0, 1.0f },
286 { LIMIT(pointSizeGranularity), FEATURE(largePoints), 0, 0, 0, 0.0f },
287 { LIMIT(lineWidthGranularity), FEATURE(wideLines), 0, 0, 0, 0.0f }
290 log << TestLog::Message << *limits << TestLog::EndMessage;
292 //!< First build a map from limit to unsupported table index
293 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
295 for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++)
297 if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset)
299 featureLimitTable[ndx].unsuppTableNdx = unsuppNdx;
305 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
307 switch (featureLimitTable[ndx].format)
309 case LIMIT_FORMAT_UNSIGNED_INT:
311 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
312 if (featureLimitTable[ndx].unsuppTableNdx != -1)
314 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
315 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
318 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
321 if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
323 log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name
324 << " not valid-limit type MIN - actual is "
325 << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
329 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
331 if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
333 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
334 << " not valid-limit type MAX - actual is "
335 << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
342 case LIMIT_FORMAT_FLOAT:
344 float limitToCheck = featureLimitTable[ndx].floatVal;
345 if (featureLimitTable[ndx].unsuppTableNdx != -1)
347 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
348 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal;
351 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
353 if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
355 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
356 << " not valid-limit type MIN - actual is "
357 << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
361 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
363 if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
365 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
366 << " not valid-limit type MAX actual is "
367 << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
374 case LIMIT_FORMAT_SIGNED_INT:
376 deInt32 limitToCheck = featureLimitTable[ndx].intVal;
377 if (featureLimitTable[ndx].unsuppTableNdx != -1)
379 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
380 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal;
382 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
384 if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
386 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
387 << " not valid-limit type MIN actual is "
388 << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
392 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
394 if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
396 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
397 << " not valid-limit type MAX actual is "
398 << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
405 case LIMIT_FORMAT_DEVICE_SIZE:
407 deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal;
408 if (featureLimitTable[ndx].unsuppTableNdx != -1)
410 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
411 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal;
414 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
416 if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
418 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
419 << " not valid-limit type MIN actual is "
420 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
424 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
426 if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
428 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
429 << " not valid-limit type MAX actual is "
430 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
437 case LIMIT_FORMAT_BITMASK:
439 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
440 if (featureLimitTable[ndx].unsuppTableNdx != -1)
442 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
443 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
446 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
448 if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck)
450 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
451 << " not valid-limit type bitmask actual is "
452 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
465 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits->maxViewportDimensions); ndx++)
467 if (limits->maxImageDimension2D > limits->maxViewportDimensions[ndx])
469 log << TestLog::Message << "limit validation failed, maxImageDimension2D of " << limits->maxImageDimension2D
470 << "is larger than maxViewportDimension[" << ndx << "] of " << limits->maxViewportDimensions[ndx] << TestLog::EndMessage;
475 if (limits->viewportBoundsRange[0] > float(-2 * limits->maxViewportDimensions[0]))
477 log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0]
478 << "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage;
482 if (limits->viewportBoundsRange[1] < float(2 * limits->maxViewportDimensions[1] - 1))
484 log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1]
485 << "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage;
493 class CheckIncompleteResult
496 virtual ~CheckIncompleteResult (void) {}
497 virtual void getResult (Context& context, T* data) = 0;
499 void operator() (Context& context, tcu::ResultCollector& results, const std::size_t expectedCompleteSize)
501 if (expectedCompleteSize == 0)
504 vector<T> outputData (expectedCompleteSize);
505 const deUint32 usedSize = static_cast<deUint32>(expectedCompleteSize / 3);
507 ValidateQueryBits::fillBits(outputData.begin(), outputData.end()); // unused entries should have this pattern intact
509 m_result = VK_SUCCESS;
511 getResult(context, &outputData[0]); // update m_count and m_result
513 if (m_count != usedSize || m_result != VK_INCOMPLETE || !ValidateQueryBits::checkBits(outputData.begin() + m_count, outputData.end()))
514 results.fail("Query didn't return VK_INCOMPLETE");
522 struct CheckEnumeratePhysicalDevicesIncompleteResult : public CheckIncompleteResult<VkPhysicalDevice>
524 void getResult (Context& context, VkPhysicalDevice* data)
526 m_result = context.getInstanceInterface().enumeratePhysicalDevices(context.getInstance(), &m_count, data);
530 struct CheckEnumerateInstanceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
532 void getResult (Context& context, VkLayerProperties* data)
534 m_result = context.getPlatformInterface().enumerateInstanceLayerProperties(&m_count, data);
538 struct CheckEnumerateDeviceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
540 void getResult (Context& context, VkLayerProperties* data)
542 m_result = context.getInstanceInterface().enumerateDeviceLayerProperties(context.getPhysicalDevice(), &m_count, data);
546 struct CheckEnumerateInstanceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
548 CheckEnumerateInstanceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
550 void getResult (Context& context, VkExtensionProperties* data)
552 const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
553 m_result = context.getPlatformInterface().enumerateInstanceExtensionProperties(pLayerName, &m_count, data);
557 const std::string m_layerName;
560 struct CheckEnumerateDeviceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
562 CheckEnumerateDeviceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
564 void getResult (Context& context, VkExtensionProperties* data)
566 const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
567 m_result = context.getInstanceInterface().enumerateDeviceExtensionProperties(context.getPhysicalDevice(), pLayerName, &m_count, data);
571 const std::string m_layerName;
574 tcu::TestStatus enumeratePhysicalDevices (Context& context)
576 TestLog& log = context.getTestContext().getLog();
577 tcu::ResultCollector results (log);
578 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
580 log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
582 for (size_t ndx = 0; ndx < devices.size(); ndx++)
583 log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage;
585 CheckEnumeratePhysicalDevicesIncompleteResult()(context, results, devices.size());
587 return tcu::TestStatus(results.getResult(), results.getMessage());
591 void collectDuplicates (set<T>& duplicates, const vector<T>& values)
595 for (size_t ndx = 0; ndx < values.size(); ndx++)
597 const T& value = values[ndx];
599 if (!seen.insert(value).second)
600 duplicates.insert(value);
604 void checkDuplicates (tcu::ResultCollector& results, const char* what, const vector<string>& values)
606 set<string> duplicates;
608 collectDuplicates(duplicates, values);
610 for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter)
612 std::ostringstream msg;
613 msg << "Duplicate " << what << ": " << *iter;
614 results.fail(msg.str());
618 void checkDuplicateExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
620 checkDuplicates(results, "extension", extensions);
623 void checkDuplicateLayers (tcu::ResultCollector& results, const vector<string>& layers)
625 checkDuplicates(results, "layer", layers);
628 void checkKhrExtensions (tcu::ResultCollector& results,
629 const vector<string>& extensions,
630 const int numAllowedKhrExtensions,
631 const char* const* allowedKhrExtensions)
633 const set<string> allowedExtSet (allowedKhrExtensions, allowedKhrExtensions+numAllowedKhrExtensions);
635 for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter)
637 // Only Khronos-controlled extensions are checked
638 if (de::beginsWith(*extIter, "VK_KHR_") &&
639 !de::contains(allowedExtSet, *extIter))
641 results.fail("Unknown KHR extension " + *extIter);
646 void checkInstanceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
648 static const char* s_allowedInstanceKhrExtensions[] =
652 "VK_KHR_android_surface",
653 "VK_KHR_mir_surface",
654 "VK_KHR_wayland_surface",
655 "VK_KHR_win32_surface",
656 "VK_KHR_xcb_surface",
657 "VK_KHR_xlib_surface",
658 "VK_KHR_get_physical_device_properties2",
659 "VK_KHR_get_surface_capabilities2",
662 checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
663 checkDuplicateExtensions(results, extensions);
666 void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
668 static const char* s_allowedDeviceKhrExtensions[] =
671 "VK_KHR_display_swapchain",
672 "VK_KHR_sampler_mirror_clamp_to_edge",
673 "VK_KHR_shader_draw_parameters",
674 "VK_KHR_maintenance1",
675 "VK_KHR_push_descriptor",
676 "VK_KHR_descriptor_update_template",
677 "VK_KHR_incremental_present",
678 "VK_KHR_shared_presentable_image",
681 checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedDeviceKhrExtensions), s_allowedDeviceKhrExtensions);
682 checkDuplicateExtensions(results, extensions);
685 tcu::TestStatus enumerateInstanceLayers (Context& context)
687 TestLog& log = context.getTestContext().getLog();
688 tcu::ResultCollector results (log);
689 const vector<VkLayerProperties> properties = enumerateInstanceLayerProperties(context.getPlatformInterface());
690 vector<string> layerNames;
692 for (size_t ndx = 0; ndx < properties.size(); ndx++)
694 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
696 layerNames.push_back(properties[ndx].layerName);
699 checkDuplicateLayers(results, layerNames);
700 CheckEnumerateInstanceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
702 return tcu::TestStatus(results.getResult(), results.getMessage());
705 tcu::TestStatus enumerateInstanceExtensions (Context& context)
707 TestLog& log = context.getTestContext().getLog();
708 tcu::ResultCollector results (log);
711 const ScopedLogSection section (log, "Global", "Global Extensions");
712 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
713 vector<string> extensionNames;
715 for (size_t ndx = 0; ndx < properties.size(); ndx++)
717 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
719 extensionNames.push_back(properties[ndx].extensionName);
722 checkInstanceExtensions(results, extensionNames);
723 CheckEnumerateInstanceExtensionPropertiesIncompleteResult()(context, results, properties.size());
727 const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface());
729 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
731 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName);
732 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
733 vector<string> extensionNames;
735 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
737 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
739 extensionNames.push_back(properties[extNdx].extensionName);
742 checkInstanceExtensions(results, extensionNames);
743 CheckEnumerateInstanceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
747 return tcu::TestStatus(results.getResult(), results.getMessage());
750 tcu::TestStatus enumerateDeviceLayers (Context& context)
752 TestLog& log = context.getTestContext().getLog();
753 tcu::ResultCollector results (log);
754 const vector<VkLayerProperties> properties = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
755 vector<string> layerNames;
757 for (size_t ndx = 0; ndx < properties.size(); ndx++)
759 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
761 layerNames.push_back(properties[ndx].layerName);
764 checkDuplicateLayers(results, layerNames);
765 CheckEnumerateDeviceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
767 return tcu::TestStatus(results.getResult(), results.getMessage());
770 tcu::TestStatus enumerateDeviceExtensions (Context& context)
772 TestLog& log = context.getTestContext().getLog();
773 tcu::ResultCollector results (log);
776 const ScopedLogSection section (log, "Global", "Global Extensions");
777 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
778 vector<string> extensionNames;
780 for (size_t ndx = 0; ndx < properties.size(); ndx++)
782 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
784 extensionNames.push_back(properties[ndx].extensionName);
787 checkDeviceExtensions(results, extensionNames);
788 CheckEnumerateDeviceExtensionPropertiesIncompleteResult()(context, results, properties.size());
792 const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
794 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
796 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName);
797 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
798 vector<string> extensionNames;
800 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
802 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
805 extensionNames.push_back(properties[extNdx].extensionName);
808 checkDeviceExtensions(results, extensionNames);
809 CheckEnumerateDeviceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
813 return tcu::TestStatus(results.getResult(), results.getMessage());
816 #define VK_SIZE_OF(STRUCT, MEMBER) (sizeof(((STRUCT*)0)->MEMBER))
817 #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER) { (size_t)DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) }
819 tcu::TestStatus deviceFeatures (Context& context)
821 using namespace ValidateQueryBits;
823 TestLog& log = context.getTestContext().getLog();
824 VkPhysicalDeviceFeatures* features;
825 deUint8 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE];
827 const QueryMemberTableEntry featureOffsetTable[] =
829 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess),
830 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32),
831 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray),
832 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend),
833 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader),
834 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader),
835 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading),
836 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend),
837 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp),
838 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect),
839 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance),
840 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp),
841 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp),
842 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid),
843 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds),
844 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines),
845 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints),
846 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne),
847 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport),
848 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy),
849 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2),
850 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR),
851 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC),
852 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise),
853 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery),
854 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics),
855 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics),
856 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize),
857 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended),
858 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats),
859 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample),
860 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat),
861 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat),
862 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing),
863 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing),
864 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing),
865 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing),
866 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance),
867 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance),
868 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64),
869 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64),
870 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16),
871 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency),
872 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod),
873 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding),
874 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer),
875 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D),
876 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D),
877 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples),
878 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples),
879 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples),
880 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples),
881 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased),
882 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate),
883 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries),
887 deMemset(buffer, GUARD_VALUE, sizeof(buffer));
888 features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer);
890 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features);
892 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
893 << TestLog::Message << *features << TestLog::EndMessage;
895 // Requirements and dependencies
897 if (!features->robustBufferAccess)
898 return tcu::TestStatus::fail("robustBufferAccess is not supported");
900 // multiViewport requires MultiViewport (SPIR-V capability) support, which depends on Geometry
901 if (features->multiViewport && !features->geometryShader)
902 return tcu::TestStatus::fail("multiViewport is supported but geometryShader is not");
905 for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
907 if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE)
909 log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
910 return tcu::TestStatus::fail("deviceFeatures buffer overflow");
914 if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable))
916 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage;
917 return tcu::TestStatus::fail("deviceFeatures incomplete initialization");
920 return tcu::TestStatus::pass("Query succeeded");
923 static const ValidateQueryBits::QueryMemberTableEntry s_physicalDevicePropertiesOffsetTable[] =
925 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion),
926 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion),
927 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID),
928 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID),
929 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType),
930 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID),
931 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D),
932 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D),
933 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D),
934 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube),
935 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers),
936 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements),
937 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange),
938 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange),
939 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize),
940 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount),
941 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount),
942 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity),
943 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize),
944 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets),
945 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers),
946 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers),
947 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers),
948 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages),
949 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages),
950 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments),
951 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources),
952 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers),
953 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers),
954 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic),
955 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers),
956 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic),
957 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages),
958 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages),
959 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments),
960 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes),
961 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings),
962 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset),
963 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride),
964 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents),
965 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel),
966 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize),
967 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents),
968 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents),
969 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents),
970 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents),
971 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents),
972 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents),
973 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations),
974 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents),
975 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents),
976 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices),
977 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents),
978 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents),
979 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments),
980 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments),
981 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources),
982 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize),
983 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]),
984 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations),
985 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]),
986 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits),
987 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits),
988 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits),
989 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue),
990 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount),
991 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias),
992 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy),
993 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports),
994 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]),
995 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]),
996 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits),
997 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment),
998 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment),
999 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment),
1000 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment),
1001 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset),
1002 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset),
1003 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset),
1004 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset),
1005 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset),
1006 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset),
1007 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits),
1008 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth),
1009 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight),
1010 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers),
1011 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts),
1012 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts),
1013 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts),
1014 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts),
1015 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments),
1016 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts),
1017 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts),
1018 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts),
1019 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts),
1020 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts),
1021 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords),
1022 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics),
1023 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod),
1024 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances),
1025 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances),
1026 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances),
1027 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities),
1028 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]),
1029 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]),
1030 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity),
1031 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity),
1032 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines),
1033 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations),
1034 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment),
1035 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment),
1036 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize),
1037 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape),
1038 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape),
1039 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape),
1040 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize),
1041 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict),
1045 tcu::TestStatus deviceProperties (Context& context)
1047 using namespace ValidateQueryBits;
1049 TestLog& log = context.getTestContext().getLog();
1050 VkPhysicalDeviceProperties* props;
1051 VkPhysicalDeviceFeatures features;
1052 deUint8 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE];
1054 props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer);
1055 deMemset(props, GUARD_VALUE, sizeof(buffer));
1057 context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props);
1058 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features);
1060 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
1061 << TestLog::Message << *props << TestLog::EndMessage;
1063 if (!validateFeatureLimits(props, &features, log))
1064 return tcu::TestStatus::fail("deviceProperties - feature limits failed");
1066 for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
1068 if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE)
1070 log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
1071 return tcu::TestStatus::fail("deviceProperties buffer overflow");
1075 if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), s_physicalDevicePropertiesOffsetTable))
1077 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage;
1078 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
1081 // Check if deviceName string is properly terminated.
1082 if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE)
1084 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage;
1085 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
1089 const ApiVersion deviceVersion = unpackVersion(props->apiVersion);
1090 const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION);
1092 if (deviceVersion.majorNum != deqpVersion.majorNum)
1094 log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage;
1095 return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
1098 if (deviceVersion.minorNum > deqpVersion.minorNum)
1100 log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage;
1101 return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
1105 return tcu::TestStatus::pass("DeviceProperites query succeeded");
1108 tcu::TestStatus deviceQueueFamilyProperties (Context& context)
1110 TestLog& log = context.getTestContext().getLog();
1111 const vector<VkQueueFamilyProperties> queueProperties = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
1113 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage;
1115 for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++)
1116 log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage;
1118 return tcu::TestStatus::pass("Querying queue properties succeeded");
1121 tcu::TestStatus deviceMemoryProperties (Context& context)
1123 TestLog& log = context.getTestContext().getLog();
1124 VkPhysicalDeviceMemoryProperties* memProps;
1125 deUint8 buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE];
1127 memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer);
1128 deMemset(buffer, GUARD_VALUE, sizeof(buffer));
1130 context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps);
1132 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
1133 << TestLog::Message << *memProps << TestLog::EndMessage;
1135 for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
1137 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE)
1139 log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
1140 return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow");
1144 if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS)
1146 log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage;
1147 return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large");
1150 if (memProps->memoryHeapCount == 1)
1152 if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
1154 log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage;
1155 return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags");
1159 const VkMemoryPropertyFlags validPropertyFlags[] =
1162 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
1163 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1164 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
1165 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1166 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1167 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
1168 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1169 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
1172 const VkMemoryPropertyFlags requiredPropertyFlags[] =
1174 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
1177 bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)];
1178 std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
1180 for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++)
1182 bool validPropTypeFound = false;
1184 if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount)
1186 log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage;
1187 return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex");
1190 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;
1192 for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++)
1193 if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator)
1194 requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true;
1196 if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck))
1197 validPropTypeFound = true;
1199 if (!validPropTypeFound)
1201 log << TestLog::Message << "deviceMemoryProperties - propertyFlags "
1202 << memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage;
1203 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
1206 if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
1208 if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
1210 log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage;
1211 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
1216 if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1218 log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage;
1219 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
1224 bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
1225 if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound))
1227 DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags));
1228 log << TestLog::Message << "deviceMemoryProperties - required property flags "
1229 << getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage;
1231 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
1234 return tcu::TestStatus::pass("Querying memory properties succeeded");
1237 // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead
1239 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format)
1241 static const VkFormat s_requiredSampledImageBlitSrcFormats[] =
1243 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1244 VK_FORMAT_R5G6B5_UNORM_PACK16,
1245 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1250 VK_FORMAT_R8G8_UNORM,
1251 VK_FORMAT_R8G8_SNORM,
1252 VK_FORMAT_R8G8_UINT,
1253 VK_FORMAT_R8G8_SINT,
1254 VK_FORMAT_R8G8B8A8_UNORM,
1255 VK_FORMAT_R8G8B8A8_SNORM,
1256 VK_FORMAT_R8G8B8A8_UINT,
1257 VK_FORMAT_R8G8B8A8_SINT,
1258 VK_FORMAT_R8G8B8A8_SRGB,
1259 VK_FORMAT_B8G8R8A8_UNORM,
1260 VK_FORMAT_B8G8R8A8_SRGB,
1261 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1262 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1263 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1264 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1265 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1266 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1267 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1270 VK_FORMAT_R16_SFLOAT,
1271 VK_FORMAT_R16G16_UINT,
1272 VK_FORMAT_R16G16_SINT,
1273 VK_FORMAT_R16G16_SFLOAT,
1274 VK_FORMAT_R16G16B16A16_UINT,
1275 VK_FORMAT_R16G16B16A16_SINT,
1276 VK_FORMAT_R16G16B16A16_SFLOAT,
1279 VK_FORMAT_R32_SFLOAT,
1280 VK_FORMAT_R32G32_UINT,
1281 VK_FORMAT_R32G32_SINT,
1282 VK_FORMAT_R32G32_SFLOAT,
1283 VK_FORMAT_R32G32B32A32_UINT,
1284 VK_FORMAT_R32G32B32A32_SINT,
1285 VK_FORMAT_R32G32B32A32_SFLOAT,
1286 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1287 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1288 VK_FORMAT_D16_UNORM,
1289 VK_FORMAT_D32_SFLOAT
1291 static const VkFormat s_requiredSampledImageFilterLinearFormats[] =
1293 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1294 VK_FORMAT_R5G6B5_UNORM_PACK16,
1295 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1298 VK_FORMAT_R8G8_UNORM,
1299 VK_FORMAT_R8G8_SNORM,
1300 VK_FORMAT_R8G8B8A8_UNORM,
1301 VK_FORMAT_R8G8B8A8_SNORM,
1302 VK_FORMAT_R8G8B8A8_SRGB,
1303 VK_FORMAT_B8G8R8A8_UNORM,
1304 VK_FORMAT_B8G8R8A8_SRGB,
1305 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1306 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1307 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1308 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1309 VK_FORMAT_R16_SFLOAT,
1310 VK_FORMAT_R16G16_SFLOAT,
1311 VK_FORMAT_R16G16B16A16_SFLOAT,
1312 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1313 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1315 static const VkFormat s_requiredStorageImageFormats[] =
1317 VK_FORMAT_R8G8B8A8_UNORM,
1318 VK_FORMAT_R8G8B8A8_SNORM,
1319 VK_FORMAT_R8G8B8A8_UINT,
1320 VK_FORMAT_R8G8B8A8_SINT,
1321 VK_FORMAT_R16G16B16A16_UINT,
1322 VK_FORMAT_R16G16B16A16_SINT,
1323 VK_FORMAT_R16G16B16A16_SFLOAT,
1326 VK_FORMAT_R32_SFLOAT,
1327 VK_FORMAT_R32G32_UINT,
1328 VK_FORMAT_R32G32_SINT,
1329 VK_FORMAT_R32G32_SFLOAT,
1330 VK_FORMAT_R32G32B32A32_UINT,
1331 VK_FORMAT_R32G32B32A32_SINT,
1332 VK_FORMAT_R32G32B32A32_SFLOAT
1334 static const VkFormat s_requiredStorageImageAtomicFormats[] =
1339 static const VkFormat s_requiredColorAttachmentBlitDstFormats[] =
1341 VK_FORMAT_R5G6B5_UNORM_PACK16,
1342 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1346 VK_FORMAT_R8G8_UNORM,
1347 VK_FORMAT_R8G8_UINT,
1348 VK_FORMAT_R8G8_SINT,
1349 VK_FORMAT_R8G8B8A8_UNORM,
1350 VK_FORMAT_R8G8B8A8_UINT,
1351 VK_FORMAT_R8G8B8A8_SINT,
1352 VK_FORMAT_R8G8B8A8_SRGB,
1353 VK_FORMAT_B8G8R8A8_UNORM,
1354 VK_FORMAT_B8G8R8A8_SRGB,
1355 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1356 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1357 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1358 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1359 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1360 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1363 VK_FORMAT_R16_SFLOAT,
1364 VK_FORMAT_R16G16_UINT,
1365 VK_FORMAT_R16G16_SINT,
1366 VK_FORMAT_R16G16_SFLOAT,
1367 VK_FORMAT_R16G16B16A16_UINT,
1368 VK_FORMAT_R16G16B16A16_SINT,
1369 VK_FORMAT_R16G16B16A16_SFLOAT,
1372 VK_FORMAT_R32_SFLOAT,
1373 VK_FORMAT_R32G32_UINT,
1374 VK_FORMAT_R32G32_SINT,
1375 VK_FORMAT_R32G32_SFLOAT,
1376 VK_FORMAT_R32G32B32A32_UINT,
1377 VK_FORMAT_R32G32B32A32_SINT,
1378 VK_FORMAT_R32G32B32A32_SFLOAT
1380 static const VkFormat s_requiredColorAttachmentBlendFormats[] =
1382 VK_FORMAT_R5G6B5_UNORM_PACK16,
1383 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1385 VK_FORMAT_R8G8_UNORM,
1386 VK_FORMAT_R8G8B8A8_UNORM,
1387 VK_FORMAT_R8G8B8A8_SRGB,
1388 VK_FORMAT_B8G8R8A8_UNORM,
1389 VK_FORMAT_B8G8R8A8_SRGB,
1390 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1391 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1392 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1393 VK_FORMAT_R16_SFLOAT,
1394 VK_FORMAT_R16G16_SFLOAT,
1395 VK_FORMAT_R16G16B16A16_SFLOAT
1397 static const VkFormat s_requiredDepthStencilAttachmentFormats[] =
1402 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0;
1404 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format))
1405 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT;
1407 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterLinearFormats), DE_ARRAY_END(s_requiredSampledImageFilterLinearFormats), format))
1408 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
1410 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format))
1411 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
1413 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format))
1414 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
1416 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format))
1417 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT;
1419 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format))
1420 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
1422 if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format))
1423 flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
1428 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format)
1430 static const VkFormat s_requiredVertexBufferFormats[] =
1436 VK_FORMAT_R8G8_UNORM,
1437 VK_FORMAT_R8G8_SNORM,
1438 VK_FORMAT_R8G8_UINT,
1439 VK_FORMAT_R8G8_SINT,
1440 VK_FORMAT_R8G8B8A8_UNORM,
1441 VK_FORMAT_R8G8B8A8_SNORM,
1442 VK_FORMAT_R8G8B8A8_UINT,
1443 VK_FORMAT_R8G8B8A8_SINT,
1444 VK_FORMAT_B8G8R8A8_UNORM,
1445 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1446 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1447 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1448 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1449 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1450 VK_FORMAT_R16_UNORM,
1451 VK_FORMAT_R16_SNORM,
1454 VK_FORMAT_R16_SFLOAT,
1455 VK_FORMAT_R16G16_UNORM,
1456 VK_FORMAT_R16G16_SNORM,
1457 VK_FORMAT_R16G16_UINT,
1458 VK_FORMAT_R16G16_SINT,
1459 VK_FORMAT_R16G16_SFLOAT,
1460 VK_FORMAT_R16G16B16A16_UNORM,
1461 VK_FORMAT_R16G16B16A16_SNORM,
1462 VK_FORMAT_R16G16B16A16_UINT,
1463 VK_FORMAT_R16G16B16A16_SINT,
1464 VK_FORMAT_R16G16B16A16_SFLOAT,
1467 VK_FORMAT_R32_SFLOAT,
1468 VK_FORMAT_R32G32_UINT,
1469 VK_FORMAT_R32G32_SINT,
1470 VK_FORMAT_R32G32_SFLOAT,
1471 VK_FORMAT_R32G32B32_UINT,
1472 VK_FORMAT_R32G32B32_SINT,
1473 VK_FORMAT_R32G32B32_SFLOAT,
1474 VK_FORMAT_R32G32B32A32_UINT,
1475 VK_FORMAT_R32G32B32A32_SINT,
1476 VK_FORMAT_R32G32B32A32_SFLOAT
1478 static const VkFormat s_requiredUniformTexelBufferFormats[] =
1484 VK_FORMAT_R8G8_UNORM,
1485 VK_FORMAT_R8G8_SNORM,
1486 VK_FORMAT_R8G8_UINT,
1487 VK_FORMAT_R8G8_SINT,
1488 VK_FORMAT_R8G8B8A8_UNORM,
1489 VK_FORMAT_R8G8B8A8_SNORM,
1490 VK_FORMAT_R8G8B8A8_UINT,
1491 VK_FORMAT_R8G8B8A8_SINT,
1492 VK_FORMAT_B8G8R8A8_UNORM,
1493 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1494 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1495 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1496 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1497 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1498 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1501 VK_FORMAT_R16_SFLOAT,
1502 VK_FORMAT_R16G16_UINT,
1503 VK_FORMAT_R16G16_SINT,
1504 VK_FORMAT_R16G16_SFLOAT,
1505 VK_FORMAT_R16G16B16A16_UINT,
1506 VK_FORMAT_R16G16B16A16_SINT,
1507 VK_FORMAT_R16G16B16A16_SFLOAT,
1510 VK_FORMAT_R32_SFLOAT,
1511 VK_FORMAT_R32G32_UINT,
1512 VK_FORMAT_R32G32_SINT,
1513 VK_FORMAT_R32G32_SFLOAT,
1514 VK_FORMAT_R32G32B32A32_UINT,
1515 VK_FORMAT_R32G32B32A32_SINT,
1516 VK_FORMAT_R32G32B32A32_SFLOAT,
1517 VK_FORMAT_B10G11R11_UFLOAT_PACK32
1519 static const VkFormat s_requiredStorageTexelBufferFormats[] =
1521 VK_FORMAT_R8G8B8A8_UNORM,
1522 VK_FORMAT_R8G8B8A8_SNORM,
1523 VK_FORMAT_R8G8B8A8_UINT,
1524 VK_FORMAT_R8G8B8A8_SINT,
1525 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1526 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1527 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1528 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1529 VK_FORMAT_R16G16B16A16_UINT,
1530 VK_FORMAT_R16G16B16A16_SINT,
1531 VK_FORMAT_R16G16B16A16_SFLOAT,
1534 VK_FORMAT_R32_SFLOAT,
1535 VK_FORMAT_R32G32_UINT,
1536 VK_FORMAT_R32G32_SINT,
1537 VK_FORMAT_R32G32_SFLOAT,
1538 VK_FORMAT_R32G32B32A32_UINT,
1539 VK_FORMAT_R32G32B32A32_SINT,
1540 VK_FORMAT_R32G32B32A32_SFLOAT
1542 static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] =
1548 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0;
1550 if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format))
1551 flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
1553 if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format))
1554 flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
1556 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format))
1557 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
1559 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format))
1560 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
1565 tcu::TestStatus formatProperties (Context& context, VkFormat format)
1567 TestLog& log = context.getTestContext().getLog();
1568 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1573 VkFormatFeatureFlags VkFormatProperties::* field;
1574 const char* fieldName;
1575 VkFormatFeatureFlags requiredFeatures;
1578 { &VkFormatProperties::linearTilingFeatures, "linearTilingFeatures", (VkFormatFeatureFlags)0 },
1579 { &VkFormatProperties::optimalTilingFeatures, "optimalTilingFeatures", getRequiredOptimalTilingFeatures(format) },
1580 { &VkFormatProperties::bufferFeatures, "buffeFeatures", getRequiredBufferFeatures(format) }
1583 log << TestLog::Message << properties << TestLog::EndMessage;
1585 for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
1587 const char* const fieldName = fields[fieldNdx].fieldName;
1588 const VkFormatFeatureFlags supported = properties.*fields[fieldNdx].field;
1589 const VkFormatFeatureFlags required = fields[fieldNdx].requiredFeatures;
1591 if ((supported & required) != required)
1593 log << TestLog::Message << "ERROR in " << fieldName << ":\n"
1594 << " required: " << getFormatFeatureFlagsStr(required) << "\n "
1595 << " missing: " << getFormatFeatureFlagsStr(~supported & required)
1596 << TestLog::EndMessage;
1602 return tcu::TestStatus::pass("Query and validation passed");
1604 return tcu::TestStatus::fail("Required features not supported");
1607 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features)
1609 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1611 return (properties.optimalTilingFeatures & features) == features;
1614 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features)
1616 for (const VkFormat* cur = begin; cur != end; ++cur)
1618 if (!optimalTilingFeaturesSupported(context, *cur, features))
1625 tcu::TestStatus testDepthStencilSupported (Context& context)
1627 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
1628 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
1629 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT");
1631 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
1632 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
1633 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT");
1635 return tcu::TestStatus::pass("Required depth/stencil formats supported");
1638 tcu::TestStatus testCompressedFormatsSupported (Context& context)
1640 static const VkFormat s_allBcFormats[] =
1642 VK_FORMAT_BC1_RGB_UNORM_BLOCK,
1643 VK_FORMAT_BC1_RGB_SRGB_BLOCK,
1644 VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
1645 VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
1646 VK_FORMAT_BC2_UNORM_BLOCK,
1647 VK_FORMAT_BC2_SRGB_BLOCK,
1648 VK_FORMAT_BC3_UNORM_BLOCK,
1649 VK_FORMAT_BC3_SRGB_BLOCK,
1650 VK_FORMAT_BC4_UNORM_BLOCK,
1651 VK_FORMAT_BC4_SNORM_BLOCK,
1652 VK_FORMAT_BC5_UNORM_BLOCK,
1653 VK_FORMAT_BC5_SNORM_BLOCK,
1654 VK_FORMAT_BC6H_UFLOAT_BLOCK,
1655 VK_FORMAT_BC6H_SFLOAT_BLOCK,
1656 VK_FORMAT_BC7_UNORM_BLOCK,
1657 VK_FORMAT_BC7_SRGB_BLOCK,
1659 static const VkFormat s_allEtc2Formats[] =
1661 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1662 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1663 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1664 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1665 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1666 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1667 VK_FORMAT_EAC_R11_UNORM_BLOCK,
1668 VK_FORMAT_EAC_R11_SNORM_BLOCK,
1669 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1670 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1672 static const VkFormat s_allAstcLdrFormats[] =
1674 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1675 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1676 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1677 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1678 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1679 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1680 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1681 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1682 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1683 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1684 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1685 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1686 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1687 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1688 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1689 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1690 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1691 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1692 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1693 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1694 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1695 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1696 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1697 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1698 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1699 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1700 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1701 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
1706 const char* setName;
1707 const char* featureName;
1708 const VkBool32 VkPhysicalDeviceFeatures::* feature;
1709 const VkFormat* formatsBegin;
1710 const VkFormat* formatsEnd;
1711 } s_compressedFormatSets[] =
1713 { "BC", "textureCompressionBC", &VkPhysicalDeviceFeatures::textureCompressionBC, DE_ARRAY_BEGIN(s_allBcFormats), DE_ARRAY_END(s_allBcFormats) },
1714 { "ETC2", "textureCompressionETC2", &VkPhysicalDeviceFeatures::textureCompressionETC2, DE_ARRAY_BEGIN(s_allEtc2Formats), DE_ARRAY_END(s_allEtc2Formats) },
1715 { "ASTC LDR", "textureCompressionASTC_LDR", &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR, DE_ARRAY_BEGIN(s_allAstcLdrFormats), DE_ARRAY_END(s_allAstcLdrFormats) },
1718 TestLog& log = context.getTestContext().getLog();
1719 const VkPhysicalDeviceFeatures& features = context.getDeviceFeatures();
1720 int numSupportedSets = 0;
1722 int numWarnings = 0;
1724 for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx)
1726 const char* const setName = s_compressedFormatSets[setNdx].setName;
1727 const char* const featureName = s_compressedFormatSets[setNdx].featureName;
1728 const bool featureBitSet = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE;
1729 const bool allSupported = optimalTilingFeaturesSupportedForAll(context,
1730 s_compressedFormatSets[setNdx].formatsBegin,
1731 s_compressedFormatSets[setNdx].formatsEnd,
1732 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
1734 if (featureBitSet && !allSupported)
1736 log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage;
1739 else if (allSupported && !featureBitSet)
1741 log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage;
1747 log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage;
1748 numSupportedSets += 1;
1751 log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage;
1754 if (numSupportedSets == 0)
1756 log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage;
1761 return tcu::TestStatus::fail("Compressed format support not valid");
1762 else if (numWarnings > 0)
1763 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support");
1765 return tcu::TestStatus::pass("Compressed texture format support is valid");
1768 void createFormatTests (tcu::TestCaseGroup* testGroup)
1770 DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0);
1772 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
1774 const VkFormat format = (VkFormat)formatNdx;
1775 const char* const enumName = getFormatName(format);
1776 const string caseName = de::toLower(string(enumName).substr(10));
1778 addFunctionCase(testGroup, caseName, enumName, formatProperties, format);
1781 addFunctionCase(testGroup, "depth_stencil", "", testDepthStencilSupported);
1782 addFunctionCase(testGroup, "compressed_formats", "", testCompressedFormatsSupported);
1785 VkImageUsageFlags getValidImageUsageFlags (const VkFormatFeatureFlags supportedFeatures, const bool useKhrMaintenance1Semantics)
1787 VkImageUsageFlags flags = (VkImageUsageFlags)0;
1789 if (useKhrMaintenance1Semantics)
1791 if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR) != 0)
1792 flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
1794 if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR) != 0)
1795 flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
1799 // If format is supported at all, it must be valid transfer src+dst
1800 if (supportedFeatures != 0)
1801 flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
1804 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
1805 flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
1807 if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0)
1808 flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1810 if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1811 flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1813 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
1814 flags |= VK_IMAGE_USAGE_STORAGE_BIT;
1819 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
1821 if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)
1823 const VkImageUsageFlags allowedFlags = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
1824 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
1825 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
1826 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1828 // Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT
1829 if ((usage & ~allowedFlags) != 0)
1832 // TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT
1833 if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
1840 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage)
1842 VkImageCreateFlags flags = (VkImageCreateFlags)0;
1844 if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1846 flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
1848 if (type == VK_IMAGE_TYPE_2D)
1849 flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
1852 if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 &&
1853 (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1855 if (deviceFeatures.sparseBinding)
1856 flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
1858 if (deviceFeatures.sparseResidencyAliased)
1859 flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
1865 bool isValidImageCreateFlagCombination (VkImageCreateFlags)
1870 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures& deviceFeatures,
1871 const VkFormat format,
1872 const VkFormatProperties& formatProperties,
1873 const VkImageType imageType,
1874 const VkImageTiling imageTiling,
1875 const VkImageUsageFlags usageFlags,
1876 const VkImageCreateFlags createFlags)
1878 DE_UNREF(deviceFeatures);
1879 DE_UNREF(formatProperties);
1880 DE_UNREF(createFlags);
1882 // Linear images can have arbitrary limitations
1883 if (imageTiling == VK_IMAGE_TILING_LINEAR)
1886 // Support for other usages for compressed formats is optional
1887 if (isCompressedFormat(format) &&
1888 (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0)
1891 // Support for 1D, and sliced 3D compressed formats is optional
1892 if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
1895 // Support for 1D and 3D depth/stencil textures is optional
1896 if (isDepthStencilFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
1899 DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
1900 DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
1902 if (createFlags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)
1904 if (isCompressedFormat(format))
1907 if (isDepthStencilFormat(format))
1910 if (!deIsPowerOfTwo32(mapVkFormat(format).getPixelSize()))
1915 case VK_IMAGE_TYPE_2D:
1916 return (deviceFeatures.sparseResidencyImage2D == VK_TRUE);
1917 case VK_IMAGE_TYPE_3D:
1918 return (deviceFeatures.sparseResidencyImage3D == VK_TRUE);
1927 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits& deviceLimits,
1928 const VkFormat format,
1929 const VkImageUsageFlags usageFlags)
1931 if (!isCompressedFormat(format))
1933 const tcu::TextureFormat tcuFormat = mapVkFormat(format);
1934 const bool hasDepthComp = (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS);
1935 const bool hasStencilComp = (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS);
1936 const bool isColorFormat = !hasDepthComp && !hasStencilComp;
1937 VkSampleCountFlags sampleCounts = ~(VkSampleCountFlags)0;
1939 DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat);
1941 if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0)
1942 sampleCounts &= deviceLimits.storageImageSampleCounts;
1944 if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1947 sampleCounts &= deviceLimits.sampledImageDepthSampleCounts;
1950 sampleCounts &= deviceLimits.sampledImageStencilSampleCounts;
1954 const tcu::TextureChannelClass chnClass = tcu::getTextureChannelClass(tcuFormat.type);
1956 if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
1957 chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
1958 sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts;
1960 sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
1964 if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
1965 sampleCounts &= deviceLimits.framebufferColorSampleCounts;
1967 if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1970 sampleCounts &= deviceLimits.framebufferDepthSampleCounts;
1973 sampleCounts &= deviceLimits.framebufferStencilSampleCounts;
1976 // If there is no usage flag set that would have corresponding device limit,
1977 // only VK_SAMPLE_COUNT_1_BIT is required.
1978 if (sampleCounts == ~(VkSampleCountFlags)0)
1979 sampleCounts &= VK_SAMPLE_COUNT_1_BIT;
1981 return sampleCounts;
1984 return VK_SAMPLE_COUNT_1_BIT;
1987 struct ImageFormatPropertyCase
1989 typedef tcu::TestStatus (*Function) (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling);
1991 Function testFunction;
1993 VkImageType imageType;
1994 VkImageTiling tiling;
1996 ImageFormatPropertyCase (Function testFunction_, VkFormat format_, VkImageType imageType_, VkImageTiling tiling_)
1997 : testFunction (testFunction_)
1999 , imageType (imageType_)
2003 ImageFormatPropertyCase (void)
2004 : testFunction ((Function)DE_NULL)
2005 , format (VK_FORMAT_UNDEFINED)
2006 , imageType (VK_IMAGE_TYPE_LAST)
2007 , tiling (VK_IMAGE_TILING_LAST)
2011 tcu::TestStatus execImageFormatTest (Context& context, ImageFormatPropertyCase testCase)
2013 return testCase.testFunction(context, testCase.format, testCase.imageType, testCase.tiling);
2016 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
2018 DE_ASSERT(params.format == VK_FORMAT_UNDEFINED);
2020 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
2022 const VkFormat format = (VkFormat)formatNdx;
2023 const char* const enumName = getFormatName(format);
2024 const string caseName = de::toLower(string(enumName).substr(10));
2026 params.format = format;
2028 addFunctionCase(testGroup, caseName, enumName, execImageFormatTest, params);
2032 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
2034 DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST);
2036 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_OPTIMAL)));
2037 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_LINEAR)));
2040 void createImageFormatTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase::Function testFunction)
2042 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST)));
2043 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST)));
2044 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST)));
2047 tcu::TestStatus imageFormatProperties (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
2049 TestLog& log = context.getTestContext().getLog();
2050 const VkPhysicalDeviceFeatures& deviceFeatures = context.getDeviceFeatures();
2051 const VkPhysicalDeviceLimits& deviceLimits = context.getDeviceProperties().limits;
2052 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
2053 const bool hasKhrMaintenance1 = isExtensionSupported(context.getDeviceExtensions(), "VK_KHR_maintenance1");
2055 const VkFormatFeatureFlags supportedFeatures = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
2056 const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(supportedFeatures, hasKhrMaintenance1);
2058 tcu::ResultCollector results (log, "ERROR: ");
2060 if (hasKhrMaintenance1 && (supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
2062 results.check((supportedFeatures & (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR)) != 0,
2063 "A sampled image format must have VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR and VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR format feature flags set");
2066 for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
2068 if ((curUsageFlags & ~usageFlagSet) != 0 ||
2069 !isValidImageUsageFlagCombination(curUsageFlags))
2072 const VkImageCreateFlags createFlagSet = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags);
2074 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++)
2076 if ((curCreateFlags & ~createFlagSet) != 0 ||
2077 !isValidImageCreateFlagCombination(curCreateFlags))
2080 const bool isRequiredCombination = isRequiredImageParameterCombination(deviceFeatures,
2087 VkImageFormatProperties properties;
2088 VkResult queryResult;
2090 log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", "
2091 << getImageTilingStr(tiling) << ", "
2092 << getImageUsageFlagsStr(curUsageFlags) << ", "
2093 << getImageCreateFlagsStr(curCreateFlags)
2094 << TestLog::EndMessage;
2096 // Set return value to known garbage
2097 deMemset(&properties, 0xcd, sizeof(properties));
2099 queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(),
2107 if (queryResult == VK_SUCCESS)
2109 const deUint32 fullMipPyramidSize = de::max(de::max(deLog2Ceil32(properties.maxExtent.width),
2110 deLog2Ceil32(properties.maxExtent.height)),
2111 deLog2Ceil32(properties.maxExtent.depth)) + 1;
2113 log << TestLog::Message << properties << "\n" << TestLog::EndMessage;
2115 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image");
2116 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image");
2117 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image");
2118 results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image");
2120 if (tiling == VK_IMAGE_TILING_OPTIMAL && imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
2121 ((supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) ||
2122 ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) && deviceFeatures.shaderStorageImageMultisample)))
2124 const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
2125 results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
2128 results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT");
2130 if (isRequiredCombination)
2132 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= deviceLimits.maxImageDimension1D),
2133 "Reported dimensions smaller than device limits");
2134 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= deviceLimits.maxImageDimension2D &&
2135 properties.maxExtent.height >= deviceLimits.maxImageDimension2D),
2136 "Reported dimensions smaller than device limits");
2137 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= deviceLimits.maxImageDimension3D &&
2138 properties.maxExtent.height >= deviceLimits.maxImageDimension3D &&
2139 properties.maxExtent.depth >= deviceLimits.maxImageDimension3D),
2140 "Reported dimensions smaller than device limits");
2141 results.check(properties.maxMipLevels == fullMipPyramidSize, "maxMipLevels is not full mip pyramid size");
2142 results.check(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers,
2143 "maxArrayLayers smaller than device limits");
2147 results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size");
2148 results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers");
2151 results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE,
2152 "maxResourceSize smaller than minimum required size");
2154 else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED)
2156 log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage;
2158 if (isRequiredCombination)
2159 results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination");
2161 // Specification requires that all fields are set to 0
2162 results.check(properties.maxExtent.width == 0, "maxExtent.width != 0");
2163 results.check(properties.maxExtent.height == 0, "maxExtent.height != 0");
2164 results.check(properties.maxExtent.depth == 0, "maxExtent.depth != 0");
2165 results.check(properties.maxMipLevels == 0, "maxMipLevels != 0");
2166 results.check(properties.maxArrayLayers == 0, "maxArrayLayers != 0");
2167 results.check(properties.sampleCounts == 0, "sampleCounts != 0");
2168 results.check(properties.maxResourceSize == 0, "maxResourceSize != 0");
2172 results.fail("Got unexpected error" + de::toString(queryResult));
2177 return tcu::TestStatus(results.getResult(), results.getMessage());
2180 // VK_KHR_get_physical_device_properties2
2182 Move<VkInstance> createInstanceWithExtension (const PlatformInterface& vkp, const char* extensionName)
2184 const vector<VkExtensionProperties> instanceExts = enumerateInstanceExtensionProperties(vkp, DE_NULL);
2185 vector<string> enabledExts;
2187 if (!isExtensionSupported(instanceExts, RequiredExtension(extensionName)))
2188 TCU_THROW(NotSupportedError, (string(extensionName) + " is not supported").c_str());
2190 enabledExts.push_back(extensionName);
2192 return createDefaultInstance(vkp, vector<string>() /* layers */, enabledExts);
2195 tcu::TestStatus deviceFeatures2 (Context& context)
2197 const PlatformInterface& vkp = context.getPlatformInterface();
2198 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2199 const InstanceDriver vki (vkp, *instance);
2200 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2202 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2204 VkPhysicalDeviceFeatures coreFeatures;
2205 VkPhysicalDeviceFeatures2KHR extFeatures;
2207 deMemset(&coreFeatures, 0xcd, sizeof(coreFeatures));
2208 deMemset(&extFeatures.features, 0xcd, sizeof(extFeatures.features));
2210 extFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
2211 extFeatures.pNext = DE_NULL;
2213 vki.getPhysicalDeviceFeatures(devices[deviceNdx], &coreFeatures);
2214 vki.getPhysicalDeviceFeatures2KHR(devices[deviceNdx], &extFeatures);
2216 TCU_CHECK(extFeatures.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR);
2217 TCU_CHECK(extFeatures.pNext == DE_NULL);
2219 if (deMemCmp(&coreFeatures, &extFeatures.features, sizeof(VkPhysicalDeviceFeatures)) != 0)
2220 TCU_FAIL("Mismatch between features reported by vkGetPhysicalDeviceFeatures and vkGetPhysicalDeviceFeatures2KHR");
2223 return tcu::TestStatus::pass("Querying device features succeeded");
2226 tcu::TestStatus deviceProperties2 (Context& context)
2228 const PlatformInterface& vkp = context.getPlatformInterface();
2229 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2230 const InstanceDriver vki (vkp, *instance);
2231 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2233 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2235 VkPhysicalDeviceProperties coreProperties;
2236 VkPhysicalDeviceProperties2KHR extProperties;
2238 extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
2239 extProperties.pNext = DE_NULL;
2241 vki.getPhysicalDeviceProperties(devices[deviceNdx], &coreProperties);
2242 vki.getPhysicalDeviceProperties2KHR(devices[deviceNdx], &extProperties);
2244 TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR);
2245 TCU_CHECK(extProperties.pNext == DE_NULL);
2247 // We can't use memcmp() here because the structs may contain padding bytes that drivers may or may not
2248 // have written while writing the data and memcmp will compare them anyway, so we iterate through the
2249 // valid bytes for each field in the struct and compare only the valid bytes for each one.
2250 for (int propNdx = 0; propNdx < DE_LENGTH_OF_ARRAY(s_physicalDevicePropertiesOffsetTable); propNdx++)
2252 const size_t offset = s_physicalDevicePropertiesOffsetTable[propNdx].offset;
2253 const size_t size = s_physicalDevicePropertiesOffsetTable[propNdx].size;
2255 const deUint8* corePropertyBytes = reinterpret_cast<deUint8*>(&coreProperties) + offset;
2256 const deUint8* extPropertyBytes = reinterpret_cast<deUint8*>(&extProperties.properties) + offset;
2258 if (deMemCmp(corePropertyBytes, extPropertyBytes, size) != 0)
2259 TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceProperties and vkGetPhysicalDeviceProperties2KHR");
2263 return tcu::TestStatus::pass("Querying device properties succeeded");
2266 tcu::TestStatus deviceFormatProperties2 (Context& context)
2268 const PlatformInterface& vkp = context.getPlatformInterface();
2269 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2270 const InstanceDriver vki (vkp, *instance);
2271 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2273 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2275 const VkPhysicalDevice physicalDevice = devices[deviceNdx];
2277 for (int formatNdx = 0; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
2279 const VkFormat format = (VkFormat)formatNdx;
2280 VkFormatProperties coreProperties;
2281 VkFormatProperties2KHR extProperties;
2283 deMemset(&coreProperties, 0xcd, sizeof(VkFormatProperties));
2284 deMemset(&extProperties, 0xcd, sizeof(VkFormatProperties2KHR));
2286 extProperties.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR;
2287 extProperties.pNext = DE_NULL;
2289 vki.getPhysicalDeviceFormatProperties(physicalDevice, format, &coreProperties);
2290 vki.getPhysicalDeviceFormatProperties2KHR(physicalDevice, format, &extProperties);
2292 TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR);
2293 TCU_CHECK(extProperties.pNext == DE_NULL);
2295 if (deMemCmp(&coreProperties, &extProperties.formatProperties, sizeof(VkFormatProperties)) != 0)
2296 TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceFormatProperties and vkGetPhysicalDeviceFormatProperties2KHR");
2300 return tcu::TestStatus::pass("Querying device format properties succeeded");
2303 tcu::TestStatus deviceQueueFamilyProperties2 (Context& context)
2305 const PlatformInterface& vkp = context.getPlatformInterface();
2306 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2307 const InstanceDriver vki (vkp, *instance);
2308 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2310 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2312 const VkPhysicalDevice physicalDevice = devices[deviceNdx];
2313 deUint32 numCoreQueueFamilies = ~0u;
2314 deUint32 numExtQueueFamilies = ~0u;
2316 vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, DE_NULL);
2317 vki.getPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &numExtQueueFamilies, DE_NULL);
2319 TCU_CHECK_MSG(numCoreQueueFamilies == numExtQueueFamilies, "Different number of queue family properties reported");
2320 TCU_CHECK(numCoreQueueFamilies > 0);
2323 std::vector<VkQueueFamilyProperties> coreProperties (numCoreQueueFamilies);
2324 std::vector<VkQueueFamilyProperties2KHR> extProperties (numExtQueueFamilies);
2326 deMemset(&coreProperties[0], 0xcd, sizeof(VkQueueFamilyProperties)*numCoreQueueFamilies);
2327 deMemset(&extProperties[0], 0xcd, sizeof(VkQueueFamilyProperties2KHR)*numExtQueueFamilies);
2329 for (size_t ndx = 0; ndx < extProperties.size(); ++ndx)
2331 extProperties[ndx].sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR;
2332 extProperties[ndx].pNext = DE_NULL;
2335 vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, &coreProperties[0]);
2336 vki.getPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &numExtQueueFamilies, &extProperties[0]);
2338 TCU_CHECK((size_t)numCoreQueueFamilies == coreProperties.size());
2339 TCU_CHECK((size_t)numExtQueueFamilies == extProperties.size());
2340 DE_ASSERT(numCoreQueueFamilies == numExtQueueFamilies);
2342 for (size_t ndx = 0; ndx < extProperties.size(); ++ndx)
2344 TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR);
2345 TCU_CHECK(extProperties[ndx].pNext == DE_NULL);
2347 if (deMemCmp(&coreProperties[ndx], &extProperties[ndx].queueFamilyProperties, sizeof(VkQueueFamilyProperties)) != 0)
2348 TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceQueueFamilyProperties and vkGetPhysicalDeviceQueueFamilyProperties2KHR");
2353 return tcu::TestStatus::pass("Querying device queue family properties succeeded");
2356 tcu::TestStatus deviceMemoryProperties2 (Context& context)
2358 const PlatformInterface& vkp = context.getPlatformInterface();
2359 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2360 const InstanceDriver vki (vkp, *instance);
2361 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2363 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2365 VkPhysicalDeviceMemoryProperties coreProperties;
2366 VkPhysicalDeviceMemoryProperties2KHR extProperties;
2368 deMemset(&coreProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties));
2369 deMemset(&extProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties2KHR));
2371 extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR;
2372 extProperties.pNext = DE_NULL;
2374 vki.getPhysicalDeviceMemoryProperties(devices[deviceNdx], &coreProperties);
2375 vki.getPhysicalDeviceMemoryProperties2KHR(devices[deviceNdx], &extProperties);
2377 TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR);
2378 TCU_CHECK(extProperties.pNext == DE_NULL);
2380 if (deMemCmp(&coreProperties, &extProperties.memoryProperties, sizeof(VkPhysicalDeviceMemoryProperties)) != 0)
2381 TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2KHR");
2384 return tcu::TestStatus::pass("Querying device memory properties succeeded");
2387 tcu::TestStatus imageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
2389 TestLog& log = context.getTestContext().getLog();
2391 const PlatformInterface& vkp = context.getPlatformInterface();
2392 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2393 const InstanceDriver vki (vkp, *instance);
2394 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2396 const VkImageUsageFlags allUsageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT
2397 | VK_IMAGE_USAGE_TRANSFER_DST_BIT
2398 | VK_IMAGE_USAGE_SAMPLED_BIT
2399 | VK_IMAGE_USAGE_STORAGE_BIT
2400 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
2401 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
2402 | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
2403 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
2404 const VkImageCreateFlags allCreateFlags = VK_IMAGE_CREATE_SPARSE_BINDING_BIT
2405 | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT
2406 | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT
2407 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
2408 | VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
2410 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2412 const VkPhysicalDevice physicalDevice = devices[deviceNdx];
2414 for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++)
2416 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= allCreateFlags; curCreateFlags++)
2418 const VkPhysicalDeviceImageFormatInfo2KHR imageFormatInfo =
2420 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR,
2429 VkImageFormatProperties coreProperties;
2430 VkImageFormatProperties2KHR extProperties;
2431 VkResult coreResult;
2434 deMemset(&coreProperties, 0xcd, sizeof(VkImageFormatProperties));
2435 deMemset(&extProperties, 0xcd, sizeof(VkImageFormatProperties2KHR));
2437 extProperties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR;
2438 extProperties.pNext = DE_NULL;
2440 coreResult = vki.getPhysicalDeviceImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.tiling, imageFormatInfo.usage, imageFormatInfo.flags, &coreProperties);
2441 extResult = vki.getPhysicalDeviceImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &extProperties);
2443 TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR);
2444 TCU_CHECK(extProperties.pNext == DE_NULL);
2446 if ((coreResult != extResult) ||
2447 (deMemCmp(&coreProperties, &extProperties.imageFormatProperties, sizeof(VkImageFormatProperties)) != 0))
2449 log << TestLog::Message << "ERROR: device " << deviceNdx << ": mismatch with query " << imageFormatInfo << TestLog::EndMessage
2450 << TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties() returned " << coreResult << ", " << coreProperties << TestLog::EndMessage
2451 << TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties2KHR() returned " << extResult << ", " << extProperties << TestLog::EndMessage;
2452 TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceImageFormatProperties and vkGetPhysicalDeviceImageFormatProperties2KHR");
2458 return tcu::TestStatus::pass("Querying image format properties succeeded");
2461 tcu::TestStatus sparseImageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
2463 TestLog& log = context.getTestContext().getLog();
2465 const PlatformInterface& vkp = context.getPlatformInterface();
2466 const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
2467 const InstanceDriver vki (vkp, *instance);
2468 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance);
2470 const VkImageUsageFlags allUsageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT
2471 | VK_IMAGE_USAGE_TRANSFER_DST_BIT
2472 | VK_IMAGE_USAGE_SAMPLED_BIT
2473 | VK_IMAGE_USAGE_STORAGE_BIT
2474 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
2475 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
2476 | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
2477 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
2479 for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
2481 const VkPhysicalDevice physicalDevice = devices[deviceNdx];
2483 for (deUint32 sampleCountBit = VK_SAMPLE_COUNT_1_BIT; sampleCountBit <= VK_SAMPLE_COUNT_64_BIT; sampleCountBit = (sampleCountBit << 1u))
2485 for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++)
2487 const VkPhysicalDeviceSparseImageFormatInfo2KHR imageFormatInfo =
2489 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR,
2493 (VkSampleCountFlagBits)sampleCountBit,
2498 deUint32 numCoreProperties = ~0u;
2499 deUint32 numExtProperties = ~0u;
2502 vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, DE_NULL);
2503 vki.getPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &numExtProperties, DE_NULL);
2505 if (numCoreProperties != numExtProperties)
2507 log << TestLog::Message << "ERROR: device " << deviceNdx << ": different number of properties reported for " << imageFormatInfo << TestLog::EndMessage;
2508 TCU_FAIL("Mismatch in reported property count");
2511 if (numCoreProperties > 0)
2513 std::vector<VkSparseImageFormatProperties> coreProperties (numCoreProperties);
2514 std::vector<VkSparseImageFormatProperties2KHR> extProperties (numExtProperties);
2516 deMemset(&coreProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties)*numCoreProperties);
2517 deMemset(&extProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties2KHR)*numExtProperties);
2519 for (deUint32 ndx = 0; ndx < numExtProperties; ++ndx)
2521 extProperties[ndx].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR;
2522 extProperties[ndx].pNext = DE_NULL;
2525 vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, &coreProperties[0]);
2526 vki.getPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &numExtProperties, &extProperties[0]);
2528 TCU_CHECK((size_t)numCoreProperties == coreProperties.size());
2529 TCU_CHECK((size_t)numExtProperties == extProperties.size());
2531 for (deUint32 ndx = 0; ndx < numCoreProperties; ++ndx)
2533 TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR);
2534 TCU_CHECK(extProperties[ndx].pNext == DE_NULL);
2536 if ((deMemCmp(&coreProperties[ndx], &extProperties[ndx].properties, sizeof(VkSparseImageFormatProperties)) != 0))
2538 log << TestLog::Message << "ERROR: device " << deviceNdx << ": mismatch with query " << imageFormatInfo << " property " << ndx << TestLog::EndMessage
2539 << TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties() returned " << coreProperties[ndx] << TestLog::EndMessage
2540 << TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties2KHR() returned " << extProperties[ndx] << TestLog::EndMessage;
2541 TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceSparseImageFormatProperties and vkGetPhysicalDeviceSparseImageFormatProperties2KHR");
2549 return tcu::TestStatus::pass("Querying sparse image format properties succeeded");
2552 // Android CTS -specific tests
2557 void checkExtensions (tcu::ResultCollector& results, const set<string>& allowedExtensions, const vector<VkExtensionProperties>& reportedExtensions)
2559 for (vector<VkExtensionProperties>::const_iterator extension = reportedExtensions.begin(); extension != reportedExtensions.end(); ++extension)
2561 const string extensionName (extension->extensionName);
2562 const bool mustBeKnown = de::beginsWith(extensionName, "VK_KHX_") ||
2563 de::beginsWith(extensionName, "VK_GOOGLE_") ||
2564 de::beginsWith(extensionName, "VK_ANDROID_");
2566 if (mustBeKnown && !de::contains(allowedExtensions, extensionName))
2567 results.fail("Unknown extension: " + extensionName);
2571 tcu::TestStatus testNoUnknownExtensions (Context& context)
2573 TestLog& log = context.getTestContext().getLog();
2574 tcu::ResultCollector results (log);
2575 set<string> allowedInstanceExtensions;
2576 set<string> allowedDeviceExtensions;
2578 // All known extensions should be added to allowedExtensions:
2579 // allowedExtensions.insert("VK_GOOGLE_extension1");
2580 allowedDeviceExtensions.insert("VK_GOOGLE_display_timing");
2582 // Instance extensions
2583 checkExtensions(results,
2584 allowedInstanceExtensions,
2585 enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL));
2587 // Extensions exposed by instance layers
2589 const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface());
2591 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
2593 checkExtensions(results,
2594 allowedInstanceExtensions,
2595 enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName));
2599 // Device extensions
2600 checkExtensions(results,
2601 allowedDeviceExtensions,
2602 enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL));
2604 // Extensions exposed by device layers
2606 const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2608 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
2610 checkExtensions(results,
2611 allowedDeviceExtensions,
2612 enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName));
2616 return tcu::TestStatus(results.getResult(), results.getMessage());
2619 tcu::TestStatus testNoLayers (Context& context)
2621 TestLog& log = context.getTestContext().getLog();
2622 tcu::ResultCollector results (log);
2625 const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface());
2627 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
2628 results.fail(string("Instance layer enumerated: ") + layer->layerName);
2632 const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
2634 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
2635 results.fail(string("Device layer enumerated: ") + layer->layerName);
2638 return tcu::TestStatus(results.getResult(), results.getMessage());
2641 tcu::TestStatus testMandatoryExtensions (Context& context)
2643 TestLog& log = context.getTestContext().getLog();
2644 tcu::ResultCollector results (log);
2646 // Instance extensions
2648 static const char* mandatoryExtensions[] =
2650 "VK_KHR_get_physical_device_properties2",
2652 const vector<VkExtensionProperties> extensions = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
2654 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(mandatoryExtensions); ++ndx)
2656 if (!isExtensionSupported(extensions, RequiredExtension(mandatoryExtensions[ndx])))
2657 results.fail(string(mandatoryExtensions[ndx]) + " is not supported");
2661 // Device extensions
2663 static const char* mandatoryExtensions[] =
2665 "VK_KHR_maintenance1",
2667 const vector<VkExtensionProperties> extensions = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
2669 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(mandatoryExtensions); ++ndx)
2671 if (!isExtensionSupported(extensions, RequiredExtension(mandatoryExtensions[ndx])))
2672 results.fail(string(mandatoryExtensions[ndx]) + " is not supported");
2676 return tcu::TestStatus(results.getResult(), results.getMessage());
2683 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx)
2685 de::MovePtr<tcu::TestCaseGroup> infoTests (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
2688 de::MovePtr<tcu::TestCaseGroup> instanceInfoTests (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests"));
2690 addFunctionCase(instanceInfoTests.get(), "physical_devices", "Physical devices", enumeratePhysicalDevices);
2691 addFunctionCase(instanceInfoTests.get(), "layers", "Layers", enumerateInstanceLayers);
2692 addFunctionCase(instanceInfoTests.get(), "extensions", "Extensions", enumerateInstanceExtensions);
2694 infoTests->addChild(instanceInfoTests.release());
2698 de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests"));
2700 addFunctionCase(deviceInfoTests.get(), "features", "Device Features", deviceFeatures);
2701 addFunctionCase(deviceInfoTests.get(), "properties", "Device Properties", deviceProperties);
2702 addFunctionCase(deviceInfoTests.get(), "queue_family_properties", "Queue family properties", deviceQueueFamilyProperties);
2703 addFunctionCase(deviceInfoTests.get(), "memory_properties", "Memory properties", deviceMemoryProperties);
2704 addFunctionCase(deviceInfoTests.get(), "layers", "Layers", enumerateDeviceLayers);
2705 addFunctionCase(deviceInfoTests.get(), "extensions", "Extensions", enumerateDeviceExtensions);
2707 infoTests->addChild(deviceInfoTests.release());
2710 infoTests->addChild(createTestGroup(testCtx, "format_properties", "VkGetPhysicalDeviceFormatProperties() Tests", createFormatTests));
2711 infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests", createImageFormatTests, imageFormatProperties));
2714 de::MovePtr<tcu::TestCaseGroup> extendedPropertiesTests (new tcu::TestCaseGroup(testCtx, "get_physical_device_properties2", "VK_KHR_get_physical_device_properties2"));
2716 addFunctionCase(extendedPropertiesTests.get(), "features", "Extended Device Features", deviceFeatures2);
2717 addFunctionCase(extendedPropertiesTests.get(), "properties", "Extended Device Properties", deviceProperties2);
2718 addFunctionCase(extendedPropertiesTests.get(), "format_properties", "Extended Device Format Properties", deviceFormatProperties2);
2719 addFunctionCase(extendedPropertiesTests.get(), "queue_family_properties", "Extended Device Queue Family Properties", deviceQueueFamilyProperties2);
2720 addFunctionCase(extendedPropertiesTests.get(), "memory_properties", "Extended Device Memory Properties", deviceMemoryProperties2);
2722 infoTests->addChild(extendedPropertiesTests.release());
2725 infoTests->addChild(createTestGroup(testCtx, "image_format_properties2", "VkGetPhysicalDeviceImageFormatProperties2KHR() Tests", createImageFormatTests, imageFormatProperties2));
2726 infoTests->addChild(createTestGroup(testCtx, "sparse_image_format_properties2", "VkGetPhysicalDeviceSparseImageFormatProperties2KHR() Tests", createImageFormatTests, sparseImageFormatProperties2));
2729 de::MovePtr<tcu::TestCaseGroup> androidTests (new tcu::TestCaseGroup(testCtx, "android", "Android CTS Tests"));
2731 addFunctionCase(androidTests.get(), "mandatory_extensions", "Test that all mandatory extensions are supported", android::testMandatoryExtensions);
2732 addFunctionCase(androidTests.get(), "no_unknown_extensions", "Test for unknown device or instance extensions", android::testNoUnknownExtensions);
2733 addFunctionCase(androidTests.get(), "no_layers", "Test that no layers are enumerated", android::testNoLayers);
2735 infoTests->addChild(androidTests.release());
2738 return infoTests.release();