Fix errors in dynamic rendering suballocation tests
authorziga-lunarg <ziga@lunarg.com>
Sun, 13 Nov 2022 15:41:10 +0000 (16:41 +0100)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 1 Dec 2022 22:48:25 +0000 (22:48 +0000)
attachmentCount in vkCmdClearAttachments must be greater than 0
depth aspect must only be cleared if depth attachment is set
stencil aspect must only be clear if stencil attachment is set

Components: Vulkan

VK-GL-CTS issue: 4102

Affected tests:
dEQP-VK.dynamic_rendering.*.suballocation.*

Change-Id: Id7cc51794883863aa9add62adee55ef30c0f6a28

external/vulkancts/modules/vulkan/renderpass/vktRenderPassLoadStoreOpNoneTests.cpp
external/vulkancts/modules/vulkan/renderpass/vktRenderPassUnusedClearAttachmentTests.cpp

index 6f452a8..596bab6 100644 (file)
@@ -779,8 +779,10 @@ void LoadStoreOpNoneTestInstance::drawCommands(VkCommandBuffer                                             cmdBuffer,
                {
                        if (att.usage & ATTACHMENT_USAGE_DEPTH_STENCIL)
                        {
-                               clearAttachments.push_back({ getImageAspectFlags(mapVkFormat(m_testParams.depthStencilFormat)), 0u,
-                                                                                       makeClearValueDepthStencil(0.25, 64) });
+                               VkImageAspectFlags      aspectMask = 0;
+                               if (att.usage & ATTACHMENT_USAGE_DEPTH) aspectMask |= VK_IMAGE_ASPECT_DEPTH_BIT;
+                               if (att.usage & ATTACHMENT_USAGE_STENCIL) aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
+                               clearAttachments.push_back({ aspectMask, 0u, makeClearValueDepthStencil(0.25, 64) });
                        }
                        else
                        {
index 760d348..d2480c2 100644 (file)
@@ -906,7 +906,10 @@ void UnusedClearAttachmentTestInstance::createCommandBuffer (const DeviceInterfa
        RenderpassSubpass::cmdBeginRenderPass(vk, *m_cmdBuffer, &renderPassBeginInfo, &subpassBeginInfo);
 
        vk.cmdBindPipeline(*m_cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipeline);
-       vk.cmdClearAttachments(*m_cmdBuffer, static_cast<deUint32>(clearAttachments.size()), (clearAttachments.empty() ? DE_NULL : clearAttachments.data()), 1u, &clearRect);
+       if (!clearAttachments.empty())
+       {
+               vk.cmdClearAttachments(*m_cmdBuffer, static_cast<deUint32>(clearAttachments.size()), clearAttachments.data(), 1u, &clearRect);
+       }
 
        const typename RenderpassSubpass::SubpassEndInfo subpassEndInfo(DE_NULL);
        RenderpassSubpass::cmdEndRenderPass(vk, *m_cmdBuffer, &subpassEndInfo);
@@ -980,10 +983,10 @@ void UnusedClearAttachmentTestInstance::createCommandBufferDynamicRendering(cons
                m_clearColorDepth                                                                                                               // VkClearValue                                                 clearValue;
        };
 
-       const bool hasDepth             = m_testParams.depthStencilType == DEPTH_STENCIL_BOTH ||
-                                                         m_testParams.depthStencilType == DEPTH_STENCIL_DEPTH_ONLY;
-       const bool hasStencil   = m_testParams.depthStencilType == DEPTH_STENCIL_BOTH ||
-                                                         m_testParams.depthStencilType == DEPTH_STENCIL_STENCIL_ONLY;
+       const bool hasDepth             = (m_testParams.depthStencilType == DEPTH_STENCIL_BOTH ||
+                                                         m_testParams.depthStencilType == DEPTH_STENCIL_DEPTH_ONLY) && m_testParams.depthStencilUsed;
+       const bool hasStencil   = (m_testParams.depthStencilType == DEPTH_STENCIL_BOTH ||
+                                                         m_testParams.depthStencilType == DEPTH_STENCIL_STENCIL_ONLY) && m_testParams.depthStencilUsed;
 
        std::vector<VkFormat> colorAttachmentFormats(m_testParams.colorUsed.size(), VK_FORMAT_UNDEFINED);
        for (size_t i = 0; i < m_testParams.colorUsed.size(); ++i)
@@ -1046,7 +1049,10 @@ void UnusedClearAttachmentTestInstance::createCommandBufferDynamicRendering(cons
                }
 
                vk.cmdBindPipeline(*m_secCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, *m_graphicsPipeline);
-               vk.cmdClearAttachments(*m_secCmdBuffer, static_cast<deUint32>(clearAttachments.size()), (clearAttachments.empty() ? DE_NULL : clearAttachments.data()), 1u, &clearRect);
+               if (!clearAttachments.empty())
+               {
+                       vk.cmdClearAttachments(*m_secCmdBuffer, static_cast<deUint32>(clearAttachments.size()), clearAttachments.data(), 1u, &clearRect);
+               }
 
                if (m_testParams.groupParams->secondaryCmdBufferCompletelyContainsDynamicRenderpass)
                        vk.cmdEndRendering(*m_secCmdBuffer);