1 /*------------------------------------------------------------------------- 2 * Vulkan Conformance Tests 3 * ------------------------ 4 * 5 * Copyright (c) 2015 Google Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * 19 *//*! 20 * \file 21 * \brief Api Feature Query tests 22 *//*--------------------------------------------------------------------*/ 23 24 #include "vktApiFeatureInfo.hpp" 25 26 #include "vktTestCaseUtil.hpp" 27 #include "vktTestGroupUtil.hpp" 28 29 #include "vkPlatform.hpp" 30 #include "vkStrUtil.hpp" 31 #include "vkRef.hpp" 32 #include "vkDeviceUtil.hpp" 33 #include "vkQueryUtil.hpp" 34 #include "vkImageUtil.hpp" 35 #include "vkApiVersion.hpp" 36 37 #include "tcuTestLog.hpp" 38 #include "tcuFormatUtil.hpp" 39 #include "tcuTextureUtil.hpp" 40 #include "tcuResultCollector.hpp" 41 42 #include "deUniquePtr.hpp" 43 #include "deString.h" 44 #include "deStringUtil.hpp" 45 #include "deSTLUtil.hpp" 46 #include "deMemory.h" 47 #include "deMath.h" 48 49 #include <vector> 50 #include <set> 51 #include <string> 52 53 namespace vkt 54 { 55 namespace api 56 { 57 namespace 58 { 59 60 using namespace vk; 61 using std::vector; 62 using std::set; 63 using std::string; 64 using tcu::TestLog; 65 using tcu::ScopedLogSection; 66 67 enum 68 { 69 GUARD_SIZE = 0x20, //!< Number of bytes to check 70 GUARD_VALUE = 0xcd, //!< Data pattern 71 }; 72 73 static const VkDeviceSize MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE = (1LLU<<31); //!< Minimum value for VkImageFormatProperties::maxResourceSize (2GiB) 74 75 enum LimitFormat 76 { 77 LIMIT_FORMAT_SIGNED_INT, 78 LIMIT_FORMAT_UNSIGNED_INT, 79 LIMIT_FORMAT_FLOAT, 80 LIMIT_FORMAT_DEVICE_SIZE, 81 LIMIT_FORMAT_BITMASK, 82 83 LIMIT_FORMAT_LAST 84 }; 85 86 enum LimitType 87 { 88 LIMIT_TYPE_MIN, 89 LIMIT_TYPE_MAX, 90 LIMIT_TYPE_NONE, 91 92 LIMIT_TYPE_LAST 93 }; 94 95 #define LIMIT(_X_) DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_),(char*)(#_X_) 96 #define FEATURE(_X_) DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_) 97 98 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log) 99 { 100 bool limitsOk = true; 101 VkPhysicalDeviceLimits* limits = &properties->limits; 102 struct FeatureLimitTable 103 { 104 deUint32 offset; 105 char* name; 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 110 LimitFormat format; 111 LimitType type; 112 deInt32 unsuppTableNdx; 113 } featureLimitTable[] = //!< From gitlab.khronos.org/vulkan/vulkan.git:doc/specs/vulkan/chapters/features.txt@63b23f3bb3ecd211cd6e448e2001ce1088dacd35 114 { 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, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, 127 { LIMIT(sparseAddressSpaceSize), 0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, 128 { LIMIT(maxBoundDescriptorSets), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 129 { LIMIT(maxPerStageDescriptorSamplers), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 130 { LIMIT(maxPerStageDescriptorUniformBuffers), 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 131 { LIMIT(maxPerStageDescriptorStorageBuffers), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 132 { LIMIT(maxPerStageDescriptorSampledImages), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 133 { LIMIT(maxPerStageDescriptorStorageImages), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 134 { LIMIT(maxPerStageDescriptorInputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 135 { LIMIT(maxPerStageResources), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 }, 136 { LIMIT(maxDescriptorSetSamplers), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 137 { LIMIT(maxDescriptorSetUniformBuffers), 72, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 138 { LIMIT(maxDescriptorSetUniformBuffersDynamic), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 139 { LIMIT(maxDescriptorSetStorageBuffers), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 140 { LIMIT(maxDescriptorSetStorageBuffersDynamic), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 141 { LIMIT(maxDescriptorSetSampledImages), 96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 142 { LIMIT(maxDescriptorSetStorageImages), 24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 143 { LIMIT(maxDescriptorSetInputAttachments), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 }, 144 { LIMIT(maxVertexInputAttributes), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 145 { LIMIT(maxVertexInputBindings), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 146 { LIMIT(maxVertexInputAttributeOffset), 2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 147 { LIMIT(maxVertexInputBindingStride), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 148 { LIMIT(maxVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 149 { LIMIT(maxTessellationGenerationLevel), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 150 { LIMIT(maxTessellationPatchSize), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 151 { LIMIT(maxTessellationControlPerVertexInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 152 { LIMIT(maxTessellationControlPerVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 153 { LIMIT(maxTessellationControlPerPatchOutputComponents), 120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 154 { LIMIT(maxTessellationControlTotalOutputComponents), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 155 { LIMIT(maxTessellationEvaluationInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 156 { LIMIT(maxTessellationEvaluationOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 157 { LIMIT(maxGeometryShaderInvocations), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 158 { LIMIT(maxGeometryInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 159 { LIMIT(maxGeometryOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 160 { LIMIT(maxGeometryOutputVertices), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 161 { LIMIT(maxGeometryTotalOutputComponents), 1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 162 { LIMIT(maxFragmentInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 163 { LIMIT(maxFragmentOutputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 164 { LIMIT(maxFragmentDualSrcAttachments), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 165 { LIMIT(maxFragmentCombinedOutputResources), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 166 { LIMIT(maxComputeSharedMemorySize), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 167 { LIMIT(maxComputeWorkGroupCount[0]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 168 { LIMIT(maxComputeWorkGroupCount[1]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 169 { LIMIT(maxComputeWorkGroupCount[2]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 170 { LIMIT(maxComputeWorkGroupInvocations), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 171 { LIMIT(maxComputeWorkGroupSize[0]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 172 { LIMIT(maxComputeWorkGroupSize[1]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 173 { LIMIT(maxComputeWorkGroupSize[2]), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 174 { LIMIT(subPixelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 175 { LIMIT(subTexelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 176 { LIMIT(mipmapPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 177 { LIMIT(maxDrawIndexedIndexValue), (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 178 { LIMIT(maxDrawIndirectCount), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 179 { LIMIT(maxSamplerLodBias), 0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 180 { LIMIT(maxSamplerAnisotropy), 0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 181 { LIMIT(maxViewports), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 182 { LIMIT(maxViewportDimensions[0]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 183 { LIMIT(maxViewportDimensions[1]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, 184 { LIMIT(viewportBoundsRange[0]), 0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 185 { LIMIT(viewportBoundsRange[1]), 0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 186 { LIMIT(viewportSubPixelBits), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 187 { LIMIT(minMemoryMapAlignment), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 188 { LIMIT(minTexelBufferOffsetAlignment), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX, -1 }, 189 { LIMIT(minUniformBufferOffsetAlignment), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX, -1 }, 190 { LIMIT(minStorageBufferOffsetAlignment), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MAX, -1 }, 191 { LIMIT(minTexelOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 }, 192 { LIMIT(maxTexelOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 193 { LIMIT(minTexelGatherOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 }, 194 { LIMIT(maxTexelGatherOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 195 { LIMIT(minInterpolationOffset), 0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 196 { LIMIT(maxInterpolationOffset), 0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 197 { LIMIT(subPixelInterpolationOffsetBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 198 { LIMIT(maxFramebufferWidth), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 199 { LIMIT(maxFramebufferHeight), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 200 { LIMIT(maxFramebufferLayers), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 201 { LIMIT(framebufferColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 202 { LIMIT(framebufferDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 203 { LIMIT(framebufferStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 204 { LIMIT(framebufferNoAttachmentsSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 205 { LIMIT(maxColorAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 206 { LIMIT(sampledImageColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 207 { LIMIT(sampledImageIntegerSampleCounts), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 208 { LIMIT(sampledImageDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 209 { LIMIT(sampledImageStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 210 { LIMIT(storageImageSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, 211 { LIMIT(maxSampleMaskWords), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 212 { LIMIT(timestampComputeAndGraphics), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, 213 { LIMIT(timestampPeriod), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, 214 { LIMIT(maxClipDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 215 { LIMIT(maxCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 216 { LIMIT(maxCombinedClipAndCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, 217 { LIMIT(discreteQueuePriorities), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, 218 { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 219 { LIMIT(pointSizeRange[1]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 220 { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 221 { LIMIT(pointSizeRange[1]), 0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 222 { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 223 { LIMIT(lineWidthRange[1]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 224 { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 225 { LIMIT(lineWidthRange[1]), 0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, 226 { LIMIT(pointSizeGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 227 { LIMIT(lineWidthGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, 228 { LIMIT(strictLines), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_NONE, -1 }, 229 { LIMIT(standardSampleLocations), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_NONE, -1 }, 230 { LIMIT(optimalBufferCopyOffsetAlignment), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_NONE, -1 }, 231 { LIMIT(optimalBufferCopyRowPitchAlignment), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_NONE, -1 }, 232 { LIMIT(nonCoherentAtomSize), 0, 0, 128, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, 233 }; 234 235 struct UnsupportedFeatureLimitTable 236 { 237 deUint32 limitOffset; 238 char* name; 239 deUint32 featureOffset; 240 deUint32 uintVal; //!< Format is UNSIGNED_INT 241 deInt32 intVal; //!< Format is SIGNED_INT 242 deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE 243 float floatVal; //!< Format is FLOAT 244 } unsupportedFeatureTable[] = 245 { 246 { LIMIT(sparseAddressSpaceSize), FEATURE(sparseBinding), 0, 0, 0, 0.0f }, 247 { LIMIT(maxTessellationGenerationLevel), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 248 { LIMIT(maxTessellationPatchSize), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 249 { LIMIT(maxTessellationControlPerVertexInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 250 { LIMIT(maxTessellationControlPerVertexOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 251 { LIMIT(maxTessellationControlPerPatchOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 252 { LIMIT(maxTessellationControlTotalOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 253 { LIMIT(maxTessellationEvaluationInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 254 { LIMIT(maxTessellationEvaluationOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, 255 { LIMIT(maxGeometryShaderInvocations), FEATURE(geometryShader), 0, 0, 0, 0.0f }, 256 { LIMIT(maxGeometryInputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f }, 257 { LIMIT(maxGeometryOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f }, 258 { LIMIT(maxGeometryOutputVertices), FEATURE(geometryShader), 0, 0, 0, 0.0f }, 259 { LIMIT(maxGeometryTotalOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f }, 260 { LIMIT(maxFragmentDualSrcAttachments), FEATURE(dualSrcBlend), 0, 0, 0, 0.0f }, 261 { LIMIT(maxDrawIndexedIndexValue), FEATURE(fullDrawIndexUint32), (1<<24)-1, 0, 0, 0.0f }, 262 { LIMIT(maxDrawIndirectCount), FEATURE(multiDrawIndirect), 1, 0, 0, 0.0f }, 263 { LIMIT(maxSamplerAnisotropy), FEATURE(samplerAnisotropy), 1, 0, 0, 0.0f }, 264 { LIMIT(maxViewports), FEATURE(multiViewport), 1, 0, 0, 0.0f }, 265 { LIMIT(minTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f }, 266 { LIMIT(maxTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f }, 267 { LIMIT(minInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f }, 268 { LIMIT(maxInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f }, 269 { LIMIT(subPixelInterpolationOffsetBits), FEATURE(sampleRateShading), 0, 0, 0, 0.0f }, 270 { LIMIT(storageImageSampleCounts), FEATURE(shaderStorageImageMultisample), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f }, 271 { LIMIT(maxClipDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f }, 272 { LIMIT(maxCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f }, 273 { LIMIT(maxCombinedClipAndCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f }, 274 { LIMIT(pointSizeRange[0]), FEATURE(largePoints), 0, 0, 0, 1.0f }, 275 { LIMIT(pointSizeRange[1]), FEATURE(largePoints), 0, 0, 0, 1.0f }, 276 { LIMIT(lineWidthRange[0]), FEATURE(wideLines), 0, 0, 0, 1.0f }, 277 { LIMIT(lineWidthRange[1]), FEATURE(wideLines), 0, 0, 0, 1.0f }, 278 { LIMIT(pointSizeGranularity), FEATURE(largePoints), 0, 0, 0, 0.0f }, 279 { LIMIT(lineWidthGranularity), FEATURE(wideLines), 0, 0, 0, 0.0f } 280 }; 281 282 log << TestLog::Message << *limits << TestLog::EndMessage; 283 284 //!< First build a map from limit to unsupported table index 285 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++) 286 { 287 for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++) 288 { 289 if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset) 290 { 291 featureLimitTable[ndx].unsuppTableNdx = unsuppNdx; 292 break; 293 } 294 } 295 } 296 297 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++) 298 { 299 switch (featureLimitTable[ndx].format) 300 { 301 case LIMIT_FORMAT_UNSIGNED_INT: 302 { 303 deUint32 limitToCheck = featureLimitTable[ndx].uintVal; 304 if (featureLimitTable[ndx].unsuppTableNdx != -1) 305 { 306 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) 307 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal; 308 } 309 310 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) 311 { 312 313 if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) 314 { 315 log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name 316 << " not valid-limit type MIN - actual is " 317 << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 318 limitsOk = false; 319 } 320 } 321 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) 322 { 323 if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) 324 { 325 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 326 << " not valid-limit type MAX - actual is " 327 << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 328 limitsOk = false; 329 } 330 } 331 break; 332 } 333 334 case LIMIT_FORMAT_FLOAT: 335 { 336 float limitToCheck = featureLimitTable[ndx].floatVal; 337 if (featureLimitTable[ndx].unsuppTableNdx != -1) 338 { 339 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) 340 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal; 341 } 342 343 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) 344 { 345 if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) 346 { 347 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 348 << " not valid-limit type MIN - actual is " 349 << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 350 limitsOk = false; 351 } 352 } 353 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) 354 { 355 if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) 356 { 357 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 358 << " not valid-limit type MAX actual is " 359 << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 360 limitsOk = false; 361 } 362 } 363 break; 364 } 365 366 case LIMIT_FORMAT_SIGNED_INT: 367 { 368 deInt32 limitToCheck = featureLimitTable[ndx].intVal; 369 if (featureLimitTable[ndx].unsuppTableNdx != -1) 370 { 371 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) 372 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal; 373 } 374 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) 375 { 376 if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) 377 { 378 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 379 << " not valid-limit type MIN actual is " 380 << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 381 limitsOk = false; 382 } 383 } 384 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) 385 { 386 if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) 387 { 388 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 389 << " not valid-limit type MAX actual is " 390 << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 391 limitsOk = false; 392 } 393 } 394 break; 395 } 396 397 case LIMIT_FORMAT_DEVICE_SIZE: 398 { 399 deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal; 400 if (featureLimitTable[ndx].unsuppTableNdx != -1) 401 { 402 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) 403 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal; 404 } 405 406 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) 407 { 408 if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) 409 { 410 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 411 << " not valid-limit type MIN actual is " 412 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 413 limitsOk = false; 414 } 415 } 416 else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) 417 { 418 if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) 419 { 420 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 421 << " not valid-limit type MAX actual is " 422 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 423 limitsOk = false; 424 } 425 } 426 break; 427 } 428 429 case LIMIT_FORMAT_BITMASK: 430 { 431 deUint32 limitToCheck = featureLimitTable[ndx].uintVal; 432 if (featureLimitTable[ndx].unsuppTableNdx != -1) 433 { 434 if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) 435 limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal; 436 } 437 438 if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) 439 { 440 if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck) 441 { 442 log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name 443 << " not valid-limit type bitmask actual is " 444 << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; 445 limitsOk = false; 446 } 447 } 448 break; 449 } 450 451 default: 452 DE_ASSERT(0); 453 limitsOk = false; 454 } 455 } 456 457 for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits->maxViewportDimensions); ndx++) 458 { 459 if (limits->maxImageDimension2D > limits->maxViewportDimensions[ndx]) 460 { 461 log << TestLog::Message << "limit validation failed, maxImageDimension2D of " << limits->maxImageDimension2D 462 << "is larger than maxViewportDimension[" << ndx << "] of " << limits->maxViewportDimensions[ndx] << TestLog::EndMessage; 463 limitsOk = false; 464 } 465 } 466 467 if (limits->viewportBoundsRange[0] > -2 * limits->maxViewportDimensions[0]) 468 { 469 log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0] 470 << "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage; 471 limitsOk = false; 472 } 473 474 if (limits->viewportBoundsRange[1] < 2 * limits->maxViewportDimensions[1] - 1) 475 { 476 log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1] 477 << "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage; 478 limitsOk = false; 479 } 480 481 return limitsOk; 482 } 483 484 tcu::TestStatus enumeratePhysicalDevices (Context& context) 485 { 486 TestLog& log = context.getTestContext().getLog(); 487 const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance()); 488 489 log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size())); 490 491 for (size_t ndx = 0; ndx < devices.size(); ndx++) 492 log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage; 493 494 return tcu::TestStatus::pass("Enumerating devices succeeded"); 495 } 496 497 template<typename T> 498 void collectDuplicates (set<T>& duplicates, const vector<T>& values) 499 { 500 set<T> seen; 501 502 for (size_t ndx = 0; ndx < values.size(); ndx++) 503 { 504 const T& value = values[ndx]; 505 506 if (!seen.insert(value).second) 507 duplicates.insert(value); 508 } 509 } 510 511 bool checkDuplicates (TestLog& log, const char* what, const vector<string>& values) 512 { 513 set<string> duplicates; 514 515 collectDuplicates(duplicates, values); 516 517 if (duplicates.empty()) 518 { 519 return true; 520 } 521 else 522 { 523 for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter) 524 log << TestLog::Message << "Duplicate " << what << ": " << *iter << TestLog::EndMessage; 525 526 return false; 527 } 528 } 529 530 bool checkDuplicateExtensions (TestLog& log, const vector<string>& extensions) 531 { 532 return checkDuplicates(log, "extension", extensions); 533 } 534 535 bool checkDuplicateLayers (TestLog& log, const vector<string>& layers) 536 { 537 return checkDuplicates(log, "layer", layers); 538 } 539 540 tcu::TestStatus enumerateInstanceLayers (Context& context) 541 { 542 TestLog& log = context.getTestContext().getLog(); 543 const vector<VkLayerProperties> properties = enumerateInstanceLayerProperties(context.getPlatformInterface()); 544 vector<string> layerNames; 545 546 for (size_t ndx = 0; ndx < properties.size(); ndx++) 547 { 548 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; 549 550 layerNames.push_back(properties[ndx].layerName); 551 } 552 553 if (checkDuplicateLayers(log, layerNames)) 554 return tcu::TestStatus::pass("Enumerating layers succeeded"); 555 else 556 return tcu::TestStatus::fail("Duplicate layers"); 557 } 558 559 tcu::TestStatus enumerateInstanceExtensions (Context& context) 560 { 561 TestLog& log = context.getTestContext().getLog(); 562 bool hasDuplicateExtensions = false; 563 564 { 565 const ScopedLogSection section (log, "Global", "Global Extensions"); 566 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL); 567 vector<string> extensionNames; 568 569 for (size_t ndx = 0; ndx < properties.size(); ndx++) 570 { 571 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; 572 573 extensionNames.push_back(properties[ndx].extensionName); 574 } 575 576 if (!checkDuplicateExtensions(log, extensionNames)) 577 hasDuplicateExtensions = true; 578 } 579 580 { 581 const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface()); 582 583 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) 584 { 585 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName); 586 const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName); 587 vector<string> extensionNames; 588 589 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++) 590 { 591 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage; 592 593 extensionNames.push_back(properties[extNdx].extensionName); 594 } 595 596 if (!checkDuplicateExtensions(log, extensionNames)) 597 hasDuplicateExtensions = true; 598 } 599 } 600 601 if (hasDuplicateExtensions) 602 return tcu::TestStatus::fail("Duplicate extensions"); 603 else 604 return tcu::TestStatus::pass("Enumerating extensions succeeded"); 605 } 606 607 tcu::TestStatus enumerateDeviceLayers (Context& context) 608 { 609 TestLog& log = context.getTestContext().getLog(); 610 const vector<VkLayerProperties> properties = vk::enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice()); 611 vector<string> layerNames; 612 613 for (size_t ndx = 0; ndx < properties.size(); ndx++) 614 { 615 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; 616 617 layerNames.push_back(properties[ndx].layerName); 618 } 619 620 if (checkDuplicateLayers(log, layerNames)) 621 return tcu::TestStatus::pass("Enumerating layers succeeded"); 622 else 623 return tcu::TestStatus::fail("Duplicate layers"); 624 } 625 626 tcu::TestStatus enumerateDeviceExtensions (Context& context) 627 { 628 TestLog& log = context.getTestContext().getLog(); 629 bool hasDuplicateExtensions = false; 630 631 { 632 const ScopedLogSection section (log, "Global", "Global Extensions"); 633 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL); 634 vector<string> extensionNames; 635 636 for (size_t ndx = 0; ndx < properties.size(); ndx++) 637 { 638 log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; 639 640 extensionNames.push_back(properties[ndx].extensionName); 641 } 642 643 if (!checkDuplicateExtensions(log, extensionNames)) 644 hasDuplicateExtensions = true; 645 } 646 647 { 648 const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice()); 649 650 for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) 651 { 652 const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName); 653 const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName); 654 vector<string> extensionNames; 655 656 for (size_t extNdx = 0; extNdx < properties.size(); extNdx++) 657 { 658 log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage; 659 660 661 extensionNames.push_back(properties[extNdx].extensionName); 662 } 663 664 if (!checkDuplicateExtensions(log, extensionNames)) 665 hasDuplicateExtensions = true; 666 } 667 } 668 669 if (hasDuplicateExtensions) 670 return tcu::TestStatus::fail("Duplicate extensions"); 671 else 672 return tcu::TestStatus::pass("Enumerating extensions succeeded"); 673 } 674 675 #define VK_SIZE_OF(STRUCT, MEMBER) (sizeof(((STRUCT*)0)->MEMBER)) 676 #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER) { DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) } 677 678 tcu::TestStatus deviceFeatures (Context& context) 679 { 680 TestLog& log = context.getTestContext().getLog(); 681 VkPhysicalDeviceFeatures* features; 682 deUint8 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE]; 683 684 const QueryMemberTableEntry featureOffsetTable[] = 685 { 686 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess), 687 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32), 688 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray), 689 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend), 690 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader), 691 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader), 692 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading), 693 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend), 694 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp), 695 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect), 696 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance), 697 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp), 698 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp), 699 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid), 700 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds), 701 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines), 702 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints), 703 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne), 704 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport), 705 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy), 706 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2), 707 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR), 708 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC), 709 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise), 710 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery), 711 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics), 712 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics), 713 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize), 714 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended), 715 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats), 716 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample), 717 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat), 718 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat), 719 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing), 720 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing), 721 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing), 722 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing), 723 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance), 724 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance), 725 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64), 726 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64), 727 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16), 728 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency), 729 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod), 730 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding), 731 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer), 732 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D), 733 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D), 734 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples), 735 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples), 736 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples), 737 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples), 738 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased), 739 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate), 740 OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries), 741 { 0, 0 } 742 }; 743 744 745 deMemset(buffer, GUARD_VALUE, sizeof(buffer)); 746 features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer); 747 748 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features); 749 750 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage 751 << TestLog::Message << *features << TestLog::EndMessage; 752 753 if (!features->robustBufferAccess) 754 return tcu::TestStatus::fail("robustBufferAccess is not supported"); 755 756 for (int ndx = 0; ndx < GUARD_SIZE; ndx++) 757 { 758 if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE) 759 { 760 log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage; 761 return tcu::TestStatus::fail("deviceFeatures buffer overflow"); 762 } 763 } 764 765 if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable)) 766 { 767 log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage; 768 return tcu::TestStatus::fail("deviceFeatures incomplete initialization"); 769 } 770 771 772 return tcu::TestStatus::pass("Query succeeded"); 773 } 774 775 tcu::TestStatus deviceProperties (Context& context) 776 { 777 TestLog& log = context.getTestContext().getLog(); 778 VkPhysicalDeviceProperties* props; 779 VkPhysicalDeviceFeatures features; 780 deUint8 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE]; 781 782 const QueryMemberTableEntry physicalDevicePropertiesOffsetTable[] = 783 { 784 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion), 785 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion), 786 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID), 787 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID), 788 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType), 789 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID), 790 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D), 791 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D), 792 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D), 793 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube), 794 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers), 795 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements), 796 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange), 797 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange), 798 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize), 799 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount), 800 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount), 801 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity), 802 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize), 803 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets), 804 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers), 805 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers), 806 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers), 807 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages), 808 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages), 809 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments), 810 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources), 811 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers), 812 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers), 813 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic), 814 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers), 815 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic), 816 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages), 817 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages), 818 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments), 819 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes), 820 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings), 821 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset), 822 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride), 823 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents), 824 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel), 825 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize), 826 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents), 827 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents), 828 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents), 829 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents), 830 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents), 831 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents), 832 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations), 833 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents), 834 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents), 835 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices), 836 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents), 837 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents), 838 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments), 839 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments), 840 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources), 841 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize), 842 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]), 843 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations), 844 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]), 845 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits), 846 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits), 847 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits), 848 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue), 849 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount), 850 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias), 851 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy), 852 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports), 853 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]), 854 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]), 855 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits), 856 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment), 857 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment), 858 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment), 859 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment), 860 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset), 861 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset), 862 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset), 863 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset), 864 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset), 865 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset), 866 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits), 867 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth), 868 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight), 869 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers), 870 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts), 871 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts), 872 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts), 873 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts), 874 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments), 875 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts), 876 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts), 877 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts), 878 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts), 879 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts), 880 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords), 881 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics), 882 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod), 883 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances), 884 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances), 885 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances), 886 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities), 887 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]), 888 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]), 889 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity), 890 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity), 891 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines), 892 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations), 893 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment), 894 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment), 895 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize), 896 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape), 897 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape), 898 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape), 899 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize), 900 OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict), 901 { 0, 0 } 902 }; 903 904 props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer); 905 deMemset(props, GUARD_VALUE, sizeof(buffer)); 906 907 context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props); 908 context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features); 909 910 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage 911 << TestLog::Message << *props << TestLog::EndMessage; 912 913 if (!validateFeatureLimits(props, &features, log)) 914 return tcu::TestStatus::fail("deviceProperties - feature limits failed"); 915 916 for (int ndx = 0; ndx < GUARD_SIZE; ndx++) 917 { 918 if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE) 919 { 920 log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage; 921 return tcu::TestStatus::fail("deviceProperties buffer overflow"); 922 } 923 } 924 925 if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), physicalDevicePropertiesOffsetTable)) 926 { 927 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage; 928 return tcu::TestStatus::fail("deviceProperties incomplete initialization"); 929 } 930 931 // Check if deviceName string is properly terminated. 932 if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) 933 { 934 log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage; 935 return tcu::TestStatus::fail("deviceProperties incomplete initialization"); 936 } 937 938 { 939 const ApiVersion deviceVersion = unpackVersion(props->apiVersion); 940 const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION); 941 942 if (deviceVersion.majorNum != deqpVersion.majorNum) 943 { 944 log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage; 945 return tcu::TestStatus::fail("deviceProperties apiVersion not valid"); 946 } 947 948 if (deviceVersion.minorNum > deqpVersion.minorNum) 949 { 950 log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage; 951 return tcu::TestStatus::fail("deviceProperties apiVersion not valid"); 952 } 953 } 954 955 return tcu::TestStatus::pass("DeviceProperites query succeeded"); 956 } 957 958 tcu::TestStatus deviceQueueFamilyProperties (Context& context) 959 { 960 TestLog& log = context.getTestContext().getLog(); 961 const vector<VkQueueFamilyProperties> queueProperties = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice()); 962 963 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage; 964 965 for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++) 966 log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage; 967 968 return tcu::TestStatus::pass("Querying queue properties succeeded"); 969 } 970 971 tcu::TestStatus deviceMemoryProperties (Context& context) 972 { 973 TestLog& log = context.getTestContext().getLog(); 974 VkPhysicalDeviceMemoryProperties* memProps; 975 deUint8 buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE]; 976 977 memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer); 978 deMemset(buffer, GUARD_VALUE, sizeof(buffer)); 979 980 context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps); 981 982 log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage 983 << TestLog::Message << *memProps << TestLog::EndMessage; 984 985 for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++) 986 { 987 if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE) 988 { 989 log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage; 990 return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow"); 991 } 992 } 993 994 if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS) 995 { 996 log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage; 997 return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large"); 998 } 999 1000 if (memProps->memoryHeapCount == 1) 1001 { 1002 if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0) 1003 { 1004 log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage; 1005 return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags"); 1006 } 1007 } 1008 1009 const VkMemoryPropertyFlags validPropertyFlags[] = 1010 { 1011 0, 1012 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 1013 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 1014 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT, 1015 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 1016 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 1017 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT, 1018 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 1019 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT 1020 }; 1021 1022 const VkMemoryPropertyFlags requiredPropertyFlags[] = 1023 { 1024 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT 1025 }; 1026 1027 bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)]; 1028 std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false); 1029 1030 for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++) 1031 { 1032 bool validPropTypeFound = false; 1033 1034 if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount) 1035 { 1036 log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage; 1037 return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex"); 1038 } 1039 1040 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; 1041 1042 for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++) 1043 if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator) 1044 requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true; 1045 1046 if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck)) 1047 validPropTypeFound = true; 1048 1049 if (!validPropTypeFound) 1050 { 1051 log << TestLog::Message << "deviceMemoryProperties - propertyFlags " 1052 << memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage; 1053 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid"); 1054 } 1055 1056 if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) 1057 { 1058 if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0) 1059 { 1060 log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage; 1061 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags"); 1062 } 1063 } 1064 else 1065 { 1066 if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) 1067 { 1068 log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage; 1069 return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags"); 1070 } 1071 } 1072 } 1073 1074 bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false); 1075 if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound)) 1076 { 1077 DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags)); 1078 log << TestLog::Message << "deviceMemoryProperties - required property flags " 1079 << getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage; 1080 1081 return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid"); 1082 } 1083 1084 return tcu::TestStatus::pass("Querying memory properties succeeded"); 1085 } 1086 1087 // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead 1088 1089 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format) 1090 { 1091 static const VkFormat s_requiredSampledImageBlitSrcFormats[] = 1092 { 1093 VK_FORMAT_B4G4R4A4_UNORM_PACK16, 1094 VK_FORMAT_R5G6B5_UNORM_PACK16, 1095 VK_FORMAT_A1R5G5B5_UNORM_PACK16, 1096 VK_FORMAT_R8_UNORM, 1097 VK_FORMAT_R8_SNORM, 1098 VK_FORMAT_R8_UINT, 1099 VK_FORMAT_R8_SINT, 1100 VK_FORMAT_R8G8_UNORM, 1101 VK_FORMAT_R8G8_SNORM, 1102 VK_FORMAT_R8G8_UINT, 1103 VK_FORMAT_R8G8_SINT, 1104 VK_FORMAT_R8G8B8A8_UNORM, 1105 VK_FORMAT_R8G8B8A8_SNORM, 1106 VK_FORMAT_R8G8B8A8_UINT, 1107 VK_FORMAT_R8G8B8A8_SINT, 1108 VK_FORMAT_R8G8B8A8_SRGB, 1109 VK_FORMAT_B8G8R8A8_UNORM, 1110 VK_FORMAT_B8G8R8A8_SRGB, 1111 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1112 VK_FORMAT_A8B8G8R8_SNORM_PACK32, 1113 VK_FORMAT_A8B8G8R8_UINT_PACK32, 1114 VK_FORMAT_A8B8G8R8_SINT_PACK32, 1115 VK_FORMAT_A8B8G8R8_SRGB_PACK32, 1116 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 1117 VK_FORMAT_A2B10G10R10_UINT_PACK32, 1118 VK_FORMAT_R16_UINT, 1119 VK_FORMAT_R16_SINT, 1120 VK_FORMAT_R16_SFLOAT, 1121 VK_FORMAT_R16G16_UINT, 1122 VK_FORMAT_R16G16_SINT, 1123 VK_FORMAT_R16G16_SFLOAT, 1124 VK_FORMAT_R16G16B16A16_UINT, 1125 VK_FORMAT_R16G16B16A16_SINT, 1126 VK_FORMAT_R16G16B16A16_SFLOAT, 1127 VK_FORMAT_R32_UINT, 1128 VK_FORMAT_R32_SINT, 1129 VK_FORMAT_R32_SFLOAT, 1130 VK_FORMAT_R32G32_UINT, 1131 VK_FORMAT_R32G32_SINT, 1132 VK_FORMAT_R32G32_SFLOAT, 1133 VK_FORMAT_R32G32B32A32_UINT, 1134 VK_FORMAT_R32G32B32A32_SINT, 1135 VK_FORMAT_R32G32B32A32_SFLOAT, 1136 VK_FORMAT_B10G11R11_UFLOAT_PACK32, 1137 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, 1138 VK_FORMAT_D16_UNORM, 1139 VK_FORMAT_D32_SFLOAT 1140 }; 1141 static const VkFormat s_requiredSampledImageFilterLinearFormats[] = 1142 { 1143 VK_FORMAT_B4G4R4A4_UNORM_PACK16, 1144 VK_FORMAT_R5G6B5_UNORM_PACK16, 1145 VK_FORMAT_A1R5G5B5_UNORM_PACK16, 1146 VK_FORMAT_R8_UNORM, 1147 VK_FORMAT_R8_SNORM, 1148 VK_FORMAT_R8G8_UNORM, 1149 VK_FORMAT_R8G8_SNORM, 1150 VK_FORMAT_R8G8B8A8_UNORM, 1151 VK_FORMAT_R8G8B8A8_SNORM, 1152 VK_FORMAT_R8G8B8A8_SRGB, 1153 VK_FORMAT_B8G8R8A8_UNORM, 1154 VK_FORMAT_B8G8R8A8_SRGB, 1155 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1156 VK_FORMAT_A8B8G8R8_SNORM_PACK32, 1157 VK_FORMAT_A8B8G8R8_SRGB_PACK32, 1158 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 1159 VK_FORMAT_R16_SFLOAT, 1160 VK_FORMAT_R16G16_SFLOAT, 1161 VK_FORMAT_R16G16B16A16_SFLOAT, 1162 VK_FORMAT_B10G11R11_UFLOAT_PACK32, 1163 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, 1164 }; 1165 static const VkFormat s_requiredStorageImageFormats[] = 1166 { 1167 VK_FORMAT_R8G8B8A8_UNORM, 1168 VK_FORMAT_R8G8B8A8_SNORM, 1169 VK_FORMAT_R8G8B8A8_UINT, 1170 VK_FORMAT_R8G8B8A8_SINT, 1171 VK_FORMAT_R16G16B16A16_UINT, 1172 VK_FORMAT_R16G16B16A16_SINT, 1173 VK_FORMAT_R16G16B16A16_SFLOAT, 1174 VK_FORMAT_R32_UINT, 1175 VK_FORMAT_R32_SINT, 1176 VK_FORMAT_R32_SFLOAT, 1177 VK_FORMAT_R32G32_UINT, 1178 VK_FORMAT_R32G32_SINT, 1179 VK_FORMAT_R32G32_SFLOAT, 1180 VK_FORMAT_R32G32B32A32_UINT, 1181 VK_FORMAT_R32G32B32A32_SINT, 1182 VK_FORMAT_R32G32B32A32_SFLOAT 1183 }; 1184 static const VkFormat s_requiredStorageImageAtomicFormats[] = 1185 { 1186 VK_FORMAT_R32_UINT, 1187 VK_FORMAT_R32_SINT 1188 }; 1189 static const VkFormat s_requiredColorAttachmentBlitDstFormats[] = 1190 { 1191 VK_FORMAT_R5G6B5_UNORM_PACK16, 1192 VK_FORMAT_A1R5G5B5_UNORM_PACK16, 1193 VK_FORMAT_R8_UNORM, 1194 VK_FORMAT_R8_UINT, 1195 VK_FORMAT_R8_SINT, 1196 VK_FORMAT_R8G8_UNORM, 1197 VK_FORMAT_R8G8_UINT, 1198 VK_FORMAT_R8G8_SINT, 1199 VK_FORMAT_R8G8B8A8_UNORM, 1200 VK_FORMAT_R8G8B8A8_UINT, 1201 VK_FORMAT_R8G8B8A8_SINT, 1202 VK_FORMAT_R8G8B8A8_SRGB, 1203 VK_FORMAT_B8G8R8A8_UNORM, 1204 VK_FORMAT_B8G8R8A8_SRGB, 1205 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1206 VK_FORMAT_A8B8G8R8_UINT_PACK32, 1207 VK_FORMAT_A8B8G8R8_SINT_PACK32, 1208 VK_FORMAT_A8B8G8R8_SRGB_PACK32, 1209 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 1210 VK_FORMAT_A2B10G10R10_UINT_PACK32, 1211 VK_FORMAT_R16_UINT, 1212 VK_FORMAT_R16_SINT, 1213 VK_FORMAT_R16_SFLOAT, 1214 VK_FORMAT_R16G16_UINT, 1215 VK_FORMAT_R16G16_SINT, 1216 VK_FORMAT_R16G16_SFLOAT, 1217 VK_FORMAT_R16G16B16A16_UINT, 1218 VK_FORMAT_R16G16B16A16_SINT, 1219 VK_FORMAT_R16G16B16A16_SFLOAT, 1220 VK_FORMAT_R32_UINT, 1221 VK_FORMAT_R32_SINT, 1222 VK_FORMAT_R32_SFLOAT, 1223 VK_FORMAT_R32G32_UINT, 1224 VK_FORMAT_R32G32_SINT, 1225 VK_FORMAT_R32G32_SFLOAT, 1226 VK_FORMAT_R32G32B32A32_UINT, 1227 VK_FORMAT_R32G32B32A32_SINT, 1228 VK_FORMAT_R32G32B32A32_SFLOAT 1229 }; 1230 static const VkFormat s_requiredColorAttachmentBlendFormats[] = 1231 { 1232 VK_FORMAT_R5G6B5_UNORM_PACK16, 1233 VK_FORMAT_A1R5G5B5_UNORM_PACK16, 1234 VK_FORMAT_R8_UNORM, 1235 VK_FORMAT_R8G8_UNORM, 1236 VK_FORMAT_R8G8B8A8_UNORM, 1237 VK_FORMAT_R8G8B8A8_SRGB, 1238 VK_FORMAT_B8G8R8A8_UNORM, 1239 VK_FORMAT_B8G8R8A8_SRGB, 1240 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1241 VK_FORMAT_A8B8G8R8_SRGB_PACK32, 1242 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 1243 VK_FORMAT_R16_SFLOAT, 1244 VK_FORMAT_R16G16_SFLOAT, 1245 VK_FORMAT_R16G16B16A16_SFLOAT 1246 }; 1247 static const VkFormat s_requiredDepthStencilAttachmentFormats[] = 1248 { 1249 VK_FORMAT_D16_UNORM 1250 }; 1251 1252 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0; 1253 1254 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format)) 1255 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT; 1256 1257 if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterLinearFormats), DE_ARRAY_END(s_requiredSampledImageFilterLinearFormats), format)) 1258 flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; 1259 1260 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format)) 1261 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; 1262 1263 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format)) 1264 flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT; 1265 1266 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format)) 1267 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT; 1268 1269 if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format)) 1270 flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; 1271 1272 if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format)) 1273 flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; 1274 1275 return flags; 1276 } 1277 1278 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format) 1279 { 1280 static const VkFormat s_requiredVertexBufferFormats[] = 1281 { 1282 VK_FORMAT_R8_UNORM, 1283 VK_FORMAT_R8_SNORM, 1284 VK_FORMAT_R8_UINT, 1285 VK_FORMAT_R8_SINT, 1286 VK_FORMAT_R8G8_UNORM, 1287 VK_FORMAT_R8G8_SNORM, 1288 VK_FORMAT_R8G8_UINT, 1289 VK_FORMAT_R8G8_SINT, 1290 VK_FORMAT_R8G8B8A8_UNORM, 1291 VK_FORMAT_R8G8B8A8_SNORM, 1292 VK_FORMAT_R8G8B8A8_UINT, 1293 VK_FORMAT_R8G8B8A8_SINT, 1294 VK_FORMAT_B8G8R8A8_UNORM, 1295 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1296 VK_FORMAT_A8B8G8R8_SNORM_PACK32, 1297 VK_FORMAT_A8B8G8R8_UINT_PACK32, 1298 VK_FORMAT_A8B8G8R8_SINT_PACK32, 1299 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 1300 VK_FORMAT_R16_UNORM, 1301 VK_FORMAT_R16_SNORM, 1302 VK_FORMAT_R16_UINT, 1303 VK_FORMAT_R16_SINT, 1304 VK_FORMAT_R16_SFLOAT, 1305 VK_FORMAT_R16G16_UNORM, 1306 VK_FORMAT_R16G16_SNORM, 1307 VK_FORMAT_R16G16_UINT, 1308 VK_FORMAT_R16G16_SINT, 1309 VK_FORMAT_R16G16_SFLOAT, 1310 VK_FORMAT_R16G16B16A16_UNORM, 1311 VK_FORMAT_R16G16B16A16_SNORM, 1312 VK_FORMAT_R16G16B16A16_UINT, 1313 VK_FORMAT_R16G16B16A16_SINT, 1314 VK_FORMAT_R16G16B16A16_SFLOAT, 1315 VK_FORMAT_R32_UINT, 1316 VK_FORMAT_R32_SINT, 1317 VK_FORMAT_R32_SFLOAT, 1318 VK_FORMAT_R32G32_UINT, 1319 VK_FORMAT_R32G32_SINT, 1320 VK_FORMAT_R32G32_SFLOAT, 1321 VK_FORMAT_R32G32B32_UINT, 1322 VK_FORMAT_R32G32B32_SINT, 1323 VK_FORMAT_R32G32B32_SFLOAT, 1324 VK_FORMAT_R32G32B32A32_UINT, 1325 VK_FORMAT_R32G32B32A32_SINT, 1326 VK_FORMAT_R32G32B32A32_SFLOAT 1327 }; 1328 static const VkFormat s_requiredUniformTexelBufferFormats[] = 1329 { 1330 VK_FORMAT_R8_UNORM, 1331 VK_FORMAT_R8_SNORM, 1332 VK_FORMAT_R8_UINT, 1333 VK_FORMAT_R8_SINT, 1334 VK_FORMAT_R8G8_UNORM, 1335 VK_FORMAT_R8G8_SNORM, 1336 VK_FORMAT_R8G8_UINT, 1337 VK_FORMAT_R8G8_SINT, 1338 VK_FORMAT_R8G8B8A8_UNORM, 1339 VK_FORMAT_R8G8B8A8_SNORM, 1340 VK_FORMAT_R8G8B8A8_UINT, 1341 VK_FORMAT_R8G8B8A8_SINT, 1342 VK_FORMAT_B8G8R8A8_UNORM, 1343 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1344 VK_FORMAT_A8B8G8R8_SNORM_PACK32, 1345 VK_FORMAT_A8B8G8R8_UINT_PACK32, 1346 VK_FORMAT_A8B8G8R8_SINT_PACK32, 1347 VK_FORMAT_A2B10G10R10_UNORM_PACK32, 1348 VK_FORMAT_A2B10G10R10_UINT_PACK32, 1349 VK_FORMAT_R16_UINT, 1350 VK_FORMAT_R16_SINT, 1351 VK_FORMAT_R16_SFLOAT, 1352 VK_FORMAT_R16G16_UINT, 1353 VK_FORMAT_R16G16_SINT, 1354 VK_FORMAT_R16G16_SFLOAT, 1355 VK_FORMAT_R16G16B16A16_UINT, 1356 VK_FORMAT_R16G16B16A16_SINT, 1357 VK_FORMAT_R16G16B16A16_SFLOAT, 1358 VK_FORMAT_R32_UINT, 1359 VK_FORMAT_R32_SINT, 1360 VK_FORMAT_R32_SFLOAT, 1361 VK_FORMAT_R32G32_UINT, 1362 VK_FORMAT_R32G32_SINT, 1363 VK_FORMAT_R32G32_SFLOAT, 1364 VK_FORMAT_R32G32B32A32_UINT, 1365 VK_FORMAT_R32G32B32A32_SINT, 1366 VK_FORMAT_R32G32B32A32_SFLOAT, 1367 VK_FORMAT_B10G11R11_UFLOAT_PACK32 1368 }; 1369 static const VkFormat s_requiredStorageTexelBufferFormats[] = 1370 { 1371 VK_FORMAT_R8G8B8A8_UNORM, 1372 VK_FORMAT_R8G8B8A8_SNORM, 1373 VK_FORMAT_R8G8B8A8_UINT, 1374 VK_FORMAT_R8G8B8A8_SINT, 1375 VK_FORMAT_A8B8G8R8_UNORM_PACK32, 1376 VK_FORMAT_A8B8G8R8_SNORM_PACK32, 1377 VK_FORMAT_A8B8G8R8_UINT_PACK32, 1378 VK_FORMAT_A8B8G8R8_SINT_PACK32, 1379 VK_FORMAT_R16G16B16A16_UINT, 1380 VK_FORMAT_R16G16B16A16_SINT, 1381 VK_FORMAT_R16G16B16A16_SFLOAT, 1382 VK_FORMAT_R32_UINT, 1383 VK_FORMAT_R32_SINT, 1384 VK_FORMAT_R32_SFLOAT, 1385 VK_FORMAT_R32G32_UINT, 1386 VK_FORMAT_R32G32_SINT, 1387 VK_FORMAT_R32G32_SFLOAT, 1388 VK_FORMAT_R32G32B32A32_UINT, 1389 VK_FORMAT_R32G32B32A32_SINT, 1390 VK_FORMAT_R32G32B32A32_SFLOAT 1391 }; 1392 static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] = 1393 { 1394 VK_FORMAT_R32_UINT, 1395 VK_FORMAT_R32_SINT 1396 }; 1397 1398 VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0; 1399 1400 if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format)) 1401 flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT; 1402 1403 if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format)) 1404 flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; 1405 1406 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format)) 1407 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT; 1408 1409 if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format)) 1410 flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; 1411 1412 return flags; 1413 } 1414 1415 tcu::TestStatus formatProperties (Context& context, VkFormat format) 1416 { 1417 TestLog& log = context.getTestContext().getLog(); 1418 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); 1419 bool allOk = true; 1420 1421 const struct 1422 { 1423 VkFormatFeatureFlags VkFormatProperties::* field; 1424 const char* fieldName; 1425 VkFormatFeatureFlags requiredFeatures; 1426 } fields[] = 1427 { 1428 { &VkFormatProperties::linearTilingFeatures, "linearTilingFeatures", (VkFormatFeatureFlags)0 }, 1429 { &VkFormatProperties::optimalTilingFeatures, "optimalTilingFeatures", getRequiredOptimalTilingFeatures(format) }, 1430 { &VkFormatProperties::bufferFeatures, "buffeFeatures", getRequiredBufferFeatures(format) } 1431 }; 1432 1433 log << TestLog::Message << properties << TestLog::EndMessage; 1434 1435 for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++) 1436 { 1437 const char* const fieldName = fields[fieldNdx].fieldName; 1438 const VkFormatFeatureFlags supported = properties.*fields[fieldNdx].field; 1439 const VkFormatFeatureFlags required = fields[fieldNdx].requiredFeatures; 1440 1441 if ((supported & required) != required) 1442 { 1443 log << TestLog::Message << "ERROR in " << fieldName << ":\n" 1444 << " required: " << getFormatFeatureFlagsStr(required) << "\n " 1445 << " missing: " << getFormatFeatureFlagsStr(~supported & required) 1446 << TestLog::EndMessage; 1447 allOk = false; 1448 } 1449 } 1450 1451 if (allOk) 1452 return tcu::TestStatus::pass("Query and validation passed"); 1453 else 1454 return tcu::TestStatus::fail("Required features not supported"); 1455 } 1456 1457 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features) 1458 { 1459 const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); 1460 1461 return (properties.optimalTilingFeatures & features) == features; 1462 } 1463 1464 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features) 1465 { 1466 for (const VkFormat* cur = begin; cur != end; ++cur) 1467 { 1468 if (!optimalTilingFeaturesSupported(context, *cur, features)) 1469 return false; 1470 } 1471 1472 return true; 1473 } 1474 1475 tcu::TestStatus testDepthStencilSupported (Context& context) 1476 { 1477 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) && 1478 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) 1479 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT"); 1480 1481 if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) && 1482 !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) 1483 return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT"); 1484 1485 return tcu::TestStatus::pass("Required depth/stencil formats supported"); 1486 } 1487 1488 tcu::TestStatus testCompressedFormatsSupported (Context& context) 1489 { 1490 static const VkFormat s_allBcFormats[] = 1491 { 1492 VK_FORMAT_BC1_RGB_UNORM_BLOCK, 1493 VK_FORMAT_BC1_RGB_SRGB_BLOCK, 1494 VK_FORMAT_BC1_RGBA_UNORM_BLOCK, 1495 VK_FORMAT_BC1_RGBA_SRGB_BLOCK, 1496 VK_FORMAT_BC2_UNORM_BLOCK, 1497 VK_FORMAT_BC2_SRGB_BLOCK, 1498 VK_FORMAT_BC3_UNORM_BLOCK, 1499 VK_FORMAT_BC3_SRGB_BLOCK, 1500 VK_FORMAT_BC4_UNORM_BLOCK, 1501 VK_FORMAT_BC4_SNORM_BLOCK, 1502 VK_FORMAT_BC5_UNORM_BLOCK, 1503 VK_FORMAT_BC5_SNORM_BLOCK, 1504 VK_FORMAT_BC6H_UFLOAT_BLOCK, 1505 VK_FORMAT_BC6H_SFLOAT_BLOCK, 1506 VK_FORMAT_BC7_UNORM_BLOCK, 1507 VK_FORMAT_BC7_SRGB_BLOCK, 1508 }; 1509 static const VkFormat s_allEtc2Formats[] = 1510 { 1511 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, 1512 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, 1513 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, 1514 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK, 1515 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, 1516 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, 1517 VK_FORMAT_EAC_R11_UNORM_BLOCK, 1518 VK_FORMAT_EAC_R11_SNORM_BLOCK, 1519 VK_FORMAT_EAC_R11G11_UNORM_BLOCK, 1520 VK_FORMAT_EAC_R11G11_SNORM_BLOCK, 1521 }; 1522 static const VkFormat s_allAstcLdrFormats[] = 1523 { 1524 VK_FORMAT_ASTC_4x4_UNORM_BLOCK, 1525 VK_FORMAT_ASTC_4x4_SRGB_BLOCK, 1526 VK_FORMAT_ASTC_5x4_UNORM_BLOCK, 1527 VK_FORMAT_ASTC_5x4_SRGB_BLOCK, 1528 VK_FORMAT_ASTC_5x5_UNORM_BLOCK, 1529 VK_FORMAT_ASTC_5x5_SRGB_BLOCK, 1530 VK_FORMAT_ASTC_6x5_UNORM_BLOCK, 1531 VK_FORMAT_ASTC_6x5_SRGB_BLOCK, 1532 VK_FORMAT_ASTC_6x6_UNORM_BLOCK, 1533 VK_FORMAT_ASTC_6x6_SRGB_BLOCK, 1534 VK_FORMAT_ASTC_8x5_UNORM_BLOCK, 1535 VK_FORMAT_ASTC_8x5_SRGB_BLOCK, 1536 VK_FORMAT_ASTC_8x6_UNORM_BLOCK, 1537 VK_FORMAT_ASTC_8x6_SRGB_BLOCK, 1538 VK_FORMAT_ASTC_8x8_UNORM_BLOCK, 1539 VK_FORMAT_ASTC_8x8_SRGB_BLOCK, 1540 VK_FORMAT_ASTC_10x5_UNORM_BLOCK, 1541 VK_FORMAT_ASTC_10x5_SRGB_BLOCK, 1542 VK_FORMAT_ASTC_10x6_UNORM_BLOCK, 1543 VK_FORMAT_ASTC_10x6_SRGB_BLOCK, 1544 VK_FORMAT_ASTC_10x8_UNORM_BLOCK, 1545 VK_FORMAT_ASTC_10x8_SRGB_BLOCK, 1546 VK_FORMAT_ASTC_10x10_UNORM_BLOCK, 1547 VK_FORMAT_ASTC_10x10_SRGB_BLOCK, 1548 VK_FORMAT_ASTC_12x10_UNORM_BLOCK, 1549 VK_FORMAT_ASTC_12x10_SRGB_BLOCK, 1550 VK_FORMAT_ASTC_12x12_UNORM_BLOCK, 1551 VK_FORMAT_ASTC_12x12_SRGB_BLOCK, 1552 }; 1553 1554 static const struct 1555 { 1556 const char* setName; 1557 const char* featureName; 1558 const VkBool32 VkPhysicalDeviceFeatures::* feature; 1559 const VkFormat* formatsBegin; 1560 const VkFormat* formatsEnd; 1561 } s_compressedFormatSets[] = 1562 { 1563 { "BC", "textureCompressionBC", &VkPhysicalDeviceFeatures::textureCompressionBC, DE_ARRAY_BEGIN(s_allBcFormats), DE_ARRAY_END(s_allBcFormats) }, 1564 { "ETC2", "textureCompressionETC2", &VkPhysicalDeviceFeatures::textureCompressionETC2, DE_ARRAY_BEGIN(s_allEtc2Formats), DE_ARRAY_END(s_allEtc2Formats) }, 1565 { "ASTC LDR", "textureCompressionASTC_LDR", &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR, DE_ARRAY_BEGIN(s_allAstcLdrFormats), DE_ARRAY_END(s_allAstcLdrFormats) }, 1566 }; 1567 1568 TestLog& log = context.getTestContext().getLog(); 1569 const VkPhysicalDeviceFeatures& features = context.getDeviceFeatures(); 1570 int numSupportedSets = 0; 1571 int numErrors = 0; 1572 int numWarnings = 0; 1573 1574 for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx) 1575 { 1576 const char* const setName = s_compressedFormatSets[setNdx].setName; 1577 const char* const featureName = s_compressedFormatSets[setNdx].featureName; 1578 const bool featureBitSet = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE; 1579 const bool allSupported = optimalTilingFeaturesSupportedForAll(context, 1580 s_compressedFormatSets[setNdx].formatsBegin, 1581 s_compressedFormatSets[setNdx].formatsEnd, 1582 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); 1583 1584 if (featureBitSet && !allSupported) 1585 { 1586 log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage; 1587 numErrors += 1; 1588 } 1589 else if (allSupported && !featureBitSet) 1590 { 1591 log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage; 1592 numWarnings += 1; 1593 } 1594 1595 if (featureBitSet) 1596 { 1597 log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage; 1598 numSupportedSets += 1; 1599 } 1600 else 1601 log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage; 1602 } 1603 1604 if (numSupportedSets == 0) 1605 { 1606 log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage; 1607 numErrors += 1; 1608 } 1609 1610 if (numErrors > 0) 1611 return tcu::TestStatus::fail("Compressed format support not valid"); 1612 else if (numWarnings > 0) 1613 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support"); 1614 else 1615 return tcu::TestStatus::pass("Compressed texture format support is valid"); 1616 } 1617 1618 void createFormatTests (tcu::TestCaseGroup* testGroup) 1619 { 1620 DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0); 1621 1622 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_FORMAT_LAST; ++formatNdx) 1623 { 1624 const VkFormat format = (VkFormat)formatNdx; 1625 const char* const enumName = getFormatName(format); 1626 const string caseName = de::toLower(string(enumName).substr(10)); 1627 1628 addFunctionCase(testGroup, caseName, enumName, formatProperties, format); 1629 } 1630 1631 addFunctionCase(testGroup, "depth_stencil", "", testDepthStencilSupported); 1632 addFunctionCase(testGroup, "compressed_formats", "", testCompressedFormatsSupported); 1633 } 1634 1635 VkImageUsageFlags getValidImageUsageFlags (VkFormat, VkFormatFeatureFlags supportedFeatures) 1636 { 1637 VkImageUsageFlags flags = (VkImageUsageFlags)0; 1638 1639 // If format is supported at all, it must be valid transfer src+dst 1640 if (supportedFeatures != 0) 1641 flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT; 1642 1643 if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0) 1644 flags |= VK_IMAGE_USAGE_SAMPLED_BIT; 1645 1646 if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0) 1647 flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; 1648 1649 if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) 1650 flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; 1651 1652 if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0) 1653 flags |= VK_IMAGE_USAGE_STORAGE_BIT; 1654 1655 return flags; 1656 } 1657 1658 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage) 1659 { 1660 return usage != 0; 1661 } 1662 1663 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage) 1664 { 1665 VkImageCreateFlags flags = (VkImageCreateFlags)0; 1666 1667 if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0) 1668 { 1669 flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; 1670 1671 if (type == VK_IMAGE_TYPE_2D) 1672 flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; 1673 } 1674 1675 if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 && 1676 (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) 1677 { 1678 if (deviceFeatures.sparseBinding) 1679 flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT; 1680 1681 if (deviceFeatures.sparseResidencyAliased) 1682 flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT; 1683 } 1684 1685 return flags; 1686 } 1687 1688 bool isValidImageCreateFlagCombination (VkImageCreateFlags) 1689 { 1690 return true; 1691 } 1692 1693 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures& deviceFeatures, 1694 const VkFormat format, 1695 const VkFormatProperties& formatProperties, 1696 const VkImageType imageType, 1697 const VkImageTiling imageTiling, 1698 const VkImageUsageFlags usageFlags, 1699 const VkImageCreateFlags createFlags) 1700 { 1701 DE_UNREF(deviceFeatures); 1702 DE_UNREF(formatProperties); 1703 DE_UNREF(createFlags); 1704 1705 // Linear images can have arbitrary limitations 1706 if (imageTiling == VK_IMAGE_TILING_LINEAR) 1707 return false; 1708 1709 // Support for other usages for compressed formats is optional 1710 if (isCompressedFormat(format) && 1711 (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0) 1712 return false; 1713 1714 // Support for 1D, and sliced 3D compressed formats is optional 1715 if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D)) 1716 return false; 1717 1718 DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0); 1719 DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0); 1720 1721 return true; 1722 } 1723 1724 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits& deviceLimits, 1725 const VkFormat format, 1726 const VkImageUsageFlags usageFlags) 1727 { 1728 if (!isCompressedFormat(format)) 1729 { 1730 const tcu::TextureFormat tcuFormat = mapVkFormat(format); 1731 1732 if (usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) 1733 return deviceLimits.storageImageSampleCounts; 1734 else if (tcuFormat.order == tcu::TextureFormat::D) 1735 return deviceLimits.sampledImageDepthSampleCounts; 1736 else if (tcuFormat.order == tcu::TextureFormat::S) 1737 return deviceLimits.sampledImageStencilSampleCounts; 1738 else if (tcuFormat.order == tcu::TextureFormat::DS) 1739 return deviceLimits.sampledImageDepthSampleCounts & deviceLimits.sampledImageStencilSampleCounts; 1740 else 1741 { 1742 const tcu::TextureChannelClass chnClass = tcu::getTextureChannelClass(tcuFormat.type); 1743 1744 if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER || 1745 chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER) 1746 return deviceLimits.sampledImageIntegerSampleCounts; 1747 else 1748 return deviceLimits.sampledImageColorSampleCounts; 1749 } 1750 } 1751 else 1752 return VK_SAMPLE_COUNT_1_BIT; 1753 } 1754 1755 struct ImageFormatPropertyCase 1756 { 1757 VkFormat format; 1758 VkImageType imageType; 1759 VkImageTiling tiling; 1760 1761 ImageFormatPropertyCase (VkFormat format_, VkImageType imageType_, VkImageTiling tiling_) 1762 : format (format_) 1763 , imageType (imageType_) 1764 , tiling (tiling_) 1765 {} 1766 1767 ImageFormatPropertyCase (void) 1768 : format (VK_FORMAT_LAST) 1769 , imageType (VK_IMAGE_TYPE_LAST) 1770 , tiling (VK_IMAGE_TILING_LAST) 1771 {} 1772 }; 1773 1774 tcu::TestStatus imageFormatProperties (Context& context, ImageFormatPropertyCase params) 1775 { 1776 TestLog& log = context.getTestContext().getLog(); 1777 const VkFormat format = params.format; 1778 const VkImageType imageType = params.imageType; 1779 const VkImageTiling tiling = params.tiling; 1780 const VkPhysicalDeviceFeatures& deviceFeatures = context.getDeviceFeatures(); 1781 const VkPhysicalDeviceLimits& deviceLimits = context.getDeviceProperties().limits; 1782 const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); 1783 1784 const VkFormatFeatureFlags supportedFeatures = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures; 1785 const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(format, supportedFeatures); 1786 1787 tcu::ResultCollector results (log, "ERROR: "); 1788 1789 for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++) 1790 { 1791 if ((curUsageFlags & ~usageFlagSet) != 0 || 1792 !isValidImageUsageFlagCombination(curUsageFlags)) 1793 continue; 1794 1795 const VkImageCreateFlags createFlagSet = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags); 1796 1797 for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++) 1798 { 1799 if ((curCreateFlags & ~createFlagSet) != 0 || 1800 !isValidImageCreateFlagCombination(curCreateFlags)) 1801 continue; 1802 1803 const bool isRequiredCombination = isRequiredImageParameterCombination(deviceFeatures, 1804 format, 1805 formatProperties, 1806 imageType, 1807 tiling, 1808 curUsageFlags, 1809 curCreateFlags); 1810 VkImageFormatProperties properties; 1811 VkResult queryResult; 1812 1813 log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", " 1814 << getImageTilingStr(tiling) << ", " 1815 << getImageUsageFlagsStr(curUsageFlags) << ", " 1816 << getImageCreateFlagsStr(curCreateFlags) 1817 << TestLog::EndMessage; 1818 1819 // Set return value to known garbage 1820 deMemset(&properties, 0xcd, sizeof(properties)); 1821 1822 queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(), 1823 format, 1824 imageType, 1825 tiling, 1826 curUsageFlags, 1827 curCreateFlags, 1828 &properties); 1829 1830 if (queryResult == VK_SUCCESS) 1831 { 1832 const deUint32 fullMipPyramidSize = de::max(de::max(deLog2Ceil32(properties.maxExtent.width), 1833 deLog2Ceil32(properties.maxExtent.height)), 1834 deLog2Ceil32(properties.maxExtent.depth)) + 1; 1835 1836 log << TestLog::Message << properties << "\n" << TestLog::EndMessage; 1837 1838 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image"); 1839 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image"); 1840 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image"); 1841 results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image"); 1842 1843 if (tiling == VK_IMAGE_TILING_OPTIMAL) 1844 { 1845 const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags); 1846 results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported"); 1847 } 1848 else 1849 results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT"); 1850 1851 if (isRequiredCombination) 1852 { 1853 results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= deviceLimits.maxImageDimension1D), 1854 "Reported dimensions smaller than device limits"); 1855 results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= deviceLimits.maxImageDimension2D && 1856 properties.maxExtent.height >= deviceLimits.maxImageDimension2D), 1857 "Reported dimensions smaller than device limits"); 1858 results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= deviceLimits.maxImageDimension3D && 1859 properties.maxExtent.height >= deviceLimits.maxImageDimension3D && 1860 properties.maxExtent.depth >= deviceLimits.maxImageDimension3D), 1861 "Reported dimensions smaller than device limits"); 1862 results.check(properties.maxMipLevels == fullMipPyramidSize, "maxMipLevels is not full mip pyramid size"); 1863 results.check(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers, 1864 "maxArrayLayers smaller than device limits"); 1865 } 1866 else 1867 { 1868 results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size"); 1869 results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers"); 1870 } 1871 1872 results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE, 1873 "maxResourceSize smaller than minimum required size"); 1874 } 1875 else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED) 1876 { 1877 log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage; 1878 1879 if (isRequiredCombination) 1880 results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination"); 1881 1882 // Specification requires that all fields are set to 0 1883 results.check(properties.maxExtent.width == 0, "maxExtent.width != 0"); 1884 results.check(properties.maxExtent.height == 0, "maxExtent.height != 0"); 1885 results.check(properties.maxExtent.depth == 0, "maxExtent.depth != 0"); 1886 results.check(properties.maxMipLevels == 0, "maxMipLevels != 0"); 1887 results.check(properties.maxArrayLayers == 0, "maxArrayLayers != 0"); 1888 results.check(properties.sampleCounts == 0, "sampleCounts != 0"); 1889 results.check(properties.maxResourceSize == 0, "maxResourceSize != 0"); 1890 } 1891 else 1892 { 1893 results.fail("Got unexpected error" + de::toString(queryResult)); 1894 } 1895 } 1896 } 1897 1898 return tcu::TestStatus(results.getResult(), results.getMessage()); 1899 } 1900 1901 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params) 1902 { 1903 DE_ASSERT(params.format == VK_FORMAT_LAST); 1904 1905 for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_FORMAT_LAST; ++formatNdx) 1906 { 1907 const VkFormat format = (VkFormat)formatNdx; 1908 const char* const enumName = getFormatName(format); 1909 const string caseName = de::toLower(string(enumName).substr(10)); 1910 1911 params.format = format; 1912 1913 addFunctionCase(testGroup, caseName, enumName, imageFormatProperties, params); 1914 } 1915 } 1916 1917 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params) 1918 { 1919 DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST); 1920 1921 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_LAST, params.imageType, VK_IMAGE_TILING_OPTIMAL))); 1922 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(VK_FORMAT_LAST, params.imageType, VK_IMAGE_TILING_LINEAR))); 1923 } 1924 1925 void createImageFormatTests (tcu::TestCaseGroup* testGroup) 1926 { 1927 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST))); 1928 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST))); 1929 testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(VK_FORMAT_LAST, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST))); 1930 } 1931 1932 } // anonymous 1933 1934 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx) 1935 { 1936 de::MovePtr<tcu::TestCaseGroup> infoTests (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests")); 1937 1938 { 1939 de::MovePtr<tcu::TestCaseGroup> instanceInfoTests (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests")); 1940 1941 addFunctionCase(instanceInfoTests.get(), "physical_devices", "Physical devices", enumeratePhysicalDevices); 1942 addFunctionCase(instanceInfoTests.get(), "layers", "Layers", enumerateInstanceLayers); 1943 addFunctionCase(instanceInfoTests.get(), "extensions", "Extensions", enumerateInstanceExtensions); 1944 1945 infoTests->addChild(instanceInfoTests.release()); 1946 } 1947 1948 { 1949 de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests")); 1950 1951 addFunctionCase(deviceInfoTests.get(), "features", "Device Features", deviceFeatures); 1952 addFunctionCase(deviceInfoTests.get(), "properties", "Device Properties", deviceProperties); 1953 addFunctionCase(deviceInfoTests.get(), "queue_family_properties", "Queue family properties", deviceQueueFamilyProperties); 1954 addFunctionCase(deviceInfoTests.get(), "memory_properties", "Memory properties", deviceMemoryProperties); 1955 addFunctionCase(deviceInfoTests.get(), "layers", "Layers", enumerateDeviceLayers); 1956 addFunctionCase(deviceInfoTests.get(), "extensions", "Extensions", enumerateDeviceExtensions); 1957 1958 infoTests->addChild(deviceInfoTests.release()); 1959 } 1960 1961 infoTests->addChild(createTestGroup(testCtx, "format_properties", "VkGetPhysicalDeviceFormatProperties() Tests", createFormatTests)); 1962 infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests", createImageFormatTests)); 1963 1964 return infoTests.release(); 1965 } 1966 1967 } // api 1968 } // vkt 1969