Add timestamp tests that use two command buffers
authorAri Suonpaa <ari.suonpaa@siru.fi>
Tue, 30 Jan 2018 13:28:53 +0000 (15:28 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 22 Feb 2018 11:03:53 +0000 (06:03 -0500)
Added tests similar to
VkPositiveLayerTest.QueryAndCopyMultipleCommandBuffers and
VkPositiveLayerTest.QueryAndCopySecondaryCommandBuffers. Some
shipping drivers were crashing these tests. Results are not
checked and the tests pass as long as no crash happens.

New tests:

dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_*

Components: Vulkan

VK-GL-CTS issue: 842, 843

Change-Id: I1e5c863c11d4b23a387267c5d9a83e4caf9b3849

android/cts/master/vk-master.txt
external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp
external/vulkancts/mustpass/1.1.2/vk-default-no-waivers.txt
external/vulkancts/mustpass/1.1.2/vk-default.txt

index b5ce2b461ab68a76886c3175b53de0d05f08ebff..a633b62c0fa8181934dae11d448381f456d20798 100755 (executable)
@@ -160188,6 +160188,8 @@ dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_clear_depth_stencil_im
 dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_resolve_image_method
 dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_copy_query_pool_results_method
 dEQP-VK.pipeline.timestamp.misc_tests.timestamp_only
+dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_primary
+dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_secondary
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_fragment_stage
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_geometry_stage_fragment_stage
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_tessellation_control_stage_tessellation_evaluation_stage_fragment_stage
index 205abc72c4194fdbb248c29c3aa2569eddf730e5..0c685d8b94d9c8bcdd948773910a37f2b6ea05cb 100644 (file)
@@ -273,7 +273,6 @@ const std::string TransferTimestampTestParam::generateTestName(void) const
        result += "with_" + getTransferMethodStr(m_method, false);
 
        return result;
-
 }
 
 const std::string TransferTimestampTestParam::generateTestDescription(void) const
@@ -291,7 +290,27 @@ const std::string TransferTimestampTestParam::generateTestDescription(void) cons
        result += "with " + getTransferMethodStr(m_method, true);
 
        return result;
+}
+
+class TwoCmdBuffersTestParam : public TimestampTestParam
+{
+public:
+                                                       TwoCmdBuffersTestParam  (const VkPipelineStageFlagBits* stages,
+                                                                                                        const deUint32                                 stageCount,
+                                                                                                        const bool                                             inRenderPass,
+                                                                                                        const VkCommandBufferLevel             cmdBufferLevel);
+                                                       ~TwoCmdBuffersTestParam (void) { }
+       VkCommandBufferLevel    getCmdBufferLevel               (void) const { return m_cmdBufferLevel; }
+protected:
+       VkCommandBufferLevel    m_cmdBufferLevel;
+};
 
+TwoCmdBuffersTestParam::TwoCmdBuffersTestParam (const VkPipelineStageFlagBits* stages,
+                                                                                                const deUint32                                 stageCount,
+                                                                                                const bool                                             inRenderPass,
+                                                                                                const VkCommandBufferLevel             cmdBufferLevel)
+: TimestampTestParam(stages, stageCount, inRenderPass), m_cmdBufferLevel(cmdBufferLevel)
+{
 }
 
 class SimpleGraphicsPipelineBuilder
@@ -2122,6 +2141,146 @@ void TransferTestInstance::initialImageTransition (VkCommandBuffer cmdBuffer, Vk
        vk.cmdPipelineBarrier(cmdBuffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, DE_NULL, 0, DE_NULL, 1, &imageMemBarrier);
 }
 
+class TwoCmdBuffersTest : public TimestampTest
+{
+public:
+                                                       TwoCmdBuffersTest       (tcu::TestContext&                              testContext,
+                                                                                                const std::string&                             name,
+                                                                                                const std::string&                             description,
+                                                                                                const TwoCmdBuffersTestParam*  param)
+: TimestampTest (testContext, name, description, param), m_cmdBufferLevel(param->getCmdBufferLevel()) { }
+       virtual                                 ~TwoCmdBuffersTest      (void) { }
+       virtual TestInstance*   createInstance          (Context&                                               context) const;
+
+protected:
+       VkCommandBufferLevel    m_cmdBufferLevel;
+};
+
+class TwoCmdBuffersTestInstance : public TimestampTestInstance
+{
+public:
+                                                       TwoCmdBuffersTestInstance       (Context&                               context,
+                                                                                                                const StageFlagVector  stages,
+                                                                                                                const bool                             inRenderPass,
+                                                                                                                VkCommandBufferLevel   cmdBufferLevel);
+       virtual                                 ~TwoCmdBuffersTestInstance      (void);
+       virtual tcu::TestStatus iterate                                         (void);
+protected:
+       virtual void                    configCommandBuffer                     (void);
+
+protected:
+       Move<VkCommandBuffer>   m_secondCmdBuffer;
+       Move<VkBuffer>                  m_dstBuffer;
+       de::MovePtr<Allocation> m_dstBufferAlloc;
+       VkCommandBufferLevel    m_cmdBufferLevel;
+};
+
+TestInstance* TwoCmdBuffersTest::createInstance (Context& context) const
+{
+       return new TwoCmdBuffersTestInstance(context, m_stages, m_inRenderPass, m_cmdBufferLevel);
+}
+
+TwoCmdBuffersTestInstance::TwoCmdBuffersTestInstance (Context&                                 context,
+                                                                                                         const StageFlagVector         stages,
+                                                                                                         const bool                            inRenderPass,
+                                                                                                         VkCommandBufferLevel          cmdBufferLevel)
+: TimestampTestInstance (context, stages, inRenderPass), m_cmdBufferLevel(cmdBufferLevel)
+{
+       const DeviceInterface&  vk                      = context.getDeviceInterface();
+       const VkDevice                  vkDevice        = context.getDevice();
+
+       m_secondCmdBuffer       = allocateCommandBuffer(vk, vkDevice, *m_cmdPool, cmdBufferLevel);
+       m_dstBuffer                     = createBufferAndBindMemory(1024, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, &m_dstBufferAlloc);
+}
+
+TwoCmdBuffersTestInstance::~TwoCmdBuffersTestInstance (void)
+{
+}
+
+void TwoCmdBuffersTestInstance::configCommandBuffer (void)
+{
+       const DeviceInterface&                  vk                                      = m_context.getDeviceInterface();
+
+       const VkCommandBufferBeginInfo  cmdBufferBeginInfo      =
+       {
+               VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,    // VkStructureType                          sType;
+               DE_NULL,                                                                                // const void*                              pNext;
+               0u,                                                                                             // VkCommandBufferUsageFlags                flags;
+               (const VkCommandBufferInheritanceInfo*)DE_NULL  // const VkCommandBufferInheritanceInfo*    pInheritanceInfo;
+       };
+
+       if (m_cmdBufferLevel == VK_COMMAND_BUFFER_LEVEL_PRIMARY)
+       {
+               VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
+               vk.cmdResetQueryPool(*m_cmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
+               vk.cmdWriteTimestamp(*m_cmdBuffer, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, *m_queryPool, 0);
+               VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
+               VK_CHECK(vk.beginCommandBuffer(*m_secondCmdBuffer, &cmdBufferBeginInfo));
+               vk.cmdCopyQueryPoolResults(*m_secondCmdBuffer, *m_queryPool, 0u, 1u, *m_dstBuffer, 0u, 0u, 0u);
+               VK_CHECK(vk.endCommandBuffer(*m_secondCmdBuffer));
+       }
+       else
+       {
+               const VkCommandBufferInheritanceInfo inheritanceInfo            =
+               {
+                       VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,      // VkStructureType                  sType;
+                       DE_NULL,                                                                                        // const void*                      pNext;
+                       DE_NULL,                                                                                        // VkRenderPass                     renderPass;
+                       0u,                                                                                                     // deUint32                         subpass;
+                       DE_NULL,                                                                                        // VkFramebuffer                    framebuffer;
+                       VK_FALSE,                                                                                       // VkBool32                         occlusionQueryEnable;
+                       0u,                                                                                                     // VkQueryControlFlags              queryFlags;
+                       0u                                                                                                      // VkQueryPipelineStatisticFlags    pipelineStatistics;
+               };
+
+               const VkCommandBufferBeginInfo cmdBufferBeginInfoSecondary      =
+               {
+                       VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,    // VkStructureType                          sType;
+                       DE_NULL,                                                                                // const void*                              pNext;
+                       0u,                                                                                             // VkCommandBufferUsageFlags                flags;
+                       &inheritanceInfo                                                                // const VkCommandBufferInheritanceInfo*    pInheritanceInfo;
+               };
+
+               VK_CHECK(vk.beginCommandBuffer(*m_secondCmdBuffer, &cmdBufferBeginInfoSecondary));
+               vk.cmdResetQueryPool(*m_secondCmdBuffer, *m_queryPool, 0u, TimestampTest::ENTRY_COUNT);
+               vk.cmdWriteTimestamp(*m_secondCmdBuffer, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, *m_queryPool, 0);
+               VK_CHECK(vk.endCommandBuffer(*m_secondCmdBuffer));
+               VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
+               vk.cmdExecuteCommands(m_cmdBuffer.get(), 1u, &m_secondCmdBuffer.get());
+               vk.cmdCopyQueryPoolResults(*m_cmdBuffer, *m_queryPool, 0u, 1u, *m_dstBuffer, 0u, 0u, 0u);
+               VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
+       }
+}
+
+tcu::TestStatus TwoCmdBuffersTestInstance::iterate (void)
+{
+       const DeviceInterface&          vk                              = m_context.getDeviceInterface();
+       const VkQueue                           queue                   = m_context.getUniversalQueue();
+
+       configCommandBuffer();
+
+       const VkCommandBuffer           cmdBuffers[]    = { m_cmdBuffer.get(), m_secondCmdBuffer.get() };
+
+       const VkSubmitInfo                      submitInfo              =
+       {
+               VK_STRUCTURE_TYPE_SUBMIT_INFO,                                                                  // VkStructureType                sType;
+               DE_NULL,                                                                                                                // const void*                    pNext;
+               0u,                                                                                                                             // deUint32                       waitSemaphoreCount;
+               DE_NULL,                                                                                                                // const VkSemaphore*             pWaitSemaphores;
+               (const VkPipelineStageFlags*)DE_NULL,                                                   // const VkPipelineStageFlags*    pWaitDstStageMask;
+               m_cmdBufferLevel == VK_COMMAND_BUFFER_LEVEL_PRIMARY ? 2u : 1u,  // deUint32                       commandBufferCount;
+               cmdBuffers,                                                                                                             // const VkCommandBuffer*         pCommandBuffers;
+               0u,                                                                                                                             // deUint32                       signalSemaphoreCount;
+               DE_NULL,                                                                                                                // const VkSemaphore*             pSignalSemaphores;
+       };
+
+       VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, DE_NULL));
+       VK_CHECK(vk.queueWaitIdle(queue));
+
+       // Always pass in case no crash occurred.
+       return tcu::TestStatus::pass("Pass");
+}
+
 } // anonymous
 
 tcu::TestCaseGroup* createTimestampTests (tcu::TestContext& testCtx)
@@ -2191,7 +2350,7 @@ tcu::TestCaseGroup* createTimestampTests (tcu::TestContext& testCtx)
 
        // Basic Compute Tests
        {
-               de::MovePtr<tcu::TestCaseGroup> basicComputeTests (new tcu::TestCaseGroup(testCtx, "basic_compute_tests", "Record timestamp for computer stages"));
+               de::MovePtr<tcu::TestCaseGroup> basicComputeTests (new tcu::TestCaseGroup(testCtx, "basic_compute_tests", "Record timestamp for compute stages"));
 
                const VkPipelineStageFlagBits basicComputeStages[][2] =
                {
@@ -2239,6 +2398,18 @@ tcu::TestCaseGroup* createTimestampTests (tcu::TestContext& testCtx)
                                                                                          "Only write timestamp command in the commmand buffer",
                                                                                          &param));
 
+               TwoCmdBuffersTestParam twoCmdBuffersParamPrimary(miscStages, 1u, false, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
+               miscTests->addChild(new TwoCmdBuffersTest(testCtx,
+                                                                                                 "two_cmd_buffers_primary",
+                                                                                                 "Issue query in a command buffer and copy it on another primary command buffer",
+                                                                                                 &twoCmdBuffersParamPrimary));
+
+               TwoCmdBuffersTestParam twoCmdBuffersParamSecondary(miscStages, 1u, false, VK_COMMAND_BUFFER_LEVEL_SECONDARY);
+               miscTests->addChild(new TwoCmdBuffersTest(testCtx,
+                                                                                                 "two_cmd_buffers_secondary",
+                                                                                                 "Issue query in a secondary command buffer and copy it on a primary command buffer",
+                                                                                                 &twoCmdBuffersParamSecondary));
+
                timestampTests->addChild(miscTests.release());
        }
 
index 6fc758f91866aacb4e78e5056c6d05351e696ee5..51310721b0b5dfc5c2e25e3f22871873be2398b1 100644 (file)
@@ -160193,6 +160193,8 @@ dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_clear_depth_stencil_im
 dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_resolve_image_method
 dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_copy_query_pool_results_method
 dEQP-VK.pipeline.timestamp.misc_tests.timestamp_only
+dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_primary
+dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_secondary
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_fragment_stage
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_geometry_stage_fragment_stage
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_tessellation_control_stage_tessellation_evaluation_stage_fragment_stage
index dd6eef5ca28cc885f5e5e98e27248e0e92c63162..dcb6081053431aaec90fea1b135b8b44ce7fec3d 100644 (file)
@@ -160193,6 +160193,8 @@ dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_clear_depth_stencil_im
 dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_resolve_image_method
 dEQP-VK.pipeline.timestamp.transfer_tests.host_stage_with_copy_query_pool_results_method
 dEQP-VK.pipeline.timestamp.misc_tests.timestamp_only
+dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_primary
+dEQP-VK.pipeline.timestamp.misc_tests.two_cmd_buffers_secondary
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_fragment_stage
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_geometry_stage_fragment_stage
 dEQP-VK.pipeline.cache.graphics_tests.vertex_stage_tessellation_control_stage_tessellation_evaluation_stage_fragment_stage