Fix image blit mirrored comparisons
authorDzmitry Malyshau <dmalyshau@mozilla.com>
Wed, 9 May 2018 17:14:21 +0000 (13:14 -0400)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 22 May 2018 09:34:23 +0000 (05:34 -0400)
The old looping would not go through any iterations for mirrored offsets.
The looping has to be mirrored when the destination is mirrored, and the
source texture coordinate computation adjusted accordingly.

Affects:
dEQP-VK.api.copy_and_blit.core.blit_image.*.mirror*.*

Change-Id: I8feb1d8b90c8013b292865b0e3b20ef414b05920
Components: Vulkan

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

index 04205b4..03729ee 100644 (file)
@@ -2029,16 +2029,18 @@ struct CompareEachPixelInEachRegion
                {
                        const VkImageBlit& blit = regionIter->imageBlit;
 
-                       const int       dx              = deSign32(blit.dstOffsets[1].x - blit.dstOffsets[0].x);
-                       const int       dy              = deSign32(blit.dstOffsets[1].y - blit.dstOffsets[0].y);
+                       const int       xStart  = deMin32(blit.dstOffsets[0].x, blit.dstOffsets[1].x);
+                       const int       yStart  = deMin32(blit.dstOffsets[0].y, blit.dstOffsets[1].y);
+                       const int       xEnd    = deMax32(blit.dstOffsets[0].x, blit.dstOffsets[1].x);
+                       const int       yEnd    = deMax32(blit.dstOffsets[0].y, blit.dstOffsets[1].y);
                        const float     xScale  = static_cast<float>(blit.srcOffsets[1].x - blit.srcOffsets[0].x) / static_cast<float>(blit.dstOffsets[1].x - blit.dstOffsets[0].x);
                        const float     yScale  = static_cast<float>(blit.srcOffsets[1].y - blit.srcOffsets[0].y) / static_cast<float>(blit.dstOffsets[1].y - blit.dstOffsets[0].y);
                        const float srcInvW     = 1.0f / static_cast<float>(sourceWidth);
                        const float srcInvH     = 1.0f / static_cast<float>(sourceHeight);
 
                        for (int z = 0; z < sourceDepth; z++)
-                       for (int y = blit.dstOffsets[0].y; y < blit.dstOffsets[1].y; y += dy)
-                       for (int x = blit.dstOffsets[0].x; x < blit.dstOffsets[1].x; x += dx)
+                       for (int y = yStart; y < yEnd; y++)
+                       for (int x = xStart; x < xEnd; x++)
                        {
                                const tcu::Vec2 srcNormCoord
                                (