Synchronize clears and reads in transient attachment tests
authorRicardo Garcia <rgarcia@igalia.com>
Thu, 9 Jun 2022 08:55:46 +0000 (10:55 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 16 Jun 2022 18:07:24 +0000 (18:07 +0000)
These tests use a render pass with no draw operations to clear a color
or depth/stencil attachment and use it as an input attachment in a
second render pass, but they were missing a barrier to synchronize both
operations.

Affected tests:
dEQP-VK.fragment_operations.transient_attachment_bit*

Components: Vulkan
VK-GL-CTS issue: 3717

Change-Id: Ifcd1817fa631973e4f74866546dfad4e021a16bc

external/vulkancts/modules/vulkan/fragment_ops/vktFragmentOperationsTransientAttachmentTests.cpp

index cb65549..1262201 100644 (file)
@@ -35,6 +35,7 @@
 #include "vkObjUtil.hpp"
 #include "vkQueryUtil.hpp"
 #include "vkTypeUtil.hpp"
+#include "vkBarrierUtil.hpp"
 
 #include "tcuImageCompare.hpp"
 #include "tcuTestLog.hpp"
@@ -451,12 +452,8 @@ tcu::TestStatus    TransientAttachmentTestInstance::iterate (void)
                updater.update(vk, device);
        }
 
-       const tcu::TextureFormat                        tcuFormat                                       = mapVkFormat(m_testFormat);
-       VkImageLayout                                           inputLayout                                     = tcuFormat.order == tcu::TextureFormat::DS
-                                                                                                                                       ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
-                                                                                                                                       : tcuFormat.order == tcu::TextureFormat::D
-                                                                                                                                       ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
-                                                                                                                                       : tcuFormat.order == tcu::TextureFormat::S
+       const bool                                                      isDepthStencil                          = isDepthStencilFormat(m_testFormat);
+       VkImageLayout                                           inputLayout                                     = isDepthStencil
                                                                                                                                        ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
                                                                                                                                        : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
 
@@ -514,6 +511,16 @@ tcu::TestStatus    TransientAttachmentTestInstance::iterate (void)
                beginRenderPass(vk, *cmdBuffer, *renderPassOne, *framebufferOne, renderArea, clearValue);
                endRenderPass(vk, *cmdBuffer);
 
+               // Synchronize clear and read operations.
+               {
+                       const auto srcAccess    = isDepthStencil ? VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT : VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+                       const auto dstAccess    = VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
+                       const auto srcStage             = isDepthStencil ? (VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT) : VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+                       const auto dstStage             = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
+                       const auto clearToLoad  = makeMemoryBarrier(srcAccess, dstAccess);
+                       cmdPipelineMemoryBarrier(vk, *cmdBuffer, srcStage, dstStage, &clearToLoad);
+               }
+
                // Draw with input attachment
                beginRenderPass(vk, *cmdBuffer, *renderPassTwo, *framebufferTwo, renderArea);
                vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);