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