Fix stencil rendering in draw_with_dynamic_rendering.multi_draw tests
authorSÅ‚awomir Cygan <slawomir.cygan@intel.com>
Thu, 21 Oct 2021 13:18:19 +0000 (15:18 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 22 Oct 2021 22:00:33 +0000 (22:00 +0000)
This fixes few issues with handling depth/stencil attachment in this test:

Stencil attachment is now passed to rendering info, alongside depth attachment.

A barrier transitioning depth stencil subresource from UNFEFINED layout is added.

A barrier initializing color subresource is fixed to be executed with desition stage
that involves color.

Components: Vulkan

VK-GL-CTS Issue: 3235

Affects: dEQP-VK.draw_with_dynamic_rendering.multi_draw.*

Change-Id: I2b1a0bb04dae24328ab798a9e436e1000db901de
(cherry picked from commit 9f2876528c93cd47a59604ce4f30e8525560f280)

external/vulkancts/framework/vulkan/vkCmdUtil.cpp
external/vulkancts/framework/vulkan/vkCmdUtil.hpp
external/vulkancts/modules/vulkan/draw/vktDrawInvertedDepthRangesTests.cpp
external/vulkancts/modules/vulkan/draw/vktDrawMultiExtTests.cpp

index 6b68820..67ec659 100644 (file)
@@ -243,7 +243,8 @@ void beginRendering(const DeviceInterface&          vk,
 void beginRendering(const DeviceInterface&             vk,
                                        const VkCommandBuffer           commandBuffer,
                                        const VkImageView                       colorImageView,
-                                       const VkImageView                       depthImageView,
+                                       const VkImageView                       depthStencilImageView,
+                                       const bool                                      useStencilAttachment,
                                        const VkRect2D&                         renderArea,
                                        const VkClearValue&                     clearColorValue,
                                        const VkClearValue&                     clearDepthValue,
@@ -268,11 +269,11 @@ void beginRendering(const DeviceInterface&                vk,
                clearColorValue                                                                                 // VkClearValue                                                 clearValue;
        };
 
-       VkRenderingAttachmentInfoKHR depthAttachment
+       VkRenderingAttachmentInfoKHR depthStencilAttachment
        {
                VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,                // VkStructureType                                              sType;
                DE_NULL,                                                                                                // const void*                                                  pNext;
-               depthImageView,                                                                                 // VkImageView                                                  imageView;
+               depthStencilImageView,                                                                  // VkImageView                                                  imageView;
                depthImageLayout,                                                                               // VkImageLayout                                                imageLayout;
                VK_RESOLVE_MODE_NONE,                                                                   // VkResolveModeFlagBits                                resolveMode;
                DE_NULL,                                                                                                // VkImageView                                                  resolveImageView;
@@ -286,14 +287,14 @@ void beginRendering(const DeviceInterface&                vk,
        {
                VK_STRUCTURE_TYPE_RENDERING_INFO_KHR,
                DE_NULL,
-               renderingFlags,                                                                                 // VkRenderingFlagsKHR                                  flags;
-               renderArea,                                                                                             // VkRect2D                                                             renderArea;
-               layerCount,                                                                                             // deUint32                                                             layerCount;
-               viewMask,                                                                                               // deUint32                                                             viewMask;
-               1u,                                                                                                             // deUint32                                                             colorAttachmentCount;
-               &colorAttachment,                                                                               // const VkRenderingAttachmentInfoKHR*  pColorAttachments;
-               &depthAttachment,                                                                               // const VkRenderingAttachmentInfoKHR*  pDepthAttachment;
-               DE_NULL,                                                                                                // const VkRenderingAttachmentInfoKHR*  pStencilAttachment;
+               renderingFlags,                                                                                         // VkRenderingFlagsKHR                                  flags;
+               renderArea,                                                                                                     // VkRect2D                                                             renderArea;
+               layerCount,                                                                                                     // deUint32                                                             layerCount;
+               viewMask,                                                                                                       // deUint32                                                             viewMask;
+               1u,                                                                                                                     // deUint32                                                             colorAttachmentCount;
+               &colorAttachment,                                                                                       // const VkRenderingAttachmentInfoKHR*  pColorAttachments;
+               &depthStencilAttachment,                                                                        // const VkRenderingAttachmentInfoKHR*  pDepthAttachment;
+               useStencilAttachment ? &depthStencilAttachment : DE_NULL,       // const VkRenderingAttachmentInfoKHR*  pStencilAttachment;
        };
 
        vk.cmdBeginRenderingKHR(commandBuffer, &renderingInfo);
index 1a28b28..e74dda7 100644 (file)
@@ -124,7 +124,8 @@ void beginRendering (const DeviceInterface&         vk,
 void beginRendering (const DeviceInterface&            vk,
                                         const VkCommandBuffer          commandBuffer,
                                         const VkImageView                      colorImageView,
-                                        const VkImageView                      depthImageView,
+                                        const VkImageView                      depthStencilImageView,
+                                        const bool                                     useStencilAttachment,
                                         const VkRect2D&                        renderArea,
                                         const VkClearValue&            clearColorValue,
                                         const VkClearValue&            clearDepthValue,
index fb40ac3..8063226 100644 (file)
@@ -362,7 +362,7 @@ InvertedDepthRangesTestInstance::ColorAndDepth InvertedDepthRangesTestInstance::
        }
 
        if (m_params.useDynamicRendering)
-               beginRendering(vk, *cmdBuffer, *m_colorTargetView, *m_depthTargetView, makeRect2D(kImageExtent), clearColor, clearDepth);
+               beginRendering(vk, *cmdBuffer, *m_colorTargetView, *m_depthTargetView, false, makeRect2D(kImageExtent), clearColor, clearDepth);
        else
                beginRenderPass(vk, *cmdBuffer, *m_renderPass, *m_framebuffer, makeRect2D(kImageExtent));
 
index bd145de..b93abdb 100644 (file)
@@ -1007,7 +1007,7 @@ tcu::TestStatus MultiDrawInstance::iterate (void)
 
        if (m_params.useDynamicRendering)
        {
-               // Transition color attachment to the proper initial layout for dynamic rendering
+               // Transition color and depth stencil attachment to the proper initial layout for dynamic rendering
                const auto colorPreBarrier = makeImageMemoryBarrier(
                        0u,
                        VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
@@ -1018,10 +1018,23 @@ tcu::TestStatus MultiDrawInstance::iterate (void)
                vkd.cmdPipelineBarrier(
                        cmdBuffer,
                        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
-                       (VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT),
+                       VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
                        0u, 0u, nullptr, 0u, nullptr, 1u, &colorPreBarrier);
 
-               beginRendering(vkd, cmdBuffer, *colorBufferView, *dsBufferView, scissor, clearValues[0], clearValues[1],
+               const auto dsPreBarrier = makeImageMemoryBarrier(
+                       0u,
+                       VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
+                       VK_IMAGE_LAYOUT_UNDEFINED,
+                       VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+                       dsBuffer.get(), dsSubresourceRange);
+
+               vkd.cmdPipelineBarrier(
+                       cmdBuffer,
+                       VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+                       (VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT),
+                       0u, 0u, nullptr, 0u, nullptr, 1u, &dsPreBarrier);
+
+               beginRendering(vkd, cmdBuffer, *colorBufferView, *dsBufferView, true, scissor, clearValues[0], clearValues[1],
                                           vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, vk::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
                                           VK_ATTACHMENT_LOAD_OP_CLEAR);
        }