Improve buffer to buffer copy tests
authorRicardo Garcia <rgarcia@igalia.com>
Wed, 21 Jul 2021 10:33:51 +0000 (12:33 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 6 Aug 2021 07:28:05 +0000 (07:28 +0000)
Buffer to buffer copy tests were filling the source and destination
buffers with the same contents, using functions that were both used for
images and buffers.

When filling source buffers, a linear memory allocation of R32_UINT
elements was filled with color red, which resulted in all bytes
containing value 255.

When filling destination buffers, the same procedure was followed using
color white. However, due to R32_UINT only having one component, this
also resulted in every buffer byte containing value 255.

The copy operation that followed could fail (e.g. with the
implementation not doing anything) and the test could still pass. This
commit makes the destination buffer be filled with zeros so as to verify
regions are being interpreted correctly.

Affected tests:
dEQP-VK.api.copy_and_blit.*buffer_to_buffer*

Components: Vulkan
VK-GL-CTS issue: 3008

Change-Id: I49e5ea5a4843540e57be22c67107db82b7903da2

external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp

index d7b235d..6c3da53 100644 (file)
@@ -73,6 +73,7 @@ enum FillMode
 {
        FILL_MODE_GRADIENT = 0,
        FILL_MODE_WHITE,
+       FILL_MODE_BLACK,
        FILL_MODE_RED,
        FILL_MODE_MULTISAMPLE,
        FILL_MODE_BLUE_RED_X,
@@ -534,6 +535,7 @@ void CopiesAndBlittingTestInstance::generateBuffer (tcu::PixelBufferAccess buffe
        const tcu::Vec4         greenColor      (0.0,                   maxValue.y(),   0.0,                    maxValue.w());
        const tcu::Vec4         blueColor       (0.0,                   0.0,                    maxValue.z(),   maxValue.w());
        const tcu::Vec4         whiteColor      (maxValue.x(),  maxValue.y(),   maxValue.z(),   maxValue.w());
+       const tcu::Vec4         blackColor      (0.0f,                  0.0f,                   0.0f,                   0.0f);
 
        for (int z = 0; z < depth;  ++z)
        for (int y = 0; y < height; ++y)
@@ -552,6 +554,17 @@ void CopiesAndBlittingTestInstance::generateBuffer (tcu::PixelBufferAccess buffe
                                        buffer.setPixel(whiteColor, x, y, z);
                                break;
 
+                       case FILL_MODE_BLACK:
+                               if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
+                               {
+                                       buffer.setPixDepth(0.0f, x, y, z);
+                                       if (tcu::hasStencilComponent(buffer.getFormat().order))
+                                               buffer.setPixStencil(0, x, y, z);
+                               }
+                               else
+                                       buffer.setPixel(blackColor, x, y, z);
+                               break;
+
                        case FILL_MODE_RED:
                                if (tcu::isCombinedDepthStencilType(buffer.getFormat().type))
                                {
@@ -1994,7 +2007,7 @@ tcu::TestStatus CopyBufferToBuffer::iterate (void)
 
        const int dstLevelWidth         = (int)(m_params.dst.buffer.size/4);
        m_destinationTextureLevel       = de::MovePtr<tcu::TextureLevel>(new tcu::TextureLevel(mapVkFormat(VK_FORMAT_R32_UINT), dstLevelWidth, 1));
-       generateBuffer(m_destinationTextureLevel->getAccess(), dstLevelWidth, 1, 1, FILL_MODE_WHITE);
+       generateBuffer(m_destinationTextureLevel->getAccess(), dstLevelWidth, 1, 1, FILL_MODE_BLACK);
 
        generateExpectedResult();