Added two-step variants of surface clear tests
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / api / vktApiImageClearingTests.cpp
index 01fb791..beebce1 100644 (file)
@@ -64,10 +64,11 @@ namespace
 
 enum AllocationKind
 {
-       ALLOCATION_KIND_SUBALLOCATED,
+       ALLOCATION_KIND_SUBALLOCATED = 0,
        ALLOCATION_KIND_DEDICATED,
-};
 
+       ALLOCATION_KIND_LAST,
+};
 
 de::MovePtr<Allocation> allocateBuffer (const InstanceInterface&       vki,
                                                                                const DeviceInterface&          vkd,
@@ -150,7 +151,7 @@ deUint32 greatestCommonDivisor (const deUint32 a, const deUint32 b)
        deUint32 x=a;
        deUint32 y=b;
 
-       while (x%b != 0)
+       while (x%y != 0)
        {
                temp = y;
                y = x%y;
@@ -190,9 +191,10 @@ inline bool isInClearRange (const UVec4& clearCoords, const deUint32 x, const de
        {
                // Only layers in range passed to clear command are cleared
 
-               const deUint32 clearBaseLayer = (imageViewLayerRange ? imageViewLayerRange->baseArrayLayer : 0) + attachmentClearLayerRange->baseArrayLayer;
+               const deUint32  clearBaseLayer  = (imageViewLayerRange ? imageViewLayerRange->baseArrayLayer : 0) + attachmentClearLayerRange->baseArrayLayer;
+               const deUint32  clearLayerCount = (attachmentClearLayerRange->layerCount == VK_REMAINING_ARRAY_LAYERS) ? imageViewLayerRange->layerCount : clearBaseLayer + attachmentClearLayerRange->layerCount;
 
-               if ((arrayLayer < clearBaseLayer) || (arrayLayer >= (clearBaseLayer + attachmentClearLayerRange->layerCount)))
+               if ((arrayLayer < clearBaseLayer) || (arrayLayer >= (clearLayerCount)))
                {
                        return false;
                }
@@ -1140,20 +1142,34 @@ void ImageClearingTestInstance::beginRenderPass (VkSubpassContents content, VkCl
 class ClearColorImageTestInstance : public ImageClearingTestInstance
 {
 public:
-                               ClearColorImageTestInstance     (Context& context, const TestParams& testParams) : ImageClearingTestInstance (context, testParams) {}
+                               ClearColorImageTestInstance     (Context& context, const TestParams& testParams, bool twoStep = false) : ImageClearingTestInstance (context, testParams), m_twoStep(twoStep) {}
        TestStatus      iterate                                         (void);
+protected:
+       bool            m_twoStep;
+};
+
+class TwoStepClearColorImageTestInstance : public ClearColorImageTestInstance
+{
+public:
+       TwoStepClearColorImageTestInstance (Context& context, const TestParams& testParams) : ClearColorImageTestInstance(context, testParams, true) {}
 };
 
 TestStatus ClearColorImageTestInstance::iterate (void)
 {
        std::vector<VkImageSubresourceRange> subresourceRanges;
+       std::vector<VkImageSubresourceRange> steptwoRanges;
 
        if (m_imageMipLevels == 1)
-               subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u, m_params.clearLayerRange.baseArrayLayer, m_params.clearLayerRange.layerCount));
+       {
+               subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u,                                   1u,                                                     m_params.clearLayerRange.baseArrayLayer, m_twoStep ? 1 : m_params.clearLayerRange.layerCount));
+               steptwoRanges.push_back(        makeImageSubresourceRange(m_imageAspectFlags, 0u,                                       VK_REMAINING_MIP_LEVELS,        m_params.clearLayerRange.baseArrayLayer, VK_REMAINING_ARRAY_LAYERS));
+       }
        else
        {
-               subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags,       0u,                                             m_thresholdMipLevel,            m_params.clearLayerRange.baseArrayLayer, m_params.clearLayerRange.layerCount));
-               subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags,       m_thresholdMipLevel,    VK_REMAINING_MIP_LEVELS,        m_params.clearLayerRange.baseArrayLayer, m_params.clearLayerRange.layerCount));
+               subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, 0u,                                   m_thresholdMipLevel,            m_params.clearLayerRange.baseArrayLayer, m_params.clearLayerRange.layerCount));
+               subresourceRanges.push_back(makeImageSubresourceRange(m_imageAspectFlags, m_thresholdMipLevel,  VK_REMAINING_MIP_LEVELS,        m_params.clearLayerRange.baseArrayLayer, m_params.clearLayerRange.layerCount));
+               steptwoRanges.push_back(        makeImageSubresourceRange(m_imageAspectFlags, 0u,                                       m_thresholdMipLevel,            m_params.clearLayerRange.baseArrayLayer, VK_REMAINING_ARRAY_LAYERS));
+               steptwoRanges.push_back(        makeImageSubresourceRange(m_imageAspectFlags, m_thresholdMipLevel,      VK_REMAINING_MIP_LEVELS,        m_params.clearLayerRange.baseArrayLayer, VK_REMAINING_ARRAY_LAYERS));
        }
 
        beginCommandBuffer(0);
@@ -1184,7 +1200,11 @@ TestStatus ClearColorImageTestInstance::iterate (void)
 
        // Different clear color per range
        for (std::size_t i = 0u; i < subresourceRanges.size(); ++i)
+       {
                m_vkd.cmdClearColorImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[i].color, 1, &subresourceRanges[i]);
+               if (m_twoStep)
+                       m_vkd.cmdClearColorImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[i].color, 1, &steptwoRanges[i]);
+       }
 
        pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,                            // VkPipelineStageFlags         srcStageMask
                                                 VK_PIPELINE_STAGE_TRANSFER_BIT,                                // VkPipelineStageFlags         dstStageMask
@@ -1202,13 +1222,22 @@ TestStatus ClearColorImageTestInstance::iterate (void)
 class ClearDepthStencilImageTestInstance : public ImageClearingTestInstance
 {
 public:
-                               ClearDepthStencilImageTestInstance      (Context& context, const TestParams& testParams) : ImageClearingTestInstance (context, testParams) {}
+                               ClearDepthStencilImageTestInstance      (Context& context, const TestParams& testParams, bool twoStep = false) : ImageClearingTestInstance (context, testParams), m_twoStep(twoStep) {}
        TestStatus      iterate                                                         (void);
+protected:
+       bool            m_twoStep;
+};
+
+class TwoStepClearDepthStencilImageTestInstance : public ClearDepthStencilImageTestInstance
+{
+public:
+       TwoStepClearDepthStencilImageTestInstance (Context& context, const TestParams& testParams) : ClearDepthStencilImageTestInstance (context, testParams, true) { }
 };
 
 TestStatus ClearDepthStencilImageTestInstance::iterate (void)
 {
-       const VkImageSubresourceRange subresourceRange = makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u, m_params.clearLayerRange.baseArrayLayer, m_params.clearLayerRange.layerCount);
+       const VkImageSubresourceRange subresourceRange  = makeImageSubresourceRange(m_imageAspectFlags, 0u, 1u,                                                 m_params.clearLayerRange.baseArrayLayer, m_twoStep ? 1 : m_params.clearLayerRange.layerCount);
+       const VkImageSubresourceRange steptwoRange              = makeImageSubresourceRange(m_imageAspectFlags, 0u, VK_REMAINING_MIP_LEVELS,    m_params.clearLayerRange.baseArrayLayer, VK_REMAINING_ARRAY_LAYERS);
 
        beginCommandBuffer(0);
 
@@ -1238,6 +1267,9 @@ TestStatus ClearDepthStencilImageTestInstance::iterate (void)
 
        m_vkd.cmdClearDepthStencilImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[0].depthStencil, 1, &subresourceRange);
 
+       if (m_twoStep)
+               m_vkd.cmdClearDepthStencilImage(*m_commandBuffer, *m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &m_params.clearValue[0].depthStencil, 1, &steptwoRange);
+
        pipelineImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,                                    // VkPipelineStageFlags         srcStageMask
                                                 VK_PIPELINE_STAGE_TRANSFER_BIT,                                        // VkPipelineStageFlags         dstStageMask
                                                 VK_ACCESS_TRANSFER_WRITE_BIT,                                          // VkAccessFlags                        srcAccessMask
@@ -1631,26 +1663,47 @@ TestCaseGroup* createImageClearingTestsCommon (TestContext& testCtx, tcu::TestCa
                deUint32                imageLayerCount;
                LayerRange              imageViewRange;
                LayerRange              clearLayerRange;
+               bool                    twoStep;
                const char*             testName;
        };
        const ImageLayerParams imageLayerParamsToTest[] =
        {
                {
-                       1u,                                     // imageLayerCount
-                       {0u, 1u},                       // imageViewRange
-                       {0u, 1u},                       // clearLayerRange
-                       DE_NULL                         // testName
+                       1u,                                                                     // imageLayerCount
+                       {0u, 1u},                                                       // imageViewRange
+                       {0u, 1u},                                                       // clearLayerRange
+                       false,                                                          // twoStep
+                       "single_layer"                                          // testName
+               },
+               {
+                       16u,                                                            // imageLayerCount
+                       {3u, 12u},                                                      // imageViewRange
+                       {2u, 5u},                                                       // clearLayerRange
+                       false,                                                          // twoStep
+                       "multiple_layers"                                       // testName
                },
                {
-                       16u,                            // imageLayerCount
-                       {3u, 12u},                      // imageViewRange
-                       {2u, 5u},                       // clearLayerRange
-                       "multiple_layers"       // testName
+                       16u,                                                            // imageLayerCount
+                       { 3u, 12u },                                            // imageViewRange
+                       { 8u, VK_REMAINING_ARRAY_LAYERS },      // clearLayerRange
+                       false,                                                          // twoStep
+                       "remaining_array_layers"                        // testName
                },
+               {
+                       16u,                                                            // imageLayerCount
+                       { 3u, 12u },                                            // imageViewRange
+                       { 8u, VK_REMAINING_ARRAY_LAYERS },      // clearLayerRange
+                       true,                                                           // twoStep
+                       "remaining_array_layers_twostep"        // testName
+               }
        };
 
+       // Include test cases with VK_REMAINING_ARRAY_LAYERS when using vkCmdClearColorImage
        const size_t    numOfImageLayerParamsToTest                             = DE_LENGTH_OF_ARRAY(imageLayerParamsToTest);
 
+       // Exclude test cases with VK_REMAINING_ARRAY_LAYERS when using vkCmdClearAttachments
+       const size_t    numOfAttachmentLayerParamsToTest                = numOfImageLayerParamsToTest - 2;
+
        // Clear color image
        {
                const VkImageType                       imageTypesToTest[]              =
@@ -1669,152 +1722,168 @@ TestCaseGroup* createImageClearingTestsCommon (TestContext& testCtx, tcu::TestCa
                };
 
                for (size_t     imageTypeIndex = 0; imageTypeIndex < numOfImageTypesToTest; ++imageTypeIndex)
-               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
-               for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfImageLayerParamsToTest; ++imageLayerParamsIndex)
                {
+                       de::MovePtr<TestCaseGroup> imageTypeGroup(new TestCaseGroup(testCtx, getImageTypeCaseName(imageTypesToTest[imageTypeIndex]), ""));
 
-                       if (imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount > 1u && imageTypesToTest[imageTypeIndex] == VK_IMAGE_TYPE_3D)
+                       for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfImageLayerParamsToTest; ++imageLayerParamsIndex)
                        {
                                // 3D ARRAY images are not supported
-                               continue;
-                       }
-
-                       const VkFormat          format          = colorImageFormatsToTest[imageFormatIndex];
-                       const TestParams        testParams      =
-                       {
-                               false,                                                                                                                          // bool                         useSingleMipLevel;
-                               imageTypesToTest[imageTypeIndex],                                                                       // VkImageType          imageType;
-                               format,                                                                                                                         // VkFormat                     imageFormat;
-                               imageDimensionsByType[imageTypeIndex],                                                          // VkExtent3D           imageExtent;
-                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,          // deUint32         imageLayerCount;
-                               {
-                                       0u,
-                                       imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount
-                               },                                                                                                                                      // LayerRange           imageViewLayerRange;
-                               makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f),                            // VkClearValue         initValue;
-                               {
-                                       makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f),                            // VkClearValue         clearValue[0];
-                                       makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f),                            // VkClearValue         clearValue[1];
-                               },
-                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,          // LayerRange       clearLayerRange;
-                               allocationKind                                                                                                          // AllocationKind       allocationKind;
-                       };
+                               if (imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount > 1u && imageTypesToTest[imageTypeIndex] == VK_IMAGE_TYPE_3D)
+                                       continue;
 
-                       std::ostringstream      testCaseName;
-                       testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(format);
-                       if (imageLayerParamsToTest[imageLayerParamsIndex].testName != DE_NULL)
-                               testCaseName << "_" << imageLayerParamsToTest[imageLayerParamsIndex].testName;
+                               de::MovePtr<TestCaseGroup> imageLayersGroup(new TestCaseGroup(testCtx, imageLayerParamsToTest[imageLayerParamsIndex].testName, ""));
 
-                       colorImageClearTests->addChild(new InstanceFactory1<ClearColorImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Image", testParams));
+                               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
+                               {
+                                       const VkFormat          format                  = colorImageFormatsToTest[imageFormatIndex];
+                                       const std::string       testCaseName    = getFormatCaseName(format);
+                                       const TestParams        testParams              =
+                                       {
+                                               false,                                                                                                                          // bool                         useSingleMipLevel;
+                                               imageTypesToTest[imageTypeIndex],                                                                       // VkImageType          imageType;
+                                               format,                                                                                                                         // VkFormat                     imageFormat;
+                                               imageDimensionsByType[imageTypeIndex],                                                          // VkExtent3D           imageExtent;
+                                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,          // deUint32         imageLayerCount;
+                                               {
+                                                       0u,
+                                                       imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount
+                                               },                                                                                                                                      // LayerRange           imageViewLayerRange;
+                                               makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f),                            // VkClearValue         initValue;
+                                               {
+                                                       makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f),                            // VkClearValue         clearValue[0];
+                                                       makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f),                            // VkClearValue         clearValue[1];
+                                               },
+                                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,          // LayerRange       clearLayerRange;
+                                               allocationKind                                                                                                          // AllocationKind       allocationKind;
+                                       };
+                                       if (!imageLayerParamsToTest[imageLayerParamsIndex].twoStep)
+                                               imageLayersGroup->addChild(new InstanceFactory1<ClearColorImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Clear Color Image", testParams));
+                                       else
+                                               imageLayersGroup->addChild(new InstanceFactory1<TwoStepClearColorImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Clear Color Image", testParams));
+                               }
+                               imageTypeGroup->addChild(imageLayersGroup.release());
+                       }
+                       colorImageClearTests->addChild(imageTypeGroup.release());
                }
-
                imageClearingTests->addChild(colorImageClearTests.release());
        }
 
        // Clear depth/stencil image
        {
-               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
                for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfImageLayerParamsToTest; ++imageLayerParamsIndex)
                {
-                       const TestParams testParams =
+                       de::MovePtr<TestCaseGroup> imageLayersGroup(new TestCaseGroup(testCtx, imageLayerParamsToTest[imageLayerParamsIndex].testName, ""));
+
+                       for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
                        {
-                               true,                                                                                                                           // bool                         useSingleMipLevel;
-                               VK_IMAGE_TYPE_2D,                                                                                                       // VkImageType          imageType;
-                               depthStencilImageFormatsToTest[imageFormatIndex],                                       // VkFormat                     format;
-                               { 256, 256, 1 },                                                                                                        // VkExtent3D           extent;
-                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,          // deUint32         imageLayerCount;
+                               const VkFormat          format                  = depthStencilImageFormatsToTest[imageFormatIndex];
+                               const std::string       testCaseName    = getFormatCaseName(format);
+                               const TestParams        testParams              =
                                {
-                                       0u,
-                                       imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount
-                               },                                                                                                                                      // LayerRange           imageViewLayerRange;
-                               makeClearValueDepthStencil(0.5f, 0x03),                                                         // VkClearValue         initValue
-                               {
-                                       makeClearValueDepthStencil(0.1f, 0x06),                                                         // VkClearValue         clearValue[0];
-                                       makeClearValueDepthStencil(0.3f, 0x04),                                                         // VkClearValue         clearValue[1];
-                               },
-                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,          // LayerRange       clearLayerRange;
-                               allocationKind                                                                                                          // AllocationKind       allocationKind;
-                       };
-
-                       std::ostringstream      testCaseName;
-                       testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(testParams.imageFormat);
-                       if (imageLayerParamsToTest[imageLayerParamsIndex].testName != DE_NULL)
-                               testCaseName << "_" << imageLayerParamsToTest[imageLayerParamsIndex].testName;
-
-                       depthStencilImageClearTests->addChild(new InstanceFactory1<ClearDepthStencilImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Image", testParams));
+                                       true,                                                                                                                           // bool                         useSingleMipLevel;
+                                       VK_IMAGE_TYPE_2D,                                                                                                       // VkImageType          imageType;
+                                       format,                                                                                                                         // VkFormat                     format;
+                                       { 256, 256, 1 },                                                                                                        // VkExtent3D           extent;
+                                       imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,          // deUint32         imageLayerCount;
+                                       {
+                                               0u,
+                                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount
+                                       },                                                                                                                                      // LayerRange           imageViewLayerRange;
+                                       makeClearValueDepthStencil(0.5f, 0x03),                                                         // VkClearValue         initValue
+                                       {
+                                               makeClearValueDepthStencil(0.1f, 0x06),                                                         // VkClearValue         clearValue[0];
+                                               makeClearValueDepthStencil(0.3f, 0x04),                                                         // VkClearValue         clearValue[1];
+                                       },
+                                       imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,          // LayerRange       clearLayerRange;
+                                       allocationKind                                                                                                          // AllocationKind       allocationKind;
+                               };
+
+                               if (!imageLayerParamsToTest[imageLayerParamsIndex].twoStep)
+                                       imageLayersGroup->addChild(new InstanceFactory1<ClearDepthStencilImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Clear Depth/Stencil Image", testParams));
+                               else
+                                       imageLayersGroup->addChild(new InstanceFactory1<TwoStepClearDepthStencilImageTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Clear Depth/Stencil Image", testParams));
+                       }
+                       depthStencilImageClearTests->addChild(imageLayersGroup.release());
                }
-
                imageClearingTests->addChild(depthStencilImageClearTests.release());
        }
 
        // Clear color attachment
        {
-               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
-               for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfImageLayerParamsToTest; ++imageLayerParamsIndex)
+               for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfAttachmentLayerParamsToTest; ++imageLayerParamsIndex)
                {
-                       const VkFormat          format          = colorImageFormatsToTest[imageFormatIndex];
-
-                       const TestParams        testParams =
+                       if (!imageLayerParamsToTest[imageLayerParamsIndex].twoStep)
                        {
-                               true,                                                                                                                   // bool                         useSingleMipLevel;
-                               VK_IMAGE_TYPE_2D,                                                                                               // VkImageType          imageType;
-                               format,                                                                                                                 // VkFormat                     format;
-                               { 256, 256, 1 },                                                                                                // VkExtent3D           extent;
-                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,  // deUint32         imageLayerCount;
-                               imageLayerParamsToTest[imageLayerParamsIndex].imageViewRange,   // LayerRange           imageViewLayerRange;
-                               makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f),                    // VkClearValue         initValue
-                               {
-                                       makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f),                    // VkClearValue         clearValue[0];
-                                       makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f),                    // VkClearValue         clearValue[1];
-                               },
-                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,  // LayerRange       clearLayerRange;
-                               allocationKind                                                                                                  // AllocationKind       allocationKind;
-                       };
+                               de::MovePtr<TestCaseGroup> colorAttachmentClearLayersGroup(new TestCaseGroup(testCtx, imageLayerParamsToTest[imageLayerParamsIndex].testName, ""));
+                               de::MovePtr<TestCaseGroup> partialColorAttachmentClearLayersGroup(new TestCaseGroup(testCtx, imageLayerParamsToTest[imageLayerParamsIndex].testName, ""));
 
-                       std::ostringstream      testCaseName;
-                       testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(format);
-                       if (imageLayerParamsToTest[imageLayerParamsIndex].testName != DE_NULL)
-                               testCaseName << "_" << imageLayerParamsToTest[imageLayerParamsIndex].testName;
-
-                       colorAttachmentClearTests->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Color Attachment", testParams));
-                       partialColorAttachmentClearTests->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Partial Clear Color Attachment", testParams));
+                               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfColorImageFormatsToTest; ++imageFormatIndex)
+                               {
+                                       const VkFormat          format                  = colorImageFormatsToTest[imageFormatIndex];
+                                       const std::string       testCaseName    = getFormatCaseName(format);
+                                       const TestParams        testParams              =
+                                       {
+                                               true,                                                                                                                   // bool                         useSingleMipLevel;
+                                               VK_IMAGE_TYPE_2D,                                                                                               // VkImageType          imageType;
+                                               format,                                                                                                                 // VkFormat                     format;
+                                               { 256, 256, 1 },                                                                                                // VkExtent3D           extent;
+                                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,  // deUint32         imageLayerCount;
+                                               imageLayerParamsToTest[imageLayerParamsIndex].imageViewRange,   // LayerRange           imageViewLayerRange;
+                                               makeClearColorValue(format, 0.2f, 0.1f, 0.7f, 0.8f),                    // VkClearValue         initValue
+                                               {
+                                                       makeClearColorValue(format, 0.1f, 0.5f, 0.3f, 0.9f),                    // VkClearValue         clearValue[0];
+                                                       makeClearColorValue(format, 0.3f, 0.6f, 0.2f, 0.7f),                    // VkClearValue         clearValue[1];
+                                               },
+                                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,  // LayerRange       clearLayerRange;
+                                               allocationKind                                                                                                  // AllocationKind       allocationKind;
+                                       };
+                                       colorAttachmentClearLayersGroup->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Clear Color Attachment", testParams));
+                                       partialColorAttachmentClearLayersGroup->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Partial Clear Color Attachment", testParams));
+                               }
+                               colorAttachmentClearTests->addChild(colorAttachmentClearLayersGroup.release());
+                               partialColorAttachmentClearTests->addChild(partialColorAttachmentClearLayersGroup.release());
+                       }
                }
-
                imageClearingTests->addChild(colorAttachmentClearTests.release());
                imageClearingTests->addChild(partialColorAttachmentClearTests.release());
        }
 
        // Clear depth/stencil attachment
        {
-               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
-               for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfImageLayerParamsToTest; ++imageLayerParamsIndex)
+               for (size_t imageLayerParamsIndex = 0; imageLayerParamsIndex < numOfAttachmentLayerParamsToTest; ++imageLayerParamsIndex)
                {
-                       const TestParams testParams =
+                       if (!imageLayerParamsToTest[imageLayerParamsIndex].twoStep)
                        {
-                               true,                                                                                                                   // bool                         useSingleMipLevel;
-                               VK_IMAGE_TYPE_2D,                                                                                               // VkImageType          imageType;
-                               depthStencilImageFormatsToTest[imageFormatIndex],                               // VkFormat                     format;
-                               { 256, 256, 1 },                                                                                                // VkExtent3D           extent;
-                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,  // deUint32         imageLayerCount;
-                               imageLayerParamsToTest[imageLayerParamsIndex].imageViewRange,   // LayerRange           imageViewLayerRange;
-                               makeClearValueDepthStencil(0.5f, 0x03),                                                 // VkClearValue         initValue
-                               {
-                                       makeClearValueDepthStencil(0.1f, 0x06),                                                 // VkClearValue         clearValue[0];
-                                       makeClearValueDepthStencil(0.3f, 0x04),                                                 // VkClearValue         clearValue[1];
-                               },
-                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,  // LayerRange       clearLayerRange;
-                               allocationKind                                                                                                  // AllocationKind       allocationKind;
-                       };
-
-                       std::ostringstream      testCaseName;
-                       testCaseName << getImageTypeCaseName(testParams.imageType) << "_" << getFormatCaseName(testParams.imageFormat);
-                       if (imageLayerParamsToTest[imageLayerParamsIndex].testName != DE_NULL)
-                               testCaseName << "_" << imageLayerParamsToTest[imageLayerParamsIndex].testName;
+                               de::MovePtr<TestCaseGroup> depthStencilLayersGroup(new TestCaseGroup(testCtx, imageLayerParamsToTest[imageLayerParamsIndex].testName, ""));
+                               de::MovePtr<TestCaseGroup> partialDepthStencilLayersGroup(new TestCaseGroup(testCtx, imageLayerParamsToTest[imageLayerParamsIndex].testName, ""));
 
-                       depthStencilAttachmentClearTests->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Clear Depth/Stencil Attachment", testParams));
-                       partialDepthStencilAttachmentClearTests->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName.str(), "Parital Clear Depth/Stencil Attachment", testParams));
+                               for (size_t imageFormatIndex = 0; imageFormatIndex < numOfDepthStencilImageFormatsToTest; ++imageFormatIndex)
+                               {
+                                       const VkFormat          format                  = depthStencilImageFormatsToTest[imageFormatIndex];
+                                       const std::string       testCaseName    = getFormatCaseName(format);
+                                       const TestParams        testParams              =
+                                       {
+                                               true,                                                                                                                   // bool                         useSingleMipLevel;
+                                               VK_IMAGE_TYPE_2D,                                                                                               // VkImageType          imageType;
+                                               format,                                                                                                                 // VkFormat                     format;
+                                               { 256, 256, 1 },                                                                                                // VkExtent3D           extent;
+                                               imageLayerParamsToTest[imageLayerParamsIndex].imageLayerCount,  // deUint32         imageLayerCount;
+                                               imageLayerParamsToTest[imageLayerParamsIndex].imageViewRange,   // LayerRange           imageViewLayerRange;
+                                               makeClearValueDepthStencil(0.5f, 0x03),                                                 // VkClearValue         initValue
+                                               {
+                                                       makeClearValueDepthStencil(0.1f, 0x06),                                                 // VkClearValue         clearValue[0];
+                                                       makeClearValueDepthStencil(0.3f, 0x04),                                                 // VkClearValue         clearValue[1];
+                                               },
+                                               imageLayerParamsToTest[imageLayerParamsIndex].clearLayerRange,  // LayerRange       clearLayerRange;
+                                               allocationKind                                                                                                  // AllocationKind       allocationKind;
+                                       };
+                                       depthStencilLayersGroup->addChild(new InstanceFactory1<ClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Clear Depth/Stencil Attachment", testParams));
+                                       partialDepthStencilLayersGroup->addChild(new InstanceFactory1<PartialClearAttachmentTestInstance, TestParams>(testCtx, NODETYPE_SELF_VALIDATE, testCaseName, "Parital Clear Depth/Stencil Attachment", testParams));
+                               }
+                               depthStencilAttachmentClearTests->addChild(depthStencilLayersGroup.release());
+                               partialDepthStencilAttachmentClearTests->addChild(partialDepthStencilLayersGroup.release());
+                       }
                }
-
                imageClearingTests->addChild(depthStencilAttachmentClearTests.release());
                imageClearingTests->addChild(partialDepthStencilAttachmentClearTests.release());
        }