Fix incomplete VkImageSubresourceRange
authorNoah Fredriks <Noah.Fredriks@amd.com>
Wed, 11 Jul 2018 21:56:05 +0000 (17:56 -0400)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 25 Oct 2018 13:50:56 +0000 (09:50 -0400)
Pipeline image barrier arraySize doesn't include the entire image.

Affects: dEQP-VK.api.copy_and_blit.core.resolve_image.whole_array*

Components: Vulkan

VK-GL-CTS Issue: 910

Change-Id: I9974c9390478cf70f2238e03a7180fc81166f84e

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

index b85af3662dfee411115714e0fb81b1220208dc8d..123b5a5cca15b09f38219178e74c8793c335fe85 100644 (file)
@@ -2616,7 +2616,7 @@ public:
        virtual tcu::TestStatus                                         iterate                                         (void);
 protected:
        virtual tcu::TestStatus                                         checkTestResult                         (tcu::ConstPixelBufferAccess result);
-       void                                                                            copyMSImageToMSImage            (void);
+       void                                                                            copyMSImageToMSImage            (deUint32 copyArraySize);
 private:
        Move<VkImage>                                                           m_multisampledImage;
        de::MovePtr<Allocation>                                         m_multisampledImageAlloc;
@@ -3173,11 +3173,17 @@ tcu::TestStatus ResolveImageToImage::iterate (void)
        generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.dst.image.extent.depth, FILL_MODE_MULTISAMPLE);
        generateExpectedResult();
 
+       VkImage         sourceImage             = m_multisampledImage.get();
+       deUint32        sourceArraySize = getArraySize(m_params.src.image);
+
        switch (m_options)
        {
-               case COPY_MS_IMAGE_TO_MS_IMAGE:
                case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
-                       copyMSImageToMSImage();
+                       // Duplicate the multisampled image to a multisampled image array
+                       sourceArraySize = getArraySize(m_params.dst.image);
+               case COPY_MS_IMAGE_TO_MS_IMAGE:
+                       copyMSImageToMSImage(sourceArraySize);
+                       sourceImage     = m_multisampledCopyImage.get();
                        break;
                default:
                        break;
@@ -3203,13 +3209,13 @@ tcu::TestStatus ResolveImageToImage::iterate (void)
                        VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,           // VkImageLayout                        newLayout;
                        VK_QUEUE_FAMILY_IGNORED,                                        // deUint32                                     srcQueueFamilyIndex;
                        VK_QUEUE_FAMILY_IGNORED,                                        // deUint32                                     dstQueueFamilyIndex;
-                       m_multisampledImage.get(),                                      // VkImage                                      image;
+                       sourceImage,                                                            // VkImage                                      image;
                        {                                                                                       // VkImageSubresourceRange      subresourceRange;
                                getAspectFlags(srcTcuFormat),           // VkImageAspectFlags   aspectMask;
                                0u,                                                                     // deUint32                             baseMipLevel;
                                1u,                                                                     // deUint32                             mipLevels;
                                0u,                                                                     // deUint32                             baseArraySlice;
-                               getArraySize(m_params.src.image)        // deUint32                             arraySize;
+                               sourceArraySize                                         // deUint32                             arraySize;
                        }
                },
                // destination image
@@ -3263,7 +3269,7 @@ tcu::TestStatus ResolveImageToImage::iterate (void)
 
        VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
        vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, DE_LENGTH_OF_ARRAY(imageBarriers), imageBarriers);
-       vk.cmdResolveImage(*m_cmdBuffer, m_multisampledImage.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageResolves.data());
+       vk.cmdResolveImage(*m_cmdBuffer, sourceImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageResolves.data());
        vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &postImageBarrier);
        VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
        submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer);
@@ -3305,7 +3311,7 @@ void ResolveImageToImage::copyRegionToTextureLevel(tcu::ConstPixelBufferAccess s
        tcu::copy(dstSubRegion, srcSubRegion);
 }
 
-void ResolveImageToImage::copyMSImageToMSImage (void)
+void ResolveImageToImage::copyMSImageToMSImage (deUint32 copyArraySize)
 {
        const DeviceInterface&                  vk                                      = m_context.getDeviceInterface();
        const VkDevice                                  vkDevice                        = m_context.getDevice();
@@ -3313,7 +3319,7 @@ void ResolveImageToImage::copyMSImageToMSImage (void)
        const tcu::TextureFormat                srcTcuFormat            = mapVkFormat(m_params.src.image.format);
        std::vector<VkImageCopy>                imageCopies;
 
-       for (deUint32 layerNdx = 0; layerNdx < getArraySize(m_params.dst.image); ++layerNdx)
+       for (deUint32 layerNdx = 0; layerNdx < copyArraySize; ++layerNdx)
        {
                const VkImageSubresourceLayers  sourceSubresourceLayers =
                {
@@ -3379,13 +3385,13 @@ void ResolveImageToImage::copyMSImageToMSImage (void)
                                0u,                                                                     // deUint32                             baseMipLevel;
                                1u,                                                                     // deUint32                             mipLevels;
                                0u,                                                                     // deUint32                             baseArraySlice;
-                               getArraySize(m_params.dst.image)        // deUint32                             arraySize;
+                               copyArraySize                                           // deUint32                             arraySize;
                        }
                },
        };
 
        const VkImageMemoryBarrier      postImageBarriers               =
-       // source image
+       // destination image
        {
                VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,         // VkStructureType                      sType;
                DE_NULL,                                                                        // const void*                          pNext;
@@ -3401,7 +3407,7 @@ void ResolveImageToImage::copyMSImageToMSImage (void)
                        0u,                                                                     // deUint32                             baseMipLevel;
                        1u,                                                                     // deUint32                             mipLevels;
                        0u,                                                                     // deUint32                             baseArraySlice;
-                       getArraySize(m_params.dst.image)        // deUint32                             arraySize;
+                       copyArraySize                                           // deUint32                             arraySize;
                }
        };
 
@@ -3420,8 +3426,6 @@ void ResolveImageToImage::copyMSImageToMSImage (void)
        VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
 
        submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
-
-       m_multisampledImage = m_multisampledCopyImage;
 }
 
 class ResolveImageToImageTestCase : public vkt::TestCase