Fix issues in pipeline.timestamp.transfer_tests
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / pipeline / vktPipelineDepthTests.cpp
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Imagination Technologies Ltd.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief Depth Tests
23  *//*--------------------------------------------------------------------*/
24
25 #include "vktPipelineDepthTests.hpp"
26 #include "vktPipelineClearUtil.hpp"
27 #include "vktPipelineImageUtil.hpp"
28 #include "vktPipelineVertexUtil.hpp"
29 #include "vktPipelineReferenceRenderer.hpp"
30 #include "vktTestCase.hpp"
31 #include "vktTestCaseUtil.hpp"
32 #include "vkImageUtil.hpp"
33 #include "vkMemUtil.hpp"
34 #include "vkPrograms.hpp"
35 #include "vkQueryUtil.hpp"
36 #include "vkRef.hpp"
37 #include "vkRefUtil.hpp"
38 #include "vkTypeUtil.hpp"
39 #include "tcuImageCompare.hpp"
40 #include "deUniquePtr.hpp"
41 #include "deStringUtil.hpp"
42 #include "deMemory.h"
43
44 #include <sstream>
45 #include <vector>
46
47 namespace vkt
48 {
49 namespace pipeline
50 {
51
52 using namespace vk;
53
54 namespace
55 {
56
57 bool isSupportedDepthStencilFormat (const InstanceInterface& instanceInterface, VkPhysicalDevice device, VkFormat format)
58 {
59         VkFormatProperties formatProps;
60
61         instanceInterface.getPhysicalDeviceFormatProperties(device, format, &formatProps);
62
63         return (formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0u;
64 }
65
66 tcu::TestStatus testSupportsDepthStencilFormat (Context& context, VkFormat format)
67 {
68         DE_ASSERT(vk::isDepthStencilFormat(format));
69
70         if (isSupportedDepthStencilFormat(context.getInstanceInterface(), context.getPhysicalDevice(), format))
71                 return tcu::TestStatus::pass("Format can be used in depth/stencil attachment");
72         else
73                 return tcu::TestStatus::fail("Unsupported depth/stencil attachment format");
74 }
75
76 tcu::TestStatus testSupportsAtLeastOneDepthStencilFormat (Context& context, const std::vector<VkFormat> formats)
77 {
78         std::ostringstream      supportedFormatsMsg;
79         bool                            pass                                    = false;
80
81         DE_ASSERT(!formats.empty());
82
83         for (size_t formatNdx = 0; formatNdx < formats.size(); formatNdx++)
84         {
85                 const VkFormat format = formats[formatNdx];
86
87                 DE_ASSERT(vk::isDepthStencilFormat(format));
88
89                 if (isSupportedDepthStencilFormat(context.getInstanceInterface(), context.getPhysicalDevice(), format))
90                 {
91                         pass = true;
92                         supportedFormatsMsg << vk::getFormatName(format);
93
94                         if (formatNdx < formats.size() - 1)
95                                 supportedFormatsMsg << ", ";
96                 }
97         }
98
99         if (pass)
100                 return tcu::TestStatus::pass(std::string("Supported depth/stencil formats: ") + supportedFormatsMsg.str());
101         else
102                 return tcu::TestStatus::fail("All depth/stencil formats are unsupported");
103 }
104
105 class DepthTest : public vkt::TestCase
106 {
107 public:
108         enum
109         {
110                 QUAD_COUNT = 4
111         };
112
113         static const float                                      quadDepths[QUAD_COUNT];
114
115                                                                                 DepthTest                               (tcu::TestContext&              testContext,
116                                                                                                                                  const std::string&             name,
117                                                                                                                                  const std::string&             description,
118                                                                                                                                  const VkFormat                 depthFormat,
119                                                                                                                                  const VkCompareOp              depthCompareOps[QUAD_COUNT]);
120         virtual                                                         ~DepthTest                              (void);
121         virtual void                                            initPrograms                    (SourceCollections& programCollection) const;
122         virtual TestInstance*                           createInstance                  (Context& context) const;
123
124 private:
125         const VkFormat                                          m_depthFormat;
126         VkCompareOp                                                     m_depthCompareOps[QUAD_COUNT];
127 };
128
129 class DepthTestInstance : public vkt::TestInstance
130 {
131 public:
132                                                                                 DepthTestInstance               (Context& context, const VkFormat depthFormat, const VkCompareOp depthCompareOps[DepthTest::QUAD_COUNT]);
133         virtual                                                         ~DepthTestInstance              (void);
134         virtual tcu::TestStatus                         iterate                                 (void);
135
136 private:
137         tcu::TestStatus                                         verifyImage                             (void);
138
139 private:
140         VkCompareOp                                                     m_depthCompareOps[DepthTest::QUAD_COUNT];
141         const tcu::UVec2                                        m_renderSize;
142         const VkFormat                                          m_colorFormat;
143         const VkFormat                                          m_depthFormat;
144         VkImageSubresourceRange                         m_depthImageSubresourceRange;
145
146         Move<VkImage>                                           m_colorImage;
147         de::MovePtr<Allocation>                         m_colorImageAlloc;
148         Move<VkImage>                                           m_depthImage;
149         de::MovePtr<Allocation>                         m_depthImageAlloc;
150         Move<VkImageView>                                       m_colorAttachmentView;
151         Move<VkImageView>                                       m_depthAttachmentView;
152         Move<VkRenderPass>                                      m_renderPass;
153         Move<VkFramebuffer>                                     m_framebuffer;
154
155         Move<VkShaderModule>                            m_vertexShaderModule;
156         Move<VkShaderModule>                            m_fragmentShaderModule;
157
158         Move<VkBuffer>                                          m_vertexBuffer;
159         std::vector<Vertex4RGBA>                        m_vertices;
160         de::MovePtr<Allocation>                         m_vertexBufferAlloc;
161
162         Move<VkPipelineLayout>                          m_pipelineLayout;
163         Move<VkPipeline>                                        m_graphicsPipelines[DepthTest::QUAD_COUNT];
164
165         Move<VkCommandPool>                                     m_cmdPool;
166         Move<VkCommandBuffer>                           m_cmdBuffer;
167
168         Move<VkFence>                                           m_fence;
169 };
170
171 const float DepthTest::quadDepths[QUAD_COUNT] =
172 {
173         0.1f,
174         0.0f,
175         0.3f,
176         0.2f
177 };
178
179 DepthTest::DepthTest (tcu::TestContext&         testContext,
180                                           const std::string&    name,
181                                           const std::string&    description,
182                                           const VkFormat                depthFormat,
183                                           const VkCompareOp             depthCompareOps[QUAD_COUNT])
184         : vkt::TestCase (testContext, name, description)
185         , m_depthFormat (depthFormat)
186 {
187         deMemcpy(m_depthCompareOps, depthCompareOps, sizeof(VkCompareOp) * QUAD_COUNT);
188 }
189
190 DepthTest::~DepthTest (void)
191 {
192 }
193
194 TestInstance* DepthTest::createInstance (Context& context) const
195 {
196         return new DepthTestInstance(context, m_depthFormat, m_depthCompareOps);
197 }
198
199 void DepthTest::initPrograms (SourceCollections& programCollection) const
200 {
201         programCollection.glslSources.add("color_vert") << glu::VertexSource(
202                 "#version 310 es\n"
203                 "layout(location = 0) in vec4 position;\n"
204                 "layout(location = 1) in vec4 color;\n"
205                 "layout(location = 0) out highp vec4 vtxColor;\n"
206                 "void main (void)\n"
207                 "{\n"
208                 "       gl_Position = position;\n"
209                 "       vtxColor = color;\n"
210                 "}\n");
211
212         programCollection.glslSources.add("color_frag") << glu::FragmentSource(
213                 "#version 310 es\n"
214                 "layout(location = 0) in highp vec4 vtxColor;\n"
215                 "layout(location = 0) out highp vec4 fragColor;\n"
216                 "void main (void)\n"
217                 "{\n"
218                 "       fragColor = vtxColor;\n"
219                 "}\n");
220 }
221
222 DepthTestInstance::DepthTestInstance (Context&                          context,
223                                                                           const VkFormat                depthFormat,
224                                                                           const VkCompareOp             depthCompareOps[DepthTest::QUAD_COUNT])
225         : vkt::TestInstance     (context)
226         , m_renderSize          (32, 32)
227         , m_colorFormat         (VK_FORMAT_R8G8B8A8_UNORM)
228         , m_depthFormat         (depthFormat)
229 {
230         const DeviceInterface&          vk                                              = context.getDeviceInterface();
231         const VkDevice                          vkDevice                                = context.getDevice();
232         const deUint32                          queueFamilyIndex                = context.getUniversalQueueFamilyIndex();
233         SimpleAllocator                         memAlloc                                (vk, vkDevice, getPhysicalDeviceMemoryProperties(context.getInstanceInterface(), context.getPhysicalDevice()));
234         const VkComponentMapping        componentMappingRGBA    = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
235
236         // Copy depth operators
237         deMemcpy(m_depthCompareOps, depthCompareOps, sizeof(VkCompareOp) * DepthTest::QUAD_COUNT);
238
239         // Create color image
240         {
241                 const VkImageCreateInfo colorImageParams =
242                 {
243                         VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,                                                                            // VkStructureType                      sType;
244                         DE_NULL,                                                                                                                                        // const void*                          pNext;
245                         0u,                                                                                                                                                     // VkImageCreateFlags           flags;
246                         VK_IMAGE_TYPE_2D,                                                                                                                       // VkImageType                          imageType;
247                         m_colorFormat,                                                                                                                          // VkFormat                                     format;
248                         { m_renderSize.x(), m_renderSize.y(), 1u },                                                                     // VkExtent3D                           extent;
249                         1u,                                                                                                                                                     // deUint32                                     mipLevels;
250                         1u,                                                                                                                                                     // deUint32                                     arrayLayers;
251                         VK_SAMPLE_COUNT_1_BIT,                                                                                                          // VkSampleCountFlagBits        samples;
252                         VK_IMAGE_TILING_OPTIMAL,                                                                                                        // VkImageTiling                        tiling;
253                         VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,          // VkImageUsageFlags            usage;
254                         VK_SHARING_MODE_EXCLUSIVE,                                                                                                      // VkSharingMode                        sharingMode;
255                         1u,                                                                                                                                                     // deUint32                                     queueFamilyIndexCount;
256                         &queueFamilyIndex,                                                                                                                      // const deUint32*                      pQueueFamilyIndices;
257                         VK_IMAGE_LAYOUT_UNDEFINED,                                                                                                      // VkImageLayout                        initialLayout;
258                 };
259
260                 m_colorImage                    = createImage(vk, vkDevice, &colorImageParams);
261
262                 // Allocate and bind color image memory
263                 m_colorImageAlloc               = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_colorImage), MemoryRequirement::Any);
264                 VK_CHECK(vk.bindImageMemory(vkDevice, *m_colorImage, m_colorImageAlloc->getMemory(), m_colorImageAlloc->getOffset()));
265         }
266
267         // Create depth image
268         {
269                 // Check format support
270                 if (!isSupportedDepthStencilFormat(context.getInstanceInterface(), context.getPhysicalDevice(), m_depthFormat))
271                         throw tcu::NotSupportedError(std::string("Unsupported depth/stencil format: ") + getFormatName(m_depthFormat));
272
273                 const VkImageCreateInfo depthImageParams =
274                 {
275                         VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,                    // VkStructureType                      sType;
276                         DE_NULL,                                                                                // const void*                          pNext;
277                         0u,                                                                                             // VkImageCreateFlags           flags;
278                         VK_IMAGE_TYPE_2D,                                                               // VkImageType                          imageType;
279                         m_depthFormat,                                                                  // VkFormat                                     format;
280                         { m_renderSize.x(), m_renderSize.y(), 1u },             // VkExtent3D                           extent;
281                         1u,                                                                                             // deUint32                                     mipLevels;
282                         1u,                                                                                             // deUint32                                     arrayLayers;
283                         VK_SAMPLE_COUNT_1_BIT,                                                  // VkSampleCountFlagBits        samples;
284                         VK_IMAGE_TILING_OPTIMAL,                                                // VkImageTiling                        tiling;
285                         VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,    // VkImageUsageFlags            usage;
286                         VK_SHARING_MODE_EXCLUSIVE,                                              // VkSharingMode                        sharingMode;
287                         1u,                                                                                             // deUint32                                     queueFamilyIndexCount;
288                         &queueFamilyIndex,                                                              // const deUint32*                      pQueueFamilyIndices;
289                         VK_IMAGE_LAYOUT_UNDEFINED,                                              // VkImageLayout                        initialLayout;
290                 };
291
292                 m_depthImage = createImage(vk, vkDevice, &depthImageParams);
293
294                 // Allocate and bind depth image memory
295                 m_depthImageAlloc = memAlloc.allocate(getImageMemoryRequirements(vk, vkDevice, *m_depthImage), MemoryRequirement::Any);
296                 VK_CHECK(vk.bindImageMemory(vkDevice, *m_depthImage, m_depthImageAlloc->getMemory(), m_depthImageAlloc->getOffset()));
297
298                 const VkImageAspectFlags aspect = (mapVkFormat(m_depthFormat).order == tcu::TextureFormat::DS ? VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT
299                                                                                                                                                                                                           : VK_IMAGE_ASPECT_DEPTH_BIT);
300                 m_depthImageSubresourceRange    = makeImageSubresourceRange(aspect, 0u, depthImageParams.mipLevels, 0u, depthImageParams.arrayLayers);
301         }
302
303         // Create color attachment view
304         {
305                 const VkImageViewCreateInfo colorAttachmentViewParams =
306                 {
307                         VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,               // VkStructureType                      sType;
308                         DE_NULL,                                                                                // const void*                          pNext;
309                         0u,                                                                                             // VkImageViewCreateFlags       flags;
310                         *m_colorImage,                                                                  // VkImage                                      image;
311                         VK_IMAGE_VIEW_TYPE_2D,                                                  // VkImageViewType                      viewType;
312                         m_colorFormat,                                                                  // VkFormat                                     format;
313                         componentMappingRGBA,                                                   // VkComponentMapping           components;
314                         { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }   // VkImageSubresourceRange      subresourceRange;
315                 };
316
317                 m_colorAttachmentView = createImageView(vk, vkDevice, &colorAttachmentViewParams);
318         }
319
320         // Create depth attachment view
321         {
322                 const VkImageViewCreateInfo depthAttachmentViewParams =
323                 {
324                         VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,               // VkStructureType                      sType;
325                         DE_NULL,                                                                                // const void*                          pNext;
326                         0u,                                                                                             // VkImageViewCreateFlags       flags;
327                         *m_depthImage,                                                                  // VkImage                                      image;
328                         VK_IMAGE_VIEW_TYPE_2D,                                                  // VkImageViewType                      viewType;
329                         m_depthFormat,                                                                  // VkFormat                                     format;
330                         componentMappingRGBA,                                                   // VkComponentMapping           components;
331                         m_depthImageSubresourceRange,                                   // VkImageSubresourceRange      subresourceRange;
332                 };
333
334                 m_depthAttachmentView = createImageView(vk, vkDevice, &depthAttachmentViewParams);
335         }
336
337         // Create render pass
338         {
339                 const VkAttachmentDescription colorAttachmentDescription =
340                 {
341                         0u,                                                                                                     // VkAttachmentDescriptionFlags         flags;
342                         m_colorFormat,                                                                          // VkFormat                                                     format;
343                         VK_SAMPLE_COUNT_1_BIT,                                                          // VkSampleCountFlagBits                        samples;
344                         VK_ATTACHMENT_LOAD_OP_CLEAR,                                            // VkAttachmentLoadOp                           loadOp;
345                         VK_ATTACHMENT_STORE_OP_STORE,                                           // VkAttachmentStoreOp                          storeOp;
346                         VK_ATTACHMENT_LOAD_OP_DONT_CARE,                                        // VkAttachmentLoadOp                           stencilLoadOp;
347                         VK_ATTACHMENT_STORE_OP_DONT_CARE,                                       // VkAttachmentStoreOp                          stencilStoreOp;
348                         VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,                       // VkImageLayout                                        initialLayout;
349                         VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL                        // VkImageLayout                                        finalLayout;
350                 };
351
352                 const VkAttachmentDescription depthAttachmentDescription =
353                 {
354                         0u,                                                                                                     // VkAttachmentDescriptionFlags         flags;
355                         m_depthFormat,                                                                          // VkFormat                                                     format;
356                         VK_SAMPLE_COUNT_1_BIT,                                                          // VkSampleCountFlagBits                        samples;
357                         VK_ATTACHMENT_LOAD_OP_CLEAR,                                            // VkAttachmentLoadOp                           loadOp;
358                         VK_ATTACHMENT_STORE_OP_DONT_CARE,                                       // VkAttachmentStoreOp                          storeOp;
359                         VK_ATTACHMENT_LOAD_OP_DONT_CARE,                                        // VkAttachmentLoadOp                           stencilLoadOp;
360                         VK_ATTACHMENT_STORE_OP_DONT_CARE,                                       // VkAttachmentStoreOp                          stencilStoreOp;
361                         VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,       // VkImageLayout                                        initialLayout;
362                         VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,       // VkImageLayout                                        finalLayout;
363                 };
364
365                 const VkAttachmentDescription attachments[2] =
366                 {
367                         colorAttachmentDescription,
368                         depthAttachmentDescription
369                 };
370
371                 const VkAttachmentReference colorAttachmentReference =
372                 {
373                         0u,                                                                                                     // deUint32                     attachment;
374                         VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL                        // VkImageLayout        layout;
375                 };
376
377                 const VkAttachmentReference depthAttachmentReference =
378                 {
379                         1u,                                                                                                     // deUint32                     attachment;
380                         VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL        // VkImageLayout        layout;
381                 };
382
383                 const VkSubpassDescription subpassDescription =
384                 {
385                         0u,                                                                                                     // VkSubpassDescriptionFlags            flags;
386                         VK_PIPELINE_BIND_POINT_GRAPHICS,                                        // VkPipelineBindPoint                          pipelineBindPoint;
387                         0u,                                                                                                     // deUint32                                                     inputAttachmentCount;
388                         DE_NULL,                                                                                        // const VkAttachmentReference*         pInputAttachments;
389                         1u,                                                                                                     // deUint32                                                     colorAttachmentCount;
390                         &colorAttachmentReference,                                                      // const VkAttachmentReference*         pColorAttachments;
391                         DE_NULL,                                                                                        // const VkAttachmentReference*         pResolveAttachments;
392                         &depthAttachmentReference,                                                      // const VkAttachmentReference*         pDepthStencilAttachment;
393                         0u,                                                                                                     // deUint32                                                     preserveAttachmentCount;
394                         DE_NULL                                                                                         // const VkAttachmentReference*         pPreserveAttachments;
395                 };
396
397                 const VkRenderPassCreateInfo renderPassParams =
398                 {
399                         VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,                      // VkStructureType                                      sType;
400                         DE_NULL,                                                                                        // const void*                                          pNext;
401                         0u,                                                                                                     // VkRenderPassCreateFlags                      flags;
402                         2u,                                                                                                     // deUint32                                                     attachmentCount;
403                         attachments,                                                                            // const VkAttachmentDescription*       pAttachments;
404                         1u,                                                                                                     // deUint32                                                     subpassCount;
405                         &subpassDescription,                                                            // const VkSubpassDescription*          pSubpasses;
406                         0u,                                                                                                     // deUint32                                                     dependencyCount;
407                         DE_NULL                                                                                         // const VkSubpassDependency*           pDependencies;
408                 };
409
410                 m_renderPass = createRenderPass(vk, vkDevice, &renderPassParams);
411         }
412
413         // Create framebuffer
414         {
415                 const VkImageView attachmentBindInfos[2] =
416                 {
417                         *m_colorAttachmentView,
418                         *m_depthAttachmentView,
419                 };
420
421                 const VkFramebufferCreateInfo framebufferParams =
422                 {
423                         VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,                      // VkStructureType                              sType;
424                         DE_NULL,                                                                                        // const void*                                  pNext;
425                         0u,                                                                                                     // VkFramebufferCreateFlags             flags;
426                         *m_renderPass,                                                                          // VkRenderPass                                 renderPass;
427                         2u,                                                                                                     // deUint32                                             attachmentCount;
428                         attachmentBindInfos,                                                            // const VkImageView*                   pAttachments;
429                         (deUint32)m_renderSize.x(),                                                     // deUint32                                             width;
430                         (deUint32)m_renderSize.y(),                                                     // deUint32                                             height;
431                         1u                                                                                                      // deUint32                                             layers;
432                 };
433
434                 m_framebuffer = createFramebuffer(vk, vkDevice, &framebufferParams);
435         }
436
437         // Create pipeline layout
438         {
439                 const VkPipelineLayoutCreateInfo pipelineLayoutParams =
440                 {
441                         VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,          // VkStructureType                                      sType;
442                         DE_NULL,                                                                                        // const void*                                          pNext;
443                         0u,                                                                                                     // VkPipelineLayoutCreateFlags          flags;
444                         0u,                                                                                                     // deUint32                                                     setLayoutCount;
445                         DE_NULL,                                                                                        // const VkDescriptorSetLayout*         pSetLayouts;
446                         0u,                                                                                                     // deUint32                                                     pushConstantRangeCount;
447                         DE_NULL                                                                                         // const VkPushConstantRange*           pPushConstantRanges;
448                 };
449
450                 m_pipelineLayout = createPipelineLayout(vk, vkDevice, &pipelineLayoutParams);
451         }
452
453         // Shader modules
454         m_vertexShaderModule    = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("color_vert"), 0);
455         m_fragmentShaderModule  = createShaderModule(vk, vkDevice, m_context.getBinaryCollection().get("color_frag"), 0);
456
457         // Create pipeline
458         {
459                 const VkPipelineShaderStageCreateInfo shaderStages[2] =
460                 {
461                         {
462                                 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,    // VkStructureType                                              sType;
463                                 DE_NULL,                                                                                                // const void*                                                  pNext;
464                                 0u,                                                                                                             // VkPipelineShaderStageCreateFlags             flags;
465                                 VK_SHADER_STAGE_VERTEX_BIT,                                                             // VkShaderStageFlagBits                                stage;
466                                 *m_vertexShaderModule,                                                                  // VkShaderModule                                               module;
467                                 "main",                                                                                                 // const char*                                                  pName;
468                                 DE_NULL                                                                                                 // const VkSpecializationInfo*                  pSpecializationInfo;
469                         },
470                         {
471                                 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,    // VkStructureType                                              sType;
472                                 DE_NULL,                                                                                                // const void*                                                  pNext;
473                                 0u,                                                                                                             // VkPipelineShaderStageCreateFlags             flags;
474                                 VK_SHADER_STAGE_FRAGMENT_BIT,                                                   // VkShaderStageFlagBits                                stage;
475                                 *m_fragmentShaderModule,                                                                // VkShaderModule                                               module;
476                                 "main",                                                                                                 // const char*                                                  pName;
477                                 DE_NULL                                                                                                 // const VkSpecializationInfo*                  pSpecializationInfo;
478                         }
479                 };
480
481                 const VkVertexInputBindingDescription vertexInputBindingDescription =
482                 {
483                         0u,                                                                     // deUint32                                     binding;
484                         sizeof(Vertex4RGBA),                            // deUint32                                     strideInBytes;
485                         VK_VERTEX_INPUT_RATE_VERTEX                     // VkVertexInputStepRate        inputRate;
486                 };
487
488                 const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[2] =
489                 {
490                         {
491                                 0u,                                                                     // deUint32     location;
492                                 0u,                                                                     // deUint32     binding;
493                                 VK_FORMAT_R32G32B32A32_SFLOAT,          // VkFormat     format;
494                                 0u                                                                      // deUint32     offset;
495                         },
496                         {
497                                 1u,                                                                     // deUint32     location;
498                                 0u,                                                                     // deUint32     binding;
499                                 VK_FORMAT_R32G32B32A32_SFLOAT,          // VkFormat     format;
500                                 DE_OFFSET_OF(Vertex4RGBA, color),       // deUint32     offset;
501                         }
502                 };
503
504                 const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
505                 {
506                         VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,              // VkStructureType                                                      sType;
507                         DE_NULL,                                                                                                                // const void*                                                          pNext;
508                         0u,                                                                                                                             // VkPipelineVertexInputStateCreateFlags        flags;
509                         1u,                                                                                                                             // deUint32                                                                     vertexBindingDescriptionCount;
510                         &vertexInputBindingDescription,                                                                 // const VkVertexInputBindingDescription*       pVertexBindingDescriptions;
511                         2u,                                                                                                                             // deUint32                                                                     vertexAttributeDescriptionCount;
512                         vertexInputAttributeDescriptions                                                                // const VkVertexInputAttributeDescription*     pVertexAttributeDescriptions;
513                 };
514
515                 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateParams =
516                 {
517                         VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,    // VkStructureType                                                      sType;
518                         DE_NULL,                                                                                                                // const void*                                                          pNext;
519                         0u,                                                                                                                             // VkPipelineInputAssemblyStateCreateFlags      flags;
520                         VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,                                                    // VkPrimitiveTopology                                          topology;
521                         false                                                                                                                   // VkBool32                                                                     primitiveRestartEnable;
522                 };
523
524                 const VkViewport viewport =
525                 {
526                         0.0f,                                           // float        x;
527                         0.0f,                                           // float        y;
528                         (float)m_renderSize.x(),        // float        width;
529                         (float)m_renderSize.y(),        // float        height;
530                         0.0f,                                           // float        minDepth;
531                         1.0f                                            // float        maxDepth;
532                 };
533                 const VkRect2D scissor =
534                 {
535                         { 0, 0 },                                                                                               // VkOffset2D  offset;
536                         { m_renderSize.x(), m_renderSize.y() }                                  // VkExtent2D  extent;
537                 };
538                 const VkPipelineViewportStateCreateInfo viewportStateParams =
539                 {
540                         VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,                  // VkStructureType                                              sType;
541                         DE_NULL,                                                                                                                // const void*                                                  pNext;
542                         0u,                                                                                                                             // VkPipelineViewportStateCreateFlags   flags;
543                         1u,                                                                                                                             // deUint32                                                             viewportCount;
544                         &viewport,                                                                                                              // const VkViewport*                                    pViewports;
545                         1u,                                                                                                                             // deUint32                                                             scissorCount;
546                         &scissor                                                                                                                // const VkRect2D*                                              pScissors;
547                 };
548
549                 const VkPipelineRasterizationStateCreateInfo rasterStateParams =
550                 {
551                         VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,             // VkStructureType                                                      sType;
552                         DE_NULL,                                                                                                                // const void*                                                          pNext;
553                         0u,                                                                                                                             // VkPipelineRasterizationStateCreateFlags      flags;
554                         false,                                                                                                                  // VkBool32                                                                     depthClampEnable;
555                         false,                                                                                                                  // VkBool32                                                                     rasterizerDiscardEnable;
556                         VK_POLYGON_MODE_FILL,                                                                                   // VkPolygonMode                                                        polygonMode;
557                         VK_CULL_MODE_NONE,                                                                                              // VkCullModeFlags                                                      cullMode;
558                         VK_FRONT_FACE_COUNTER_CLOCKWISE,                                                                // VkFrontFace                                                          frontFace;
559                         VK_FALSE,                                                                                                               // VkBool32                                                                     depthBiasEnable;
560                         0.0f,                                                                                                                   // float                                                                        depthBiasConstantFactor;
561                         0.0f,                                                                                                                   // float                                                                        depthBiasClamp;
562                         0.0f,                                                                                                                   // float                                                                        depthBiasSlopeFactor;
563                         1.0f,                                                                                                                   // float                                                                        lineWidth;
564                 };
565
566                 const VkPipelineColorBlendAttachmentState colorBlendAttachmentState =
567                 {
568                         false,                                                                                                                                          // VkBool32                                     blendEnable;
569                         VK_BLEND_FACTOR_ONE,                                                                                                            // VkBlendFactor                        srcColorBlendFactor;
570                         VK_BLEND_FACTOR_ZERO,                                                                                                           // VkBlendFactor                        dstColorBlendFactor;
571                         VK_BLEND_OP_ADD,                                                                                                                        // VkBlendOp                            colorBlendOp;
572                         VK_BLEND_FACTOR_ONE,                                                                                                            // VkBlendFactor                        srcAlphaBlendFactor;
573                         VK_BLEND_FACTOR_ZERO,                                                                                                           // VkBlendFactor                        dstAlphaBlendFactor;
574                         VK_BLEND_OP_ADD,                                                                                                                        // VkBlendOp                            alphaBlendOp;
575                         VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |                                           // VkColorComponentFlags        colorWriteMask;
576                                 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
577                 };
578
579                 const VkPipelineColorBlendStateCreateInfo colorBlendStateParams =
580                 {
581                         VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,       // VkStructureType                                                              sType;
582                         DE_NULL,                                                                                                        // const void*                                                                  pNext;
583                         0,                                                                                                                      // VkPipelineColorBlendStateCreateFlags                 flags;
584                         false,                                                                                                          // VkBool32                                                                             logicOpEnable;
585                         VK_LOGIC_OP_COPY,                                                                                       // VkLogicOp                                                                    logicOp;
586                         1u,                                                                                                                     // deUint32                                                                             attachmentCount;
587                         &colorBlendAttachmentState,                                                                     // const VkPipelineColorBlendAttachmentState*   pAttachments;
588                         { 0.0f, 0.0f, 0.0f, 0.0f },                                                                     // float                                                                                blendConstants[4];
589                 };
590
591                 const VkPipelineMultisampleStateCreateInfo      multisampleStateParams  =
592                 {
593                         VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,       // VkStructureType                                                      sType;
594                         DE_NULL,                                                                                                        // const void*                                                          pNext;
595                         0u,                                                                                                                     // VkPipelineMultisampleStateCreateFlags        flags;
596                         VK_SAMPLE_COUNT_1_BIT,                                                                          // VkSampleCountFlagBits                                        rasterizationSamples;
597                         false,                                                                                                          // VkBool32                                                                     sampleShadingEnable;
598                         0.0f,                                                                                                           // float                                                                        minSampleShading;
599                         DE_NULL,                                                                                                        // const VkSampleMask*                                          pSampleMask;
600                         false,                                                                                                          // VkBool32                                                                     alphaToCoverageEnable;
601                         false                                                                                                           // VkBool32                                                                     alphaToOneEnable;
602                 };
603                 VkPipelineDepthStencilStateCreateInfo depthStencilStateParams =
604                 {
605                         VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,     // VkStructureType                                                      sType;
606                         DE_NULL,                                                                                                        // const void*                                                          pNext;
607                         0u,                                                                                                                     // VkPipelineDepthStencilStateCreateFlags       flags;
608                         true,                                                                                                           // VkBool32                                                                     depthTestEnable;
609                         true,                                                                                                           // VkBool32                                                                     depthWriteEnable;
610                         VK_COMPARE_OP_LESS,                                                                                     // VkCompareOp                                                          depthCompareOp;
611                         false,                                                                                                          // VkBool32                                                                     depthBoundsTestEnable;
612                         false,                                                                                                          // VkBool32                                                                     stencilTestEnable;
613                         // VkStencilOpState     front;
614                         {
615                                 VK_STENCIL_OP_KEEP,             // VkStencilOp  failOp;
616                                 VK_STENCIL_OP_KEEP,             // VkStencilOp  passOp;
617                                 VK_STENCIL_OP_KEEP,             // VkStencilOp  depthFailOp;
618                                 VK_COMPARE_OP_NEVER,    // VkCompareOp  compareOp;
619                                 0u,                                             // deUint32             compareMask;
620                                 0u,                                             // deUint32             writeMask;
621                                 0u,                                             // deUint32             reference;
622                         },
623                         // VkStencilOpState     back;
624                         {
625                                 VK_STENCIL_OP_KEEP,             // VkStencilOp  failOp;
626                                 VK_STENCIL_OP_KEEP,             // VkStencilOp  passOp;
627                                 VK_STENCIL_OP_KEEP,             // VkStencilOp  depthFailOp;
628                                 VK_COMPARE_OP_NEVER,    // VkCompareOp  compareOp;
629                                 0u,                                             // deUint32             compareMask;
630                                 0u,                                             // deUint32             writeMask;
631                                 0u,                                             // deUint32             reference;
632                         },
633                         0.0f,                                                                                                           // float                        minDepthBounds;
634                         1.0f,                                                                                                           // float                        maxDepthBounds;
635                 };
636
637                 const VkGraphicsPipelineCreateInfo graphicsPipelineParams =
638                 {
639                         VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,        // VkStructureType                                                                      sType;
640                         DE_NULL,                                                                                        // const void*                                                                          pNext;
641                         0u,                                                                                                     // VkPipelineCreateFlags                                                        flags;
642                         2u,                                                                                                     // deUint32                                                                                     stageCount;
643                         shaderStages,                                                                           // const VkPipelineShaderStageCreateInfo*                       pStages;
644                         &vertexInputStateParams,                                                        // const VkPipelineVertexInputStateCreateInfo*          pVertexInputState;
645                         &inputAssemblyStateParams,                                                      // const VkPipelineInputAssemblyStateCreateInfo*        pInputAssemblyState;
646                         DE_NULL,                                                                                        // const VkPipelineTessellationStateCreateInfo*         pTessellationState;
647                         &viewportStateParams,                                                           // const VkPipelineViewportStateCreateInfo*                     pViewportState;
648                         &rasterStateParams,                                                                     // const VkPipelineRasterizationStateCreateInfo*        pRasterizationState;
649                         &multisampleStateParams,                                                        // const VkPipelineMultisampleStateCreateInfo*          pMultisampleState;
650                         &depthStencilStateParams,                                                       // const VkPipelineDepthStencilStateCreateInfo*         pDepthStencilState;
651                         &colorBlendStateParams,                                                         // const VkPipelineColorBlendStateCreateInfo*           pColorBlendState;
652                         (const VkPipelineDynamicStateCreateInfo*)DE_NULL,       // const VkPipelineDynamicStateCreateInfo*                      pDynamicState;
653                         *m_pipelineLayout,                                                                      // VkPipelineLayout                                                                     layout;
654                         *m_renderPass,                                                                          // VkRenderPass                                                                         renderPass;
655                         0u,                                                                                                     // deUint32                                                                                     subpass;
656                         0u,                                                                                                     // VkPipeline                                                                           basePipelineHandle;
657                         0u,                                                                                                     // deInt32                                                                                      basePipelineIndex;
658                 };
659
660                 for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
661                 {
662                         depthStencilStateParams.depthCompareOp  = depthCompareOps[quadNdx];
663                         m_graphicsPipelines[quadNdx]                    = createGraphicsPipeline(vk, vkDevice, DE_NULL, &graphicsPipelineParams);
664                 }
665         }
666
667         // Create vertex buffer
668         {
669                 const VkBufferCreateInfo vertexBufferParams =
670                 {
671                         VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,           // VkStructureType              sType;
672                         DE_NULL,                                                                        // const void*                  pNext;
673                         0u,                                                                                     // VkBufferCreateFlags  flags;
674                         1024u,                                                                          // VkDeviceSize                 size;
675                         VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,                      // VkBufferUsageFlags   usage;
676                         VK_SHARING_MODE_EXCLUSIVE,                                      // VkSharingMode                sharingMode;
677                         1u,                                                                                     // deUint32                             queueFamilyIndexCount;
678                         &queueFamilyIndex                                                       // const deUint32*              pQueueFamilyIndices;
679                 };
680
681                 m_vertices                      = createOverlappingQuads();
682                 m_vertexBuffer          = createBuffer(vk, vkDevice, &vertexBufferParams);
683                 m_vertexBufferAlloc     = memAlloc.allocate(getBufferMemoryRequirements(vk, vkDevice, *m_vertexBuffer), MemoryRequirement::HostVisible);
684
685                 VK_CHECK(vk.bindBufferMemory(vkDevice, *m_vertexBuffer, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset()));
686
687                 // Adjust depths
688                 for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
689                         for (int vertexNdx = 0; vertexNdx < 6; vertexNdx++)
690                                 m_vertices[quadNdx * 6 + vertexNdx].position.z() = DepthTest::quadDepths[quadNdx];
691
692                 // Load vertices into vertex buffer
693                 deMemcpy(m_vertexBufferAlloc->getHostPtr(), m_vertices.data(), m_vertices.size() * sizeof(Vertex4RGBA));
694                 flushMappedMemoryRange(vk, vkDevice, m_vertexBufferAlloc->getMemory(), m_vertexBufferAlloc->getOffset(), vertexBufferParams.size);
695         }
696
697         // Create command pool
698         {
699                 const VkCommandPoolCreateInfo cmdPoolParams =
700                 {
701                         VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,     // VkStructureType              sType;
702                         DE_NULL,                                                                        // const void*                  pNext;
703                         VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,           // VkCmdPoolCreateFlags flags;
704                         queueFamilyIndex                                                        // deUint32                             queueFamilyIndex;
705                 };
706
707                 m_cmdPool = createCommandPool(vk, vkDevice, &cmdPoolParams);
708         }
709
710         // Create command buffer
711         {
712                 const VkCommandBufferAllocateInfo cmdBufferAllocateInfo =
713                 {
714                         VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType                      sType;
715                         DE_NULL,                                                                                // const void*                          pNext;
716                         *m_cmdPool,                                                                             // VkCommandPool                        commandPool;
717                         VK_COMMAND_BUFFER_LEVEL_PRIMARY,                                // VkCommandBufferLevel         level;
718                         1u                                                                                              // deUint32                                     bufferCount;
719                 };
720
721                 const VkCommandBufferBeginInfo cmdBufferBeginInfo =
722                 {
723                         VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,    // VkStructureType                                      sType;
724                         DE_NULL,                                                                                // const void*                                          pNext;
725                         0u,                                                                                             // VkCommandBufferUsageFlags            flags;
726                         (const VkCommandBufferInheritanceInfo*)DE_NULL,
727                 };
728
729                 const VkClearValue attachmentClearValues[2] =
730                 {
731                         defaultClearValue(m_colorFormat),
732                         defaultClearValue(m_depthFormat),
733                 };
734
735                 const VkRenderPassBeginInfo renderPassBeginInfo =
736                 {
737                         VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,                               // VkStructureType              sType;
738                         DE_NULL,                                                                                                // const void*                  pNext;
739                         *m_renderPass,                                                                                  // VkRenderPass                 renderPass;
740                         *m_framebuffer,                                                                                 // VkFramebuffer                framebuffer;
741                         { { 0, 0 }, { m_renderSize.x(), m_renderSize.y() } },   // VkRect2D                             renderArea;
742                         2,                                                                                                              // deUint32                             clearValueCount;
743                         attachmentClearValues                                                                   // const VkClearValue*  pClearValues;
744                 };
745
746                 const VkImageMemoryBarrier imageLayoutBarriers[] =
747                 {
748                         // color image layout transition
749                         {
750                                 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,                                                                 // VkStructureType            sType;
751                                 DE_NULL,                                                                                                                                // const void*                pNext;
752                                 (VkAccessFlags)0,                                                                                                               // VkAccessFlags              srcAccessMask;
753                                 VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,                                                                   // VkAccessFlags              dstAccessMask;
754                                 VK_IMAGE_LAYOUT_UNDEFINED,                                                                                              // VkImageLayout              oldLayout;
755                                 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,                                                               // VkImageLayout              newLayout;
756                                 VK_QUEUE_FAMILY_IGNORED,                                                                                                // uint32_t                   srcQueueFamilyIndex;
757                                 VK_QUEUE_FAMILY_IGNORED,                                                                                                // uint32_t                   dstQueueFamilyIndex;
758                                 *m_colorImage,                                                                                                                  // VkImage                    image;
759                                 { VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u }                                                   // VkImageSubresourceRange    subresourceRange;
760                         },
761                         // depth image layout transition
762                         {
763                                 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,                                                                 // VkStructureType            sType;
764                                 DE_NULL,                                                                                                                                // const void*                pNext;
765                                 (VkAccessFlags)0,                                                                                                               // VkAccessFlags              srcAccessMask;
766                                 VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,                                                   // VkAccessFlags              dstAccessMask;
767                                 VK_IMAGE_LAYOUT_UNDEFINED,                                                                                              // VkImageLayout              oldLayout;
768                                 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,                                               // VkImageLayout              newLayout;
769                                 VK_QUEUE_FAMILY_IGNORED,                                                                                                // uint32_t                   srcQueueFamilyIndex;
770                                 VK_QUEUE_FAMILY_IGNORED,                                                                                                // uint32_t                   dstQueueFamilyIndex;
771                                 *m_depthImage,                                                                                                                  // VkImage                    image;
772                                 m_depthImageSubresourceRange,                                                                                   // VkImageSubresourceRange    subresourceRange;
773                         },
774                 };
775
776                 m_cmdBuffer = allocateCommandBuffer(vk, vkDevice, &cmdBufferAllocateInfo);
777
778                 VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
779
780                 vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, (VkDependencyFlags)0,
781                         0u, DE_NULL, 0u, DE_NULL, DE_LENGTH_OF_ARRAY(imageLayoutBarriers), imageLayoutBarriers);
782
783                 vk.cmdBeginRenderPass(*m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
784
785                 const VkDeviceSize              quadOffset              = (m_vertices.size() / DepthTest::QUAD_COUNT) * sizeof(Vertex4RGBA);
786
787                 for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
788                 {
789                         VkDeviceSize vertexBufferOffset = quadOffset * quadNdx;
790
791                         vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipelines[quadNdx]);
792                         vk.cmdBindVertexBuffers(*m_cmdBuffer, 0, 1, &m_vertexBuffer.get(), &vertexBufferOffset);
793                         vk.cmdDraw(*m_cmdBuffer, (deUint32)(m_vertices.size() / DepthTest::QUAD_COUNT), 1, 0, 0);
794                 }
795
796                 vk.cmdEndRenderPass(*m_cmdBuffer);
797                 VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
798         }
799
800         // Create fence
801         {
802                 const VkFenceCreateInfo fenceParams =
803                 {
804                         VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,    // VkStructureType              sType;
805                         DE_NULL,                                                                // const void*                  pNext;
806                         0u                                                                              // VkFenceCreateFlags   flags;
807                 };
808
809                 m_fence = createFence(vk, vkDevice, &fenceParams);
810         }
811 }
812
813 DepthTestInstance::~DepthTestInstance (void)
814 {
815 }
816
817 tcu::TestStatus DepthTestInstance::iterate (void)
818 {
819         const DeviceInterface&          vk                      = m_context.getDeviceInterface();
820         const VkDevice                          vkDevice        = m_context.getDevice();
821         const VkQueue                           queue           = m_context.getUniversalQueue();
822         const VkSubmitInfo                      submitInfo      =
823         {
824                 VK_STRUCTURE_TYPE_SUBMIT_INFO,  // VkStructureType                      sType;
825                 DE_NULL,                                                // const void*                          pNext;
826                 0u,                                                             // deUint32                                     waitSemaphoreCount;
827                 DE_NULL,                                                // const VkSemaphore*           pWaitSemaphores;
828                 (const VkPipelineStageFlags*)DE_NULL,
829                 1u,                                                             // deUint32                                     commandBufferCount;
830                 &m_cmdBuffer.get(),                             // const VkCommandBuffer*       pCommandBuffers;
831                 0u,                                                             // deUint32                                     signalSemaphoreCount;
832                 DE_NULL                                                 // const VkSemaphore*           pSignalSemaphores;
833         };
834
835         VK_CHECK(vk.resetFences(vkDevice, 1, &m_fence.get()));
836         VK_CHECK(vk.queueSubmit(queue, 1, &submitInfo, *m_fence));
837         VK_CHECK(vk.waitForFences(vkDevice, 1, &m_fence.get(), true, ~(0ull) /* infinity*/));
838
839         return verifyImage();
840 }
841
842 tcu::TestStatus DepthTestInstance::verifyImage (void)
843 {
844         const tcu::TextureFormat        tcuColorFormat  = mapVkFormat(m_colorFormat);
845         const tcu::TextureFormat        tcuDepthFormat  = mapVkFormat(m_depthFormat);
846         const ColorVertexShader         vertexShader;
847         const ColorFragmentShader       fragmentShader  (tcuColorFormat, tcuDepthFormat);
848         const rr::Program                       program                 (&vertexShader, &fragmentShader);
849         ReferenceRenderer                       refRenderer             (m_renderSize.x(), m_renderSize.y(), 1, tcuColorFormat, tcuDepthFormat, &program);
850         bool                                            compareOk               = false;
851
852         // Render reference image
853         {
854                 for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
855                 {
856                         // Set depth state
857                         rr::RenderState renderState(refRenderer.getViewportState());
858                         renderState.fragOps.depthTestEnabled = true;
859                         renderState.fragOps.depthFunc = mapVkCompareOp(m_depthCompareOps[quadNdx]);
860
861                         refRenderer.draw(renderState,
862                                                          rr::PRIMITIVETYPE_TRIANGLES,
863                                                          std::vector<Vertex4RGBA>(m_vertices.begin() + quadNdx * 6,
864                                                                                                           m_vertices.begin() + (quadNdx + 1) * 6));
865                 }
866         }
867
868         // Compare result with reference image
869         {
870                 const DeviceInterface&                  vk                                      = m_context.getDeviceInterface();
871                 const VkDevice                                  vkDevice                        = m_context.getDevice();
872                 const VkQueue                                   queue                           = m_context.getUniversalQueue();
873                 const deUint32                                  queueFamilyIndex        = m_context.getUniversalQueueFamilyIndex();
874                 SimpleAllocator                                 allocator                       (vk, vkDevice, getPhysicalDeviceMemoryProperties(m_context.getInstanceInterface(), m_context.getPhysicalDevice()));
875                 de::MovePtr<tcu::TextureLevel>  result                          = readColorAttachment(vk, vkDevice, queue, queueFamilyIndex, allocator, *m_colorImage, m_colorFormat, m_renderSize);
876
877                 compareOk = tcu::intThresholdPositionDeviationCompare(m_context.getTestContext().getLog(),
878                                                                                                                           "IntImageCompare",
879                                                                                                                           "Image comparison",
880                                                                                                                           refRenderer.getAccess(),
881                                                                                                                           result->getAccess(),
882                                                                                                                           tcu::UVec4(2, 2, 2, 2),
883                                                                                                                           tcu::IVec3(1, 1, 0),
884                                                                                                                           true,
885                                                                                                                           tcu::COMPARE_LOG_RESULT);
886         }
887
888         if (compareOk)
889                 return tcu::TestStatus::pass("Result image matches reference");
890         else
891                 return tcu::TestStatus::fail("Image mismatch");
892 }
893
894 std::string getFormatCaseName (const VkFormat format)
895 {
896         const std::string       fullName        = getFormatName(format);
897
898         DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_"));
899
900         return de::toLower(fullName.substr(10));
901 }
902
903 std::string     getCompareOpsName (const VkCompareOp quadDepthOps[DepthTest::QUAD_COUNT])
904 {
905         std::ostringstream name;
906
907         for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
908         {
909                 const std::string       fullOpName      = getCompareOpName(quadDepthOps[quadNdx]);
910
911                 DE_ASSERT(de::beginsWith(fullOpName, "VK_COMPARE_OP_"));
912
913                 name << de::toLower(fullOpName.substr(14));
914
915                 if (quadNdx < DepthTest::QUAD_COUNT - 1)
916                         name << "_";
917         }
918
919         return name.str();
920 }
921
922 std::string     getCompareOpsDescription (const VkCompareOp quadDepthOps[DepthTest::QUAD_COUNT])
923 {
924         std::ostringstream desc;
925         desc << "Draws " << DepthTest::QUAD_COUNT << " quads with depth compare ops: ";
926
927         for (int quadNdx = 0; quadNdx < DepthTest::QUAD_COUNT; quadNdx++)
928         {
929                 desc << getCompareOpName(quadDepthOps[quadNdx]) << " at depth " << DepthTest::quadDepths[quadNdx];
930
931                 if (quadNdx < DepthTest::QUAD_COUNT - 1)
932                         desc << ", ";
933         }
934         return desc.str();
935 }
936
937
938 } // anonymous
939
940 tcu::TestCaseGroup* createDepthTests (tcu::TestContext& testCtx)
941 {
942         const VkFormat depthFormats[] =
943         {
944                 VK_FORMAT_D16_UNORM,
945                 VK_FORMAT_X8_D24_UNORM_PACK32,
946                 VK_FORMAT_D32_SFLOAT,
947                 VK_FORMAT_D16_UNORM_S8_UINT,
948                 VK_FORMAT_D24_UNORM_S8_UINT,
949                 VK_FORMAT_D32_SFLOAT_S8_UINT
950         };
951
952         // Each entry configures the depth compare operators of QUAD_COUNT quads.
953         // All entries cover pair-wise combinations of compare operators.
954         const VkCompareOp depthOps[][DepthTest::QUAD_COUNT] =
955         {
956                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_NOT_EQUAL },
957                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_GREATER },
958                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_LESS_OR_EQUAL },
959                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_GREATER_OR_EQUAL },
960                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_ALWAYS },
961                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_LESS },
962                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_NEVER },
963                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_EQUAL },
964                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_LESS },
965                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_NOT_EQUAL },
966                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_GREATER },
967                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_LESS_OR_EQUAL },
968                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_EQUAL },
969                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_ALWAYS },
970                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_GREATER_OR_EQUAL },
971                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_LESS },
972                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_ALWAYS },
973                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_GREATER },
974                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_NOT_EQUAL },
975                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_GREATER_OR_EQUAL },
976                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_NEVER },
977                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_GREATER },
978                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_LESS_OR_EQUAL },
979                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_NOT_EQUAL },
980                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_GREATER_OR_EQUAL },
981                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_LESS_OR_EQUAL },
982                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_LESS },
983                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_EQUAL },
984                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_NEVER },
985                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_LESS_OR_EQUAL },
986                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_EQUAL },
987                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_LESS },
988                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_ALWAYS },
989                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_GREATER_OR_EQUAL },
990                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_NEVER },
991                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_GREATER_OR_EQUAL },
992                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_LESS_OR_EQUAL },
993                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_NEVER },
994                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_EQUAL },
995                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_NOT_EQUAL },
996                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_ALWAYS },
997                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_ALWAYS },
998                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_LESS },
999                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_EQUAL },
1000                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_GREATER },
1001                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_NOT_EQUAL },
1002                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_LESS_OR_EQUAL },
1003                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_GREATER_OR_EQUAL },
1004                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_NEVER },
1005                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_LESS },
1006                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_ALWAYS },
1007                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_GREATER },
1008                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_EQUAL },
1009                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_NOT_EQUAL },
1010                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_LESS },
1011                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_NEVER },
1012                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_NOT_EQUAL },
1013                 { VK_COMPARE_OP_GREATER,                        VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_EQUAL },
1014                 { VK_COMPARE_OP_EQUAL,                          VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_LESS_OR_EQUAL },
1015                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_GREATER },
1016                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_NEVER },
1017                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_GREATER },
1018                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_NOT_EQUAL },
1019                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_ALWAYS },
1020                 { VK_COMPARE_OP_LESS_OR_EQUAL,          VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_GREATER },
1021                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_LESS,                             VK_COMPARE_OP_GREATER },
1022                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_GREATER_OR_EQUAL },
1023                 { VK_COMPARE_OP_ALWAYS,                         VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_LESS_OR_EQUAL },
1024                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_GREATER_OR_EQUAL, VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_LESS },
1025                 { VK_COMPARE_OP_GREATER_OR_EQUAL,       VK_COMPARE_OP_NEVER,                    VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_NEVER },
1026                 { VK_COMPARE_OP_LESS,                           VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_EQUAL,                    VK_COMPARE_OP_EQUAL },
1027                 { VK_COMPARE_OP_NEVER,                          VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_ALWAYS,                   VK_COMPARE_OP_GREATER_OR_EQUAL },
1028                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_GREATER,                  VK_COMPARE_OP_ALWAYS },
1029                 { VK_COMPARE_OP_NOT_EQUAL,                      VK_COMPARE_OP_LESS_OR_EQUAL,    VK_COMPARE_OP_NOT_EQUAL,                VK_COMPARE_OP_GREATER }
1030         };
1031
1032         de::MovePtr<tcu::TestCaseGroup> depthTests (new tcu::TestCaseGroup(testCtx, "depth", "Depth tests"));
1033
1034         // Tests for format features
1035         {
1036                 de::MovePtr<tcu::TestCaseGroup> formatFeaturesTests (new tcu::TestCaseGroup(testCtx, "format_features", "Checks depth format features"));
1037
1038                 // Formats that must be supported in all implementations
1039                 addFunctionCase(formatFeaturesTests.get(),
1040                                                 "support_d16_unorm",
1041                                                 "Tests if VK_FORMAT_D16_UNORM is supported as depth/stencil attachment format",
1042                                                 testSupportsDepthStencilFormat,
1043                                                 VK_FORMAT_D16_UNORM);
1044
1045                 // Sets where at least one of the formats must be supported
1046                 const VkFormat  depthOnlyFormats[]              = { VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_D32_SFLOAT };
1047                 const VkFormat  depthStencilFormats[]   = { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT };
1048
1049                 addFunctionCase(formatFeaturesTests.get(),
1050                                                 "support_d24_unorm_or_d32_sfloat",
1051                                                 "Tests if any of VK_FORMAT_D24_UNORM_X8 or VK_FORMAT_D32_SFLOAT are supported as depth/stencil attachment format",
1052                                                 testSupportsAtLeastOneDepthStencilFormat,
1053                                                 std::vector<VkFormat>(depthOnlyFormats, depthOnlyFormats + DE_LENGTH_OF_ARRAY(depthOnlyFormats)));
1054
1055                 addFunctionCase(formatFeaturesTests.get(),
1056                                                 "support_d24_unorm_s8_uint_or_d32_sfloat_s8_uint",
1057                                                 "Tests if any of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT are supported as depth/stencil attachment format",
1058                                                 testSupportsAtLeastOneDepthStencilFormat,
1059                                                 std::vector<VkFormat>(depthStencilFormats, depthStencilFormats + DE_LENGTH_OF_ARRAY(depthStencilFormats)));
1060
1061                 depthTests->addChild(formatFeaturesTests.release());
1062         }
1063
1064         // Tests for format and compare operators
1065         {
1066                 de::MovePtr<tcu::TestCaseGroup> formatTests (new tcu::TestCaseGroup(testCtx, "format", "Uses different depth formats"));
1067
1068                 for (size_t formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthFormats); formatNdx++)
1069                 {
1070                         de::MovePtr<tcu::TestCaseGroup> formatTest              (new tcu::TestCaseGroup(testCtx,
1071                                                                                                                                                                         getFormatCaseName(depthFormats[formatNdx]).c_str(),
1072                                                                                                                                                                         (std::string("Uses format ") + getFormatName(depthFormats[formatNdx])).c_str()));
1073                         de::MovePtr<tcu::TestCaseGroup> compareOpsTests (new tcu::TestCaseGroup(testCtx, "compare_ops", "Combines depth compare operators"));
1074
1075                         for (size_t opsNdx = 0; opsNdx < DE_LENGTH_OF_ARRAY(depthOps); opsNdx++)
1076                         {
1077                                 compareOpsTests->addChild(new DepthTest(testCtx,
1078                                                                                                                 getCompareOpsName(depthOps[opsNdx]),
1079                                                                                                                 getCompareOpsDescription(depthOps[opsNdx]),
1080                                                                                                                 depthFormats[formatNdx],
1081                                                                                                                 depthOps[opsNdx]));
1082                         }
1083                         formatTest->addChild(compareOpsTests.release());
1084                         formatTests->addChild(formatTest.release());
1085                 }
1086                 depthTests->addChild(formatTests.release());
1087         }
1088
1089         return depthTests.release();
1090 }
1091
1092 } // pipeline
1093 } // vkt