Home | History | Annotate | Download | only in api
      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_), (const char*)(#_X_)
     96 #define FEATURE(_X_)	DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_)
     97 
     98 inline bool isExtensionSupported (const vector<string>& extensionStrings, const string& extensionName)
     99 {
    100 	return de::contains(extensionStrings.begin(), extensionStrings.end(), extensionName);
    101 }
    102 
    103 bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log)
    104 {
    105 	bool						limitsOk	= true;
    106 	VkPhysicalDeviceLimits*		limits		= &properties->limits;
    107 	struct FeatureLimitTable
    108 	{
    109 		deUint32		offset;
    110 		const char*		name;
    111 		deUint32		uintVal;			//!< Format is UNSIGNED_INT
    112 		deInt32			intVal;				//!< Format is SIGNED_INT
    113 		deUint64		deviceSizeVal;		//!< Format is DEVICE_SIZE
    114 		float			floatVal;			//!< Format is FLOAT
    115 		LimitFormat		format;
    116 		LimitType		type;
    117 		deInt32			unsuppTableNdx;
    118 	} featureLimitTable[] =   //!< Based on 1.0.28 Vulkan spec
    119 	{
    120 		{ LIMIT(maxImageDimension1D),								4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    121 		{ LIMIT(maxImageDimension2D),								4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    122 		{ LIMIT(maxImageDimension3D),								256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    123 		{ LIMIT(maxImageDimensionCube),								4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    124 		{ LIMIT(maxImageArrayLayers),								256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
    125 		{ LIMIT(maxTexelBufferElements),							65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    126 		{ LIMIT(maxUniformBufferRange),								16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    127 		{ LIMIT(maxStorageBufferRange),								0, 0, 0, 0, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
    128 		{ LIMIT(maxPushConstantsSize),								128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    129 		{ LIMIT(maxMemoryAllocationCount),							4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    130 		{ LIMIT(maxSamplerAllocationCount),							0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
    131 		{ LIMIT(bufferImageGranularity),							0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
    132 		{ LIMIT(bufferImageGranularity),							0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
    133 		{ LIMIT(sparseAddressSpaceSize),							0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
    134 		{ LIMIT(maxBoundDescriptorSets),							4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    135 		{ LIMIT(maxPerStageDescriptorSamplers),						16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    136 		{ LIMIT(maxPerStageDescriptorUniformBuffers),				12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    137 		{ LIMIT(maxPerStageDescriptorStorageBuffers),				4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    138 		{ LIMIT(maxPerStageDescriptorSampledImages),				16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    139 		{ LIMIT(maxPerStageDescriptorStorageImages),				4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    140 		{ LIMIT(maxPerStageDescriptorInputAttachments),				4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    141 		{ LIMIT(maxPerStageResources),								0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 },
    142 		{ LIMIT(maxDescriptorSetSamplers),							96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    143 		{ LIMIT(maxDescriptorSetUniformBuffers),					72, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    144 		{ LIMIT(maxDescriptorSetUniformBuffersDynamic),				8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    145 		{ LIMIT(maxDescriptorSetStorageBuffers),					24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    146 		{ LIMIT(maxDescriptorSetStorageBuffersDynamic),				4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    147 		{ LIMIT(maxDescriptorSetSampledImages),						96, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    148 		{ LIMIT(maxDescriptorSetStorageImages),						24, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    149 		{ LIMIT(maxDescriptorSetInputAttachments),					0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE  , -1 },
    150 		{ LIMIT(maxVertexInputAttributes),							16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    151 		{ LIMIT(maxVertexInputBindings),							16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    152 		{ LIMIT(maxVertexInputAttributeOffset),						2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    153 		{ LIMIT(maxVertexInputBindingStride),						2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    154 		{ LIMIT(maxVertexOutputComponents),							64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    155 		{ LIMIT(maxTessellationGenerationLevel),					64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    156 		{ LIMIT(maxTessellationPatchSize),							32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    157 		{ LIMIT(maxTessellationControlPerVertexInputComponents),	64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    158 		{ LIMIT(maxTessellationControlPerVertexOutputComponents),	64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    159 		{ LIMIT(maxTessellationControlPerPatchOutputComponents),	120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    160 		{ LIMIT(maxTessellationControlTotalOutputComponents),		2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    161 		{ LIMIT(maxTessellationEvaluationInputComponents),			64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    162 		{ LIMIT(maxTessellationEvaluationOutputComponents),			64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    163 		{ LIMIT(maxGeometryShaderInvocations),						32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    164 		{ LIMIT(maxGeometryInputComponents),						64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    165 		{ LIMIT(maxGeometryOutputComponents),						64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    166 		{ LIMIT(maxGeometryOutputVertices),							256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    167 		{ LIMIT(maxGeometryTotalOutputComponents),					1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    168 		{ LIMIT(maxFragmentInputComponents),						64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    169 		{ LIMIT(maxFragmentOutputAttachments),						4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    170 		{ LIMIT(maxFragmentDualSrcAttachments),						1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    171 		{ LIMIT(maxFragmentCombinedOutputResources),				4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN  , -1 },
    172 		{ LIMIT(maxComputeSharedMemorySize),						16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
    173 		{ LIMIT(maxComputeWorkGroupCount[0]),						65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
    174 		{ LIMIT(maxComputeWorkGroupCount[1]),						65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
    175 		{ LIMIT(maxComputeWorkGroupCount[2]),						65535,  0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN   , -1 },
    176 		{ LIMIT(maxComputeWorkGroupInvocations),					128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    177 		{ LIMIT(maxComputeWorkGroupSize[0]),						128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    178 		{ LIMIT(maxComputeWorkGroupSize[1]),						128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    179 		{ LIMIT(maxComputeWorkGroupSize[2]),						64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    180 		{ LIMIT(subPixelPrecisionBits),								4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    181 		{ LIMIT(subTexelPrecisionBits),								4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    182 		{ LIMIT(mipmapPrecisionBits),								4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    183 		{ LIMIT(maxDrawIndexedIndexValue),							(deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    184 		{ LIMIT(maxDrawIndirectCount),								65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN    , -1 },
    185 		{ LIMIT(maxSamplerLodBias),									0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    186 		{ LIMIT(maxSamplerAnisotropy),								0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    187 		{ LIMIT(maxViewports),										16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    188 		{ LIMIT(maxViewportDimensions[0]),							4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    189 		{ LIMIT(maxViewportDimensions[1]),							4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 },
    190 		{ LIMIT(viewportBoundsRange[0]),							0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
    191 		{ LIMIT(viewportBoundsRange[1]),							0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    192 		{ LIMIT(viewportSubPixelBits),								0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    193 		{ LIMIT(minMemoryMapAlignment),								64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    194 		{ LIMIT(minTexelBufferOffsetAlignment),						0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
    195 		{ LIMIT(minTexelBufferOffsetAlignment),						0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
    196 		{ LIMIT(minUniformBufferOffsetAlignment),					0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
    197 		{ LIMIT(minUniformBufferOffsetAlignment),					0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
    198 		{ LIMIT(minStorageBufferOffsetAlignment),					0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
    199 		{ LIMIT(minStorageBufferOffsetAlignment),					0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
    200 		{ LIMIT(minTexelOffset),									0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
    201 		{ LIMIT(maxTexelOffset),									7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    202 		{ LIMIT(minTexelGatherOffset),								0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 },
    203 		{ LIMIT(maxTexelGatherOffset),								7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    204 		{ LIMIT(minInterpolationOffset),							0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
    205 		{ LIMIT(maxInterpolationOffset),							0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    206 		{ LIMIT(subPixelInterpolationOffsetBits),					4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    207 		{ LIMIT(maxFramebufferWidth),								4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    208 		{ LIMIT(maxFramebufferHeight),								4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    209 		{ LIMIT(maxFramebufferLayers),								0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    210 		{ LIMIT(framebufferColorSampleCounts),						VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    211 		{ LIMIT(framebufferDepthSampleCounts),						VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    212 		{ LIMIT(framebufferStencilSampleCounts),					VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    213 		{ LIMIT(framebufferNoAttachmentsSampleCounts),				VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    214 		{ LIMIT(maxColorAttachments),								4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    215 		{ LIMIT(sampledImageColorSampleCounts),						VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    216 		{ LIMIT(sampledImageIntegerSampleCounts),					VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    217 		{ LIMIT(sampledImageDepthSampleCounts),						VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    218 		{ LIMIT(sampledImageStencilSampleCounts),					VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    219 		{ LIMIT(storageImageSampleCounts),							VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 },
    220 		{ LIMIT(maxSampleMaskWords),								1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    221 		{ LIMIT(timestampComputeAndGraphics),						0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
    222 		{ LIMIT(timestampPeriod),									0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
    223 		{ LIMIT(maxClipDistances),									8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    224 		{ LIMIT(maxCullDistances),									8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    225 		{ LIMIT(maxCombinedClipAndCullDistances),					8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 },
    226 		{ LIMIT(discreteQueuePriorities),							8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
    227 		{ LIMIT(pointSizeRange[0]),									0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    228 		{ LIMIT(pointSizeRange[0]),									0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
    229 		{ LIMIT(pointSizeRange[1]),									0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    230 		{ LIMIT(lineWidthRange[0]),									0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    231 		{ LIMIT(lineWidthRange[0]),									0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
    232 		{ LIMIT(lineWidthRange[1]),									0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 },
    233 		{ LIMIT(pointSizeGranularity),								0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
    234 		{ LIMIT(lineWidthGranularity),								0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 },
    235 		{ LIMIT(strictLines),										0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
    236 		{ LIMIT(standardSampleLocations),							0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 },
    237 		{ LIMIT(optimalBufferCopyOffsetAlignment),					0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
    238 		{ LIMIT(optimalBufferCopyRowPitchAlignment),				0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 },
    239 		{ LIMIT(nonCoherentAtomSize),								0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 },
    240 		{ LIMIT(nonCoherentAtomSize),								0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 },
    241 	};
    242 
    243 	const struct UnsupportedFeatureLimitTable
    244 	{
    245 		deUint32		limitOffset;
    246 		const char*		name;
    247 		deUint32		featureOffset;
    248 		deUint32		uintVal;			//!< Format is UNSIGNED_INT
    249 		deInt32			intVal;				//!< Format is SIGNED_INT
    250 		deUint64		deviceSizeVal;		//!< Format is DEVICE_SIZE
    251 		float			floatVal;			//!< Format is FLOAT
    252 	} unsupportedFeatureTable[] =
    253 	{
    254 		{ LIMIT(sparseAddressSpaceSize),							FEATURE(sparseBinding),					0, 0, 0, 0.0f },
    255 		{ LIMIT(maxTessellationGenerationLevel),					FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    256 		{ LIMIT(maxTessellationPatchSize),							FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    257 		{ LIMIT(maxTessellationControlPerVertexInputComponents),	FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    258 		{ LIMIT(maxTessellationControlPerVertexOutputComponents),	FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    259 		{ LIMIT(maxTessellationControlPerPatchOutputComponents),	FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    260 		{ LIMIT(maxTessellationControlTotalOutputComponents),		FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    261 		{ LIMIT(maxTessellationEvaluationInputComponents),			FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    262 		{ LIMIT(maxTessellationEvaluationOutputComponents),			FEATURE(tessellationShader),			0, 0, 0, 0.0f },
    263 		{ LIMIT(maxGeometryShaderInvocations),						FEATURE(geometryShader),				0, 0, 0, 0.0f },
    264 		{ LIMIT(maxGeometryInputComponents),						FEATURE(geometryShader),				0, 0, 0, 0.0f },
    265 		{ LIMIT(maxGeometryOutputComponents),						FEATURE(geometryShader),				0, 0, 0, 0.0f },
    266 		{ LIMIT(maxGeometryOutputVertices),							FEATURE(geometryShader),				0, 0, 0, 0.0f },
    267 		{ LIMIT(maxGeometryTotalOutputComponents),					FEATURE(geometryShader),				0, 0, 0, 0.0f },
    268 		{ LIMIT(maxFragmentDualSrcAttachments),						FEATURE(dualSrcBlend),					0, 0, 0, 0.0f },
    269 		{ LIMIT(maxDrawIndexedIndexValue),							FEATURE(fullDrawIndexUint32),			(1<<24)-1, 0, 0, 0.0f },
    270 		{ LIMIT(maxDrawIndirectCount),								FEATURE(multiDrawIndirect),				1, 0, 0, 0.0f },
    271 		{ LIMIT(maxSamplerAnisotropy),								FEATURE(samplerAnisotropy),				1, 0, 0, 0.0f },
    272 		{ LIMIT(maxViewports),										FEATURE(multiViewport),					1, 0, 0, 0.0f },
    273 		{ LIMIT(minTexelGatherOffset),								FEATURE(shaderImageGatherExtended),		0, 0, 0, 0.0f },
    274 		{ LIMIT(maxTexelGatherOffset),								FEATURE(shaderImageGatherExtended),		0, 0, 0, 0.0f },
    275 		{ LIMIT(minInterpolationOffset),							FEATURE(sampleRateShading),				0, 0, 0, 0.0f },
    276 		{ LIMIT(maxInterpolationOffset),							FEATURE(sampleRateShading),				0, 0, 0, 0.0f },
    277 		{ LIMIT(subPixelInterpolationOffsetBits),					FEATURE(sampleRateShading),				0, 0, 0, 0.0f },
    278 		{ LIMIT(storageImageSampleCounts),							FEATURE(shaderStorageImageMultisample),	VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f },
    279 		{ LIMIT(maxClipDistances),									FEATURE(shaderClipDistance),			0, 0, 0, 0.0f },
    280 		{ LIMIT(maxCullDistances),									FEATURE(shaderClipDistance),			0, 0, 0, 0.0f },
    281 		{ LIMIT(maxCombinedClipAndCullDistances),					FEATURE(shaderClipDistance),			0, 0, 0, 0.0f },
    282 		{ LIMIT(pointSizeRange[0]),									FEATURE(largePoints),					0, 0, 0, 1.0f },
    283 		{ LIMIT(pointSizeRange[1]),									FEATURE(largePoints),					0, 0, 0, 1.0f },
    284 		{ LIMIT(lineWidthRange[0]),									FEATURE(wideLines),						0, 0, 0, 1.0f },
    285 		{ LIMIT(lineWidthRange[1]),									FEATURE(wideLines),						0, 0, 0, 1.0f },
    286 		{ LIMIT(pointSizeGranularity),								FEATURE(largePoints),					0, 0, 0, 0.0f },
    287 		{ LIMIT(lineWidthGranularity),								FEATURE(wideLines),						0, 0, 0, 0.0f }
    288 	};
    289 
    290 	log << TestLog::Message << *limits << TestLog::EndMessage;
    291 
    292 	//!< First build a map from limit to unsupported table index
    293 	for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
    294 	{
    295 		for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++)
    296 		{
    297 			if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset)
    298 			{
    299 				featureLimitTable[ndx].unsuppTableNdx = unsuppNdx;
    300 				break;
    301 			}
    302 		}
    303 	}
    304 
    305 	for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++)
    306 	{
    307 		switch (featureLimitTable[ndx].format)
    308 		{
    309 			case LIMIT_FORMAT_UNSIGNED_INT:
    310 			{
    311 				deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
    312 				if (featureLimitTable[ndx].unsuppTableNdx != -1)
    313 				{
    314 					if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
    315 						limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
    316 				}
    317 
    318 				if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
    319 				{
    320 
    321 					if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
    322 					{
    323 						log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name
    324 							<< " not valid-limit type MIN - actual is "
    325 							<< *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    326 						limitsOk = false;
    327 					}
    328 				}
    329 				else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
    330 				{
    331 					if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
    332 					{
    333 						log << TestLog::Message << "limit validation failed,  " << featureLimitTable[ndx].name
    334 							<< " not valid-limit type MAX - actual is "
    335 							<< *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    336 						limitsOk = false;
    337 					}
    338 				}
    339 				break;
    340 			}
    341 
    342 			case LIMIT_FORMAT_FLOAT:
    343 			{
    344 				float limitToCheck = featureLimitTable[ndx].floatVal;
    345 				if (featureLimitTable[ndx].unsuppTableNdx != -1)
    346 				{
    347 					if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
    348 						limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal;
    349 				}
    350 
    351 				if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
    352 				{
    353 					if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
    354 					{
    355 						log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
    356 							<< " not valid-limit type MIN - actual is "
    357 							<< *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    358 						limitsOk = false;
    359 					}
    360 				}
    361 				else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
    362 				{
    363 					if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
    364 					{
    365 						log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
    366 							<< " not valid-limit type MAX actual is "
    367 							<< *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    368 						limitsOk = false;
    369 					}
    370 				}
    371 				break;
    372 			}
    373 
    374 			case LIMIT_FORMAT_SIGNED_INT:
    375 			{
    376 				deInt32 limitToCheck = featureLimitTable[ndx].intVal;
    377 				if (featureLimitTable[ndx].unsuppTableNdx != -1)
    378 				{
    379 					if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
    380 						limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal;
    381 				}
    382 				if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
    383 				{
    384 					if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
    385 					{
    386 						log << TestLog::Message <<  "limit validation failed, " << featureLimitTable[ndx].name
    387 							<< " not valid-limit type MIN actual is "
    388 							<< *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    389 						limitsOk = false;
    390 					}
    391 				}
    392 				else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
    393 				{
    394 					if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
    395 					{
    396 						log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
    397 							<< " not valid-limit type MAX actual is "
    398 							<< *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    399 						limitsOk = false;
    400 					}
    401 				}
    402 				break;
    403 			}
    404 
    405 			case LIMIT_FORMAT_DEVICE_SIZE:
    406 			{
    407 				deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal;
    408 				if (featureLimitTable[ndx].unsuppTableNdx != -1)
    409 				{
    410 					if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
    411 						limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal;
    412 				}
    413 
    414 				if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
    415 				{
    416 					if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck)
    417 					{
    418 						log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
    419 							<< " not valid-limit type MIN actual is "
    420 							<< *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    421 						limitsOk = false;
    422 					}
    423 				}
    424 				else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX)
    425 				{
    426 					if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck)
    427 					{
    428 						log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
    429 							<< " not valid-limit type MAX actual is "
    430 							<< *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    431 						limitsOk = false;
    432 					}
    433 				}
    434 				break;
    435 			}
    436 
    437 			case LIMIT_FORMAT_BITMASK:
    438 			{
    439 				deUint32 limitToCheck = featureLimitTable[ndx].uintVal;
    440 				if (featureLimitTable[ndx].unsuppTableNdx != -1)
    441 				{
    442 					if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE)
    443 						limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal;
    444 				}
    445 
    446 				if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN)
    447 				{
    448 					if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck)
    449 					{
    450 						log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name
    451 							<< " not valid-limit type bitmask actual is "
    452 							<< *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage;
    453 						limitsOk = false;
    454 					}
    455 				}
    456 				break;
    457 			}
    458 
    459 			default:
    460 				DE_ASSERT(0);
    461 				limitsOk = false;
    462 		}
    463 	}
    464 
    465 	for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits->maxViewportDimensions); ndx++)
    466 	{
    467 		if (limits->maxImageDimension2D > limits->maxViewportDimensions[ndx])
    468 		{
    469 			log << TestLog::Message << "limit validation failed, maxImageDimension2D of " << limits->maxImageDimension2D
    470 				<< "is larger than maxViewportDimension[" << ndx << "] of " << limits->maxViewportDimensions[ndx] << TestLog::EndMessage;
    471 			limitsOk = false;
    472 		}
    473 	}
    474 
    475 	if (limits->viewportBoundsRange[0] > float(-2 * limits->maxViewportDimensions[0]))
    476 	{
    477 		log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0]
    478 			<< "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage;
    479 		limitsOk = false;
    480 	}
    481 
    482 	if (limits->viewportBoundsRange[1] < float(2 * limits->maxViewportDimensions[1] - 1))
    483 	{
    484 		log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1]
    485 			<< "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage;
    486 		limitsOk = false;
    487 	}
    488 
    489 	return limitsOk;
    490 }
    491 
    492 template<typename T>
    493 class CheckIncompleteResult
    494 {
    495 public:
    496 	virtual			~CheckIncompleteResult	(void) {}
    497 	virtual void	getResult				(Context& context, T* data) = 0;
    498 
    499 	void operator() (Context& context, tcu::ResultCollector& results, const std::size_t expectedCompleteSize)
    500 	{
    501 		if (expectedCompleteSize == 0)
    502 			return;
    503 
    504 		vector<T>		outputData	(expectedCompleteSize);
    505 		const deUint32	usedSize	= static_cast<deUint32>(expectedCompleteSize / 3);
    506 
    507 		ValidateQueryBits::fillBits(outputData.begin(), outputData.end());	// unused entries should have this pattern intact
    508 		m_count		= usedSize;
    509 		m_result	= VK_SUCCESS;
    510 
    511 		getResult(context, &outputData[0]);									// update m_count and m_result
    512 
    513 		if (m_count != usedSize || m_result != VK_INCOMPLETE || !ValidateQueryBits::checkBits(outputData.begin() + m_count, outputData.end()))
    514 			results.fail("Query didn't return VK_INCOMPLETE");
    515 	}
    516 
    517 protected:
    518 	deUint32	m_count;
    519 	VkResult	m_result;
    520 };
    521 
    522 struct CheckEnumeratePhysicalDevicesIncompleteResult : public CheckIncompleteResult<VkPhysicalDevice>
    523 {
    524 	void getResult (Context& context, VkPhysicalDevice* data)
    525 	{
    526 		m_result = context.getInstanceInterface().enumeratePhysicalDevices(context.getInstance(), &m_count, data);
    527 	}
    528 };
    529 
    530 struct CheckEnumerateInstanceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
    531 {
    532 	void getResult (Context& context, VkLayerProperties* data)
    533 	{
    534 		m_result = context.getPlatformInterface().enumerateInstanceLayerProperties(&m_count, data);
    535 	}
    536 };
    537 
    538 struct CheckEnumerateDeviceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties>
    539 {
    540 	void getResult (Context& context, VkLayerProperties* data)
    541 	{
    542 		m_result = context.getInstanceInterface().enumerateDeviceLayerProperties(context.getPhysicalDevice(), &m_count, data);
    543 	}
    544 };
    545 
    546 struct CheckEnumerateInstanceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
    547 {
    548 	CheckEnumerateInstanceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
    549 
    550 	void getResult (Context& context, VkExtensionProperties* data)
    551 	{
    552 		const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
    553 		m_result = context.getPlatformInterface().enumerateInstanceExtensionProperties(pLayerName, &m_count, data);
    554 	}
    555 
    556 private:
    557 	const std::string	m_layerName;
    558 };
    559 
    560 struct CheckEnumerateDeviceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties>
    561 {
    562 	CheckEnumerateDeviceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {}
    563 
    564 	void getResult (Context& context, VkExtensionProperties* data)
    565 	{
    566 		const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL);
    567 		m_result = context.getInstanceInterface().enumerateDeviceExtensionProperties(context.getPhysicalDevice(), pLayerName, &m_count, data);
    568 	}
    569 
    570 private:
    571 	const std::string	m_layerName;
    572 };
    573 
    574 tcu::TestStatus enumeratePhysicalDevices (Context& context)
    575 {
    576 	TestLog&						log		= context.getTestContext().getLog();
    577 	tcu::ResultCollector			results	(log);
    578 	const vector<VkPhysicalDevice>	devices	= enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
    579 
    580 	log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
    581 
    582 	for (size_t ndx = 0; ndx < devices.size(); ndx++)
    583 		log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage;
    584 
    585 	CheckEnumeratePhysicalDevicesIncompleteResult()(context, results, devices.size());
    586 
    587 	return tcu::TestStatus(results.getResult(), results.getMessage());
    588 }
    589 
    590 template<typename T>
    591 void collectDuplicates (set<T>& duplicates, const vector<T>& values)
    592 {
    593 	set<T> seen;
    594 
    595 	for (size_t ndx = 0; ndx < values.size(); ndx++)
    596 	{
    597 		const T& value = values[ndx];
    598 
    599 		if (!seen.insert(value).second)
    600 			duplicates.insert(value);
    601 	}
    602 }
    603 
    604 void checkDuplicates (tcu::ResultCollector& results, const char* what, const vector<string>& values)
    605 {
    606 	set<string> duplicates;
    607 
    608 	collectDuplicates(duplicates, values);
    609 
    610 	for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter)
    611 	{
    612 		std::ostringstream msg;
    613 		msg << "Duplicate " << what << ": " << *iter;
    614 		results.fail(msg.str());
    615 	}
    616 }
    617 
    618 void checkDuplicateExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
    619 {
    620 	checkDuplicates(results, "extension", extensions);
    621 }
    622 
    623 void checkDuplicateLayers (tcu::ResultCollector& results, const vector<string>& layers)
    624 {
    625 	checkDuplicates(results, "layer", layers);
    626 }
    627 
    628 void checkKhrExtensions (tcu::ResultCollector&		results,
    629 						 const vector<string>&		extensions,
    630 						 const int					numAllowedKhrExtensions,
    631 						 const char* const*			allowedKhrExtensions)
    632 {
    633 	const set<string>	allowedExtSet		(allowedKhrExtensions, allowedKhrExtensions+numAllowedKhrExtensions);
    634 
    635 	for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter)
    636 	{
    637 		// Only Khronos-controlled extensions are checked
    638 		if (de::beginsWith(*extIter, "VK_KHR_") &&
    639 			!de::contains(allowedExtSet, *extIter))
    640 		{
    641 			results.fail("Unknown KHR extension " + *extIter);
    642 		}
    643 	}
    644 }
    645 
    646 void checkInstanceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
    647 {
    648 	static const char* s_allowedInstanceKhrExtensions[] =
    649 	{
    650 		"VK_KHR_surface",
    651 		"VK_KHR_display",
    652 		"VK_KHR_android_surface",
    653 		"VK_KHR_mir_surface",
    654 		"VK_KHR_wayland_surface",
    655 		"VK_KHR_win32_surface",
    656 		"VK_KHR_xcb_surface",
    657 		"VK_KHR_xlib_surface",
    658 		"VK_KHR_get_physical_device_properties2",
    659 		"VK_KHR_get_surface_capabilities2",
    660 		"VK_KHR_external_memory_capabilities",
    661 		"VK_KHR_external_semaphore_capabilities",
    662 		"VK_KHR_external_fence_capabilities",
    663 		"VK_KHR_sampler_ycbcr_conversion"
    664 	};
    665 
    666 	checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions);
    667 	checkDuplicateExtensions(results, extensions);
    668 }
    669 
    670 void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions)
    671 {
    672 	static const char* s_allowedDeviceKhrExtensions[] =
    673 	{
    674 		"VK_KHR_swapchain",
    675 		"VK_KHR_display_swapchain",
    676 		"VK_KHR_sampler_mirror_clamp_to_edge",
    677 		"VK_KHR_shader_draw_parameters",
    678 		"VK_KHR_maintenance1",
    679 		"VK_KHR_push_descriptor",
    680 		"VK_KHR_descriptor_update_template",
    681 		"VK_KHR_incremental_present",
    682 		"VK_KHR_shared_presentable_image",
    683 		"VK_KHR_storage_buffer_storage_class",
    684 		"VK_KHR_16bit_storage",
    685 		"VK_KHR_get_memory_requirements2",
    686 		"VK_KHR_external_memory",
    687 		"VK_KHR_external_memory_fd",
    688 		"VK_KHR_external_memory_win32",
    689 		"VK_KHR_external_semaphore",
    690 		"VK_KHR_external_semaphore_fd",
    691 		"VK_KHR_external_semaphore_win32",
    692 		"VK_KHR_external_fence",
    693 		"VK_KHR_external_fence_fd",
    694 		"VK_KHR_external_fence_win32",
    695 		"VK_KHR_win32_keyed_mutex",
    696 		"VK_KHR_dedicated_allocation",
    697 		"VK_KHR_variable_pointers",
    698 		"VK_KHR_relaxed_block_layout",
    699 		"VK_KHR_bind_memory2",
    700 		"VK_KHR_maintenance2",
    701 		"VK_KHR_image_format_list",
    702 		"VK_KHR_sampler_ycbcr_conversion",
    703 	};
    704 
    705 	checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedDeviceKhrExtensions), s_allowedDeviceKhrExtensions);
    706 	checkDuplicateExtensions(results, extensions);
    707 }
    708 
    709 tcu::TestStatus enumerateInstanceLayers (Context& context)
    710 {
    711 	TestLog&						log					= context.getTestContext().getLog();
    712 	tcu::ResultCollector			results				(log);
    713 	const vector<VkLayerProperties>	properties			= enumerateInstanceLayerProperties(context.getPlatformInterface());
    714 	vector<string>					layerNames;
    715 
    716 	for (size_t ndx = 0; ndx < properties.size(); ndx++)
    717 	{
    718 		log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
    719 
    720 		layerNames.push_back(properties[ndx].layerName);
    721 	}
    722 
    723 	checkDuplicateLayers(results, layerNames);
    724 	CheckEnumerateInstanceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
    725 
    726 	return tcu::TestStatus(results.getResult(), results.getMessage());
    727 }
    728 
    729 tcu::TestStatus enumerateInstanceExtensions (Context& context)
    730 {
    731 	TestLog&				log		= context.getTestContext().getLog();
    732 	tcu::ResultCollector	results	(log);
    733 
    734 	{
    735 		const ScopedLogSection				section		(log, "Global", "Global Extensions");
    736 		const vector<VkExtensionProperties>	properties	= enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
    737 		vector<string>						extensionNames;
    738 
    739 		for (size_t ndx = 0; ndx < properties.size(); ndx++)
    740 		{
    741 			log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
    742 
    743 			extensionNames.push_back(properties[ndx].extensionName);
    744 		}
    745 
    746 		checkInstanceExtensions(results, extensionNames);
    747 		CheckEnumerateInstanceExtensionPropertiesIncompleteResult()(context, results, properties.size());
    748 	}
    749 
    750 	{
    751 		const vector<VkLayerProperties>	layers	= enumerateInstanceLayerProperties(context.getPlatformInterface());
    752 
    753 		for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
    754 		{
    755 			const ScopedLogSection				section				(log, layer->layerName, string("Layer: ") + layer->layerName);
    756 			const vector<VkExtensionProperties>	properties			= enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
    757 			vector<string>						extensionNames;
    758 
    759 			for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
    760 			{
    761 				log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
    762 
    763 				extensionNames.push_back(properties[extNdx].extensionName);
    764 			}
    765 
    766 			checkInstanceExtensions(results, extensionNames);
    767 			CheckEnumerateInstanceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
    768 		}
    769 	}
    770 
    771 	return tcu::TestStatus(results.getResult(), results.getMessage());
    772 }
    773 
    774 tcu::TestStatus enumerateDeviceLayers (Context& context)
    775 {
    776 	TestLog&						log			= context.getTestContext().getLog();
    777 	tcu::ResultCollector			results		(log);
    778 	const vector<VkLayerProperties>	properties	= enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
    779 	vector<string>					layerNames;
    780 
    781 	for (size_t ndx = 0; ndx < properties.size(); ndx++)
    782 	{
    783 		log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
    784 
    785 		layerNames.push_back(properties[ndx].layerName);
    786 	}
    787 
    788 	checkDuplicateLayers(results, layerNames);
    789 	CheckEnumerateDeviceLayerPropertiesIncompleteResult()(context, results, layerNames.size());
    790 
    791 	return tcu::TestStatus(results.getResult(), results.getMessage());
    792 }
    793 
    794 tcu::TestStatus enumerateDeviceExtensions (Context& context)
    795 {
    796 	TestLog&				log		= context.getTestContext().getLog();
    797 	tcu::ResultCollector	results	(log);
    798 
    799 	{
    800 		const ScopedLogSection				section		(log, "Global", "Global Extensions");
    801 		const vector<VkExtensionProperties>	properties	= enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
    802 		vector<string>						extensionNames;
    803 
    804 		for (size_t ndx = 0; ndx < properties.size(); ndx++)
    805 		{
    806 			log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
    807 
    808 			extensionNames.push_back(properties[ndx].extensionName);
    809 		}
    810 
    811 		checkDeviceExtensions(results, extensionNames);
    812 		CheckEnumerateDeviceExtensionPropertiesIncompleteResult()(context, results, properties.size());
    813 	}
    814 
    815 	{
    816 		const vector<VkLayerProperties>	layers	= enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
    817 
    818 		for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
    819 		{
    820 			const ScopedLogSection				section		(log, layer->layerName, string("Layer: ") + layer->layerName);
    821 			const vector<VkExtensionProperties>	properties	= enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
    822 			vector<string>						extensionNames;
    823 
    824 			for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
    825 			{
    826 				log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
    827 
    828 
    829 				extensionNames.push_back(properties[extNdx].extensionName);
    830 			}
    831 
    832 			checkDeviceExtensions(results, extensionNames);
    833 			CheckEnumerateDeviceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size());
    834 		}
    835 	}
    836 
    837 	return tcu::TestStatus(results.getResult(), results.getMessage());
    838 }
    839 
    840 #define VK_SIZE_OF(STRUCT, MEMBER)					(sizeof(((STRUCT*)0)->MEMBER))
    841 #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER)			{ (size_t)DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) }
    842 
    843 tcu::TestStatus deviceFeatures (Context& context)
    844 {
    845 	using namespace ValidateQueryBits;
    846 
    847 	TestLog&						log			= context.getTestContext().getLog();
    848 	VkPhysicalDeviceFeatures*		features;
    849 	deUint8							buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE];
    850 
    851 	const QueryMemberTableEntry featureOffsetTable[] =
    852 	{
    853 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess),
    854 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32),
    855 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray),
    856 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend),
    857 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader),
    858 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader),
    859 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading),
    860 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend),
    861 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp),
    862 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect),
    863 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance),
    864 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp),
    865 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp),
    866 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid),
    867 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds),
    868 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines),
    869 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints),
    870 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne),
    871 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport),
    872 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy),
    873 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2),
    874 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR),
    875 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC),
    876 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise),
    877 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery),
    878 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics),
    879 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics),
    880 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize),
    881 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended),
    882 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats),
    883 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample),
    884 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat),
    885 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat),
    886 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing),
    887 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing),
    888 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing),
    889 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing),
    890 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance),
    891 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance),
    892 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64),
    893 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64),
    894 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16),
    895 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency),
    896 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod),
    897 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding),
    898 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer),
    899 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D),
    900 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D),
    901 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples),
    902 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples),
    903 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples),
    904 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples),
    905 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased),
    906 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate),
    907 		OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries),
    908 		{ 0, 0 }
    909 	};
    910 
    911 	deMemset(buffer, GUARD_VALUE, sizeof(buffer));
    912 	features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer);
    913 
    914 	context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features);
    915 
    916 	log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
    917 		<< TestLog::Message << *features << TestLog::EndMessage;
    918 
    919 	// Requirements and dependencies
    920 	{
    921 		if (!features->robustBufferAccess)
    922 			return tcu::TestStatus::fail("robustBufferAccess is not supported");
    923 
    924 		// multiViewport requires MultiViewport (SPIR-V capability) support, which depends on Geometry
    925 		if (features->multiViewport && !features->geometryShader)
    926 			return tcu::TestStatus::fail("multiViewport is supported but geometryShader is not");
    927 	}
    928 
    929 	for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
    930 	{
    931 		if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE)
    932 		{
    933 			log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
    934 			return tcu::TestStatus::fail("deviceFeatures buffer overflow");
    935 		}
    936 	}
    937 
    938 	if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable))
    939 	{
    940 		log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage;
    941 		return tcu::TestStatus::fail("deviceFeatures incomplete initialization");
    942 	}
    943 
    944 	return tcu::TestStatus::pass("Query succeeded");
    945 }
    946 
    947 static const ValidateQueryBits::QueryMemberTableEntry s_physicalDevicePropertiesOffsetTable[] =
    948 {
    949 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion),
    950 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion),
    951 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID),
    952 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID),
    953 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType),
    954 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID),
    955 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D),
    956 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D),
    957 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D),
    958 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube),
    959 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers),
    960 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements),
    961 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange),
    962 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange),
    963 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize),
    964 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount),
    965 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount),
    966 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity),
    967 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize),
    968 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets),
    969 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers),
    970 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers),
    971 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers),
    972 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages),
    973 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages),
    974 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments),
    975 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources),
    976 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers),
    977 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers),
    978 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic),
    979 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers),
    980 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic),
    981 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages),
    982 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages),
    983 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments),
    984 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes),
    985 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings),
    986 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset),
    987 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride),
    988 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents),
    989 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel),
    990 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize),
    991 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents),
    992 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents),
    993 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents),
    994 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents),
    995 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents),
    996 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents),
    997 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations),
    998 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents),
    999 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents),
   1000 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices),
   1001 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents),
   1002 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents),
   1003 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments),
   1004 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments),
   1005 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources),
   1006 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize),
   1007 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]),
   1008 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations),
   1009 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]),
   1010 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits),
   1011 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits),
   1012 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits),
   1013 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue),
   1014 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount),
   1015 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias),
   1016 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy),
   1017 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports),
   1018 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]),
   1019 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]),
   1020 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits),
   1021 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment),
   1022 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment),
   1023 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment),
   1024 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment),
   1025 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset),
   1026 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset),
   1027 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset),
   1028 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset),
   1029 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset),
   1030 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset),
   1031 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits),
   1032 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth),
   1033 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight),
   1034 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers),
   1035 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts),
   1036 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts),
   1037 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts),
   1038 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts),
   1039 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments),
   1040 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts),
   1041 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts),
   1042 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts),
   1043 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts),
   1044 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts),
   1045 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords),
   1046 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics),
   1047 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod),
   1048 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances),
   1049 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances),
   1050 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances),
   1051 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities),
   1052 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]),
   1053 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]),
   1054 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity),
   1055 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity),
   1056 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines),
   1057 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations),
   1058 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment),
   1059 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment),
   1060 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize),
   1061 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape),
   1062 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape),
   1063 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape),
   1064 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize),
   1065 	OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict),
   1066 	{ 0, 0 }
   1067 };
   1068 
   1069 tcu::TestStatus deviceProperties (Context& context)
   1070 {
   1071 	using namespace ValidateQueryBits;
   1072 
   1073 	TestLog&						log			= context.getTestContext().getLog();
   1074 	VkPhysicalDeviceProperties*		props;
   1075 	VkPhysicalDeviceFeatures		features;
   1076 	deUint8							buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE];
   1077 
   1078 	props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer);
   1079 	deMemset(props, GUARD_VALUE, sizeof(buffer));
   1080 
   1081 	context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props);
   1082 	context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features);
   1083 
   1084 	log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
   1085 		<< TestLog::Message << *props << TestLog::EndMessage;
   1086 
   1087 	if (!validateFeatureLimits(props, &features, log))
   1088 		return tcu::TestStatus::fail("deviceProperties - feature limits failed");
   1089 
   1090 	for (int ndx = 0; ndx < GUARD_SIZE; ndx++)
   1091 	{
   1092 		if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE)
   1093 		{
   1094 			log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
   1095 			return tcu::TestStatus::fail("deviceProperties buffer overflow");
   1096 		}
   1097 	}
   1098 
   1099 	if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), s_physicalDevicePropertiesOffsetTable))
   1100 	{
   1101 		log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage;
   1102 		return tcu::TestStatus::fail("deviceProperties incomplete initialization");
   1103 	}
   1104 
   1105 	// Check if deviceName string is properly terminated.
   1106 	if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE)
   1107 	{
   1108 		log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage;
   1109 		return tcu::TestStatus::fail("deviceProperties incomplete initialization");
   1110 	}
   1111 
   1112 	{
   1113 		const ApiVersion deviceVersion = unpackVersion(props->apiVersion);
   1114 		const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION);
   1115 
   1116 		if (deviceVersion.majorNum != deqpVersion.majorNum)
   1117 		{
   1118 			log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage;
   1119 			return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
   1120 		}
   1121 
   1122 		if (deviceVersion.minorNum > deqpVersion.minorNum)
   1123 		{
   1124 			log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage;
   1125 			return tcu::TestStatus::fail("deviceProperties apiVersion not valid");
   1126 		}
   1127 	}
   1128 
   1129 	return tcu::TestStatus::pass("DeviceProperites query succeeded");
   1130 }
   1131 
   1132 tcu::TestStatus deviceQueueFamilyProperties (Context& context)
   1133 {
   1134 	TestLog&								log					= context.getTestContext().getLog();
   1135 	const vector<VkQueueFamilyProperties>	queueProperties		= getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
   1136 
   1137 	log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage;
   1138 
   1139 	for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++)
   1140 		log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage;
   1141 
   1142 	return tcu::TestStatus::pass("Querying queue properties succeeded");
   1143 }
   1144 
   1145 tcu::TestStatus deviceMemoryProperties (Context& context)
   1146 {
   1147 	TestLog&							log			= context.getTestContext().getLog();
   1148 	VkPhysicalDeviceMemoryProperties*	memProps;
   1149 	deUint8								buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE];
   1150 
   1151 	memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer);
   1152 	deMemset(buffer, GUARD_VALUE, sizeof(buffer));
   1153 
   1154 	context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps);
   1155 
   1156 	log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
   1157 		<< TestLog::Message << *memProps << TestLog::EndMessage;
   1158 
   1159 	for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++)
   1160 	{
   1161 		if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE)
   1162 		{
   1163 			log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage;
   1164 			return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow");
   1165 		}
   1166 	}
   1167 
   1168 	if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS)
   1169 	{
   1170 		log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage;
   1171 		return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large");
   1172 	}
   1173 
   1174 	if (memProps->memoryHeapCount == 1)
   1175 	{
   1176 		if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
   1177 		{
   1178 			log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage;
   1179 			return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags");
   1180 		}
   1181 	}
   1182 
   1183 	const VkMemoryPropertyFlags validPropertyFlags[] =
   1184 	{
   1185 		0,
   1186 		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
   1187 		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
   1188 		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
   1189 		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
   1190 		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
   1191 		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
   1192 		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
   1193 		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
   1194 	};
   1195 
   1196 	const VkMemoryPropertyFlags requiredPropertyFlags[] =
   1197 	{
   1198 		VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
   1199 	};
   1200 
   1201 	bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)];
   1202 	std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
   1203 
   1204 	for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++)
   1205 	{
   1206 		bool validPropTypeFound = false;
   1207 
   1208 		if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount)
   1209 		{
   1210 			log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage;
   1211 			return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex");
   1212 		}
   1213 
   1214 		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;
   1215 
   1216 		for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++)
   1217 			if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator)
   1218 				requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true;
   1219 
   1220 		if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck))
   1221 			validPropTypeFound = true;
   1222 
   1223 		if (!validPropTypeFound)
   1224 		{
   1225 			log << TestLog::Message << "deviceMemoryProperties - propertyFlags "
   1226 				<< memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage;
   1227 			return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
   1228 		}
   1229 
   1230 		if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
   1231 		{
   1232 			if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0)
   1233 			{
   1234 				log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage;
   1235 				return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
   1236 			}
   1237 		}
   1238 		else
   1239 		{
   1240 			if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
   1241 			{
   1242 				log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage;
   1243 				return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags");
   1244 			}
   1245 		}
   1246 	}
   1247 
   1248 	bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false);
   1249 	if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound))
   1250 	{
   1251 		DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags));
   1252 		log << TestLog::Message << "deviceMemoryProperties - required property flags "
   1253 			<< getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage;
   1254 
   1255 		return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid");
   1256 	}
   1257 
   1258 	return tcu::TestStatus::pass("Querying memory properties succeeded");
   1259 }
   1260 
   1261 // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead
   1262 
   1263 VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format)
   1264 {
   1265 	static const VkFormat s_requiredSampledImageBlitSrcFormats[] =
   1266 	{
   1267 		VK_FORMAT_B4G4R4A4_UNORM_PACK16,
   1268 		VK_FORMAT_R5G6B5_UNORM_PACK16,
   1269 		VK_FORMAT_A1R5G5B5_UNORM_PACK16,
   1270 		VK_FORMAT_R8_UNORM,
   1271 		VK_FORMAT_R8_SNORM,
   1272 		VK_FORMAT_R8_UINT,
   1273 		VK_FORMAT_R8_SINT,
   1274 		VK_FORMAT_R8G8_UNORM,
   1275 		VK_FORMAT_R8G8_SNORM,
   1276 		VK_FORMAT_R8G8_UINT,
   1277 		VK_FORMAT_R8G8_SINT,
   1278 		VK_FORMAT_R8G8B8A8_UNORM,
   1279 		VK_FORMAT_R8G8B8A8_SNORM,
   1280 		VK_FORMAT_R8G8B8A8_UINT,
   1281 		VK_FORMAT_R8G8B8A8_SINT,
   1282 		VK_FORMAT_R8G8B8A8_SRGB,
   1283 		VK_FORMAT_B8G8R8A8_UNORM,
   1284 		VK_FORMAT_B8G8R8A8_SRGB,
   1285 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1286 		VK_FORMAT_A8B8G8R8_SNORM_PACK32,
   1287 		VK_FORMAT_A8B8G8R8_UINT_PACK32,
   1288 		VK_FORMAT_A8B8G8R8_SINT_PACK32,
   1289 		VK_FORMAT_A8B8G8R8_SRGB_PACK32,
   1290 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
   1291 		VK_FORMAT_A2B10G10R10_UINT_PACK32,
   1292 		VK_FORMAT_R16_UINT,
   1293 		VK_FORMAT_R16_SINT,
   1294 		VK_FORMAT_R16_SFLOAT,
   1295 		VK_FORMAT_R16G16_UINT,
   1296 		VK_FORMAT_R16G16_SINT,
   1297 		VK_FORMAT_R16G16_SFLOAT,
   1298 		VK_FORMAT_R16G16B16A16_UINT,
   1299 		VK_FORMAT_R16G16B16A16_SINT,
   1300 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1301 		VK_FORMAT_R32_UINT,
   1302 		VK_FORMAT_R32_SINT,
   1303 		VK_FORMAT_R32_SFLOAT,
   1304 		VK_FORMAT_R32G32_UINT,
   1305 		VK_FORMAT_R32G32_SINT,
   1306 		VK_FORMAT_R32G32_SFLOAT,
   1307 		VK_FORMAT_R32G32B32A32_UINT,
   1308 		VK_FORMAT_R32G32B32A32_SINT,
   1309 		VK_FORMAT_R32G32B32A32_SFLOAT,
   1310 		VK_FORMAT_B10G11R11_UFLOAT_PACK32,
   1311 		VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
   1312 		VK_FORMAT_D16_UNORM,
   1313 		VK_FORMAT_D32_SFLOAT
   1314 	};
   1315 	static const VkFormat s_requiredSampledImageFilterLinearFormats[] =
   1316 	{
   1317 		VK_FORMAT_B4G4R4A4_UNORM_PACK16,
   1318 		VK_FORMAT_R5G6B5_UNORM_PACK16,
   1319 		VK_FORMAT_A1R5G5B5_UNORM_PACK16,
   1320 		VK_FORMAT_R8_UNORM,
   1321 		VK_FORMAT_R8_SNORM,
   1322 		VK_FORMAT_R8G8_UNORM,
   1323 		VK_FORMAT_R8G8_SNORM,
   1324 		VK_FORMAT_R8G8B8A8_UNORM,
   1325 		VK_FORMAT_R8G8B8A8_SNORM,
   1326 		VK_FORMAT_R8G8B8A8_SRGB,
   1327 		VK_FORMAT_B8G8R8A8_UNORM,
   1328 		VK_FORMAT_B8G8R8A8_SRGB,
   1329 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1330 		VK_FORMAT_A8B8G8R8_SNORM_PACK32,
   1331 		VK_FORMAT_A8B8G8R8_SRGB_PACK32,
   1332 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
   1333 		VK_FORMAT_R16_SFLOAT,
   1334 		VK_FORMAT_R16G16_SFLOAT,
   1335 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1336 		VK_FORMAT_B10G11R11_UFLOAT_PACK32,
   1337 		VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
   1338 	};
   1339 	static const VkFormat s_requiredStorageImageFormats[] =
   1340 	{
   1341 		VK_FORMAT_R8G8B8A8_UNORM,
   1342 		VK_FORMAT_R8G8B8A8_SNORM,
   1343 		VK_FORMAT_R8G8B8A8_UINT,
   1344 		VK_FORMAT_R8G8B8A8_SINT,
   1345 		VK_FORMAT_R16G16B16A16_UINT,
   1346 		VK_FORMAT_R16G16B16A16_SINT,
   1347 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1348 		VK_FORMAT_R32_UINT,
   1349 		VK_FORMAT_R32_SINT,
   1350 		VK_FORMAT_R32_SFLOAT,
   1351 		VK_FORMAT_R32G32_UINT,
   1352 		VK_FORMAT_R32G32_SINT,
   1353 		VK_FORMAT_R32G32_SFLOAT,
   1354 		VK_FORMAT_R32G32B32A32_UINT,
   1355 		VK_FORMAT_R32G32B32A32_SINT,
   1356 		VK_FORMAT_R32G32B32A32_SFLOAT
   1357 	};
   1358 	static const VkFormat s_requiredStorageImageAtomicFormats[] =
   1359 	{
   1360 		VK_FORMAT_R32_UINT,
   1361 		VK_FORMAT_R32_SINT
   1362 	};
   1363 	static const VkFormat s_requiredColorAttachmentBlitDstFormats[] =
   1364 	{
   1365 		VK_FORMAT_R5G6B5_UNORM_PACK16,
   1366 		VK_FORMAT_A1R5G5B5_UNORM_PACK16,
   1367 		VK_FORMAT_R8_UNORM,
   1368 		VK_FORMAT_R8_UINT,
   1369 		VK_FORMAT_R8_SINT,
   1370 		VK_FORMAT_R8G8_UNORM,
   1371 		VK_FORMAT_R8G8_UINT,
   1372 		VK_FORMAT_R8G8_SINT,
   1373 		VK_FORMAT_R8G8B8A8_UNORM,
   1374 		VK_FORMAT_R8G8B8A8_UINT,
   1375 		VK_FORMAT_R8G8B8A8_SINT,
   1376 		VK_FORMAT_R8G8B8A8_SRGB,
   1377 		VK_FORMAT_B8G8R8A8_UNORM,
   1378 		VK_FORMAT_B8G8R8A8_SRGB,
   1379 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1380 		VK_FORMAT_A8B8G8R8_UINT_PACK32,
   1381 		VK_FORMAT_A8B8G8R8_SINT_PACK32,
   1382 		VK_FORMAT_A8B8G8R8_SRGB_PACK32,
   1383 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
   1384 		VK_FORMAT_A2B10G10R10_UINT_PACK32,
   1385 		VK_FORMAT_R16_UINT,
   1386 		VK_FORMAT_R16_SINT,
   1387 		VK_FORMAT_R16_SFLOAT,
   1388 		VK_FORMAT_R16G16_UINT,
   1389 		VK_FORMAT_R16G16_SINT,
   1390 		VK_FORMAT_R16G16_SFLOAT,
   1391 		VK_FORMAT_R16G16B16A16_UINT,
   1392 		VK_FORMAT_R16G16B16A16_SINT,
   1393 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1394 		VK_FORMAT_R32_UINT,
   1395 		VK_FORMAT_R32_SINT,
   1396 		VK_FORMAT_R32_SFLOAT,
   1397 		VK_FORMAT_R32G32_UINT,
   1398 		VK_FORMAT_R32G32_SINT,
   1399 		VK_FORMAT_R32G32_SFLOAT,
   1400 		VK_FORMAT_R32G32B32A32_UINT,
   1401 		VK_FORMAT_R32G32B32A32_SINT,
   1402 		VK_FORMAT_R32G32B32A32_SFLOAT
   1403 	};
   1404 	static const VkFormat s_requiredColorAttachmentBlendFormats[] =
   1405 	{
   1406 		VK_FORMAT_R5G6B5_UNORM_PACK16,
   1407 		VK_FORMAT_A1R5G5B5_UNORM_PACK16,
   1408 		VK_FORMAT_R8_UNORM,
   1409 		VK_FORMAT_R8G8_UNORM,
   1410 		VK_FORMAT_R8G8B8A8_UNORM,
   1411 		VK_FORMAT_R8G8B8A8_SRGB,
   1412 		VK_FORMAT_B8G8R8A8_UNORM,
   1413 		VK_FORMAT_B8G8R8A8_SRGB,
   1414 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1415 		VK_FORMAT_A8B8G8R8_SRGB_PACK32,
   1416 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
   1417 		VK_FORMAT_R16_SFLOAT,
   1418 		VK_FORMAT_R16G16_SFLOAT,
   1419 		VK_FORMAT_R16G16B16A16_SFLOAT
   1420 	};
   1421 	static const VkFormat s_requiredDepthStencilAttachmentFormats[] =
   1422 	{
   1423 		VK_FORMAT_D16_UNORM
   1424 	};
   1425 
   1426 	VkFormatFeatureFlags	flags	= (VkFormatFeatureFlags)0;
   1427 
   1428 	if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format))
   1429 		flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT;
   1430 
   1431 	if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterLinearFormats), DE_ARRAY_END(s_requiredSampledImageFilterLinearFormats), format))
   1432 		flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
   1433 
   1434 	if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format))
   1435 		flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
   1436 
   1437 	if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format))
   1438 		flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
   1439 
   1440 	if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format))
   1441 		flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT;
   1442 
   1443 	if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format))
   1444 		flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
   1445 
   1446 	if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format))
   1447 		flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
   1448 
   1449 	return flags;
   1450 }
   1451 
   1452 VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format)
   1453 {
   1454 	static const VkFormat s_requiredVertexBufferFormats[] =
   1455 	{
   1456 		VK_FORMAT_R8_UNORM,
   1457 		VK_FORMAT_R8_SNORM,
   1458 		VK_FORMAT_R8_UINT,
   1459 		VK_FORMAT_R8_SINT,
   1460 		VK_FORMAT_R8G8_UNORM,
   1461 		VK_FORMAT_R8G8_SNORM,
   1462 		VK_FORMAT_R8G8_UINT,
   1463 		VK_FORMAT_R8G8_SINT,
   1464 		VK_FORMAT_R8G8B8A8_UNORM,
   1465 		VK_FORMAT_R8G8B8A8_SNORM,
   1466 		VK_FORMAT_R8G8B8A8_UINT,
   1467 		VK_FORMAT_R8G8B8A8_SINT,
   1468 		VK_FORMAT_B8G8R8A8_UNORM,
   1469 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1470 		VK_FORMAT_A8B8G8R8_SNORM_PACK32,
   1471 		VK_FORMAT_A8B8G8R8_UINT_PACK32,
   1472 		VK_FORMAT_A8B8G8R8_SINT_PACK32,
   1473 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
   1474 		VK_FORMAT_R16_UNORM,
   1475 		VK_FORMAT_R16_SNORM,
   1476 		VK_FORMAT_R16_UINT,
   1477 		VK_FORMAT_R16_SINT,
   1478 		VK_FORMAT_R16_SFLOAT,
   1479 		VK_FORMAT_R16G16_UNORM,
   1480 		VK_FORMAT_R16G16_SNORM,
   1481 		VK_FORMAT_R16G16_UINT,
   1482 		VK_FORMAT_R16G16_SINT,
   1483 		VK_FORMAT_R16G16_SFLOAT,
   1484 		VK_FORMAT_R16G16B16A16_UNORM,
   1485 		VK_FORMAT_R16G16B16A16_SNORM,
   1486 		VK_FORMAT_R16G16B16A16_UINT,
   1487 		VK_FORMAT_R16G16B16A16_SINT,
   1488 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1489 		VK_FORMAT_R32_UINT,
   1490 		VK_FORMAT_R32_SINT,
   1491 		VK_FORMAT_R32_SFLOAT,
   1492 		VK_FORMAT_R32G32_UINT,
   1493 		VK_FORMAT_R32G32_SINT,
   1494 		VK_FORMAT_R32G32_SFLOAT,
   1495 		VK_FORMAT_R32G32B32_UINT,
   1496 		VK_FORMAT_R32G32B32_SINT,
   1497 		VK_FORMAT_R32G32B32_SFLOAT,
   1498 		VK_FORMAT_R32G32B32A32_UINT,
   1499 		VK_FORMAT_R32G32B32A32_SINT,
   1500 		VK_FORMAT_R32G32B32A32_SFLOAT
   1501 	};
   1502 	static const VkFormat s_requiredUniformTexelBufferFormats[] =
   1503 	{
   1504 		VK_FORMAT_R8_UNORM,
   1505 		VK_FORMAT_R8_SNORM,
   1506 		VK_FORMAT_R8_UINT,
   1507 		VK_FORMAT_R8_SINT,
   1508 		VK_FORMAT_R8G8_UNORM,
   1509 		VK_FORMAT_R8G8_SNORM,
   1510 		VK_FORMAT_R8G8_UINT,
   1511 		VK_FORMAT_R8G8_SINT,
   1512 		VK_FORMAT_R8G8B8A8_UNORM,
   1513 		VK_FORMAT_R8G8B8A8_SNORM,
   1514 		VK_FORMAT_R8G8B8A8_UINT,
   1515 		VK_FORMAT_R8G8B8A8_SINT,
   1516 		VK_FORMAT_B8G8R8A8_UNORM,
   1517 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1518 		VK_FORMAT_A8B8G8R8_SNORM_PACK32,
   1519 		VK_FORMAT_A8B8G8R8_UINT_PACK32,
   1520 		VK_FORMAT_A8B8G8R8_SINT_PACK32,
   1521 		VK_FORMAT_A2B10G10R10_UNORM_PACK32,
   1522 		VK_FORMAT_A2B10G10R10_UINT_PACK32,
   1523 		VK_FORMAT_R16_UINT,
   1524 		VK_FORMAT_R16_SINT,
   1525 		VK_FORMAT_R16_SFLOAT,
   1526 		VK_FORMAT_R16G16_UINT,
   1527 		VK_FORMAT_R16G16_SINT,
   1528 		VK_FORMAT_R16G16_SFLOAT,
   1529 		VK_FORMAT_R16G16B16A16_UINT,
   1530 		VK_FORMAT_R16G16B16A16_SINT,
   1531 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1532 		VK_FORMAT_R32_UINT,
   1533 		VK_FORMAT_R32_SINT,
   1534 		VK_FORMAT_R32_SFLOAT,
   1535 		VK_FORMAT_R32G32_UINT,
   1536 		VK_FORMAT_R32G32_SINT,
   1537 		VK_FORMAT_R32G32_SFLOAT,
   1538 		VK_FORMAT_R32G32B32A32_UINT,
   1539 		VK_FORMAT_R32G32B32A32_SINT,
   1540 		VK_FORMAT_R32G32B32A32_SFLOAT,
   1541 		VK_FORMAT_B10G11R11_UFLOAT_PACK32
   1542 	};
   1543 	static const VkFormat s_requiredStorageTexelBufferFormats[] =
   1544 	{
   1545 		VK_FORMAT_R8G8B8A8_UNORM,
   1546 		VK_FORMAT_R8G8B8A8_SNORM,
   1547 		VK_FORMAT_R8G8B8A8_UINT,
   1548 		VK_FORMAT_R8G8B8A8_SINT,
   1549 		VK_FORMAT_A8B8G8R8_UNORM_PACK32,
   1550 		VK_FORMAT_A8B8G8R8_SNORM_PACK32,
   1551 		VK_FORMAT_A8B8G8R8_UINT_PACK32,
   1552 		VK_FORMAT_A8B8G8R8_SINT_PACK32,
   1553 		VK_FORMAT_R16G16B16A16_UINT,
   1554 		VK_FORMAT_R16G16B16A16_SINT,
   1555 		VK_FORMAT_R16G16B16A16_SFLOAT,
   1556 		VK_FORMAT_R32_UINT,
   1557 		VK_FORMAT_R32_SINT,
   1558 		VK_FORMAT_R32_SFLOAT,
   1559 		VK_FORMAT_R32G32_UINT,
   1560 		VK_FORMAT_R32G32_SINT,
   1561 		VK_FORMAT_R32G32_SFLOAT,
   1562 		VK_FORMAT_R32G32B32A32_UINT,
   1563 		VK_FORMAT_R32G32B32A32_SINT,
   1564 		VK_FORMAT_R32G32B32A32_SFLOAT
   1565 	};
   1566 	static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] =
   1567 	{
   1568 		VK_FORMAT_R32_UINT,
   1569 		VK_FORMAT_R32_SINT
   1570 	};
   1571 
   1572 	VkFormatFeatureFlags	flags	= (VkFormatFeatureFlags)0;
   1573 
   1574 	if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format))
   1575 		flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
   1576 
   1577 	if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format))
   1578 		flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
   1579 
   1580 	if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format))
   1581 		flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
   1582 
   1583 	if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format))
   1584 		flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
   1585 
   1586 	return flags;
   1587 }
   1588 
   1589 tcu::TestStatus formatProperties (Context& context, VkFormat format)
   1590 {
   1591 	TestLog&					log					= context.getTestContext().getLog();
   1592 	const VkFormatProperties	properties			= getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
   1593 	bool						allOk				= true;
   1594 
   1595 	// \todo [2017-05-16 pyry] This should be extended to cover for example COLOR_ATTACHMENT for depth formats etc.
   1596 	// \todo [2017-05-18 pyry] Any other color conversion related features that can't be supported by regular formats?
   1597 	const VkFormatFeatureFlags	notAllowedFeatures	= VK_FORMAT_FEATURE_DISJOINT_BIT_KHR;
   1598 
   1599 
   1600 	const struct
   1601 	{
   1602 		VkFormatFeatureFlags VkFormatProperties::*	field;
   1603 		const char*									fieldName;
   1604 		VkFormatFeatureFlags						requiredFeatures;
   1605 	} fields[] =
   1606 	{
   1607 		{ &VkFormatProperties::linearTilingFeatures,	"linearTilingFeatures",		(VkFormatFeatureFlags)0						},
   1608 		{ &VkFormatProperties::optimalTilingFeatures,	"optimalTilingFeatures",	getRequiredOptimalTilingFeatures(format)	},
   1609 		{ &VkFormatProperties::bufferFeatures,			"bufferFeatures",			getRequiredBufferFeatures(format)			}
   1610 	};
   1611 
   1612 	log << TestLog::Message << properties << TestLog::EndMessage;
   1613 
   1614 	for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
   1615 	{
   1616 		const char* const				fieldName	= fields[fieldNdx].fieldName;
   1617 		const VkFormatFeatureFlags		supported	= properties.*fields[fieldNdx].field;
   1618 		const VkFormatFeatureFlags		required	= fields[fieldNdx].requiredFeatures;
   1619 
   1620 		if ((supported & required) != required)
   1621 		{
   1622 			log << TestLog::Message << "ERROR in " << fieldName << ":\n"
   1623 								    << "  required: " << getFormatFeatureFlagsStr(required) << "\n  "
   1624 									<< "  missing: " << getFormatFeatureFlagsStr(~supported & required)
   1625 				<< TestLog::EndMessage;
   1626 			allOk = false;
   1627 		}
   1628 
   1629 		if ((supported & notAllowedFeatures) != 0)
   1630 		{
   1631 			log << TestLog::Message << "ERROR in " << fieldName << ":\n"
   1632 									<< "  has: " << getFormatFeatureFlagsStr(supported & notAllowedFeatures)
   1633 				<< TestLog::EndMessage;
   1634 			allOk = false;
   1635 		}
   1636 	}
   1637 
   1638 	if (allOk)
   1639 		return tcu::TestStatus::pass("Query and validation passed");
   1640 	else
   1641 		return tcu::TestStatus::fail("Required features not supported");
   1642 }
   1643 
   1644 VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR getPhysicalDeviceSamplerYcbcrConversionFeatures (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
   1645 {
   1646 	VkPhysicalDeviceFeatures2KHR						coreFeatures;
   1647 	VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR	ycbcrFeatures;
   1648 
   1649 	deMemset(&coreFeatures, 0, sizeof(coreFeatures));
   1650 	deMemset(&ycbcrFeatures, 0, sizeof(ycbcrFeatures));
   1651 
   1652 	coreFeatures.sType		= VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
   1653 	coreFeatures.pNext		= &ycbcrFeatures;
   1654 	ycbcrFeatures.sType		= VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR;
   1655 
   1656 	vk.getPhysicalDeviceFeatures2KHR(physicalDevice, &coreFeatures);
   1657 
   1658 	return ycbcrFeatures;
   1659 }
   1660 
   1661 void checkYcbcrConversionSupport (Context& context)
   1662 {
   1663 	if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_KHR_sampler_ycbcr_conversion"))
   1664 		TCU_THROW(NotSupportedError, "VK_KHR_sampler_ycbcr_conversion is not supported");
   1665 
   1666 	// Hard dependency for ycbcr
   1667 	TCU_CHECK(de::contains(context.getInstanceExtensions().begin(), context.getInstanceExtensions().end(), "VK_KHR_get_physical_device_properties2"));
   1668 
   1669 	{
   1670 		const VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR	ycbcrFeatures	= getPhysicalDeviceSamplerYcbcrConversionFeatures(context.getInstanceInterface(), context.getPhysicalDevice());
   1671 
   1672 		if (ycbcrFeatures.samplerYcbcrConversion == VK_FALSE)
   1673 			TCU_THROW(NotSupportedError, "samplerYcbcrConversion is not supported");
   1674 	}
   1675 }
   1676 
   1677 VkFormatFeatureFlags getAllowedYcbcrFormatFeatures (VkFormat format)
   1678 {
   1679 	DE_ASSERT(isYCbCrFormat(format));
   1680 
   1681 	VkFormatFeatureFlags	flags	= (VkFormatFeatureFlags)0;
   1682 
   1683 	// all formats *may* support these
   1684 	flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
   1685 	flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
   1686 	flags |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR;
   1687 	flags |= VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR;
   1688 	flags |= VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR;
   1689 	flags |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR;
   1690 	flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR;
   1691 	flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR;
   1692 	flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR;
   1693 	flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR;
   1694     flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_KHR;
   1695 
   1696 	// multi-plane formats *may* support DISJOINT_BIT_KHR
   1697 	if (getPlaneCount(format) >= 2)
   1698 		flags |= VK_FORMAT_FEATURE_DISJOINT_BIT_KHR;
   1699 
   1700 	if (isChromaSubsampled(format))
   1701 		flags |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR;
   1702 
   1703 	return flags;
   1704 }
   1705 
   1706 tcu::TestStatus ycbcrFormatProperties (Context& context, VkFormat format)
   1707 {
   1708 	DE_ASSERT(isYCbCrFormat(format));
   1709 	checkYcbcrConversionSupport(context);
   1710 
   1711 	TestLog&					log						= context.getTestContext().getLog();
   1712 	const VkFormatProperties	properties				= getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
   1713 	bool						allOk					= true;
   1714 	const VkFormatFeatureFlags	allowedImageFeatures	= getAllowedYcbcrFormatFeatures(format);
   1715 
   1716 	const struct
   1717 	{
   1718 		VkFormatFeatureFlags VkFormatProperties::*	field;
   1719 		const char*									fieldName;
   1720 		bool										requiredFeatures;
   1721 		VkFormatFeatureFlags						allowedFeatures;
   1722 	} fields[] =
   1723 	{
   1724 		{ &VkFormatProperties::linearTilingFeatures,	"linearTilingFeatures",		false,	allowedImageFeatures	},
   1725 		{ &VkFormatProperties::optimalTilingFeatures,	"optimalTilingFeatures",	true,	allowedImageFeatures	},
   1726 		{ &VkFormatProperties::bufferFeatures,			"bufferFeatures",			false,	(VkFormatFeatureFlags)0	}
   1727 	};
   1728 	static const VkFormat		s_requiredBaseFormats[]	=
   1729 	{
   1730 		VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR,
   1731 		VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR
   1732 	};
   1733 	const bool					isRequiredBaseFormat	(de::contains(DE_ARRAY_BEGIN(s_requiredBaseFormats), DE_ARRAY_END(s_requiredBaseFormats), format));
   1734 
   1735 	log << TestLog::Message << properties << TestLog::EndMessage;
   1736 
   1737 	for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++)
   1738 	{
   1739 		const char* const				fieldName	= fields[fieldNdx].fieldName;
   1740 		const VkFormatFeatureFlags		supported	= properties.*fields[fieldNdx].field;
   1741 		const VkFormatFeatureFlags		allowed		= fields[fieldNdx].allowedFeatures;
   1742 
   1743 		if (isRequiredBaseFormat && fields[fieldNdx].requiredFeatures)
   1744 		{
   1745 			const VkFormatFeatureFlags	required	= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
   1746 													| VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR
   1747 													| VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR
   1748 													| VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR;
   1749 
   1750 			if ((supported & required) != required)
   1751 			{
   1752 				log << TestLog::Message << "ERROR in " << fieldName << ":\n"
   1753 										<< "  required: " << getFormatFeatureFlagsStr(required) << "\n  "
   1754 										<< "  missing: " << getFormatFeatureFlagsStr(~supported & required)
   1755 					<< TestLog::EndMessage;
   1756 				allOk = false;
   1757 			}
   1758 
   1759 			if ((supported & (VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR | VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR)) == 0)
   1760 			{
   1761 				log << TestLog::Message << "ERROR in " << fieldName << ":\n"
   1762 										<< "  Either VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR or VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR required"
   1763 					<< TestLog::EndMessage;
   1764 				allOk = false;
   1765 			}
   1766 		}
   1767 
   1768 		if ((supported & ~allowed) != 0)
   1769 		{
   1770 			log << TestLog::Message << "ERROR in " << fieldName << ":\n"
   1771 								    << "  has: " << getFormatFeatureFlagsStr(supported & ~allowed)
   1772 				<< TestLog::EndMessage;
   1773 			allOk = false;
   1774 		}
   1775 	}
   1776 
   1777 	if (allOk)
   1778 		return tcu::TestStatus::pass("Query and validation passed");
   1779 	else
   1780 		return tcu::TestStatus::fail("Required features not supported");
   1781 }
   1782 
   1783 bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features)
   1784 {
   1785 	const VkFormatProperties	properties	= getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
   1786 
   1787 	return (properties.optimalTilingFeatures & features) == features;
   1788 }
   1789 
   1790 bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features)
   1791 {
   1792 	for (const VkFormat* cur = begin; cur != end; ++cur)
   1793 	{
   1794 		if (!optimalTilingFeaturesSupported(context, *cur, features))
   1795 			return false;
   1796 	}
   1797 
   1798 	return true;
   1799 }
   1800 
   1801 tcu::TestStatus testDepthStencilSupported (Context& context)
   1802 {
   1803 	if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
   1804 		!optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
   1805 		return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT");
   1806 
   1807 	if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) &&
   1808 		!optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
   1809 		return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT");
   1810 
   1811 	return tcu::TestStatus::pass("Required depth/stencil formats supported");
   1812 }
   1813 
   1814 tcu::TestStatus testCompressedFormatsSupported (Context& context)
   1815 {
   1816 	static const VkFormat s_allBcFormats[] =
   1817 	{
   1818 		VK_FORMAT_BC1_RGB_UNORM_BLOCK,
   1819 		VK_FORMAT_BC1_RGB_SRGB_BLOCK,
   1820 		VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
   1821 		VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
   1822 		VK_FORMAT_BC2_UNORM_BLOCK,
   1823 		VK_FORMAT_BC2_SRGB_BLOCK,
   1824 		VK_FORMAT_BC3_UNORM_BLOCK,
   1825 		VK_FORMAT_BC3_SRGB_BLOCK,
   1826 		VK_FORMAT_BC4_UNORM_BLOCK,
   1827 		VK_FORMAT_BC4_SNORM_BLOCK,
   1828 		VK_FORMAT_BC5_UNORM_BLOCK,
   1829 		VK_FORMAT_BC5_SNORM_BLOCK,
   1830 		VK_FORMAT_BC6H_UFLOAT_BLOCK,
   1831 		VK_FORMAT_BC6H_SFLOAT_BLOCK,
   1832 		VK_FORMAT_BC7_UNORM_BLOCK,
   1833 		VK_FORMAT_BC7_SRGB_BLOCK,
   1834 	};
   1835 	static const VkFormat s_allEtc2Formats[] =
   1836 	{
   1837 		VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
   1838 		VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
   1839 		VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
   1840 		VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
   1841 		VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
   1842 		VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
   1843 		VK_FORMAT_EAC_R11_UNORM_BLOCK,
   1844 		VK_FORMAT_EAC_R11_SNORM_BLOCK,
   1845 		VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
   1846 		VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
   1847 	};
   1848 	static const VkFormat s_allAstcLdrFormats[] =
   1849 	{
   1850 		VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
   1851 		VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
   1852 		VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
   1853 		VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
   1854 		VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
   1855 		VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
   1856 		VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
   1857 		VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
   1858 		VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
   1859 		VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
   1860 		VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
   1861 		VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
   1862 		VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
   1863 		VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
   1864 		VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
   1865 		VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
   1866 		VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
   1867 		VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
   1868 		VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
   1869 		VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
   1870 		VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
   1871 		VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
   1872 		VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
   1873 		VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
   1874 		VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
   1875 		VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
   1876 		VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
   1877 		VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
   1878 	};
   1879 
   1880 	static const struct
   1881 	{
   1882 		const char*									setName;
   1883 		const char*									featureName;
   1884 		const VkBool32 VkPhysicalDeviceFeatures::*	feature;
   1885 		const VkFormat*								formatsBegin;
   1886 		const VkFormat*								formatsEnd;
   1887 	} s_compressedFormatSets[] =
   1888 	{
   1889 		{ "BC",			"textureCompressionBC",			&VkPhysicalDeviceFeatures::textureCompressionBC,		DE_ARRAY_BEGIN(s_allBcFormats),			DE_ARRAY_END(s_allBcFormats)		},
   1890 		{ "ETC2",		"textureCompressionETC2",		&VkPhysicalDeviceFeatures::textureCompressionETC2,		DE_ARRAY_BEGIN(s_allEtc2Formats),		DE_ARRAY_END(s_allEtc2Formats)		},
   1891 		{ "ASTC LDR",	"textureCompressionASTC_LDR",	&VkPhysicalDeviceFeatures::textureCompressionASTC_LDR,	DE_ARRAY_BEGIN(s_allAstcLdrFormats),	DE_ARRAY_END(s_allAstcLdrFormats)	},
   1892 	};
   1893 
   1894 	TestLog&						log					= context.getTestContext().getLog();
   1895 	const VkPhysicalDeviceFeatures&	features			= context.getDeviceFeatures();
   1896 	int								numSupportedSets	= 0;
   1897 	int								numErrors			= 0;
   1898 	int								numWarnings			= 0;
   1899 
   1900 	for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx)
   1901 	{
   1902 		const char* const	setName			= s_compressedFormatSets[setNdx].setName;
   1903 		const char* const	featureName		= s_compressedFormatSets[setNdx].featureName;
   1904 		const bool			featureBitSet	= features.*s_compressedFormatSets[setNdx].feature == VK_TRUE;
   1905 		const bool			allSupported	= optimalTilingFeaturesSupportedForAll(context,
   1906 																				   s_compressedFormatSets[setNdx].formatsBegin,
   1907 																				   s_compressedFormatSets[setNdx].formatsEnd,
   1908 																				   VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
   1909 
   1910 		if (featureBitSet && !allSupported)
   1911 		{
   1912 			log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage;
   1913 			numErrors += 1;
   1914 		}
   1915 		else if (allSupported && !featureBitSet)
   1916 		{
   1917 			log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage;
   1918 			numWarnings += 1;
   1919 		}
   1920 
   1921 		if (featureBitSet)
   1922 		{
   1923 			log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage;
   1924 			numSupportedSets += 1;
   1925 		}
   1926 		else
   1927 			log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage;
   1928 	}
   1929 
   1930 	if (numSupportedSets == 0)
   1931 	{
   1932 		log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage;
   1933 		numErrors += 1;
   1934 	}
   1935 
   1936 	if (numErrors > 0)
   1937 		return tcu::TestStatus::fail("Compressed format support not valid");
   1938 	else if (numWarnings > 0)
   1939 		return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support");
   1940 	else
   1941 		return tcu::TestStatus::pass("Compressed texture format support is valid");
   1942 }
   1943 
   1944 void createFormatTests (tcu::TestCaseGroup* testGroup)
   1945 {
   1946 	DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0);
   1947 
   1948 	static const struct
   1949 	{
   1950 		VkFormat								begin;
   1951 		VkFormat								end;
   1952 		FunctionInstance1<VkFormat>::Function	testFunction;
   1953 	} s_formatRanges[] =
   1954 	{
   1955 		// core formats
   1956 		{ (VkFormat)(VK_FORMAT_UNDEFINED+1),	VK_CORE_FORMAT_LAST,										formatProperties },
   1957 
   1958 		// YCbCr formats
   1959 		{ VK_FORMAT_G8B8G8R8_422_UNORM_KHR,		(VkFormat)(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR+1),	ycbcrFormatProperties },
   1960 	};
   1961 
   1962 	for (int rangeNdx = 0; rangeNdx < DE_LENGTH_OF_ARRAY(s_formatRanges); ++rangeNdx)
   1963 	{
   1964 		const VkFormat								rangeBegin		= s_formatRanges[rangeNdx].begin;
   1965 		const VkFormat								rangeEnd		= s_formatRanges[rangeNdx].end;
   1966 		const FunctionInstance1<VkFormat>::Function	testFunction	= s_formatRanges[rangeNdx].testFunction;
   1967 
   1968 		for (VkFormat format = rangeBegin; format != rangeEnd; format = (VkFormat)(format+1))
   1969 		{
   1970 			const char* const	enumName	= getFormatName(format);
   1971 			const string		caseName	= de::toLower(string(enumName).substr(10));
   1972 
   1973 			addFunctionCase(testGroup, caseName, enumName, testFunction, format);
   1974 		}
   1975 	}
   1976 
   1977 	addFunctionCase(testGroup, "depth_stencil",			"",	testDepthStencilSupported);
   1978 	addFunctionCase(testGroup, "compressed_formats",	"",	testCompressedFormatsSupported);
   1979 }
   1980 
   1981 VkImageUsageFlags getValidImageUsageFlags (const VkFormatFeatureFlags supportedFeatures, const bool useKhrMaintenance1Semantics)
   1982 {
   1983 	VkImageUsageFlags	flags	= (VkImageUsageFlags)0;
   1984 
   1985 	if (useKhrMaintenance1Semantics)
   1986 	{
   1987 		if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR) != 0)
   1988 			flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
   1989 
   1990 		if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR) != 0)
   1991 			flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
   1992 	}
   1993 	else
   1994 	{
   1995 		// If format is supported at all, it must be valid transfer src+dst
   1996 		if (supportedFeatures != 0)
   1997 			flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT;
   1998 	}
   1999 
   2000 	if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
   2001 		flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
   2002 
   2003 	if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0)
   2004 		flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
   2005 
   2006 	if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
   2007 		flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
   2008 
   2009 	if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0)
   2010 		flags |= VK_IMAGE_USAGE_STORAGE_BIT;
   2011 
   2012 	return flags;
   2013 }
   2014 
   2015 bool isValidImageUsageFlagCombination (VkImageUsageFlags usage)
   2016 {
   2017 	if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)
   2018 	{
   2019 		const VkImageUsageFlags		allowedFlags	= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
   2020 													| VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
   2021 													| VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
   2022 													| VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
   2023 
   2024 		// Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT
   2025 		if ((usage & ~allowedFlags) != 0)
   2026 			return false;
   2027 
   2028 		// TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT
   2029 		if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0)
   2030 			return false;
   2031 	}
   2032 
   2033 	return usage != 0;
   2034 }
   2035 
   2036 VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage)
   2037 {
   2038 	VkImageCreateFlags	flags	= (VkImageCreateFlags)0;
   2039 
   2040 	if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
   2041 	{
   2042 		flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
   2043 
   2044 		if (type == VK_IMAGE_TYPE_2D)
   2045 			flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
   2046 	}
   2047 
   2048 	if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 &&
   2049 		(usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)
   2050 	{
   2051 		if (deviceFeatures.sparseBinding)
   2052 			flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT;
   2053 
   2054 		if (deviceFeatures.sparseResidencyAliased)
   2055 			flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT;
   2056 	}
   2057 
   2058 	return flags;
   2059 }
   2060 
   2061 bool isValidImageCreateFlagCombination (VkImageCreateFlags)
   2062 {
   2063 	return true;
   2064 }
   2065 
   2066 bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures&	deviceFeatures,
   2067 										  const VkFormat					format,
   2068 										  const VkFormatProperties&			formatProperties,
   2069 										  const VkImageType					imageType,
   2070 										  const VkImageTiling				imageTiling,
   2071 										  const VkImageUsageFlags			usageFlags,
   2072 										  const VkImageCreateFlags			createFlags)
   2073 {
   2074 	DE_UNREF(deviceFeatures);
   2075 	DE_UNREF(formatProperties);
   2076 	DE_UNREF(createFlags);
   2077 
   2078 	// Linear images can have arbitrary limitations
   2079 	if (imageTiling == VK_IMAGE_TILING_LINEAR)
   2080 		return false;
   2081 
   2082 	// Support for other usages for compressed formats is optional
   2083 	if (isCompressedFormat(format) &&
   2084 		(usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0)
   2085 		return false;
   2086 
   2087 	// Support for 1D, and sliced 3D compressed formats is optional
   2088 	if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
   2089 		return false;
   2090 
   2091 	// Support for 1D and 3D depth/stencil textures is optional
   2092 	if (isDepthStencilFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D))
   2093 		return false;
   2094 
   2095 	DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0);
   2096 	DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0);
   2097 
   2098 	if (createFlags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)
   2099 	{
   2100 		if (isCompressedFormat(format))
   2101 			return false;
   2102 
   2103 		if (isDepthStencilFormat(format))
   2104 			return false;
   2105 
   2106 		if (!deIsPowerOfTwo32(mapVkFormat(format).getPixelSize()))
   2107 			return false;
   2108 
   2109 		switch (imageType)
   2110 		{
   2111 			case VK_IMAGE_TYPE_2D:
   2112 				return (deviceFeatures.sparseResidencyImage2D == VK_TRUE);
   2113 			case VK_IMAGE_TYPE_3D:
   2114 				return (deviceFeatures.sparseResidencyImage3D == VK_TRUE);
   2115 			default:
   2116 				return false;
   2117 		}
   2118 	}
   2119 
   2120 	return true;
   2121 }
   2122 
   2123 VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits&	deviceLimits,
   2124 														 const VkFormat					format,
   2125 														 const VkImageUsageFlags		usageFlags)
   2126 {
   2127 	if (!isCompressedFormat(format))
   2128 	{
   2129 		const tcu::TextureFormat		tcuFormat		= mapVkFormat(format);
   2130 		const bool						hasDepthComp	= (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS);
   2131 		const bool						hasStencilComp	= (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS);
   2132 		const bool						isColorFormat	= !hasDepthComp && !hasStencilComp;
   2133 		VkSampleCountFlags				sampleCounts	= ~(VkSampleCountFlags)0;
   2134 
   2135 		DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat);
   2136 
   2137 		if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0)
   2138 			sampleCounts &= deviceLimits.storageImageSampleCounts;
   2139 
   2140 		if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0)
   2141 		{
   2142 			if (hasDepthComp)
   2143 				sampleCounts &= deviceLimits.sampledImageDepthSampleCounts;
   2144 
   2145 			if (hasStencilComp)
   2146 				sampleCounts &= deviceLimits.sampledImageStencilSampleCounts;
   2147 
   2148 			if (isColorFormat)
   2149 			{
   2150 				const tcu::TextureChannelClass	chnClass	= tcu::getTextureChannelClass(tcuFormat.type);
   2151 
   2152 				if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER ||
   2153 					chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER)
   2154 					sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts;
   2155 				else
   2156 					sampleCounts &= deviceLimits.sampledImageColorSampleCounts;
   2157 			}
   2158 		}
   2159 
   2160 		if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0)
   2161 			sampleCounts &= deviceLimits.framebufferColorSampleCounts;
   2162 
   2163 		if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)
   2164 		{
   2165 			if (hasDepthComp)
   2166 				sampleCounts &= deviceLimits.framebufferDepthSampleCounts;
   2167 
   2168 			if (hasStencilComp)
   2169 				sampleCounts &= deviceLimits.framebufferStencilSampleCounts;
   2170 		}
   2171 
   2172 		// If there is no usage flag set that would have corresponding device limit,
   2173 		// only VK_SAMPLE_COUNT_1_BIT is required.
   2174 		if (sampleCounts == ~(VkSampleCountFlags)0)
   2175 			sampleCounts &= VK_SAMPLE_COUNT_1_BIT;
   2176 
   2177 		return sampleCounts;
   2178 	}
   2179 	else
   2180 		return VK_SAMPLE_COUNT_1_BIT;
   2181 }
   2182 
   2183 struct ImageFormatPropertyCase
   2184 {
   2185 	typedef tcu::TestStatus (*Function) (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling);
   2186 
   2187 	Function		testFunction;
   2188 	VkFormat		format;
   2189 	VkImageType		imageType;
   2190 	VkImageTiling	tiling;
   2191 
   2192 	ImageFormatPropertyCase (Function testFunction_, VkFormat format_, VkImageType imageType_, VkImageTiling tiling_)
   2193 		: testFunction	(testFunction_)
   2194 		, format		(format_)
   2195 		, imageType		(imageType_)
   2196 		, tiling		(tiling_)
   2197 	{}
   2198 
   2199 	ImageFormatPropertyCase (void)
   2200 		: testFunction	((Function)DE_NULL)
   2201 		, format		(VK_FORMAT_UNDEFINED)
   2202 		, imageType		(VK_IMAGE_TYPE_LAST)
   2203 		, tiling		(VK_IMAGE_TILING_LAST)
   2204 	{}
   2205 };
   2206 
   2207 tcu::TestStatus execImageFormatTest (Context& context, ImageFormatPropertyCase testCase)
   2208 {
   2209 	return testCase.testFunction(context, testCase.format, testCase.imageType, testCase.tiling);
   2210 }
   2211 
   2212 void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
   2213 {
   2214 	DE_ASSERT(params.format == VK_FORMAT_UNDEFINED);
   2215 
   2216 	for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
   2217 	{
   2218 		const VkFormat		format			= (VkFormat)formatNdx;
   2219 		const char* const	enumName		= getFormatName(format);
   2220 		const string		caseName		= de::toLower(string(enumName).substr(10));
   2221 
   2222 		params.format = format;
   2223 
   2224 		addFunctionCase(testGroup, caseName, enumName, execImageFormatTest, params);
   2225 	}
   2226 }
   2227 
   2228 void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params)
   2229 {
   2230 	DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST);
   2231 
   2232 	testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal",	"",	createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_OPTIMAL)));
   2233 	testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear",	"",	createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_LINEAR)));
   2234 }
   2235 
   2236 void createImageFormatTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase::Function testFunction)
   2237 {
   2238 	testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST)));
   2239 	testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST)));
   2240 	testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST)));
   2241 }
   2242 
   2243 tcu::TestStatus imageFormatProperties (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
   2244 {
   2245 	TestLog&						log					= context.getTestContext().getLog();
   2246 	const VkPhysicalDeviceFeatures&	deviceFeatures		= context.getDeviceFeatures();
   2247 	const VkPhysicalDeviceLimits&	deviceLimits		= context.getDeviceProperties().limits;
   2248 	const VkFormatProperties		formatProperties	= getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format);
   2249 	const bool						hasKhrMaintenance1	= isExtensionSupported(context.getDeviceExtensions(), "VK_KHR_maintenance1");
   2250 
   2251 	const VkFormatFeatureFlags		supportedFeatures	= tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures;
   2252 	const VkImageUsageFlags			usageFlagSet		= getValidImageUsageFlags(supportedFeatures, hasKhrMaintenance1);
   2253 
   2254 	tcu::ResultCollector			results				(log, "ERROR: ");
   2255 
   2256 	if (hasKhrMaintenance1 && (supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0)
   2257 	{
   2258 		results.check((supportedFeatures & (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR)) != 0,
   2259 					  "A sampled image format must have VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR and VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR format feature flags set");
   2260 	}
   2261 
   2262 	for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++)
   2263 	{
   2264 		if ((curUsageFlags & ~usageFlagSet) != 0 ||
   2265 			!isValidImageUsageFlagCombination(curUsageFlags))
   2266 			continue;
   2267 
   2268 		const VkImageCreateFlags	createFlagSet		= getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags);
   2269 
   2270 		for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++)
   2271 		{
   2272 			if ((curCreateFlags & ~createFlagSet) != 0 ||
   2273 				!isValidImageCreateFlagCombination(curCreateFlags))
   2274 				continue;
   2275 
   2276 			const bool				isRequiredCombination	= isRequiredImageParameterCombination(deviceFeatures,
   2277 																								  format,
   2278 																								  formatProperties,
   2279 																								  imageType,
   2280 																								  tiling,
   2281 																								  curUsageFlags,
   2282 																								  curCreateFlags);
   2283 			VkImageFormatProperties	properties;
   2284 			VkResult				queryResult;
   2285 
   2286 			log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", "
   2287 									<< getImageTilingStr(tiling) << ", "
   2288 									<< getImageUsageFlagsStr(curUsageFlags) << ", "
   2289 									<< getImageCreateFlagsStr(curCreateFlags)
   2290 				<< TestLog::EndMessage;
   2291 
   2292 			// Set return value to known garbage
   2293 			deMemset(&properties, 0xcd, sizeof(properties));
   2294 
   2295 			queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(),
   2296 																								format,
   2297 																								imageType,
   2298 																								tiling,
   2299 																								curUsageFlags,
   2300 																								curCreateFlags,
   2301 																								&properties);
   2302 
   2303 			if (queryResult == VK_SUCCESS)
   2304 			{
   2305 				const deUint32	fullMipPyramidSize	= de::max(de::max(deLog2Ceil32(properties.maxExtent.width),
   2306 																	  deLog2Ceil32(properties.maxExtent.height)),
   2307 															  deLog2Ceil32(properties.maxExtent.depth)) + 1;
   2308 
   2309 				log << TestLog::Message << properties << "\n" << TestLog::EndMessage;
   2310 
   2311 				results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image");
   2312 				results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image");
   2313 				results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image");
   2314 				results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image");
   2315 
   2316 				if (tiling == VK_IMAGE_TILING_OPTIMAL && imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
   2317 					 (supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)))
   2318 				{
   2319 					const VkSampleCountFlags	requiredSampleCounts	= getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags);
   2320 					results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported");
   2321 				}
   2322 				else
   2323 					results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT");
   2324 
   2325 				if (isRequiredCombination)
   2326 				{
   2327 					results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width	>= deviceLimits.maxImageDimension1D),
   2328 								  "Reported dimensions smaller than device limits");
   2329 					results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width	>= deviceLimits.maxImageDimension2D &&
   2330 																	properties.maxExtent.height	>= deviceLimits.maxImageDimension2D),
   2331 								  "Reported dimensions smaller than device limits");
   2332 					results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width	>= deviceLimits.maxImageDimension3D &&
   2333 																	properties.maxExtent.height	>= deviceLimits.maxImageDimension3D &&
   2334 																	properties.maxExtent.depth	>= deviceLimits.maxImageDimension3D),
   2335 								  "Reported dimensions smaller than device limits");
   2336 					results.check(properties.maxMipLevels == fullMipPyramidSize, "maxMipLevels is not full mip pyramid size");
   2337 					results.check(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers,
   2338 								  "maxArrayLayers smaller than device limits");
   2339 				}
   2340 				else
   2341 				{
   2342 					results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size");
   2343 					results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers");
   2344 				}
   2345 
   2346 				results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE,
   2347 							  "maxResourceSize smaller than minimum required size");
   2348 			}
   2349 			else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED)
   2350 			{
   2351 				log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage;
   2352 
   2353 				if (isRequiredCombination)
   2354 					results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination");
   2355 
   2356 				// Specification requires that all fields are set to 0
   2357 				results.check(properties.maxExtent.width	== 0, "maxExtent.width != 0");
   2358 				results.check(properties.maxExtent.height	== 0, "maxExtent.height != 0");
   2359 				results.check(properties.maxExtent.depth	== 0, "maxExtent.depth != 0");
   2360 				results.check(properties.maxMipLevels		== 0, "maxMipLevels != 0");
   2361 				results.check(properties.maxArrayLayers		== 0, "maxArrayLayers != 0");
   2362 				results.check(properties.sampleCounts		== 0, "sampleCounts != 0");
   2363 				results.check(properties.maxResourceSize	== 0, "maxResourceSize != 0");
   2364 			}
   2365 			else
   2366 			{
   2367 				results.fail("Got unexpected error" + de::toString(queryResult));
   2368 			}
   2369 		}
   2370 	}
   2371 
   2372 	return tcu::TestStatus(results.getResult(), results.getMessage());
   2373 }
   2374 
   2375 // VK_KHR_get_physical_device_properties2
   2376 
   2377 Move<VkInstance> createInstanceWithExtension (const PlatformInterface& vkp, const char* extensionName)
   2378 {
   2379 	const vector<VkExtensionProperties>	instanceExts	= enumerateInstanceExtensionProperties(vkp, DE_NULL);
   2380 	vector<string>						enabledExts;
   2381 
   2382 	if (!isExtensionSupported(instanceExts, RequiredExtension(extensionName)))
   2383 		TCU_THROW(NotSupportedError, (string(extensionName) + " is not supported").c_str());
   2384 
   2385 	enabledExts.push_back(extensionName);
   2386 
   2387 	return createDefaultInstance(vkp, vector<string>() /* layers */, enabledExts);
   2388 }
   2389 
   2390 tcu::TestStatus deviceFeatures2 (Context& context)
   2391 {
   2392 	const PlatformInterface&		vkp			= context.getPlatformInterface();
   2393 	const Unique<VkInstance>		instance	(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2394 	const InstanceDriver			vki			(vkp, *instance);
   2395 	const vector<VkPhysicalDevice>	devices		= enumeratePhysicalDevices(vki, *instance);
   2396 
   2397 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2398 	{
   2399 		VkPhysicalDeviceFeatures		coreFeatures;
   2400 		VkPhysicalDeviceFeatures2KHR	extFeatures;
   2401 
   2402 		deMemset(&coreFeatures, 0xcd, sizeof(coreFeatures));
   2403 		deMemset(&extFeatures.features, 0xcd, sizeof(extFeatures.features));
   2404 
   2405 		extFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
   2406 		extFeatures.pNext = DE_NULL;
   2407 
   2408 		vki.getPhysicalDeviceFeatures(devices[deviceNdx], &coreFeatures);
   2409 		vki.getPhysicalDeviceFeatures2KHR(devices[deviceNdx], &extFeatures);
   2410 
   2411 		TCU_CHECK(extFeatures.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR);
   2412 		TCU_CHECK(extFeatures.pNext == DE_NULL);
   2413 
   2414 		if (deMemCmp(&coreFeatures, &extFeatures.features, sizeof(VkPhysicalDeviceFeatures)) != 0)
   2415 			TCU_FAIL("Mismatch between features reported by vkGetPhysicalDeviceFeatures and vkGetPhysicalDeviceFeatures2KHR");
   2416 	}
   2417 
   2418 	return tcu::TestStatus::pass("Querying device features succeeded");
   2419 }
   2420 
   2421 tcu::TestStatus deviceProperties2 (Context& context)
   2422 {
   2423 	const PlatformInterface&		vkp			= context.getPlatformInterface();
   2424 	const Unique<VkInstance>		instance	(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2425 	const InstanceDriver			vki			(vkp, *instance);
   2426 	const vector<VkPhysicalDevice>	devices		= enumeratePhysicalDevices(vki, *instance);
   2427 
   2428 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2429 	{
   2430 		VkPhysicalDeviceProperties		coreProperties;
   2431 		VkPhysicalDeviceProperties2KHR	extProperties;
   2432 
   2433 		extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
   2434 		extProperties.pNext = DE_NULL;
   2435 
   2436 		vki.getPhysicalDeviceProperties(devices[deviceNdx], &coreProperties);
   2437 		vki.getPhysicalDeviceProperties2KHR(devices[deviceNdx], &extProperties);
   2438 
   2439 		TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR);
   2440 		TCU_CHECK(extProperties.pNext == DE_NULL);
   2441 
   2442 		// We can't use memcmp() here because the structs may contain padding bytes that drivers may or may not
   2443 		// have written while writing the data and memcmp will compare them anyway, so we iterate through the
   2444 		// valid bytes for each field in the struct and compare only the valid bytes for each one.
   2445 		for (int propNdx = 0; propNdx < DE_LENGTH_OF_ARRAY(s_physicalDevicePropertiesOffsetTable); propNdx++)
   2446 		{
   2447 			const size_t offset					= s_physicalDevicePropertiesOffsetTable[propNdx].offset;
   2448 			const size_t size					= s_physicalDevicePropertiesOffsetTable[propNdx].size;
   2449 
   2450 			const deUint8* corePropertyBytes	= reinterpret_cast<deUint8*>(&coreProperties) + offset;
   2451 			const deUint8* extPropertyBytes		= reinterpret_cast<deUint8*>(&extProperties.properties) + offset;
   2452 
   2453 			if (deMemCmp(corePropertyBytes, extPropertyBytes, size) != 0)
   2454 				TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceProperties and vkGetPhysicalDeviceProperties2KHR");
   2455 		}
   2456 	}
   2457 
   2458 	return tcu::TestStatus::pass("Querying device properties succeeded");
   2459 }
   2460 
   2461 tcu::TestStatus deviceFormatProperties2 (Context& context)
   2462 {
   2463 	const PlatformInterface&		vkp			= context.getPlatformInterface();
   2464 	const Unique<VkInstance>		instance	(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2465 	const InstanceDriver			vki			(vkp, *instance);
   2466 	const vector<VkPhysicalDevice>	devices		= enumeratePhysicalDevices(vki, *instance);
   2467 
   2468 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2469 	{
   2470 		const VkPhysicalDevice	physicalDevice	= devices[deviceNdx];
   2471 
   2472 		for (int formatNdx = 0; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx)
   2473 		{
   2474 			const VkFormat			format			= (VkFormat)formatNdx;
   2475 			VkFormatProperties		coreProperties;
   2476 			VkFormatProperties2KHR	extProperties;
   2477 
   2478 			deMemset(&coreProperties, 0xcd, sizeof(VkFormatProperties));
   2479 			deMemset(&extProperties, 0xcd, sizeof(VkFormatProperties2KHR));
   2480 
   2481 			extProperties.sType	= VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR;
   2482 			extProperties.pNext = DE_NULL;
   2483 
   2484 			vki.getPhysicalDeviceFormatProperties(physicalDevice, format, &coreProperties);
   2485 			vki.getPhysicalDeviceFormatProperties2KHR(physicalDevice, format, &extProperties);
   2486 
   2487 			TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR);
   2488 			TCU_CHECK(extProperties.pNext == DE_NULL);
   2489 
   2490 		if (deMemCmp(&coreProperties, &extProperties.formatProperties, sizeof(VkFormatProperties)) != 0)
   2491 			TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceFormatProperties and vkGetPhysicalDeviceFormatProperties2KHR");
   2492 		}
   2493 	}
   2494 
   2495 	return tcu::TestStatus::pass("Querying device format properties succeeded");
   2496 }
   2497 
   2498 tcu::TestStatus deviceQueueFamilyProperties2 (Context& context)
   2499 {
   2500 	const PlatformInterface&		vkp			= context.getPlatformInterface();
   2501 	const Unique<VkInstance>		instance	(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2502 	const InstanceDriver			vki			(vkp, *instance);
   2503 	const vector<VkPhysicalDevice>	devices		= enumeratePhysicalDevices(vki, *instance);
   2504 
   2505 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2506 	{
   2507 		const VkPhysicalDevice	physicalDevice			= devices[deviceNdx];
   2508 		deUint32				numCoreQueueFamilies	= ~0u;
   2509 		deUint32				numExtQueueFamilies		= ~0u;
   2510 
   2511 		vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, DE_NULL);
   2512 		vki.getPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &numExtQueueFamilies, DE_NULL);
   2513 
   2514 		TCU_CHECK_MSG(numCoreQueueFamilies == numExtQueueFamilies, "Different number of queue family properties reported");
   2515 		TCU_CHECK(numCoreQueueFamilies > 0);
   2516 
   2517 		{
   2518 			std::vector<VkQueueFamilyProperties>		coreProperties	(numCoreQueueFamilies);
   2519 			std::vector<VkQueueFamilyProperties2KHR>	extProperties	(numExtQueueFamilies);
   2520 
   2521 			deMemset(&coreProperties[0], 0xcd, sizeof(VkQueueFamilyProperties)*numCoreQueueFamilies);
   2522 			deMemset(&extProperties[0], 0xcd, sizeof(VkQueueFamilyProperties2KHR)*numExtQueueFamilies);
   2523 
   2524 			for (size_t ndx = 0; ndx < extProperties.size(); ++ndx)
   2525 			{
   2526 				extProperties[ndx].sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR;
   2527 				extProperties[ndx].pNext = DE_NULL;
   2528 			}
   2529 
   2530 			vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, &coreProperties[0]);
   2531 			vki.getPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &numExtQueueFamilies, &extProperties[0]);
   2532 
   2533 			TCU_CHECK((size_t)numCoreQueueFamilies == coreProperties.size());
   2534 			TCU_CHECK((size_t)numExtQueueFamilies == extProperties.size());
   2535 			DE_ASSERT(numCoreQueueFamilies == numExtQueueFamilies);
   2536 
   2537 			for (size_t ndx = 0; ndx < extProperties.size(); ++ndx)
   2538 			{
   2539 				TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR);
   2540 				TCU_CHECK(extProperties[ndx].pNext == DE_NULL);
   2541 
   2542 				if (deMemCmp(&coreProperties[ndx], &extProperties[ndx].queueFamilyProperties, sizeof(VkQueueFamilyProperties)) != 0)
   2543 					TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceQueueFamilyProperties and vkGetPhysicalDeviceQueueFamilyProperties2KHR");
   2544 			}
   2545 		}
   2546 	}
   2547 
   2548 	return tcu::TestStatus::pass("Querying device queue family properties succeeded");
   2549 }
   2550 
   2551 tcu::TestStatus deviceMemoryProperties2 (Context& context)
   2552 {
   2553 	const PlatformInterface&		vkp			= context.getPlatformInterface();
   2554 	const Unique<VkInstance>		instance	(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2555 	const InstanceDriver			vki			(vkp, *instance);
   2556 	const vector<VkPhysicalDevice>	devices		= enumeratePhysicalDevices(vki, *instance);
   2557 
   2558 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2559 	{
   2560 		VkPhysicalDeviceMemoryProperties		coreProperties;
   2561 		VkPhysicalDeviceMemoryProperties2KHR	extProperties;
   2562 
   2563 		deMemset(&coreProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties));
   2564 		deMemset(&extProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties2KHR));
   2565 
   2566 		extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR;
   2567 		extProperties.pNext = DE_NULL;
   2568 
   2569 		vki.getPhysicalDeviceMemoryProperties(devices[deviceNdx], &coreProperties);
   2570 		vki.getPhysicalDeviceMemoryProperties2KHR(devices[deviceNdx], &extProperties);
   2571 
   2572 		TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR);
   2573 		TCU_CHECK(extProperties.pNext == DE_NULL);
   2574 
   2575 		if (deMemCmp(&coreProperties, &extProperties.memoryProperties, sizeof(VkPhysicalDeviceMemoryProperties)) != 0)
   2576 			TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2KHR");
   2577 	}
   2578 
   2579 	return tcu::TestStatus::pass("Querying device memory properties succeeded");
   2580 }
   2581 
   2582 tcu::TestStatus imageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
   2583 {
   2584 	TestLog&						log				= context.getTestContext().getLog();
   2585 
   2586 	const PlatformInterface&		vkp				= context.getPlatformInterface();
   2587 	const Unique<VkInstance>		instance		(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2588 	const InstanceDriver			vki				(vkp, *instance);
   2589 	const vector<VkPhysicalDevice>	devices			= enumeratePhysicalDevices(vki, *instance);
   2590 
   2591 	const VkImageUsageFlags			allUsageFlags	= VK_IMAGE_USAGE_TRANSFER_SRC_BIT
   2592 													| VK_IMAGE_USAGE_TRANSFER_DST_BIT
   2593 													| VK_IMAGE_USAGE_SAMPLED_BIT
   2594 													| VK_IMAGE_USAGE_STORAGE_BIT
   2595 													| VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
   2596 													| VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
   2597 													| VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
   2598 													| VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
   2599 	const VkImageCreateFlags		allCreateFlags	= VK_IMAGE_CREATE_SPARSE_BINDING_BIT
   2600 													| VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT
   2601 													| VK_IMAGE_CREATE_SPARSE_ALIASED_BIT
   2602 													| VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
   2603 													| VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
   2604 
   2605 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2606 	{
   2607 		const VkPhysicalDevice	physicalDevice	= devices[deviceNdx];
   2608 
   2609 		for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++)
   2610 		{
   2611 			for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= allCreateFlags; curCreateFlags++)
   2612 			{
   2613 				const VkPhysicalDeviceImageFormatInfo2KHR	imageFormatInfo	=
   2614 				{
   2615 					VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR,
   2616 					DE_NULL,
   2617 					format,
   2618 					imageType,
   2619 					tiling,
   2620 					curUsageFlags,
   2621 					curCreateFlags
   2622 				};
   2623 
   2624 				VkImageFormatProperties						coreProperties;
   2625 				VkImageFormatProperties2KHR					extProperties;
   2626 				VkResult									coreResult;
   2627 				VkResult									extResult;
   2628 
   2629 				deMemset(&coreProperties, 0xcd, sizeof(VkImageFormatProperties));
   2630 				deMemset(&extProperties, 0xcd, sizeof(VkImageFormatProperties2KHR));
   2631 
   2632 				extProperties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR;
   2633 				extProperties.pNext = DE_NULL;
   2634 
   2635 				coreResult	= vki.getPhysicalDeviceImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.tiling, imageFormatInfo.usage, imageFormatInfo.flags, &coreProperties);
   2636 				extResult	= vki.getPhysicalDeviceImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &extProperties);
   2637 
   2638 				TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR);
   2639 				TCU_CHECK(extProperties.pNext == DE_NULL);
   2640 
   2641 				if ((coreResult != extResult) ||
   2642 					(deMemCmp(&coreProperties, &extProperties.imageFormatProperties, sizeof(VkImageFormatProperties)) != 0))
   2643 				{
   2644 					log << TestLog::Message << "ERROR: device " << deviceNdx << ": mismatch with query " << imageFormatInfo << TestLog::EndMessage
   2645 						<< TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties() returned " << coreResult << ", " << coreProperties << TestLog::EndMessage
   2646 						<< TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties2KHR() returned " << extResult << ", " << extProperties << TestLog::EndMessage;
   2647 					TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceImageFormatProperties and vkGetPhysicalDeviceImageFormatProperties2KHR");
   2648 				}
   2649 			}
   2650 		}
   2651 	}
   2652 
   2653 	return tcu::TestStatus::pass("Querying image format properties succeeded");
   2654 }
   2655 
   2656 tcu::TestStatus sparseImageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling)
   2657 {
   2658 	TestLog&						log				= context.getTestContext().getLog();
   2659 
   2660 	const PlatformInterface&		vkp				= context.getPlatformInterface();
   2661 	const Unique<VkInstance>		instance		(createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2"));
   2662 	const InstanceDriver			vki				(vkp, *instance);
   2663 	const vector<VkPhysicalDevice>	devices			= enumeratePhysicalDevices(vki, *instance);
   2664 
   2665 	const VkImageUsageFlags			allUsageFlags	= VK_IMAGE_USAGE_TRANSFER_SRC_BIT
   2666 													| VK_IMAGE_USAGE_TRANSFER_DST_BIT
   2667 													| VK_IMAGE_USAGE_SAMPLED_BIT
   2668 													| VK_IMAGE_USAGE_STORAGE_BIT
   2669 													| VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
   2670 													| VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
   2671 													| VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
   2672 													| VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
   2673 
   2674 	for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx)
   2675 	{
   2676 		const VkPhysicalDevice	physicalDevice	= devices[deviceNdx];
   2677 
   2678 		for (deUint32 sampleCountBit = VK_SAMPLE_COUNT_1_BIT; sampleCountBit <= VK_SAMPLE_COUNT_64_BIT; sampleCountBit = (sampleCountBit << 1u))
   2679 		{
   2680 			for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++)
   2681 			{
   2682 				const VkPhysicalDeviceSparseImageFormatInfo2KHR	imageFormatInfo	=
   2683 				{
   2684 					VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR,
   2685 					DE_NULL,
   2686 					format,
   2687 					imageType,
   2688 					(VkSampleCountFlagBits)sampleCountBit,
   2689 					curUsageFlags,
   2690 					tiling,
   2691 				};
   2692 
   2693 				deUint32										numCoreProperties	= ~0u;
   2694 				deUint32										numExtProperties	= ~0u;
   2695 
   2696 				// Query count
   2697 				vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, DE_NULL);
   2698 				vki.getPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &numExtProperties, DE_NULL);
   2699 
   2700 				if (numCoreProperties != numExtProperties)
   2701 				{
   2702 					log << TestLog::Message << "ERROR: device " << deviceNdx << ": different number of properties reported for " << imageFormatInfo << TestLog::EndMessage;
   2703 					TCU_FAIL("Mismatch in reported property count");
   2704 				}
   2705 
   2706 				if (numCoreProperties > 0)
   2707 				{
   2708 					std::vector<VkSparseImageFormatProperties>		coreProperties	(numCoreProperties);
   2709 					std::vector<VkSparseImageFormatProperties2KHR>	extProperties	(numExtProperties);
   2710 
   2711 					deMemset(&coreProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties)*numCoreProperties);
   2712 					deMemset(&extProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties2KHR)*numExtProperties);
   2713 
   2714 					for (deUint32 ndx = 0; ndx < numExtProperties; ++ndx)
   2715 					{
   2716 						extProperties[ndx].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR;
   2717 						extProperties[ndx].pNext = DE_NULL;
   2718 					}
   2719 
   2720 					vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, &coreProperties[0]);
   2721 					vki.getPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &numExtProperties, &extProperties[0]);
   2722 
   2723 					TCU_CHECK((size_t)numCoreProperties == coreProperties.size());
   2724 					TCU_CHECK((size_t)numExtProperties == extProperties.size());
   2725 
   2726 					for (deUint32 ndx = 0; ndx < numCoreProperties; ++ndx)
   2727 					{
   2728 						TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR);
   2729 						TCU_CHECK(extProperties[ndx].pNext == DE_NULL);
   2730 
   2731 						if ((deMemCmp(&coreProperties[ndx], &extProperties[ndx].properties, sizeof(VkSparseImageFormatProperties)) != 0))
   2732 						{
   2733 							log << TestLog::Message << "ERROR: device " << deviceNdx << ": mismatch with query " << imageFormatInfo << " property " << ndx << TestLog::EndMessage
   2734 								<< TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties() returned " << coreProperties[ndx] << TestLog::EndMessage
   2735 								<< TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties2KHR() returned " << extProperties[ndx] << TestLog::EndMessage;
   2736 							TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceSparseImageFormatProperties and vkGetPhysicalDeviceSparseImageFormatProperties2KHR");
   2737 						}
   2738 					}
   2739 				}
   2740 			}
   2741 		}
   2742 	}
   2743 
   2744 	return tcu::TestStatus::pass("Querying sparse image format properties succeeded");
   2745 }
   2746 
   2747 // Android CTS -specific tests
   2748 
   2749 namespace android
   2750 {
   2751 
   2752 void checkExtensions (tcu::ResultCollector& results, const set<string>& allowedExtensions, const vector<VkExtensionProperties>& reportedExtensions)
   2753 {
   2754 	for (vector<VkExtensionProperties>::const_iterator extension = reportedExtensions.begin(); extension != reportedExtensions.end(); ++extension)
   2755 	{
   2756 		const string	extensionName	(extension->extensionName);
   2757 		const bool		mustBeKnown		= de::beginsWith(extensionName, "VK_KHX_")		||
   2758 										  de::beginsWith(extensionName, "VK_GOOGLE_")	||
   2759 										  de::beginsWith(extensionName, "VK_ANDROID_");
   2760 
   2761 		if (mustBeKnown && !de::contains(allowedExtensions, extensionName))
   2762 			results.fail("Unknown extension: " + extensionName);
   2763 	}
   2764 }
   2765 
   2766 tcu::TestStatus testNoUnknownExtensions (Context& context)
   2767 {
   2768 	TestLog&				log					= context.getTestContext().getLog();
   2769 	tcu::ResultCollector	results				(log);
   2770 	set<string>				allowedInstanceExtensions;
   2771 	set<string>				allowedDeviceExtensions;
   2772 
   2773 	// All known extensions should be added to allowedExtensions:
   2774 	// allowedExtensions.insert("VK_GOOGLE_extension1");
   2775 	allowedDeviceExtensions.insert("VK_GOOGLE_display_timing");
   2776 
   2777 	// Instance extensions
   2778 	checkExtensions(results,
   2779 					allowedInstanceExtensions,
   2780 					enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL));
   2781 
   2782 	// Extensions exposed by instance layers
   2783 	{
   2784 		const vector<VkLayerProperties>	layers	= enumerateInstanceLayerProperties(context.getPlatformInterface());
   2785 
   2786 		for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
   2787 		{
   2788 			checkExtensions(results,
   2789 							allowedInstanceExtensions,
   2790 							enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName));
   2791 		}
   2792 	}
   2793 
   2794 	// Device extensions
   2795 	checkExtensions(results,
   2796 					allowedDeviceExtensions,
   2797 					enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL));
   2798 
   2799 	// Extensions exposed by device layers
   2800 	{
   2801 		const vector<VkLayerProperties>	layers	= enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
   2802 
   2803 		for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
   2804 		{
   2805 			checkExtensions(results,
   2806 							allowedDeviceExtensions,
   2807 							enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName));
   2808 		}
   2809 	}
   2810 
   2811 	return tcu::TestStatus(results.getResult(), results.getMessage());
   2812 }
   2813 
   2814 tcu::TestStatus testNoLayers (Context& context)
   2815 {
   2816 	TestLog&				log		= context.getTestContext().getLog();
   2817 	tcu::ResultCollector	results	(log);
   2818 
   2819 	{
   2820 		const vector<VkLayerProperties>	layers	= enumerateInstanceLayerProperties(context.getPlatformInterface());
   2821 
   2822 		for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
   2823 			results.fail(string("Instance layer enumerated: ") + layer->layerName);
   2824 	}
   2825 
   2826 	{
   2827 		const vector<VkLayerProperties>	layers	= enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
   2828 
   2829 		for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
   2830 			results.fail(string("Device layer enumerated: ") + layer->layerName);
   2831 	}
   2832 
   2833 	return tcu::TestStatus(results.getResult(), results.getMessage());
   2834 }
   2835 
   2836 tcu::TestStatus testMandatoryExtensions (Context& context)
   2837 {
   2838 	TestLog&				log		= context.getTestContext().getLog();
   2839 	tcu::ResultCollector	results	(log);
   2840 
   2841 	// Instance extensions
   2842 	{
   2843 		static const char*					mandatoryExtensions[]	=
   2844 		{
   2845 			"VK_KHR_get_physical_device_properties2",
   2846 		};
   2847 		const vector<VkExtensionProperties>	extensions				= enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
   2848 
   2849 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(mandatoryExtensions); ++ndx)
   2850 		{
   2851 			if (!isExtensionSupported(extensions, RequiredExtension(mandatoryExtensions[ndx])))
   2852 				results.fail(string(mandatoryExtensions[ndx]) + " is not supported");
   2853 		}
   2854 	}
   2855 
   2856 	// Device extensions
   2857 	{
   2858 		static const char*					mandatoryExtensions[]	=
   2859 		{
   2860 			"VK_KHR_maintenance1",
   2861 		};
   2862 		const vector<VkExtensionProperties>	extensions				= enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
   2863 
   2864 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(mandatoryExtensions); ++ndx)
   2865 		{
   2866 			if (!isExtensionSupported(extensions, RequiredExtension(mandatoryExtensions[ndx])))
   2867 				results.fail(string(mandatoryExtensions[ndx]) + " is not supported");
   2868 		}
   2869 	}
   2870 
   2871 	return tcu::TestStatus(results.getResult(), results.getMessage());
   2872 }
   2873 
   2874 } // android
   2875 
   2876 } // anonymous
   2877 
   2878 tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx)
   2879 {
   2880 	de::MovePtr<tcu::TestCaseGroup>	infoTests	(new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
   2881 
   2882 	{
   2883 		de::MovePtr<tcu::TestCaseGroup> instanceInfoTests	(new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests"));
   2884 
   2885 		addFunctionCase(instanceInfoTests.get(), "physical_devices",		"Physical devices",			enumeratePhysicalDevices);
   2886 		addFunctionCase(instanceInfoTests.get(), "layers",					"Layers",					enumerateInstanceLayers);
   2887 		addFunctionCase(instanceInfoTests.get(), "extensions",				"Extensions",				enumerateInstanceExtensions);
   2888 
   2889 		infoTests->addChild(instanceInfoTests.release());
   2890 	}
   2891 
   2892 	{
   2893 		de::MovePtr<tcu::TestCaseGroup> deviceInfoTests	(new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests"));
   2894 
   2895 		addFunctionCase(deviceInfoTests.get(), "features",					"Device Features",			deviceFeatures);
   2896 		addFunctionCase(deviceInfoTests.get(), "properties",				"Device Properties",		deviceProperties);
   2897 		addFunctionCase(deviceInfoTests.get(), "queue_family_properties",	"Queue family properties",	deviceQueueFamilyProperties);
   2898 		addFunctionCase(deviceInfoTests.get(), "memory_properties",			"Memory properties",		deviceMemoryProperties);
   2899 		addFunctionCase(deviceInfoTests.get(), "layers",					"Layers",					enumerateDeviceLayers);
   2900 		addFunctionCase(deviceInfoTests.get(), "extensions",				"Extensions",				enumerateDeviceExtensions);
   2901 
   2902 		infoTests->addChild(deviceInfoTests.release());
   2903 	}
   2904 
   2905 	infoTests->addChild(createTestGroup(testCtx, "format_properties",		"VkGetPhysicalDeviceFormatProperties() Tests",		createFormatTests));
   2906 	infoTests->addChild(createTestGroup(testCtx, "image_format_properties",	"VkGetPhysicalDeviceImageFormatProperties() Tests",	createImageFormatTests,	imageFormatProperties));
   2907 	// \todo [2017-05-16 pyry] Extend image_format_properties to cover ycbcr formats
   2908 
   2909 	{
   2910 		de::MovePtr<tcu::TestCaseGroup> extendedPropertiesTests (new tcu::TestCaseGroup(testCtx, "get_physical_device_properties2", "VK_KHR_get_physical_device_properties2"));
   2911 
   2912 		addFunctionCase(extendedPropertiesTests.get(), "features",					"Extended Device Features",					deviceFeatures2);
   2913 		addFunctionCase(extendedPropertiesTests.get(), "properties",				"Extended Device Properties",				deviceProperties2);
   2914 		addFunctionCase(extendedPropertiesTests.get(), "format_properties",			"Extended Device Format Properties",		deviceFormatProperties2);
   2915 		addFunctionCase(extendedPropertiesTests.get(), "queue_family_properties",	"Extended Device Queue Family Properties",	deviceQueueFamilyProperties2);
   2916 		addFunctionCase(extendedPropertiesTests.get(), "memory_properties",			"Extended Device Memory Properties",		deviceMemoryProperties2);
   2917 
   2918 		infoTests->addChild(extendedPropertiesTests.release());
   2919 	}
   2920 
   2921 	infoTests->addChild(createTestGroup(testCtx, "image_format_properties2",		"VkGetPhysicalDeviceImageFormatProperties2KHR() Tests",			createImageFormatTests, imageFormatProperties2));
   2922 	infoTests->addChild(createTestGroup(testCtx, "sparse_image_format_properties2",	"VkGetPhysicalDeviceSparseImageFormatProperties2KHR() Tests",	createImageFormatTests, sparseImageFormatProperties2));
   2923 	// \todo [2017-05-16 pyry] Extend image_format_properties2 to cover ycbcr formats
   2924 
   2925 	{
   2926 		de::MovePtr<tcu::TestCaseGroup>	androidTests	(new tcu::TestCaseGroup(testCtx, "android", "Android CTS Tests"));
   2927 
   2928 		addFunctionCase(androidTests.get(),	"mandatory_extensions",		"Test that all mandatory extensions are supported",	android::testMandatoryExtensions);
   2929 		addFunctionCase(androidTests.get(), "no_unknown_extensions",	"Test for unknown device or instance extensions",	android::testNoUnknownExtensions);
   2930 		addFunctionCase(androidTests.get(), "no_layers",				"Test that no layers are enumerated",				android::testNoLayers);
   2931 
   2932 		infoTests->addChild(androidTests.release());
   2933 	}
   2934 
   2935 	return infoTests.release();
   2936 }
   2937 
   2938 } // api
   2939 } // vkt
   2940