Fix post-copy barrier in readImageAspect()
authorPyry Haulos <phaulos@google.com>
Fri, 2 Dec 2016 16:34:43 +0000 (08:34 -0800)
committerPyry Haulos <phaulos@google.com>
Fri, 2 Dec 2016 16:34:43 +0000 (08:34 -0800)
 * Barrier was using TOP_OF_PIPE_BIT for flushing buffer contents for
host access. HOST_BIT must be used instead.

 * For combined depth stencil formats image was left in wrong image layout
for later stencil aspect copy.

Affects combined DS format cases in:

dEQP-VK.api.copy_and_blit.blit_image.all_formats.*

Change-Id: I80263efbc12da21c8205768687725416419e923e

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

index ed125dc..5fd91a8 100644 (file)
@@ -585,6 +585,26 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage                                   image,
                pixelDataSize                                                           // VkDeviceSize         size;
        };
 
+       const VkImageMemoryBarrier                              postImageBarrier                =
+       {
+               VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,         // VkStructureType                      sType;
+               DE_NULL,                                                                        // const void*                          pNext;
+               VK_ACCESS_TRANSFER_READ_BIT,                            // VkAccessFlags                        srcAccessMask;
+               VK_ACCESS_TRANSFER_WRITE_BIT,                           // VkAccessFlags                        dstAccessMask;
+               VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,           // VkImageLayout                        oldLayout;
+               VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,           // VkImageLayout                        newLayout;
+               VK_QUEUE_FAMILY_IGNORED,                                        // deUint32                                     srcQueueFamilyIndex;
+               VK_QUEUE_FAMILY_IGNORED,                                        // deUint32                                     dstQueueFamilyIndex;
+               image,                                                                          // VkImage                                      image;
+               {
+                       aspect,                                                                 // VkImageAspectFlags   aspectMask;
+                       0u,                                                                                     // deUint32                             baseMipLevel;
+                       1u,                                                                                     // deUint32                             mipLevels;
+                       0u,                                                                                     // deUint32                             baseArraySlice;
+                       1u,                                                                                     // deUint32                             arraySize;
+               }                                                                                       // VkImageSubresourceRange      subresourceRange;
+       };
+
        // Copy image to buffer
        const VkExtent3D                        imageExtent             = { (deUint32)dst.getWidth(), (deUint32)dst.getHeight(), 1u };
        const VkBufferImageCopy         copyRegion              =
@@ -613,7 +633,7 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage                                    image,
        VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
        vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &imageBarrier);
        vk.cmdCopyImageToBuffer(*cmdBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, *buffer, 1u, &copyRegion);
-       vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 0, (const VkImageMemoryBarrier*)DE_NULL);
+       vk.cmdPipelineBarrier(*cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT|VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 1, &bufferBarrier, 1, &postImageBarrier);
        VK_CHECK(vk.endCommandBuffer(*cmdBuffer));
 
        const VkSubmitInfo                                              submitInfo                              =