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 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
100 bool limitsOk = true;
101 VkPhysicalDeviceLimits* limits = &properties->limits;
102 struct FeatureLimitTable
106 deUint32 uintVal; //!< Format is UNSIGNED_INT
107 deInt32 intVal; //!< Format is SIGNED_INT
108 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE
109 float floatVal; //!< Format is FLOAT
112 deInt32 unsuppTableNdx;
113 } featureLimitTable[] = //!< Based on 1.0.28 Vulkan spec
115 { LIMIT(maxImageDimension1D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
116 { LIMIT(maxImageDimension2D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
117 { LIMIT(maxImageDimension3D), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
118 { LIMIT(maxImageDimensionCube), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
119 { LIMIT(maxImageArrayLayers), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
120 { LIMIT(maxTexelBufferElements), 65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
121 { LIMIT(maxUniformBufferRange), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
122 { LIMIT(maxStorageBufferRange), 0, 0, 0, 0, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
123 { LIMIT(maxPushConstantsSize), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
124 { LIMIT(maxMemoryAllocationCount), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
125 { LIMIT(maxSamplerAllocationCount), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
126 { LIMIT(bufferImageGranularity), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
127 { LIMIT(bufferImageGranularity), 0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
128 { LIMIT(sparseAddressSpaceSize), 0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
129 { LIMIT(maxBoundDescriptorSets), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
130 { LIMIT(maxPerStageDescriptorSamplers), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
131 { LIMIT(maxPerStageDescriptorUniformBuffers), 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
132 { LIMIT(maxPerStageDescriptorStorageBuffers), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
133 { LIMIT(maxPerStageDescriptorSampledImages), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
134 { LIMIT(maxPerStageDescriptorStorageImages), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
135 { LIMIT(maxPerStageDescriptorInputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
136 { LIMIT(maxPerStageResources), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
137 { LIMIT(maxDescriptorSetSamplers), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
138 { LIMIT(maxDescriptorSetUniformBuffers), 72, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
139 { LIMIT(maxDescriptorSetUniformBuffersDynamic), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
140 { LIMIT(maxDescriptorSetStorageBuffers), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
141 { LIMIT(maxDescriptorSetStorageBuffersDynamic), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
142 { LIMIT(maxDescriptorSetSampledImages), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
143 { LIMIT(maxDescriptorSetStorageImages), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
144 { LIMIT(maxDescriptorSetInputAttachments), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
145 { LIMIT(maxVertexInputAttributes), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
146 { LIMIT(maxVertexInputBindings), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
147 { LIMIT(maxVertexInputAttributeOffset), 2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
148 { LIMIT(maxVertexInputBindingStride), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
149 { LIMIT(maxVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
150 { LIMIT(maxTessellationGenerationLevel), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
151 { LIMIT(maxTessellationPatchSize), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
152 { LIMIT(maxTessellationControlPerVertexInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
153 { LIMIT(maxTessellationControlPerVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
154 { LIMIT(maxTessellationControlPerPatchOutputComponents), 120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
155 { LIMIT(maxTessellationControlTotalOutputComponents), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
156 { LIMIT(maxTessellationEvaluationInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
157 { LIMIT(maxTessellationEvaluationOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
158 { LIMIT(maxGeometryShaderInvocations), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
159 { LIMIT(maxGeometryInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
160 { LIMIT(maxGeometryOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
161 { LIMIT(maxGeometryOutputVertices), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
162 { LIMIT(maxGeometryTotalOutputComponents), 1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
163 { LIMIT(maxFragmentInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
164 { LIMIT(maxFragmentOutputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
165 { LIMIT(maxFragmentDualSrcAttachments), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
166 { LIMIT(maxFragmentCombinedOutputResources), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
167 { LIMIT(maxComputeSharedMemorySize), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
168 { LIMIT(maxComputeWorkGroupCount[0]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
169 { LIMIT(maxComputeWorkGroupCount[1]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
170 { LIMIT(maxComputeWorkGroupCount[2]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
171 { LIMIT(maxComputeWorkGroupInvocations), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
172 { LIMIT(maxComputeWorkGroupSize[0]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
173 { LIMIT(maxComputeWorkGroupSize[1]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
174 { LIMIT(maxComputeWorkGroupSize[2]), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
175 { LIMIT(subPixelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
176 { LIMIT(subTexelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
177 { LIMIT(mipmapPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
178 { LIMIT(maxDrawIndexedIndexValue), (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
179 { LIMIT(maxDrawIndirectCount), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
180 { LIMIT(maxSamplerLodBias), 0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
181 { LIMIT(maxSamplerAnisotropy), 0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
182 { LIMIT(maxViewports), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
183 { LIMIT(maxViewportDimensions[0]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
184 { LIMIT(maxViewportDimensions[1]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
185 { LIMIT(viewportBoundsRange[0]), 0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
186 { LIMIT(viewportBoundsRange[1]), 0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
187 { LIMIT(viewportSubPixelBits), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
188 { LIMIT(minMemoryMapAlignment), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
189 { LIMIT(minTexelBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
190 { LIMIT(minTexelBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
191 { LIMIT(minUniformBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
192 { LIMIT(minUniformBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
193 { LIMIT(minStorageBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
194 { LIMIT(minStorageBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
195 { LIMIT(minTexelOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
196 { LIMIT(maxTexelOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
197 { LIMIT(minTexelGatherOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
198 { LIMIT(maxTexelGatherOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
199 { LIMIT(minInterpolationOffset), 0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
200 { LIMIT(maxInterpolationOffset), 0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
201 { LIMIT(subPixelInterpolationOffsetBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
202 { LIMIT(maxFramebufferWidth), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
203 { LIMIT(maxFramebufferHeight), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
204 { LIMIT(maxFramebufferLayers), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
205 { LIMIT(framebufferColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
206 { LIMIT(framebufferDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
207 { LIMIT(framebufferStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
208 { LIMIT(framebufferNoAttachmentsSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
209 { LIMIT(maxColorAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
210 { LIMIT(sampledImageColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
211 { LIMIT(sampledImageIntegerSampleCounts), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
212 { LIMIT(sampledImageDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
213 { LIMIT(sampledImageStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
214 { LIMIT(storageImageSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
215 { LIMIT(maxSampleMaskWords), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
216 { LIMIT(timestampComputeAndGraphics), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
217 { LIMIT(timestampPeriod), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
218 { LIMIT(maxClipDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
219 { LIMIT(maxCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
220 { LIMIT(maxCombinedClipAndCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
221 { LIMIT(discreteQueuePriorities), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
222 { LIMIT(pointSizeRange[0]), 0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
223 { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
224 { LIMIT(pointSizeRange[1]), 0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
225 { LIMIT(lineWidthRange[0]), 0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
226 { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
227 { LIMIT(lineWidthRange[1]), 0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
228 { LIMIT(pointSizeGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
229 { LIMIT(lineWidthGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
230 { LIMIT(strictLines), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
231 { LIMIT(standardSampleLocations), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
232 { LIMIT(optimalBufferCopyOffsetAlignment), 0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
233 { LIMIT(optimalBufferCopyRowPitchAlignment), 0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
234 { LIMIT(nonCoherentAtomSize), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
235 { LIMIT(nonCoherentAtomSize), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
238 const struct UnsupportedFeatureLimitTable
240 deUint32 limitOffset;
242 deUint32 featureOffset;
243 deUint32 uintVal; //!< Format is UNSIGNED_INT
244 deInt32 intVal; //!< Format is SIGNED_INT
245 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE
246 float floatVal; //!< Format is FLOAT
247 } unsupportedFeatureTable[] =
249 { LIMIT(sparseAddressSpaceSize), FEATURE(sparseBinding), 0, 0, 0, 0.0f },
250 { LIMIT(maxTessellationGenerationLevel), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
251 { LIMIT(maxTessellationPatchSize), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
252 { LIMIT(maxTessellationControlPerVertexInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
253 { LIMIT(maxTessellationControlPerVertexOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
254 { LIMIT(maxTessellationControlPerPatchOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
255 { LIMIT(maxTessellationControlTotalOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
256 { LIMIT(maxTessellationEvaluationInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
257 { LIMIT(maxTessellationEvaluationOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
258 { LIMIT(maxGeometryShaderInvocations), FEATURE(geometryShader), 0, 0, 0, 0.0f },
259 { LIMIT(maxGeometryInputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
260 { LIMIT(maxGeometryOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
261 { LIMIT(maxGeometryOutputVertices), FEATURE(geometryShader), 0, 0, 0, 0.0f },
262 { LIMIT(maxGeometryTotalOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
263 { LIMIT(maxFragmentDualSrcAttachments), FEATURE(dualSrcBlend), 0, 0, 0, 0.0f },
264 { LIMIT(maxDrawIndexedIndexValue), FEATURE(fullDrawIndexUint32), (1<<24)-1, 0, 0, 0.0f },
265 { LIMIT(maxDrawIndirectCount), FEATURE(multiDrawIndirect), 1, 0, 0, 0.0f },
266 { LIMIT(maxSamplerAnisotropy), FEATURE(samplerAnisotropy), 1, 0, 0, 0.0f },
267 { LIMIT(maxViewports), FEATURE(multiViewport), 1, 0, 0, 0.0f },
268 { LIMIT(minTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f },
269 { LIMIT(maxTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f },
270 { LIMIT(minInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
271 { LIMIT(maxInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
272 { LIMIT(subPixelInterpolationOffsetBits), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
273 { LIMIT(storageImageSampleCounts), FEATURE(shaderStorageImageMultisample), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f },
274 { LIMIT(maxClipDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
275 { LIMIT(maxCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
276 { LIMIT(maxCombinedClipAndCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
277 { LIMIT(pointSizeRange[0]), FEATURE(largePoints), 0, 0, 0, 1.0f },
278 { LIMIT(pointSizeRange[1]), FEATURE(largePoints), 0, 0, 0, 1.0f },
279 { LIMIT(lineWidthRange[0]), FEATURE(wideLines), 0, 0, 0, 1.0f },
280 { LIMIT(lineWidthRange[1]), FEATURE(wideLines), 0, 0, 0, 1.0f },
281 { LIMIT(pointSizeGranularity), FEATURE(largePoints), 0, 0, 0, 0.0f },
282 { LIMIT(lineWidthGranularity), FEATURE(wideLines), 0, 0, 0, 0.0f }
285 log << TestLog::Message << *limits << TestLog::EndMessage;
287 //!< First build a map from limit to unsupported table index
288 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
290 for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++)
292 if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset)
294 featureLimitTable[ndx].unsuppTableNdx = unsuppNdx;
300 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
302 switch (featureLimitTable[ndx].format)
304 case LIMIT_FORMAT_UNSIGNED_INT:
306 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
307 if (featureLimitTable[ndx].unsuppTableNdx != -1)
309 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
310 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
313 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
316 if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
318 log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name
319 << " not valid-limit type MIN - actual is "
320 << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
324 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
326 if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
328 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
329 << " not valid-limit type MAX - actual is "
330 << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
337 case LIMIT_FORMAT_FLOAT:
339 float limitToCheck = featureLimitTable[ndx].floatVal;
340 if (featureLimitTable[ndx].unsuppTableNdx != -1)
342 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
343 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal;
346 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
348 if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
350 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
351 << " not valid-limit type MIN - actual is "
352 << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
356 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
358 if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
360 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
361 << " not valid-limit type MAX actual is "
362 << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
369 case LIMIT_FORMAT_SIGNED_INT:
371 deInt32 limitToCheck = featureLimitTable[ndx].intVal;
372 if (featureLimitTable[ndx].unsuppTableNdx != -1)
374 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
375 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal;
377 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
379 if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
381 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
382 << " not valid-limit type MIN actual is "
383 << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
387 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
389 if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
391 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
392 << " not valid-limit type MAX actual is "
393 << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
400 case LIMIT_FORMAT_DEVICE_SIZE:
402 deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal;
403 if (featureLimitTable[ndx].unsuppTableNdx != -1)
405 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
406 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal;
409 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
411 if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
413 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
414 << " not valid-limit type MIN actual is "
415 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
419 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
421 if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
423 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
424 << " not valid-limit type MAX actual is "
425 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
432 case LIMIT_FORMAT_BITMASK:
434 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
435 if (featureLimitTable[ndx].unsuppTableNdx != -1)
437 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
438 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
441 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
443 if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck)
445 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
446 << " not valid-limit type bitmask actual is "
447 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
460 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits->maxViewportDimensions); ndx++)
462 if (limits->maxImageDimension2D > limits->maxViewportDimensions[ndx])
464 log << TestLog::Message << "limit validation failed, maxImageDimension2D of " << limits->maxImageDimension2D
465 << "is larger than maxViewportDimension[" << ndx << "] of " << limits->maxViewportDimensions[ndx] << TestLog::EndMessage;
470 if (limits->viewportBoundsRange[0] > -2 * limits->maxViewportDimensions[0])
472 log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0]
473 << "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage;
477 if (limits->viewportBoundsRange[1] < 2 * limits->maxViewportDimensions[1] - 1)
479 log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1]
480 << "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage;
488 class CheckIncompleteResult
491 virtual ~CheckIncompleteResult (void) {}
492 virtual void getResult (Context& context, T* data) = 0;
494 void operator() (Context& context, tcu::ResultCollector& results, const std::size_t expectedCompleteSize)
496 if (expectedCompleteSize == 0)
499 vector<T> outputData (expectedCompleteSize);
500 const deUint32 usedSize = static_cast<deUint32>(expectedCompleteSize / 3);
502 ValidateQueryBits::fillBits(outputData.begin(), outputData.end()); // unused entries should have this pattern intact
504 m_result = VK_SUCCESS;
506 getResult(context, &outputData[0]); // update m_count and m_result
508 if (m_count != usedSize || m_result != VK_INCOMPLETE || !ValidateQueryBits::checkBits(outputData.begin() + m_count, outputData.end()))
509 results.fail("Query didn't return VK_INCOMPLETE");
517 struct CheckEnumeratePhysicalDevicesIncompleteResult : public CheckIncompleteResult<VkPhysicalDevice>
519 void getResult (Context& context, VkPhysicalDevice* data)
521 m_result = context.getInstanceInterface().enumeratePhysicalDevices(context.getInstance(), &m_count, data);
525 struct CheckEnumerateInstanceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
527 void getResult (Context& context, VkLayerProperties* data)
529 m_result = context.getPlatformInterface().enumerateInstanceLayerProperties(&m_count, data);
533 struct CheckEnumerateDeviceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
535 void getResult (Context& context, VkLayerProperties* data)
537 m_result = context.getInstanceInterface().enumerateDeviceLayerProperties(context.getPhysicalDevice(), &m_count, data);
541 struct CheckEnumerateInstanceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
543 CheckEnumerateInstanceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
545 void getResult (Context& context, VkExtensionProperties* data)
547 const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
548 m_result = context.getPlatformInterface().enumerateInstanceExtensionProperties(pLayerName, &m_count, data);
552 const std::string m_layerName;
555 struct CheckEnumerateDeviceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
557 CheckEnumerateDeviceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
559 void getResult (Context& context, VkExtensionProperties* data)
561 const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
562 m_result = context.getInstanceInterface().enumerateDeviceExtensionProperties(context.getPhysicalDevice(), pLayerName, &m_count, data);
566 const std::string m_layerName;
569 tcu::TestStatus enumeratePhysicalDevices (Context& context)
571 TestLog& log = context.getTestContext().getLog();
572 tcu::ResultCollector results (log);
573 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
575 log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
577 for (size_t ndx = 0; ndx < devices.size(); ndx++)
578 log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage;
580 CheckEnumeratePhysicalDevicesIncompleteResult()(context, results, devices.size());
582 return tcu::TestStatus(results.getResult(), results.getMessage());
586 void collectDuplicates (set<T>& duplicates, const vector<T>& values)
590 for (size_t ndx = 0; ndx < values.size(); ndx++)
592 const T& value = values[ndx];
594 if (!seen.insert(value).second)
595 duplicates.insert(value);
599 void checkDuplicates (tcu::ResultCollector& results, const char* what, const vector<string>& values)
601 set<string> duplicates;
603 collectDuplicates(duplicates, values);
605 for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter)
607 std::ostringstream msg;
608 msg << "Duplicate " << what << ": " << *iter;
609 results.fail(msg.str());
613 void checkDuplicateExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
615 checkDuplicates(results, "extension", extensions);
618 void checkDuplicateLayers (tcu::ResultCollector& results, const vector<string>& layers)
620 checkDuplicates(results, "layer", layers);
623 void checkKhrExtensions (tcu::ResultCollector& results,
624 const vector<string>& extensions,
625 const int numAllowedKhrExtensions,
626 const char* const* allowedKhrExtensions)
628 const set<string> allowedExtSet (allowedKhrExtensions, allowedKhrExtensions+numAllowedKhrExtensions);
630 for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter)
632 // Only Khronos-controlled extensions are checked
633 if ((de::beginsWith(*extIter, "VK_KHR_") || de::beginsWith(*extIter, "VK_KHX_")) &&
634 !de::contains(allowedExtSet, *extIter))
636 results.fail("Unknown KHR extension " + *extIter);
641 void checkInstanceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
643 static const char* s_allowedInstanceKhrExtensions[] =
647 "VK_KHR_android_surface",
648 "VK_KHR_mir_surface",
649 "VK_KHR_wayland_surface",
650 "VK_KHR_win32_surface",
651 "VK_KHR_xcb_surface",
652 "VK_KHR_xlib_surface",
655 checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
656 checkDuplicateExtensions(results, extensions);
659 void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
661 static const char* s_allowedInstanceKhrExtensions[] =
664 "VK_KHR_display_swapchain",
665 "VK_KHR_sampler_mirror_clamp_to_edge"
668 checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
669 checkDuplicateExtensions(results, extensions);
672 tcu::TestStatus enumerateInstanceLayers (Context& context)
674 TestLog& log = context.getTestContext().getLog();
675 tcu::ResultCollector results (log);
676 const vector<VkLayerProperties> properties = enumerateInstanceLayerProperties(context.getPlatformInterface());
677 vector<string> layerNames;
679 for (size_t ndx = 0; ndx < properties.size(); ndx++)
681 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
683 layerNames.push_back(properties[ndx].layerName);
686 checkDuplicateLayers(results, layerNames);
687 CheckEnumerateInstanceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
689 return tcu::TestStatus(results.getResult(), results.getMessage());
692 tcu::TestStatus enumerateInstanceExtensions (Context& context)
694 TestLog& log = context.getTestContext().getLog();
695 tcu::ResultCollector results (log);
698 const ScopedLogSection section (log, "Global", "Global Extensions");
699 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
700 vector<string> extensionNames;
702 for (size_t ndx = 0; ndx < properties.size(); ndx++)
704 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
706 extensionNames.push_back(properties[ndx].extensionName);
709 checkInstanceExtensions(results, extensionNames);
710 CheckEnumerateInstanceExtensionPropertiesIncompleteResult()(context, results, properties.size());
714 const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface());
716 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
718 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName);
719 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
720 vector<string> extensionNames;
722 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
724 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
726 extensionNames.push_back(properties[extNdx].extensionName);
729 checkInstanceExtensions(results, extensionNames);
730 CheckEnumerateInstanceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
734 return tcu::TestStatus(results.getResult(), results.getMessage());
737 tcu::TestStatus enumerateDeviceLayers (Context& context)
739 TestLog& log = context.getTestContext().getLog();
740 tcu::ResultCollector results (log);
741 const vector<VkLayerProperties> properties = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
742 vector<string> layerNames;
744 for (size_t ndx = 0; ndx < properties.size(); ndx++)
746 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
748 layerNames.push_back(properties[ndx].layerName);
751 checkDuplicateLayers(results, layerNames);
752 CheckEnumerateDeviceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
754 return tcu::TestStatus(results.getResult(), results.getMessage());
757 tcu::TestStatus enumerateDeviceExtensions (Context& context)
759 TestLog& log = context.getTestContext().getLog();
760 tcu::ResultCollector results (log);
763 const ScopedLogSection section (log, "Global", "Global Extensions");
764 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
765 vector<string> extensionNames;
767 for (size_t ndx = 0; ndx < properties.size(); ndx++)
769 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
771 extensionNames.push_back(properties[ndx].extensionName);
774 checkDeviceExtensions(results, extensionNames);
775 CheckEnumerateDeviceExtensionPropertiesIncompleteResult()(context, results, properties.size());
779 const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
781 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
783 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName);
784 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
785 vector<string> extensionNames;
787 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
789 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
792 extensionNames.push_back(properties[extNdx].extensionName);
795 checkDeviceExtensions(results, extensionNames);
796 CheckEnumerateDeviceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
800 return tcu::TestStatus(results.getResult(), results.getMessage());
803 #define VK_SIZE_OF(STRUCT, MEMBER) (sizeof(((STRUCT*)0)->MEMBER))
804 #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER) { (size_t)DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) }
806 tcu::TestStatus deviceFeatures (Context& context)
808 using namespace ValidateQueryBits;
810 TestLog& log = context.getTestContext().getLog();
811 VkPhysicalDeviceFeatures* features;
812 deUint8 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE];
814 const QueryMemberTableEntry featureOffsetTable[] =
816 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess),
817 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32),
818 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray),
819 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend),
820 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader),
821 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader),
822 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading),
823 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend),
824 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp),
825 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect),
826 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance),
827 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp),
828 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp),
829 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid),
830 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds),
831 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines),
832 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints),
833 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne),
834 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport),
835 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy),
836 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2),
837 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR),
838 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC),
839 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise),
840 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery),
841 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics),
842 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics),
843 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize),
844 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended),
845 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats),
846 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample),
847 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat),
848 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat),
849 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing),
850 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing),
851 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing),
852 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing),
853 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance),
854 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance),
855 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64),
856 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64),
857 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16),
858 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency),
859 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod),
860 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding),
861 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer),
862 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D),
863 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D),
864 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples),
865 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples),
866 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples),
867 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples),
868 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased),
869 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate),
870 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries),
874 deMemset(buffer, GUARD_VALUE, sizeof(buffer));
875 features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer);
877 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features);
879 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
880 << TestLog::Message << *features << TestLog::EndMessage;
882 // Requirements and dependencies
884 if (!features->robustBufferAccess)
885 return tcu::TestStatus::fail("robustBufferAccess is not supported");
887 // multiViewport requires MultiViewport (SPIR-V capability) support, which depends on Geometry
888 if (features->multiViewport && !features->geometryShader)
889 return tcu::TestStatus::fail("multiViewport is supported but geometryShader is not");
892 for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
894 if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE)
896 log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
897 return tcu::TestStatus::fail("deviceFeatures buffer overflow");
901 if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable))
903 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage;
904 return tcu::TestStatus::fail("deviceFeatures incomplete initialization");
907 return tcu::TestStatus::pass("Query succeeded");
910 tcu::TestStatus deviceProperties (Context& context)
912 using namespace ValidateQueryBits;
914 TestLog& log = context.getTestContext().getLog();
915 VkPhysicalDeviceProperties* props;
916 VkPhysicalDeviceFeatures features;
917 deUint8 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE];
919 const QueryMemberTableEntry physicalDevicePropertiesOffsetTable[] =
921 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion),
922 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion),
923 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID),
924 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID),
925 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType),
926 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID),
927 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D),
928 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D),
929 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D),
930 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube),
931 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers),
932 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements),
933 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange),
934 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange),
935 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize),
936 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount),
937 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount),
938 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity),
939 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize),
940 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets),
941 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers),
942 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers),
943 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers),
944 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages),
945 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages),
946 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments),
947 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources),
948 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers),
949 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers),
950 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic),
951 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers),
952 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic),
953 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages),
954 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages),
955 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments),
956 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes),
957 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings),
958 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset),
959 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride),
960 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents),
961 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel),
962 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize),
963 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents),
964 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents),
965 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents),
966 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents),
967 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents),
968 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents),
969 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations),
970 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents),
971 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents),
972 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices),
973 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents),
974 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents),
975 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments),
976 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments),
977 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources),
978 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize),
979 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]),
980 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations),
981 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]),
982 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits),
983 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits),
984 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits),
985 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue),
986 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount),
987 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias),
988 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy),
989 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports),
990 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]),
991 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]),
992 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits),
993 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment),
994 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment),
995 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment),
996 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment),
997 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset),
998 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset),
999 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset),
1000 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset),
1001 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset),
1002 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset),
1003 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits),
1004 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth),
1005 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight),
1006 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers),
1007 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts),
1008 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts),
1009 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts),
1010 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts),
1011 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments),
1012 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts),
1013 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts),
1014 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts),
1015 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts),
1016 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts),
1017 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords),
1018 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics),
1019 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod),
1020 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances),
1021 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances),
1022 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances),
1023 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities),
1024 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]),
1025 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]),
1026 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity),
1027 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity),
1028 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines),
1029 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations),
1030 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment),
1031 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment),
1032 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize),
1033 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape),
1034 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape),
1035 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape),
1036 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize),
1037 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict),
1041 props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer);
1042 deMemset(props, GUARD_VALUE, sizeof(buffer));
1044 context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props);
1045 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features);
1047 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
1048 << TestLog::Message << *props << TestLog::EndMessage;
1050 if (!validateFeatureLimits(props, &features, log))
1051 return tcu::TestStatus::fail("deviceProperties - feature limits failed");
1053 for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
1055 if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE)
1057 log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
1058 return tcu::TestStatus::fail("deviceProperties buffer overflow");
1062 if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), physicalDevicePropertiesOffsetTable))
1064 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage;
1065 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
1068 // Check if deviceName string is properly terminated.
1069 if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE)
1071 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage;
1072 return tcu::TestStatus::fail("deviceProperties incomplete initialization");
1076 const ApiVersion deviceVersion = unpackVersion(props->apiVersion);
1077 const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION);
1079 if (deviceVersion.majorNum != deqpVersion.majorNum)
1081 log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage;
1082 return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
1085 if (deviceVersion.minorNum > deqpVersion.minorNum)
1087 log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage;
1088 return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
1092 return tcu::TestStatus::pass("DeviceProperites query succeeded");
1095 tcu::TestStatus deviceQueueFamilyProperties (Context& context)
1097 TestLog& log = context.getTestContext().getLog();
1098 const vector<VkQueueFamilyProperties> queueProperties = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
1100 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage;
1102 for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++)
1103 log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage;
1105 return tcu::TestStatus::pass("Querying queue properties succeeded");
1108 tcu::TestStatus deviceMemoryProperties (Context& context)
1110 TestLog& log = context.getTestContext().getLog();
1111 VkPhysicalDeviceMemoryProperties* memProps;
1112 deUint8 buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE];
1114 memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer);
1115 deMemset(buffer, GUARD_VALUE, sizeof(buffer));
1117 context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps);
1119 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
1120 << TestLog::Message << *memProps << TestLog::EndMessage;
1122 for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
1124 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE)
1126 log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
1127 return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow");
1131 if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS)
1133 log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage;
1134 return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large");
1137 if (memProps->memoryHeapCount == 1)
1139 if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
1141 log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage;
1142 return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags");
1146 const VkMemoryPropertyFlags validPropertyFlags[] =
1149 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
1150 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1151 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
1152 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1153 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1154 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
1155 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
1156 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
1159 const VkMemoryPropertyFlags requiredPropertyFlags[] =
1161 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
1164 bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)];
1165 std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
1167 for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++)
1169 bool validPropTypeFound = false;
1171 if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount)
1173 log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage;
1174 return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex");
1177 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;
1179 for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++)
1180 if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator)
1181 requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true;
1183 if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck))
1184 validPropTypeFound = true;
1186 if (!validPropTypeFound)
1188 log << TestLog::Message << "deviceMemoryProperties - propertyFlags "
1189 << memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage;
1190 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
1193 if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
1195 if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
1197 log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage;
1198 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
1203 if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1205 log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage;
1206 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
1211 bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
1212 if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound))
1214 DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags));
1215 log << TestLog::Message << "deviceMemoryProperties - required property flags "
1216 << getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage;
1218 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
1221 return tcu::TestStatus::pass("Querying memory properties succeeded");
1224 // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead
1226 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format)
1228 static const VkFormat s_requiredSampledImageBlitSrcFormats[] =
1230 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1231 VK_FORMAT_R5G6B5_UNORM_PACK16,
1232 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1237 VK_FORMAT_R8G8_UNORM,
1238 VK_FORMAT_R8G8_SNORM,
1239 VK_FORMAT_R8G8_UINT,
1240 VK_FORMAT_R8G8_SINT,
1241 VK_FORMAT_R8G8B8A8_UNORM,
1242 VK_FORMAT_R8G8B8A8_SNORM,
1243 VK_FORMAT_R8G8B8A8_UINT,
1244 VK_FORMAT_R8G8B8A8_SINT,
1245 VK_FORMAT_R8G8B8A8_SRGB,
1246 VK_FORMAT_B8G8R8A8_UNORM,
1247 VK_FORMAT_B8G8R8A8_SRGB,
1248 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1249 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1250 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1251 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1252 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1253 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1254 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1257 VK_FORMAT_R16_SFLOAT,
1258 VK_FORMAT_R16G16_UINT,
1259 VK_FORMAT_R16G16_SINT,
1260 VK_FORMAT_R16G16_SFLOAT,
1261 VK_FORMAT_R16G16B16A16_UINT,
1262 VK_FORMAT_R16G16B16A16_SINT,
1263 VK_FORMAT_R16G16B16A16_SFLOAT,
1266 VK_FORMAT_R32_SFLOAT,
1267 VK_FORMAT_R32G32_UINT,
1268 VK_FORMAT_R32G32_SINT,
1269 VK_FORMAT_R32G32_SFLOAT,
1270 VK_FORMAT_R32G32B32A32_UINT,
1271 VK_FORMAT_R32G32B32A32_SINT,
1272 VK_FORMAT_R32G32B32A32_SFLOAT,
1273 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1274 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1275 VK_FORMAT_D16_UNORM,
1276 VK_FORMAT_D32_SFLOAT
1278 static const VkFormat s_requiredSampledImageFilterLinearFormats[] =
1280 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
1281 VK_FORMAT_R5G6B5_UNORM_PACK16,
1282 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1285 VK_FORMAT_R8G8_UNORM,
1286 VK_FORMAT_R8G8_SNORM,
1287 VK_FORMAT_R8G8B8A8_UNORM,
1288 VK_FORMAT_R8G8B8A8_SNORM,
1289 VK_FORMAT_R8G8B8A8_SRGB,
1290 VK_FORMAT_B8G8R8A8_UNORM,
1291 VK_FORMAT_B8G8R8A8_SRGB,
1292 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1293 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1294 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1295 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1296 VK_FORMAT_R16_SFLOAT,
1297 VK_FORMAT_R16G16_SFLOAT,
1298 VK_FORMAT_R16G16B16A16_SFLOAT,
1299 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
1300 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
1302 static const VkFormat s_requiredStorageImageFormats[] =
1304 VK_FORMAT_R8G8B8A8_UNORM,
1305 VK_FORMAT_R8G8B8A8_SNORM,
1306 VK_FORMAT_R8G8B8A8_UINT,
1307 VK_FORMAT_R8G8B8A8_SINT,
1308 VK_FORMAT_R16G16B16A16_UINT,
1309 VK_FORMAT_R16G16B16A16_SINT,
1310 VK_FORMAT_R16G16B16A16_SFLOAT,
1313 VK_FORMAT_R32_SFLOAT,
1314 VK_FORMAT_R32G32_UINT,
1315 VK_FORMAT_R32G32_SINT,
1316 VK_FORMAT_R32G32_SFLOAT,
1317 VK_FORMAT_R32G32B32A32_UINT,
1318 VK_FORMAT_R32G32B32A32_SINT,
1319 VK_FORMAT_R32G32B32A32_SFLOAT
1321 static const VkFormat s_requiredStorageImageAtomicFormats[] =
1326 static const VkFormat s_requiredColorAttachmentBlitDstFormats[] =
1328 VK_FORMAT_R5G6B5_UNORM_PACK16,
1329 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1333 VK_FORMAT_R8G8_UNORM,
1334 VK_FORMAT_R8G8_UINT,
1335 VK_FORMAT_R8G8_SINT,
1336 VK_FORMAT_R8G8B8A8_UNORM,
1337 VK_FORMAT_R8G8B8A8_UINT,
1338 VK_FORMAT_R8G8B8A8_SINT,
1339 VK_FORMAT_R8G8B8A8_SRGB,
1340 VK_FORMAT_B8G8R8A8_UNORM,
1341 VK_FORMAT_B8G8R8A8_SRGB,
1342 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1343 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1344 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1345 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1346 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1347 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1350 VK_FORMAT_R16_SFLOAT,
1351 VK_FORMAT_R16G16_UINT,
1352 VK_FORMAT_R16G16_SINT,
1353 VK_FORMAT_R16G16_SFLOAT,
1354 VK_FORMAT_R16G16B16A16_UINT,
1355 VK_FORMAT_R16G16B16A16_SINT,
1356 VK_FORMAT_R16G16B16A16_SFLOAT,
1359 VK_FORMAT_R32_SFLOAT,
1360 VK_FORMAT_R32G32_UINT,
1361 VK_FORMAT_R32G32_SINT,
1362 VK_FORMAT_R32G32_SFLOAT,
1363 VK_FORMAT_R32G32B32A32_UINT,
1364 VK_FORMAT_R32G32B32A32_SINT,
1365 VK_FORMAT_R32G32B32A32_SFLOAT
1367 static const VkFormat s_requiredColorAttachmentBlendFormats[] =
1369 VK_FORMAT_R5G6B5_UNORM_PACK16,
1370 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
1372 VK_FORMAT_R8G8_UNORM,
1373 VK_FORMAT_R8G8B8A8_UNORM,
1374 VK_FORMAT_R8G8B8A8_SRGB,
1375 VK_FORMAT_B8G8R8A8_UNORM,
1376 VK_FORMAT_B8G8R8A8_SRGB,
1377 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1378 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
1379 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1380 VK_FORMAT_R16_SFLOAT,
1381 VK_FORMAT_R16G16_SFLOAT,
1382 VK_FORMAT_R16G16B16A16_SFLOAT
1384 static const VkFormat s_requiredDepthStencilAttachmentFormats[] =
1389 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0;
1391 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format))
1392 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT;
1394 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterLinearFormats), DE_ARRAY_END(s_requiredSampledImageFilterLinearFormats), format))
1395 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
1397 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format))
1398 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
1400 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format))
1401 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
1403 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format))
1404 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT;
1406 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format))
1407 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
1409 if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format))
1410 flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
1415 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format)
1417 static const VkFormat s_requiredVertexBufferFormats[] =
1423 VK_FORMAT_R8G8_UNORM,
1424 VK_FORMAT_R8G8_SNORM,
1425 VK_FORMAT_R8G8_UINT,
1426 VK_FORMAT_R8G8_SINT,
1427 VK_FORMAT_R8G8B8A8_UNORM,
1428 VK_FORMAT_R8G8B8A8_SNORM,
1429 VK_FORMAT_R8G8B8A8_UINT,
1430 VK_FORMAT_R8G8B8A8_SINT,
1431 VK_FORMAT_B8G8R8A8_UNORM,
1432 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1433 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1434 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1435 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1436 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1437 VK_FORMAT_R16_UNORM,
1438 VK_FORMAT_R16_SNORM,
1441 VK_FORMAT_R16_SFLOAT,
1442 VK_FORMAT_R16G16_UNORM,
1443 VK_FORMAT_R16G16_SNORM,
1444 VK_FORMAT_R16G16_UINT,
1445 VK_FORMAT_R16G16_SINT,
1446 VK_FORMAT_R16G16_SFLOAT,
1447 VK_FORMAT_R16G16B16A16_UNORM,
1448 VK_FORMAT_R16G16B16A16_SNORM,
1449 VK_FORMAT_R16G16B16A16_UINT,
1450 VK_FORMAT_R16G16B16A16_SINT,
1451 VK_FORMAT_R16G16B16A16_SFLOAT,
1454 VK_FORMAT_R32_SFLOAT,
1455 VK_FORMAT_R32G32_UINT,
1456 VK_FORMAT_R32G32_SINT,
1457 VK_FORMAT_R32G32_SFLOAT,
1458 VK_FORMAT_R32G32B32_UINT,
1459 VK_FORMAT_R32G32B32_SINT,
1460 VK_FORMAT_R32G32B32_SFLOAT,
1461 VK_FORMAT_R32G32B32A32_UINT,
1462 VK_FORMAT_R32G32B32A32_SINT,
1463 VK_FORMAT_R32G32B32A32_SFLOAT
1465 static const VkFormat s_requiredUniformTexelBufferFormats[] =
1471 VK_FORMAT_R8G8_UNORM,
1472 VK_FORMAT_R8G8_SNORM,
1473 VK_FORMAT_R8G8_UINT,
1474 VK_FORMAT_R8G8_SINT,
1475 VK_FORMAT_R8G8B8A8_UNORM,
1476 VK_FORMAT_R8G8B8A8_SNORM,
1477 VK_FORMAT_R8G8B8A8_UINT,
1478 VK_FORMAT_R8G8B8A8_SINT,
1479 VK_FORMAT_B8G8R8A8_UNORM,
1480 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1481 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1482 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1483 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1484 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
1485 VK_FORMAT_A2B10G10R10_UINT_PACK32,
1488 VK_FORMAT_R16_SFLOAT,
1489 VK_FORMAT_R16G16_UINT,
1490 VK_FORMAT_R16G16_SINT,
1491 VK_FORMAT_R16G16_SFLOAT,
1492 VK_FORMAT_R16G16B16A16_UINT,
1493 VK_FORMAT_R16G16B16A16_SINT,
1494 VK_FORMAT_R16G16B16A16_SFLOAT,
1497 VK_FORMAT_R32_SFLOAT,
1498 VK_FORMAT_R32G32_UINT,
1499 VK_FORMAT_R32G32_SINT,
1500 VK_FORMAT_R32G32_SFLOAT,
1501 VK_FORMAT_R32G32B32A32_UINT,
1502 VK_FORMAT_R32G32B32A32_SINT,
1503 VK_FORMAT_R32G32B32A32_SFLOAT,
1504 VK_FORMAT_B10G11R11_UFLOAT_PACK32
1506 static const VkFormat s_requiredStorageTexelBufferFormats[] =
1508 VK_FORMAT_R8G8B8A8_UNORM,
1509 VK_FORMAT_R8G8B8A8_SNORM,
1510 VK_FORMAT_R8G8B8A8_UINT,
1511 VK_FORMAT_R8G8B8A8_SINT,
1512 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
1513 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
1514 VK_FORMAT_A8B8G8R8_UINT_PACK32,
1515 VK_FORMAT_A8B8G8R8_SINT_PACK32,
1516 VK_FORMAT_R16G16B16A16_UINT,
1517 VK_FORMAT_R16G16B16A16_SINT,
1518 VK_FORMAT_R16G16B16A16_SFLOAT,
1521 VK_FORMAT_R32_SFLOAT,
1522 VK_FORMAT_R32G32_UINT,
1523 VK_FORMAT_R32G32_SINT,
1524 VK_FORMAT_R32G32_SFLOAT,
1525 VK_FORMAT_R32G32B32A32_UINT,
1526 VK_FORMAT_R32G32B32A32_SINT,
1527 VK_FORMAT_R32G32B32A32_SFLOAT
1529 static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] =
1535 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0;
1537 if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format))
1538 flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
1540 if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format))
1541 flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
1543 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format))
1544 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
1546 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format))
1547 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
1552 tcu::TestStatus formatProperties (Context& context, VkFormat format)
1554 TestLog& log = context.getTestContext().getLog();
1555 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1560 VkFormatFeatureFlags VkFormatProperties::* field;
1561 const char* fieldName;
1562 VkFormatFeatureFlags requiredFeatures;
1565 { &VkFormatProperties::linearTilingFeatures, "linearTilingFeatures", (VkFormatFeatureFlags)0 },
1566 { &VkFormatProperties::optimalTilingFeatures, "optimalTilingFeatures", getRequiredOptimalTilingFeatures(format) },
1567 { &VkFormatProperties::bufferFeatures, "buffeFeatures", getRequiredBufferFeatures(format) }
1570 log << TestLog::Message << properties << TestLog::EndMessage;
1572 for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
1574 const char* const fieldName = fields[fieldNdx].fieldName;
1575 const VkFormatFeatureFlags supported = properties.*fields[fieldNdx].field;
1576 const VkFormatFeatureFlags required = fields[fieldNdx].requiredFeatures;
1578 if ((supported & required) != required)
1580 log << TestLog::Message << "ERROR in " << fieldName << ":\n"
1581 << " required: " << getFormatFeatureFlagsStr(required) << "\n "
1582 << " missing: " << getFormatFeatureFlagsStr(~supported & required)
1583 << TestLog::EndMessage;
1589 return tcu::TestStatus::pass("Query and validation passed");
1591 return tcu::TestStatus::fail("Required features not supported");
1594 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features)
1596 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1598 return (properties.optimalTilingFeatures & features) == features;
1601 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features)
1603 for (const VkFormat* cur = begin; cur != end; ++cur)
1605 if (!optimalTilingFeaturesSupported(context, *cur, features))
1612 tcu::TestStatus testDepthStencilSupported (Context& context)
1614 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
1615 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
1616 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT");
1618 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
1619 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
1620 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT");
1622 return tcu::TestStatus::pass("Required depth/stencil formats supported");
1625 tcu::TestStatus testCompressedFormatsSupported (Context& context)
1627 static const VkFormat s_allBcFormats[] =
1629 VK_FORMAT_BC1_RGB_UNORM_BLOCK,
1630 VK_FORMAT_BC1_RGB_SRGB_BLOCK,
1631 VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
1632 VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
1633 VK_FORMAT_BC2_UNORM_BLOCK,
1634 VK_FORMAT_BC2_SRGB_BLOCK,
1635 VK_FORMAT_BC3_UNORM_BLOCK,
1636 VK_FORMAT_BC3_SRGB_BLOCK,
1637 VK_FORMAT_BC4_UNORM_BLOCK,
1638 VK_FORMAT_BC4_SNORM_BLOCK,
1639 VK_FORMAT_BC5_UNORM_BLOCK,
1640 VK_FORMAT_BC5_SNORM_BLOCK,
1641 VK_FORMAT_BC6H_UFLOAT_BLOCK,
1642 VK_FORMAT_BC6H_SFLOAT_BLOCK,
1643 VK_FORMAT_BC7_UNORM_BLOCK,
1644 VK_FORMAT_BC7_SRGB_BLOCK,
1646 static const VkFormat s_allEtc2Formats[] =
1648 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1649 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1650 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1651 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1652 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1653 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1654 VK_FORMAT_EAC_R11_UNORM_BLOCK,
1655 VK_FORMAT_EAC_R11_SNORM_BLOCK,
1656 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1657 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1659 static const VkFormat s_allAstcLdrFormats[] =
1661 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1662 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1663 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1664 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1665 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1666 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1667 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1668 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1669 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1670 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1671 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1672 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1673 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1674 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1675 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1676 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1677 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1678 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1679 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1680 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1681 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1682 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1683 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1684 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1685 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1686 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1687 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1688 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
1693 const char* setName;
1694 const char* featureName;
1695 const VkBool32 VkPhysicalDeviceFeatures::* feature;
1696 const VkFormat* formatsBegin;
1697 const VkFormat* formatsEnd;
1698 } s_compressedFormatSets[] =
1700 { "BC", "textureCompressionBC", &VkPhysicalDeviceFeatures::textureCompressionBC, DE_ARRAY_BEGIN(s_allBcFormats), DE_ARRAY_END(s_allBcFormats) },
1701 { "ETC2", "textureCompressionETC2", &VkPhysicalDeviceFeatures::textureCompressionETC2, DE_ARRAY_BEGIN(s_allEtc2Formats), DE_ARRAY_END(s_allEtc2Formats) },
1702 { "ASTC LDR", "textureCompressionASTC_LDR", &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR, DE_ARRAY_BEGIN(s_allAstcLdrFormats), DE_ARRAY_END(s_allAstcLdrFormats) },
1705 TestLog& log = context.getTestContext().getLog();
1706 const VkPhysicalDeviceFeatures& features = context.getDeviceFeatures();
1707 int numSupportedSets = 0;
1709 int numWarnings = 0;
1711 for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx)
1713 const char* const setName = s_compressedFormatSets[setNdx].setName;
1714 const char* const featureName = s_compressedFormatSets[setNdx].featureName;
1715 const bool featureBitSet = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE;
1716 const bool allSupported = optimalTilingFeaturesSupportedForAll(context,
1717 s_compressedFormatSets[setNdx].formatsBegin,
1718 s_compressedFormatSets[setNdx].formatsEnd,
1719 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
1721 if (featureBitSet && !allSupported)
1723 log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage;
1726 else if (allSupported && !featureBitSet)
1728 log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage;
1734 log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage;
1735 numSupportedSets += 1;
1738 log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage;
1741 if (numSupportedSets == 0)
1743 log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage;
1748 return tcu::TestStatus::fail("Compressed format support not valid");
1749 else if (numWarnings > 0)
1750 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support");
1752 return tcu::TestStatus::pass("Compressed texture format support is valid");
1755 void createFormatTests (tcu::TestCaseGroup* testGroup)
1757 DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0);
1759 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
1761 const VkFormat format = (VkFormat)formatNdx;
1762 const char* const enumName = getFormatName(format);
1763 const string caseName = de::toLower(string(enumName).substr(10));
1765 addFunctionCase(testGroup, caseName, enumName, formatProperties, format);
1768 addFunctionCase(testGroup, "depth_stencil", "", testDepthStencilSupported);
1769 addFunctionCase(testGroup, "compressed_formats", "", testCompressedFormatsSupported);
1772 VkImageUsageFlags getValidImageUsageFlags (VkFormat, VkFormatFeatureFlags supportedFeatures)
1774 VkImageUsageFlags flags = (VkImageUsageFlags)0;
1776 // If format is supported at all, it must be valid transfer src+dst
1777 if (supportedFeatures != 0)
1778 flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
1780 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
1781 flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
1783 if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0)
1784 flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1786 if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1787 flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1789 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
1790 flags |= VK_IMAGE_USAGE_STORAGE_BIT;
1795 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
1797 if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)
1799 const VkImageUsageFlags allowedFlags = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
1800 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
1801 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
1802 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1804 // Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT
1805 if ((usage & ~allowedFlags) != 0)
1808 // TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT
1809 if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
1816 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage)
1818 VkImageCreateFlags flags = (VkImageCreateFlags)0;
1820 if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1822 flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
1824 if (type == VK_IMAGE_TYPE_2D)
1825 flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
1828 if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 &&
1829 (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1831 if (deviceFeatures.sparseBinding)
1832 flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
1834 if (deviceFeatures.sparseResidencyAliased)
1835 flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
1841 bool isValidImageCreateFlagCombination (VkImageCreateFlags)
1846 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures& deviceFeatures,
1847 const VkFormat format,
1848 const VkFormatProperties& formatProperties,
1849 const VkImageType imageType,
1850 const VkImageTiling imageTiling,
1851 const VkImageUsageFlags usageFlags,
1852 const VkImageCreateFlags createFlags)
1854 DE_UNREF(deviceFeatures);
1855 DE_UNREF(formatProperties);
1856 DE_UNREF(createFlags);
1858 // Linear images can have arbitrary limitations
1859 if (imageTiling == VK_IMAGE_TILING_LINEAR)
1862 // Support for other usages for compressed formats is optional
1863 if (isCompressedFormat(format) &&
1864 (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0)
1867 // Support for 1D, and sliced 3D compressed formats is optional
1868 if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
1871 DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
1872 DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
1877 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits& deviceLimits,
1878 const VkFormat format,
1879 const VkImageUsageFlags usageFlags)
1881 if (!isCompressedFormat(format))
1883 const tcu::TextureFormat tcuFormat = mapVkFormat(format);
1884 const bool hasDepthComp = (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS);
1885 const bool hasStencilComp = (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS);
1886 const bool isColorFormat = !hasDepthComp && !hasStencilComp;
1887 VkSampleCountFlags sampleCounts = ~(VkSampleCountFlags)0;
1889 DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat);
1891 if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0)
1892 sampleCounts &= deviceLimits.storageImageSampleCounts;
1894 if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1897 sampleCounts &= deviceLimits.sampledImageDepthSampleCounts;
1900 sampleCounts &= deviceLimits.sampledImageStencilSampleCounts;
1904 const tcu::TextureChannelClass chnClass = tcu::getTextureChannelClass(tcuFormat.type);
1906 if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
1907 chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
1908 sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts;
1910 sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
1914 if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
1915 sampleCounts &= deviceLimits.framebufferColorSampleCounts;
1917 if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1920 sampleCounts &= deviceLimits.framebufferDepthSampleCounts;
1923 sampleCounts &= deviceLimits.framebufferStencilSampleCounts;
1926 // If there is no usage flag set that would have corresponding device limit,
1927 // only VK_SAMPLE_COUNT_1_BIT is required.
1928 if (sampleCounts == ~(VkSampleCountFlags)0)
1929 sampleCounts &= VK_SAMPLE_COUNT_1_BIT;
1931 return sampleCounts;
1934 return VK_SAMPLE_COUNT_1_BIT;
1937 struct ImageFormatPropertyCase
1940 VkImageType imageType;
1941 VkImageTiling tiling;
1943 ImageFormatPropertyCase (VkFormat format_, VkImageType imageType_, VkImageTiling tiling_)
1945 , imageType (imageType_)
1949 ImageFormatPropertyCase (void)
1950 : format (VK_FORMAT_UNDEFINED)
1951 , imageType (VK_IMAGE_TYPE_LAST)
1952 , tiling (VK_IMAGE_TILING_LAST)
1956 tcu::TestStatus imageFormatProperties (Context& context, ImageFormatPropertyCase params)
1958 TestLog& log = context.getTestContext().getLog();
1959 const VkFormat format = params.format;
1960 const VkImageType imageType = params.imageType;
1961 const VkImageTiling tiling = params.tiling;
1962 const VkPhysicalDeviceFeatures& deviceFeatures = context.getDeviceFeatures();
1963 const VkPhysicalDeviceLimits& deviceLimits = context.getDeviceProperties().limits;
1964 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1966 const VkFormatFeatureFlags supportedFeatures = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
1967 const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(format, supportedFeatures);
1969 tcu::ResultCollector results (log, "ERROR: ");
1971 for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
1973 if ((curUsageFlags & ~usageFlagSet) != 0 ||
1974 !isValidImageUsageFlagCombination(curUsageFlags))
1977 const VkImageCreateFlags createFlagSet = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags);
1979 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++)
1981 if ((curCreateFlags & ~createFlagSet) != 0 ||
1982 !isValidImageCreateFlagCombination(curCreateFlags))
1985 const bool isRequiredCombination = isRequiredImageParameterCombination(deviceFeatures,
1992 VkImageFormatProperties properties;
1993 VkResult queryResult;
1995 log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", "
1996 << getImageTilingStr(tiling) << ", "
1997 << getImageUsageFlagsStr(curUsageFlags) << ", "
1998 << getImageCreateFlagsStr(curCreateFlags)
1999 << TestLog::EndMessage;
2001 // Set return value to known garbage
2002 deMemset(&properties, 0xcd, sizeof(properties));
2004 queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(),
2012 if (queryResult == VK_SUCCESS)
2014 const deUint32 fullMipPyramidSize = de::max(de::max(deLog2Ceil32(properties.maxExtent.width),
2015 deLog2Ceil32(properties.maxExtent.height)),
2016 deLog2Ceil32(properties.maxExtent.depth)) + 1;
2018 log << TestLog::Message << properties << "\n" << TestLog::EndMessage;
2020 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image");
2021 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image");
2022 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image");
2023 results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image");
2025 if (tiling == VK_IMAGE_TILING_OPTIMAL)
2027 // Vulkan API specification has changed since initial Android Nougat release.
2028 // For NYC CTS we need to tolerate old behavior as well and issue compatibility
2031 // See spec issues 272, 282, 302, 445 and CTS issues 369, 440.
2032 const bool requiredByNewSpec = (imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
2033 ((supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) ||
2034 ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) && deviceFeatures.shaderStorageImageMultisample)));
2036 if (requiredByNewSpec)
2038 const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
2040 results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
2042 else if (properties.sampleCounts != VK_SAMPLE_COUNT_1_BIT)
2044 results.addResult(QP_TEST_RESULT_COMPATIBILITY_WARNING,
2045 "Implementation supports more sample counts than allowed by the spec");
2049 results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT");
2051 if (isRequiredCombination)
2053 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= deviceLimits.maxImageDimension1D),
2054 "Reported dimensions smaller than device limits");
2055 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= deviceLimits.maxImageDimension2D &&
2056 properties.maxExtent.height >= deviceLimits.maxImageDimension2D),
2057 "Reported dimensions smaller than device limits");
2058 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= deviceLimits.maxImageDimension3D &&
2059 properties.maxExtent.height >= deviceLimits.maxImageDimension3D &&
2060 properties.maxExtent.depth >= deviceLimits.maxImageDimension3D),
2061 "Reported dimensions smaller than device limits");
2062 results.check(properties.maxMipLevels == fullMipPyramidSize, "maxMipLevels is not full mip pyramid size");
2063 results.check(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers,
2064 "maxArrayLayers smaller than device limits");
2068 results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size");
2069 results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers");
2072 results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE,
2073 "maxResourceSize smaller than minimum required size");
2075 else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED)
2077 log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage;
2079 if (isRequiredCombination)
2080 results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination");
2082 // Specification requires that all fields are set to 0
2083 results.check(properties.maxExtent.width == 0, "maxExtent.width != 0");
2084 results.check(properties.maxExtent.height == 0, "maxExtent.height != 0");
2085 results.check(properties.maxExtent.depth == 0, "maxExtent.depth != 0");
2086 results.check(properties.maxMipLevels == 0, "maxMipLevels != 0");
2087 results.check(properties.maxArrayLayers == 0, "maxArrayLayers != 0");
2088 results.check(properties.sampleCounts == 0, "sampleCounts != 0");
2089 results.check(properties.maxResourceSize == 0, "maxResourceSize != 0");
2093 results.fail("Got unexpected error" + de::toString(queryResult));
2098 return tcu::TestStatus(results.getResult(), results.getMessage());
2101 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
2103 DE_ASSERT(params.format == VK_FORMAT_UNDEFINED);
2105 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
2107 const VkFormat format = (VkFormat)formatNdx;
2108 const char* const enumName = getFormatName(format);
2109 const string caseName = de::toLower(string(enumName).substr(10));
2111 params.format = format;
2113 addFunctionCase(testGroup, caseName, enumName, imageFormatProperties, params);
2117 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
2119 DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST);
2121 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_OPTIMAL)));
2122 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_LINEAR)));
2125 void createImageFormatTests (tcu::TestCaseGroup* testGroup)
2127 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST)));
2128 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST)));
2129 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST)));
2134 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx)
2136 de::MovePtr<tcu::TestCaseGroup> infoTests (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
2139 de::MovePtr<tcu::TestCaseGroup> instanceInfoTests (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests"));
2141 addFunctionCase(instanceInfoTests.get(), "physical_devices", "Physical devices", enumeratePhysicalDevices);
2142 addFunctionCase(instanceInfoTests.get(), "layers", "Layers", enumerateInstanceLayers);
2143 addFunctionCase(instanceInfoTests.get(), "extensions", "Extensions", enumerateInstanceExtensions);
2145 infoTests->addChild(instanceInfoTests.release());
2149 de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests"));
2151 addFunctionCase(deviceInfoTests.get(), "features", "Device Features", deviceFeatures);
2152 addFunctionCase(deviceInfoTests.get(), "properties", "Device Properties", deviceProperties);
2153 addFunctionCase(deviceInfoTests.get(), "queue_family_properties", "Queue family properties", deviceQueueFamilyProperties);
2154 addFunctionCase(deviceInfoTests.get(), "memory_properties", "Memory properties", deviceMemoryProperties);
2155 addFunctionCase(deviceInfoTests.get(), "layers", "Layers", enumerateDeviceLayers);
2156 addFunctionCase(deviceInfoTests.get(), "extensions", "Extensions", enumerateDeviceExtensions);
2158 infoTests->addChild(deviceInfoTests.release());
2161 infoTests->addChild(createTestGroup(testCtx, "format_properties", "VkGetPhysicalDeviceFormatProperties() Tests", createFormatTests));
2162 infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests", createImageFormatTests));
2164 return infoTests.release();