1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and/or associated documentation files (the
9 * "Materials"), to deal in the Materials without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Materials, and to
12 * permit persons to whom the Materials are furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice(s) and this permission notice shall be
16 * included in all copies or substantial portions of the Materials.
18 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
28 * \brief Api Feature Query tests
29 *//*--------------------------------------------------------------------*/
31 #include "vktApiFeatureInfo.hpp"
33 #include "vktTestCaseUtil.hpp"
34 #include "vktTestGroupUtil.hpp"
36 #include "vkPlatform.hpp"
37 #include "vkStrUtil.hpp"
39 #include "vkDeviceUtil.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkImageUtil.hpp"
43 #include "tcuTestLog.hpp"
44 #include "tcuFormatUtil.hpp"
45 #include "tcuTextureUtil.hpp"
47 #include "deUniquePtr.hpp"
48 #include "deStringUtil.hpp"
49 #include "deSTLUtil.hpp"
64 using tcu::ScopedLogSection;
68 GUARD_SIZE = 0x20, //!< Number of bytes to check
69 GUARD_VALUE = 0xcd, //!< Data pattern
72 static const VkDeviceSize MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE = (1LLU<<31); //!< Minimum value for VkImageFormatProperties::maxResourceSize (2GiB)
76 LIMIT_FORMAT_SIGNED_INT,
77 LIMIT_FORMAT_UNSIGNED_INT,
79 LIMIT_FORMAT_DEVICE_SIZE,
92 #define LIMIT(_X_) DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_),(char*)(#_X_)
93 #define FEATURE(_X_) DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_)
95 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
98 VkPhysicalDeviceLimits* limits = &properties->limits;
99 struct FeatureLimitTable
103 deUint32 uintVal; //!< Format is UNSIGNED_INT
104 deInt32 intVal; //!< Format is SIGNED_INT
105 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE
106 float floatVal; //!< Format is FLOAT
109 deInt32 unsuppTableNdx;
110 } featureLimitTable[] = //!< From gitlab.khronos.org/vulkan/vulkan.git:doc/specs/vulkan/chapters/features.txt@63b23f3bb3ecd211cd6e448e2001ce1088dacd35
112 { LIMIT(maxImageDimension1D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
113 { LIMIT(maxImageDimension2D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
114 { LIMIT(maxImageDimension3D), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
115 { LIMIT(maxImageDimensionCube), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
116 { LIMIT(maxImageArrayLayers), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
117 { LIMIT(maxTexelBufferElements), 65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
118 { LIMIT(maxUniformBufferRange), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
119 { LIMIT(maxPushConstantsSize), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
120 { LIMIT(maxMemoryAllocationCount), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
121 { LIMIT(bufferImageGranularity), 0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
122 { LIMIT(sparseAddressSpaceSize), 0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
123 { LIMIT(maxBoundDescriptorSets), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
124 { LIMIT(maxPerStageDescriptorSamplers), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
125 { LIMIT(maxPerStageDescriptorUniformBuffers), 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
126 { LIMIT(maxPerStageDescriptorStorageBuffers), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
127 { LIMIT(maxPerStageDescriptorSampledImages), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
128 { LIMIT(maxPerStageDescriptorStorageImages), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
129 { LIMIT(maxPerStageDescriptorInputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
130 { LIMIT(maxDescriptorSetSamplers), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
131 { LIMIT(maxDescriptorSetUniformBuffers), 72, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
132 { LIMIT(maxDescriptorSetUniformBuffersDynamic), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
133 { LIMIT(maxDescriptorSetStorageBuffers), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
134 { LIMIT(maxDescriptorSetStorageBuffersDynamic), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
135 { LIMIT(maxDescriptorSetSampledImages), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
136 { LIMIT(maxDescriptorSetStorageImages), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
137 { LIMIT(maxVertexInputAttributes), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
138 { LIMIT(maxVertexInputBindings), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
139 { LIMIT(maxVertexInputAttributeOffset), 2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
140 { LIMIT(maxVertexInputBindingStride), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
141 { LIMIT(maxVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
142 { LIMIT(maxTessellationGenerationLevel), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
143 { LIMIT(maxTessellationPatchSize), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
144 { LIMIT(maxTessellationControlPerVertexInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
145 { LIMIT(maxTessellationControlPerVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
146 { LIMIT(maxTessellationControlPerPatchOutputComponents), 120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
147 { LIMIT(maxTessellationControlTotalOutputComponents), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
148 { LIMIT(maxTessellationEvaluationInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
149 { LIMIT(maxTessellationEvaluationOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
150 { LIMIT(maxGeometryShaderInvocations), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
151 { LIMIT(maxGeometryInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
152 { LIMIT(maxGeometryOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
153 { LIMIT(maxGeometryOutputVertices), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
154 { LIMIT(maxGeometryTotalOutputComponents), 1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
155 { LIMIT(maxFragmentInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
156 { LIMIT(maxFragmentOutputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
157 { LIMIT(maxFragmentDualSrcAttachments), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
158 { LIMIT(maxFragmentCombinedOutputResources), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
159 { LIMIT(maxComputeSharedMemorySize), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
160 { LIMIT(maxComputeWorkGroupCount[0]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
161 { LIMIT(maxComputeWorkGroupCount[1]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
162 { LIMIT(maxComputeWorkGroupCount[2]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
163 { LIMIT(maxComputeWorkGroupInvocations), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
164 { LIMIT(maxComputeWorkGroupSize[0]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
165 { LIMIT(maxComputeWorkGroupSize[1]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
166 { LIMIT(maxComputeWorkGroupSize[2]), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
167 { LIMIT(subPixelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
168 { LIMIT(subTexelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
169 { LIMIT(mipmapPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
170 { LIMIT(maxDrawIndexedIndexValue), (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
171 { LIMIT(maxDrawIndirectCount), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
172 { LIMIT(maxSamplerLodBias), 0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
173 { LIMIT(maxSamplerAnisotropy), 0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
174 { LIMIT(maxViewports), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
175 { LIMIT(maxViewportDimensions[0]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
176 { LIMIT(maxViewportDimensions[1]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
177 { LIMIT(viewportBoundsRange[0]), 0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
178 { LIMIT(viewportBoundsRange[1]), 0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
179 { LIMIT(viewportSubPixelBits), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
180 { LIMIT(minMemoryMapAlignment), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
181 { LIMIT(minTexelBufferOffsetAlignment), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX, -1 },
182 { LIMIT(minUniformBufferOffsetAlignment), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX, -1 },
183 { LIMIT(minStorageBufferOffsetAlignment), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX, -1 },
184 { LIMIT(minTexelOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
185 { LIMIT(maxTexelOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
186 { LIMIT(minTexelGatherOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
187 { LIMIT(maxTexelGatherOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
188 { LIMIT(minInterpolationOffset), 0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
189 { LIMIT(maxInterpolationOffset), 0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
190 { LIMIT(subPixelInterpolationOffsetBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
191 { LIMIT(maxFramebufferWidth), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
192 { LIMIT(maxFramebufferHeight), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
193 { LIMIT(maxFramebufferLayers), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
194 { LIMIT(maxColorAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
195 { LIMIT(maxSampleMaskWords), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
196 { LIMIT(maxClipDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
197 { LIMIT(maxCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
198 { LIMIT(maxCombinedClipAndCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
199 { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
200 { LIMIT(pointSizeRange[1]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
201 { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
202 { LIMIT(pointSizeRange[1]), 0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
203 { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
204 { LIMIT(lineWidthRange[1]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
205 { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
206 { LIMIT(lineWidthRange[1]), 0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
207 { LIMIT(pointSizeGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
208 { LIMIT(lineWidthGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
209 { LIMIT(nonCoherentAtomSize), 0, 0, 128, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
212 struct UnsupportedFeatureLimitTable
214 deUint32 limitOffset;
216 deUint32 featureOffset;
217 deUint32 uintVal; //!< Format is UNSIGNED_INT
218 deInt32 intVal; //!< Format is SIGNED_INT
219 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE
220 float floatVal; //!< Format is FLOAT
221 } unsupportedFeatureTable[] =
223 { LIMIT(sparseAddressSpaceSize), FEATURE(sparseBinding), 0, 0, 0, 0.0f },
224 { LIMIT(maxTessellationGenerationLevel), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
225 { LIMIT(maxTessellationPatchSize), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
226 { LIMIT(maxTessellationControlPerVertexInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
227 { LIMIT(maxTessellationControlPerVertexOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
228 { LIMIT(maxTessellationControlPerPatchOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
229 { LIMIT(maxTessellationControlTotalOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
230 { LIMIT(maxTessellationEvaluationInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
231 { LIMIT(maxTessellationEvaluationOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f },
232 { LIMIT(maxGeometryShaderInvocations), FEATURE(geometryShader), 0, 0, 0, 0.0f },
233 { LIMIT(maxGeometryInputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
234 { LIMIT(maxGeometryOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
235 { LIMIT(maxGeometryOutputVertices), FEATURE(geometryShader), 0, 0, 0, 0.0f },
236 { LIMIT(maxGeometryTotalOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f },
237 { LIMIT(maxFragmentDualSrcAttachments), FEATURE(dualSrcBlend), 0, 0, 0, 0.0f },
238 { LIMIT(maxDrawIndexedIndexValue), FEATURE(fullDrawIndexUint32), (1<<24)-1, 0, 0, 0.0f },
239 { LIMIT(maxDrawIndirectCount), FEATURE(multiDrawIndirect), 1, 0, 0, 0.0f },
240 { LIMIT(maxSamplerAnisotropy), FEATURE(samplerAnisotropy), 1, 0, 0, 0.0f },
241 { LIMIT(maxViewports), FEATURE(multiViewport), 1, 0, 0, 0.0f },
242 { LIMIT(minTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f },
243 { LIMIT(maxTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f },
244 { LIMIT(minInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
245 { LIMIT(maxInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
246 { LIMIT(subPixelInterpolationOffsetBits), FEATURE(sampleRateShading), 0, 0, 0, 0.0f },
247 { LIMIT(storageImageSampleCounts), FEATURE(shaderStorageImageMultisample), 0, 0, 0, 0.0f },
248 { LIMIT(maxClipDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
249 { LIMIT(maxCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
250 { LIMIT(maxCombinedClipAndCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f },
251 { LIMIT(pointSizeRange[0]), FEATURE(largePoints), 0, 0, 0, 1.0f },
252 { LIMIT(pointSizeRange[1]), FEATURE(largePoints), 0, 0, 0, 1.0f },
253 { LIMIT(lineWidthRange[0]), FEATURE(wideLines), 0, 0, 0, 1.0f },
254 { LIMIT(lineWidthRange[1]), FEATURE(wideLines), 0, 0, 0, 1.0f },
255 { LIMIT(pointSizeGranularity), FEATURE(largePoints), 0, 0, 0, 0.0f },
256 { LIMIT(lineWidthGranularity), FEATURE(wideLines), 0, 0, 0, 0.0f }
259 log << TestLog::Message << *limits << TestLog::EndMessage;
261 //!< First build a map from limit to unsupported table index
262 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
264 for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++)
266 if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset)
268 featureLimitTable[ndx].unsuppTableNdx = unsuppNdx;
274 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
276 switch (featureLimitTable[ndx].format)
278 case LIMIT_FORMAT_UNSIGNED_INT:
280 deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
281 if (featureLimitTable[ndx].unsuppTableNdx != -1)
283 if (*((VkBool32*)((char*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
284 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
287 if ( featureLimitTable[ndx].type == LIMIT_TYPE_MIN )
290 if (*((deUint32*)((char*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
292 log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name
293 << " not valid-limit type MIN - actual is "
294 << *((deUint32*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
300 if (*((deUint32*)((char*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
302 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
303 << " not valid-limit type MAX - actual is "
304 << *((deUint32*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
311 case LIMIT_FORMAT_FLOAT:
313 float limitToCheck = featureLimitTable[ndx].floatVal;
314 if (featureLimitTable[ndx].unsuppTableNdx != -1)
316 if (*((VkBool32*)((char*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
317 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal;
320 if ( featureLimitTable[ndx].type == LIMIT_TYPE_MIN )
322 if (*((float*)((char*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
324 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
325 << " not valid-limit type MIN - actual is "
326 << *((float*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
332 if (*((float*)((char*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
334 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
335 << " not valid-limit type MAX actual is "
336 << *((float*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
343 case LIMIT_FORMAT_SIGNED_INT:
345 deInt32 limitToCheck = featureLimitTable[ndx].intVal;
346 if (featureLimitTable[ndx].unsuppTableNdx != -1)
348 if (*((VkBool32*)((char*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
349 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal;
351 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
353 if (*((deInt32*)((char*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
355 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
356 << " not valid-limit type MIN actual is "
357 << *((deInt32*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
363 if (*((deInt32*)((char*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
365 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
366 << " not valid-limit type MAX actual is "
367 << *((deInt32*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
374 case LIMIT_FORMAT_DEVICE_SIZE:
376 deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal;
377 if (featureLimitTable[ndx].unsuppTableNdx != -1)
379 if (*((VkBool32*)((char*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
380 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal;
383 if ( featureLimitTable[ndx].type == LIMIT_TYPE_MIN )
385 if (*((deUint64*)((char*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
387 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
388 << " not valid-limit type MIN actual is "
389 << *((deUint64*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
395 if (*((deUint64*)((char*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
397 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
398 << " not valid-limit type MAX actual is "
399 << *((deUint64*)((char*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
415 tcu::TestStatus enumeratePhysicalDevices (Context& context)
417 TestLog& log = context.getTestContext().getLog();
418 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
420 log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
422 for (size_t ndx = 0; ndx < devices.size(); ndx++)
423 log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage;
425 return tcu::TestStatus::pass("Enumerating devices succeeded");
428 tcu::TestStatus enumerateInstanceLayers (Context& context)
430 TestLog& log = context.getTestContext().getLog();
431 const vector<VkLayerProperties> properties = enumerateInstanceLayerProperties(context.getPlatformInterface());
433 for (size_t ndx = 0; ndx < properties.size(); ndx++)
434 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
436 return tcu::TestStatus::pass("Enumerating layers succeeded");
439 tcu::TestStatus enumerateInstanceExtensions (Context& context)
441 TestLog& log = context.getTestContext().getLog();
444 const ScopedLogSection section (log, "Global", "Global Extensions");
445 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
447 for (size_t ndx = 0; ndx < properties.size(); ndx++)
448 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
452 const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface());
454 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
456 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName);
457 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
459 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
460 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
464 return tcu::TestStatus::pass("Enumerating extensions succeeded");
467 tcu::TestStatus enumerateDeviceLayers (Context& context)
469 TestLog& log = context.getTestContext().getLog();
470 const vector<VkLayerProperties> properties = vk::enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
472 for (size_t ndx = 0; ndx < properties.size(); ndx++)
473 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
475 return tcu::TestStatus::pass("Enumerating layers succeeded");
478 tcu::TestStatus enumerateDeviceExtensions (Context& context)
480 TestLog& log = context.getTestContext().getLog();
483 const ScopedLogSection section (log, "Global", "Global Extensions");
484 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
486 for (size_t ndx = 0; ndx < properties.size(); ndx++)
487 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
491 const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
493 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
495 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName);
496 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
498 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
499 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
503 return tcu::TestStatus::pass("Enumerating extensions succeeded");
506 tcu::TestStatus deviceFeatures (Context& context)
508 TestLog& log = context.getTestContext().getLog();
509 VkPhysicalDeviceFeatures* features;
510 deUint8 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE];
512 deMemset(buffer, GUARD_VALUE, sizeof(buffer));
513 features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer);
515 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features);
517 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
518 << TestLog::Message << *features << TestLog::EndMessage;
520 if (!features->robustBufferAccess)
521 return tcu::TestStatus::fail("robustBufferAccess is not supported");
523 for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
525 if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE)
527 log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
528 return tcu::TestStatus::fail("deviceFeatures buffer overflow");
532 return tcu::TestStatus::pass("Query succeeded");
535 tcu::TestStatus deviceProperties (Context& context)
537 TestLog& log = context.getTestContext().getLog();
538 VkPhysicalDeviceProperties* props;
539 VkPhysicalDeviceFeatures features;
540 deUint8 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE];
542 props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer);
543 deMemset(props, GUARD_VALUE, sizeof(buffer));
545 context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props);
546 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features);
548 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
549 << TestLog::Message << *props << TestLog::EndMessage;
551 if (!validateFeatureLimits(props, &features, log))
552 return tcu::TestStatus::fail("deviceProperties - feature limits failed");
554 for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
556 if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE)
558 log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
559 return tcu::TestStatus::fail("deviceProperties buffer overflow");
563 return tcu::TestStatus::pass("DeviceProperites query succeeded");
566 tcu::TestStatus deviceQueueFamilyProperties (Context& context)
568 TestLog& log = context.getTestContext().getLog();
569 const vector<VkQueueFamilyProperties> queueProperties = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
571 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage;
573 for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++)
574 log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage;
576 return tcu::TestStatus::pass("Querying queue properties succeeded");
579 tcu::TestStatus deviceMemoryProperties (Context& context)
581 TestLog& log = context.getTestContext().getLog();
582 VkPhysicalDeviceMemoryProperties* memProps;
583 deUint8 buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE];
585 memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer);
586 deMemset(buffer, GUARD_VALUE, sizeof(buffer));
588 context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps);
590 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
591 << TestLog::Message << *memProps << TestLog::EndMessage;
593 for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
595 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE)
597 log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
598 return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow");
602 return tcu::TestStatus::pass("Querying memory properties succeeded");
605 // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead
607 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format)
609 static const VkFormat s_requiredSampledImageBlitSrcFormats[] =
611 VK_FORMAT_B4G4R4A4_UNORM_PACK16,
612 VK_FORMAT_R5G6B5_UNORM_PACK16,
613 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
618 VK_FORMAT_R8G8_UNORM,
619 VK_FORMAT_R8G8_SNORM,
622 VK_FORMAT_R8G8B8A8_UNORM,
623 VK_FORMAT_R8G8B8A8_SNORM,
624 VK_FORMAT_R8G8B8A8_UINT,
625 VK_FORMAT_R8G8B8A8_SINT,
626 VK_FORMAT_R8G8B8A8_SRGB,
627 VK_FORMAT_B8G8R8A8_UNORM,
628 VK_FORMAT_B8G8R8A8_SRGB,
629 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
630 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
631 VK_FORMAT_A8B8G8R8_UINT_PACK32,
632 VK_FORMAT_A8B8G8R8_SINT_PACK32,
633 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
634 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
635 VK_FORMAT_A2B10G10R10_UINT_PACK32,
638 VK_FORMAT_R16_SFLOAT,
639 VK_FORMAT_R16G16_UINT,
640 VK_FORMAT_R16G16_SINT,
641 VK_FORMAT_R16G16_SFLOAT,
642 VK_FORMAT_R16G16B16A16_UINT,
643 VK_FORMAT_R16G16B16A16_SINT,
644 VK_FORMAT_R16G16B16A16_SFLOAT,
647 VK_FORMAT_R32_SFLOAT,
648 VK_FORMAT_R32G32_UINT,
649 VK_FORMAT_R32G32_SINT,
650 VK_FORMAT_R32G32_SFLOAT,
651 VK_FORMAT_R32G32B32A32_UINT,
652 VK_FORMAT_R32G32B32A32_SINT,
653 VK_FORMAT_R32G32B32A32_SFLOAT,
654 VK_FORMAT_B10G11R11_UFLOAT_PACK32,
655 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
659 static const VkFormat s_requiredStorageImageFormats[] =
661 VK_FORMAT_R8G8B8A8_UNORM,
662 VK_FORMAT_R8G8B8A8_SNORM,
663 VK_FORMAT_R8G8B8A8_UINT,
664 VK_FORMAT_R8G8B8A8_SINT,
665 VK_FORMAT_R16G16B16A16_UINT,
666 VK_FORMAT_R16G16B16A16_SINT,
667 VK_FORMAT_R16G16B16A16_SFLOAT,
670 VK_FORMAT_R32_SFLOAT,
671 VK_FORMAT_R32G32_UINT,
672 VK_FORMAT_R32G32_SINT,
673 VK_FORMAT_R32G32_SFLOAT,
674 VK_FORMAT_R32G32B32A32_UINT,
675 VK_FORMAT_R32G32B32A32_SINT,
676 VK_FORMAT_R32G32B32A32_SFLOAT
678 static const VkFormat s_requiredStorageImageAtomicFormats[] =
683 static const VkFormat s_requiredColorAttachmentBlitDstFormats[] =
685 VK_FORMAT_R5G6B5_UNORM_PACK16,
686 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
690 VK_FORMAT_R8G8_UNORM,
693 VK_FORMAT_R8G8B8A8_UNORM,
694 VK_FORMAT_R8G8B8A8_UINT,
695 VK_FORMAT_R8G8B8A8_SINT,
696 VK_FORMAT_R8G8B8A8_SRGB,
697 VK_FORMAT_B8G8R8A8_UNORM,
698 VK_FORMAT_B8G8R8A8_SRGB,
699 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
700 VK_FORMAT_A8B8G8R8_UINT_PACK32,
701 VK_FORMAT_A8B8G8R8_SINT_PACK32,
702 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
703 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
704 VK_FORMAT_A2B10G10R10_UINT_PACK32,
707 VK_FORMAT_R16_SFLOAT,
708 VK_FORMAT_R16G16_UINT,
709 VK_FORMAT_R16G16_SINT,
710 VK_FORMAT_R16G16_SFLOAT,
711 VK_FORMAT_R16G16B16A16_UINT,
712 VK_FORMAT_R16G16B16A16_SINT,
713 VK_FORMAT_R16G16B16A16_SFLOAT,
716 VK_FORMAT_R32_SFLOAT,
717 VK_FORMAT_R32G32_UINT,
718 VK_FORMAT_R32G32_SINT,
719 VK_FORMAT_R32G32_SFLOAT,
720 VK_FORMAT_R32G32B32A32_UINT,
721 VK_FORMAT_R32G32B32A32_SINT,
722 VK_FORMAT_R32G32B32A32_SFLOAT
724 static const VkFormat s_requiredColorAttachmentBlendFormats[] =
726 VK_FORMAT_R5G6B5_UNORM_PACK16,
727 VK_FORMAT_A1R5G5B5_UNORM_PACK16,
729 VK_FORMAT_R8G8_UNORM,
730 VK_FORMAT_R8G8B8A8_UNORM,
731 VK_FORMAT_R8G8B8A8_SRGB,
732 VK_FORMAT_B8G8R8A8_UNORM,
733 VK_FORMAT_B8G8R8A8_SRGB,
734 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
735 VK_FORMAT_A8B8G8R8_SRGB_PACK32,
736 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
737 VK_FORMAT_R16_SFLOAT,
738 VK_FORMAT_R16G16_SFLOAT,
739 VK_FORMAT_R16G16B16A16_SFLOAT
741 static const VkFormat s_requiredDepthStencilAttachmentFormats[] =
746 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0;
748 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format))
749 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT;
751 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format))
752 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
754 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format))
755 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
757 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format))
758 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT;
760 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format))
761 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
763 if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format))
764 flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
769 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format)
771 static const VkFormat s_requiredVertexBufferFormats[] =
777 VK_FORMAT_R8G8_UNORM,
778 VK_FORMAT_R8G8_SNORM,
781 VK_FORMAT_R8G8B8A8_UNORM,
782 VK_FORMAT_R8G8B8A8_SNORM,
783 VK_FORMAT_R8G8B8A8_UINT,
784 VK_FORMAT_R8G8B8A8_SINT,
785 VK_FORMAT_B8G8R8A8_UNORM,
786 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
787 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
788 VK_FORMAT_A8B8G8R8_UINT_PACK32,
789 VK_FORMAT_A8B8G8R8_SINT_PACK32,
790 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
795 VK_FORMAT_R16_SFLOAT,
796 VK_FORMAT_R16G16_UNORM,
797 VK_FORMAT_R16G16_SNORM,
798 VK_FORMAT_R16G16_UINT,
799 VK_FORMAT_R16G16_SINT,
800 VK_FORMAT_R16G16_SFLOAT,
801 VK_FORMAT_R16G16B16A16_UNORM,
802 VK_FORMAT_R16G16B16A16_SNORM,
803 VK_FORMAT_R16G16B16A16_UINT,
804 VK_FORMAT_R16G16B16A16_SINT,
805 VK_FORMAT_R16G16B16A16_SFLOAT,
808 VK_FORMAT_R32_SFLOAT,
809 VK_FORMAT_R32G32_UINT,
810 VK_FORMAT_R32G32_SINT,
811 VK_FORMAT_R32G32_SFLOAT,
812 VK_FORMAT_R32G32B32_UINT,
813 VK_FORMAT_R32G32B32_SINT,
814 VK_FORMAT_R32G32B32_SFLOAT,
815 VK_FORMAT_R32G32B32A32_UINT,
816 VK_FORMAT_R32G32B32A32_SINT,
817 VK_FORMAT_R32G32B32A32_SFLOAT
819 static const VkFormat s_requiredUniformTexelBufferFormats[] =
825 VK_FORMAT_R8G8_UNORM,
826 VK_FORMAT_R8G8_SNORM,
829 VK_FORMAT_R8G8B8A8_UNORM,
830 VK_FORMAT_R8G8B8A8_SNORM,
831 VK_FORMAT_R8G8B8A8_UINT,
832 VK_FORMAT_R8G8B8A8_SINT,
833 VK_FORMAT_B8G8R8A8_UNORM,
834 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
835 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
836 VK_FORMAT_A8B8G8R8_UINT_PACK32,
837 VK_FORMAT_A8B8G8R8_SINT_PACK32,
838 VK_FORMAT_A2B10G10R10_UNORM_PACK32,
839 VK_FORMAT_A2B10G10R10_UINT_PACK32,
842 VK_FORMAT_R16_SFLOAT,
843 VK_FORMAT_R16G16_UINT,
844 VK_FORMAT_R16G16_SINT,
845 VK_FORMAT_R16G16_SFLOAT,
846 VK_FORMAT_R16G16B16A16_UINT,
847 VK_FORMAT_R16G16B16A16_SINT,
848 VK_FORMAT_R16G16B16A16_SFLOAT,
851 VK_FORMAT_R32_SFLOAT,
852 VK_FORMAT_R32G32_UINT,
853 VK_FORMAT_R32G32_SINT,
854 VK_FORMAT_R32G32_SFLOAT,
855 VK_FORMAT_R32G32B32A32_UINT,
856 VK_FORMAT_R32G32B32A32_SINT,
857 VK_FORMAT_R32G32B32A32_SFLOAT,
858 VK_FORMAT_B10G11R11_UFLOAT_PACK32
860 static const VkFormat s_requiredStorageTexelBufferFormats[] =
862 VK_FORMAT_R8G8B8A8_UNORM,
863 VK_FORMAT_R8G8B8A8_SNORM,
864 VK_FORMAT_R8G8B8A8_UINT,
865 VK_FORMAT_R8G8B8A8_SINT,
866 VK_FORMAT_A8B8G8R8_UNORM_PACK32,
867 VK_FORMAT_A8B8G8R8_SNORM_PACK32,
868 VK_FORMAT_A8B8G8R8_UINT_PACK32,
869 VK_FORMAT_A8B8G8R8_SINT_PACK32,
870 VK_FORMAT_R16G16B16A16_UINT,
871 VK_FORMAT_R16G16B16A16_SINT,
872 VK_FORMAT_R16G16B16A16_SFLOAT,
875 VK_FORMAT_R32_SFLOAT,
876 VK_FORMAT_R32G32_UINT,
877 VK_FORMAT_R32G32_SINT,
878 VK_FORMAT_R32G32_SFLOAT,
879 VK_FORMAT_R32G32B32A32_UINT,
880 VK_FORMAT_R32G32B32A32_SINT,
881 VK_FORMAT_R32G32B32A32_SFLOAT
883 static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] =
889 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0;
891 if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format))
892 flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
894 if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format))
895 flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
897 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format))
898 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
900 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format))
901 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
906 tcu::TestStatus formatProperties (Context& context, VkFormat format)
908 TestLog& log = context.getTestContext().getLog();
909 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
914 VkFormatFeatureFlags VkFormatProperties::* field;
915 const char* fieldName;
916 VkFormatFeatureFlags requiredFeatures;
919 { &VkFormatProperties::linearTilingFeatures, "linearTilingFeatures", (VkFormatFeatureFlags)0 },
920 { &VkFormatProperties::optimalTilingFeatures, "optimalTilingFeatures", getRequiredOptimalTilingFeatures(format) },
921 { &VkFormatProperties::bufferFeatures, "buffeFeatures", getRequiredBufferFeatures(format) }
924 log << TestLog::Message << properties << TestLog::EndMessage;
926 for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
928 const char* const fieldName = fields[fieldNdx].fieldName;
929 const VkFormatFeatureFlags supported = properties.*fields[fieldNdx].field;
930 const VkFormatFeatureFlags required = fields[fieldNdx].requiredFeatures;
932 if ((supported & required) != required)
934 log << TestLog::Message << "ERROR in " << fieldName << ":\n"
935 << " required: " << getFormatFeatureFlagsStr(required) << "\n "
936 << " missing: " << getFormatFeatureFlagsStr(~supported & required)
937 << TestLog::EndMessage;
943 return tcu::TestStatus::pass("Query and validation passed");
945 return tcu::TestStatus::fail("Required features not supported");
948 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features)
950 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
952 return (properties.optimalTilingFeatures & features) == features;
955 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features)
957 for (const VkFormat* cur = begin; cur != end; ++cur)
959 if (!optimalTilingFeaturesSupported(context, *cur, features))
966 tcu::TestStatus testDepthStencilSupported (Context& context)
968 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
969 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
970 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT");
972 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
973 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
974 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT");
976 return tcu::TestStatus::pass("Required depth/stencil formats supported");
979 tcu::TestStatus testCompressedFormatsSupported (Context& context)
981 static const VkFormat s_allBcFormats[] =
983 VK_FORMAT_BC1_RGB_UNORM_BLOCK,
984 VK_FORMAT_BC1_RGB_SRGB_BLOCK,
985 VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
986 VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
987 VK_FORMAT_BC2_UNORM_BLOCK,
988 VK_FORMAT_BC2_SRGB_BLOCK,
989 VK_FORMAT_BC3_UNORM_BLOCK,
990 VK_FORMAT_BC3_SRGB_BLOCK,
991 VK_FORMAT_BC4_UNORM_BLOCK,
992 VK_FORMAT_BC4_SNORM_BLOCK,
993 VK_FORMAT_BC5_UNORM_BLOCK,
994 VK_FORMAT_BC5_SNORM_BLOCK,
995 VK_FORMAT_BC6H_UFLOAT_BLOCK,
996 VK_FORMAT_BC6H_SFLOAT_BLOCK,
997 VK_FORMAT_BC7_UNORM_BLOCK,
998 VK_FORMAT_BC7_SRGB_BLOCK,
1000 static const VkFormat s_allEtc2Formats[] =
1002 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
1003 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
1004 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
1005 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
1006 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
1007 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
1008 VK_FORMAT_EAC_R11_UNORM_BLOCK,
1009 VK_FORMAT_EAC_R11_SNORM_BLOCK,
1010 VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
1011 VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
1013 static const VkFormat s_allAstcLdrFormats[] =
1015 VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
1016 VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
1017 VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
1018 VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
1019 VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
1020 VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
1021 VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
1022 VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
1023 VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
1024 VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
1025 VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
1026 VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
1027 VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
1028 VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
1029 VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
1030 VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
1031 VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
1032 VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
1033 VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
1034 VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
1035 VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
1036 VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
1037 VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
1038 VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
1039 VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
1040 VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
1041 VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
1042 VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
1047 const char* setName;
1048 const char* featureName;
1049 const VkBool32 VkPhysicalDeviceFeatures::* feature;
1050 const VkFormat* formatsBegin;
1051 const VkFormat* formatsEnd;
1052 } s_compressedFormatSets[] =
1054 { "BC", "textureCompressionBC", &VkPhysicalDeviceFeatures::textureCompressionBC, DE_ARRAY_BEGIN(s_allBcFormats), DE_ARRAY_END(s_allBcFormats) },
1055 { "ETC2", "textureCompressionETC2", &VkPhysicalDeviceFeatures::textureCompressionETC2, DE_ARRAY_BEGIN(s_allEtc2Formats), DE_ARRAY_END(s_allEtc2Formats) },
1056 { "ASTC LDR", "textureCompressionASTC_LDR", &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR, DE_ARRAY_BEGIN(s_allAstcLdrFormats), DE_ARRAY_END(s_allAstcLdrFormats) },
1059 TestLog& log = context.getTestContext().getLog();
1060 const VkPhysicalDeviceFeatures& features = context.getDeviceFeatures();
1061 int numSupportedSets = 0;
1063 int numWarnings = 0;
1065 for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx)
1067 const char* const setName = s_compressedFormatSets[setNdx].setName;
1068 const char* const featureName = s_compressedFormatSets[setNdx].featureName;
1069 const bool featureBitSet = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE;
1070 const bool allSupported = optimalTilingFeaturesSupportedForAll(context,
1071 s_compressedFormatSets[setNdx].formatsBegin,
1072 s_compressedFormatSets[setNdx].formatsEnd,
1073 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
1075 if (featureBitSet && !allSupported)
1077 log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage;
1080 else if (allSupported && !featureBitSet)
1082 log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage;
1088 log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage;
1089 numSupportedSets += 1;
1092 log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage;
1095 if (numSupportedSets == 0)
1097 log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage;
1102 return tcu::TestStatus::fail("Compressed format support not valid");
1103 else if (numWarnings > 0)
1104 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support");
1106 return tcu::TestStatus::pass("Compressed texture format support is valid");
1109 void createFormatTests (tcu::TestCaseGroup* testGroup)
1111 DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0);
1113 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_FORMAT_LAST; ++formatNdx)
1115 const VkFormat format = (VkFormat)formatNdx;
1116 const char* const enumName = getFormatName(format);
1117 const string caseName = de::toLower(string(enumName).substr(10));
1119 addFunctionCase(testGroup, caseName, enumName, formatProperties, format);
1122 addFunctionCase(testGroup, "depth_stencil", "", testDepthStencilSupported);
1123 addFunctionCase(testGroup, "compressed_formats", "", testCompressedFormatsSupported);
1126 VkImageUsageFlags getValidImageUsageFlags (VkFormat, VkFormatFeatureFlags supportedFeatures)
1128 VkImageUsageFlags flags = (VkImageUsageFlags)0;
1130 // If format is supported at all, it must be valid transfer src+dst
1131 if (supportedFeatures != 0)
1132 flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
1134 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
1135 flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
1137 if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0)
1138 flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
1140 if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
1141 flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
1143 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
1144 flags |= VK_IMAGE_USAGE_STORAGE_BIT;
1149 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
1154 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage)
1156 VkImageCreateFlags flags = (VkImageCreateFlags)0;
1158 if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
1160 flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
1162 if (type == VK_IMAGE_TYPE_2D)
1163 flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
1166 if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 &&
1167 (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
1169 if (deviceFeatures.sparseBinding)
1170 flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
1172 if (deviceFeatures.sparseResidencyAliased)
1173 flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
1179 bool isValidImageCreateFlagCombination (VkImageCreateFlags)
1184 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures& deviceFeatures,
1185 const VkFormat format,
1186 const VkFormatProperties& formatProperties,
1187 const VkImageType imageType,
1188 const VkImageTiling imageTiling,
1189 const VkImageUsageFlags usageFlags,
1190 const VkImageCreateFlags createFlags)
1192 DE_UNREF(deviceFeatures);
1193 DE_UNREF(formatProperties);
1194 DE_UNREF(createFlags);
1196 // Linear images can have arbitrary limitations
1197 if (imageTiling == VK_IMAGE_TILING_LINEAR)
1200 // Support for other usages for compressed formats is optional
1201 if (isCompressedFormat(format) &&
1202 (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0)
1205 // Support for 1D, and sliced 3D compressed formats is optional
1206 if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
1209 DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
1210 DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
1215 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits& deviceLimits,
1216 const VkFormat format,
1217 const VkImageUsageFlags usageFlags)
1219 if (!isCompressedFormat(format))
1221 const tcu::TextureFormat tcuFormat = mapVkFormat(format);
1223 if (usageFlags & VK_IMAGE_USAGE_STORAGE_BIT)
1224 return deviceLimits.storageImageSampleCounts;
1225 else if (tcuFormat.order == tcu::TextureFormat::D)
1226 return deviceLimits.sampledImageDepthSampleCounts;
1227 else if (tcuFormat.order == tcu::TextureFormat::S)
1228 return deviceLimits.sampledImageStencilSampleCounts;
1229 else if (tcuFormat.order == tcu::TextureFormat::DS)
1230 return deviceLimits.sampledImageDepthSampleCounts & deviceLimits.sampledImageStencilSampleCounts;
1233 const tcu::TextureChannelClass chnClass = tcu::getTextureChannelClass(tcuFormat.type);
1235 if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
1236 chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
1237 return deviceLimits.sampledImageIntegerSampleCounts;
1239 return deviceLimits.sampledImageColorSampleCounts;
1243 return VK_SAMPLE_COUNT_1_BIT;
1246 struct ImageFormatPropertyCase
1249 VkImageType imageType;
1250 VkImageTiling tiling;
1252 ImageFormatPropertyCase (VkFormat format_, VkImageType imageType_, VkImageTiling tiling_)
1254 , imageType (imageType_)
1258 ImageFormatPropertyCase (void)
1259 : format (VK_FORMAT_LAST)
1260 , imageType (VK_IMAGE_TYPE_LAST)
1261 , tiling (VK_IMAGE_TILING_LAST)
1265 tcu::TestStatus imageFormatProperties (Context& context, ImageFormatPropertyCase params)
1267 TestLog& log = context.getTestContext().getLog();
1268 const VkFormat format = params.format;
1269 const VkImageType imageType = params.imageType;
1270 const VkImageTiling tiling = params.tiling;
1271 const VkPhysicalDeviceFeatures& deviceFeatures = context.getDeviceFeatures();
1272 const VkPhysicalDeviceLimits& deviceLimits = context.getDeviceProperties().limits;
1273 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
1275 const VkFormatFeatureFlags supportedFeatures = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
1276 const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(format, supportedFeatures);
1278 for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
1280 if ((curUsageFlags & ~usageFlagSet) != 0 ||
1281 !isValidImageUsageFlagCombination(curUsageFlags))
1284 const VkImageCreateFlags createFlagSet = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags);
1286 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++)
1288 if ((curCreateFlags & ~createFlagSet) != 0 ||
1289 !isValidImageCreateFlagCombination(curCreateFlags))
1292 const bool isRequiredCombination = isRequiredImageParameterCombination(deviceFeatures,
1300 log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", "
1301 << getImageTilingStr(tiling) << ", "
1302 << getImageUsageFlagsStr(curUsageFlags) << ", "
1303 << getImageCreateFlagsStr(curCreateFlags)
1304 << TestLog::EndMessage;
1308 const VkImageFormatProperties properties = getPhysicalDeviceImageFormatProperties(context.getInstanceInterface(),
1309 context.getPhysicalDevice(),
1315 const deUint32 fullMipPyramidSize = de::max(de::max(deLog2Ceil32(properties.maxExtent.width),
1316 deLog2Ceil32(properties.maxExtent.height)),
1317 deLog2Ceil32(properties.maxExtent.depth)) + 1;
1319 log << TestLog::Message << properties << "\n" << TestLog::EndMessage;
1321 TCU_CHECK(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1));
1322 TCU_CHECK(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1));
1323 TCU_CHECK(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1));
1325 if (tiling == VK_IMAGE_TILING_OPTIMAL)
1327 const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
1328 TCU_CHECK((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts);
1331 TCU_CHECK(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT);
1333 if (isRequiredCombination)
1335 TCU_CHECK(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= deviceLimits.maxImageDimension1D));
1336 TCU_CHECK(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= deviceLimits.maxImageDimension2D &&
1337 properties.maxExtent.height >= deviceLimits.maxImageDimension2D));
1338 TCU_CHECK(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= deviceLimits.maxImageDimension3D &&
1339 properties.maxExtent.height >= deviceLimits.maxImageDimension3D &&
1340 properties.maxExtent.depth >= deviceLimits.maxImageDimension3D));
1341 TCU_CHECK(properties.maxMipLevels == fullMipPyramidSize);
1342 TCU_CHECK(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1);
1343 TCU_CHECK(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers);
1347 TCU_CHECK(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize);
1348 TCU_CHECK(properties.maxArrayLayers >= 1);
1351 TCU_CHECK(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE);
1353 catch (const Error& error)
1355 if (error.getError() == VK_ERROR_FORMAT_NOT_SUPPORTED)
1357 log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage;
1359 if (isRequiredCombination)
1360 TCU_FAIL("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination");
1368 return tcu::TestStatus::pass("All queries succeeded");
1371 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
1373 DE_ASSERT(params.format == VK_FORMAT_LAST);
1375 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_FORMAT_LAST; ++formatNdx)
1377 const VkFormat format = (VkFormat)formatNdx;
1378 const char* const enumName = getFormatName(format);
1379 const string caseName = de::toLower(string(enumName).substr(10));
1381 params.format = format;
1383 addFunctionCase(testGroup, caseName, enumName, imageFormatProperties, params);
1387 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
1389 DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST);
1391 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_LAST, params.imageType, VK_IMAGE_TILING_OPTIMAL)));
1392 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_LAST, params.imageType, VK_IMAGE_TILING_LINEAR)));
1395 void createImageFormatTests (tcu::TestCaseGroup* testGroup)
1397 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST)));
1398 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST)));
1399 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST)));
1404 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx)
1406 de::MovePtr<tcu::TestCaseGroup> infoTests (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
1409 de::MovePtr<tcu::TestCaseGroup> instanceInfoTests (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests"));
1411 addFunctionCase(instanceInfoTests.get(), "physical_devices", "Physical devices", enumeratePhysicalDevices);
1412 addFunctionCase(instanceInfoTests.get(), "layers", "Layers", enumerateInstanceLayers);
1413 addFunctionCase(instanceInfoTests.get(), "extensions", "Extensions", enumerateInstanceExtensions);
1415 infoTests->addChild(instanceInfoTests.release());
1419 de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests"));
1421 addFunctionCase(deviceInfoTests.get(), "features", "Device Features", deviceFeatures);
1422 addFunctionCase(deviceInfoTests.get(), "properties", "Device Properties", deviceProperties);
1423 addFunctionCase(deviceInfoTests.get(), "queue_family_properties", "Queue family properties", deviceQueueFamilyProperties);
1424 addFunctionCase(deviceInfoTests.get(), "memory_properties", "Memory properties", deviceMemoryProperties);
1425 addFunctionCase(deviceInfoTests.get(), "layers", "Layers", enumerateDeviceLayers);
1426 addFunctionCase(deviceInfoTests.get(), "extensions", "Extensions", enumerateDeviceExtensions);
1428 infoTests->addChild(deviceInfoTests.release());
1431 infoTests->addChild(createTestGroup(testCtx, "format_properties", "VkGetPhysicalDeviceFormatProperties() Tests", createFormatTests));
1432 infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests", createImageFormatTests));
1434 return infoTests.release();