return tcu::TestStatus::pass("render pass continue test passed");
}
-tcu::TestStatus simultaneousUsePrimaryBufferTest(Context& context)
-{
- const VkDevice vkDevice = context.getDevice();
- const DeviceInterface& vk = context.getDeviceInterface();
- const VkQueue queue = context.getUniversalQueue();
- const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
-
- const VkCommandPoolCreateInfo cmdPoolParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // VkCommandPoolCreateFlags flags;
- queueFamilyIndex, // deUint32 queueFamilyIndex;
- };
- const Unique<VkCommandPool> cmdPool (createCommandPool(vk, vkDevice, &cmdPoolParams));
-
- // Command buffer
- const VkCommandBufferAllocateInfo cmdBufParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- *cmdPool, // VkCommandPool pool;
- VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
- 1u, // uint32_t bufferCount;
- };
- const Unique<VkCommandBuffer> primCmdBuf (allocateCommandBuffer(vk, vkDevice, &cmdBufParams));
-
- // create event that will be used to check if secondary command buffer has been executed
- const Unique<VkEvent> eventOne (createEvent(vk, vkDevice));
- const Unique<VkEvent> eventTwo (createEvent(vk, vkDevice));
-
- // reset event
- VK_CHECK(vk.resetEvent(vkDevice, *eventOne));
-
- // record primary command buffer
- beginCommandBuffer(vk, *primCmdBuf, VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT);
- {
- // wait for event
- vk.cmdWaitEvents(*primCmdBuf, 1u, &eventOne.get(), VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0u, DE_NULL, 0u, DE_NULL, 0u, DE_NULL);
-
- // Set the second event
- vk.cmdSetEvent(*primCmdBuf, eventTwo.get(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
- }
- endCommandBuffer(vk, *primCmdBuf);
-
- // create fence to wait for execution of queue
- const Unique<VkFence> fence1 (createFence(vk, vkDevice));
- const Unique<VkFence> fence2 (createFence(vk, vkDevice));
-
- const VkSubmitInfo submitInfo =
- {
- VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
- DE_NULL, // pNext
- 0u, // waitSemaphoreCount
- DE_NULL, // pWaitSemaphores
- (const VkPipelineStageFlags*)DE_NULL, // pWaitDstStageMask
- 1, // commandBufferCount
- &primCmdBuf.get(), // pCommandBuffers
- 0u, // signalSemaphoreCount
- DE_NULL, // pSignalSemaphores
- };
-
- // submit first buffer
- VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence1));
-
- // submit second buffer
- VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence2));
-
- // wait for both buffer to stop at event for 100 microseconds
- vk.waitForFences(vkDevice, 1, &fence1.get(), 0u, 100000);
- vk.waitForFences(vkDevice, 1, &fence2.get(), 0u, 100000);
-
- // set event
- VK_CHECK(vk.setEvent(vkDevice, *eventOne));
-
- // wait for end of execution of the first buffer
- VK_CHECK(vk.waitForFences(vkDevice, 1, &fence1.get(), 0u, INFINITE_TIMEOUT));
- // wait for end of execution of the second buffer
- VK_CHECK(vk.waitForFences(vkDevice, 1, &fence2.get(), 0u, INFINITE_TIMEOUT));
-
- // TODO: this will be true if the command buffer was executed only once
- // TODO: add some test that will say if it was executed twice
-
- // check if buffer has been executed
- VkResult result = vk.getEventStatus(vkDevice, *eventTwo);
- if (result == VK_EVENT_SET)
- return tcu::TestStatus::pass("simultaneous use - primary buffers test succeeded");
- else
- return tcu::TestStatus::fail("simultaneous use - primary buffers test FAILED");
-}
-
-tcu::TestStatus simultaneousUseSecondaryBufferTest(Context& context)
-{
- const VkDevice vkDevice = context.getDevice();
- const DeviceInterface& vk = context.getDeviceInterface();
- const VkQueue queue = context.getUniversalQueue();
- const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
-
- const VkCommandPoolCreateInfo cmdPoolParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // VkCommandPoolCreateFlags flags;
- queueFamilyIndex, // deUint32 queueFamilyIndex;
- };
- const Unique<VkCommandPool> cmdPool (createCommandPool(vk, vkDevice, &cmdPoolParams));
-
- // Command buffer
- const VkCommandBufferAllocateInfo cmdBufParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- *cmdPool, // VkCommandPool pool;
- VK_COMMAND_BUFFER_LEVEL_PRIMARY, // VkCommandBufferLevel level;
- 1u, // uint32_t bufferCount;
- };
- const Unique<VkCommandBuffer> primCmdBuf (allocateCommandBuffer(vk, vkDevice, &cmdBufParams));
-
- // Secondary Command buffer params
- const VkCommandBufferAllocateInfo secCmdBufParams =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType;
- DE_NULL, // const void* pNext;
- *cmdPool, // VkCommandPool pool;
- VK_COMMAND_BUFFER_LEVEL_SECONDARY, // VkCommandBufferLevel level;
- 1u, // uint32_t bufferCount;
- };
- const Unique<VkCommandBuffer> secCmdBuf (allocateCommandBuffer(vk, vkDevice, &secCmdBufParams));
-
- const VkCommandBufferInheritanceInfo secCmdBufInheritInfo =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO,
- DE_NULL,
- (VkRenderPass)0u, // renderPass
- 0u, // subpass
- (VkFramebuffer)0u, // framebuffer
- VK_FALSE, // occlusionQueryEnable
- (VkQueryControlFlags)0u, // queryFlags
- (VkQueryPipelineStatisticFlags)0u, // pipelineStatistics
- };
- const VkCommandBufferBeginInfo secCmdBufBeginInfo =
- {
- VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
- DE_NULL,
- VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, // flags
- &secCmdBufInheritInfo,
- };
-
- // create event that will be used to check if secondary command buffer has been executed
- const Unique<VkEvent> eventOne (createEvent(vk, vkDevice));
- const Unique<VkEvent> eventTwo (createEvent(vk, vkDevice));
-
- // reset event
- VK_CHECK(vk.resetEvent(vkDevice, *eventOne));
- VK_CHECK(vk.resetEvent(vkDevice, *eventTwo));
-
- // record secondary command buffer
- VK_CHECK(vk.beginCommandBuffer(*secCmdBuf, &secCmdBufBeginInfo));
- {
- // allow execution of event during every stage of pipeline
- VkPipelineStageFlags stageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
-
- // wait for event
- vk.cmdWaitEvents(*secCmdBuf, 1, &eventOne.get(), stageMask, stageMask, 0, DE_NULL, 0u, DE_NULL, 0u, DE_NULL);
-
- // reset event
- vk.cmdSetEvent(*secCmdBuf, *eventTwo, stageMask);
- }
- // end recording of secondary buffers
- endCommandBuffer(vk, *secCmdBuf);
-
- // record primary command buffer
- beginCommandBuffer(vk, *primCmdBuf, 0u);
- {
- // execute secondary buffer
- vk.cmdExecuteCommands(*primCmdBuf, 1, &secCmdBuf.get());
- }
- endCommandBuffer(vk, *primCmdBuf);
-
- // create fence to wait for execution of queue
- const Unique<VkFence> fence (createFence(vk, vkDevice));
-
- const VkSubmitInfo submitInfo =
- {
- VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType
- DE_NULL, // pNext
- 0u, // waitSemaphoreCount
- DE_NULL, // pWaitSemaphores
- (const VkPipelineStageFlags*)DE_NULL, // pWaitDstStageMask
- 1, // commandBufferCount
- &primCmdBuf.get(), // pCommandBuffers
- 0u, // signalSemaphoreCount
- DE_NULL, // pSignalSemaphores
- };
-
- // submit primary buffer, the secondary should be executed too
- VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, *fence));
-
- // wait for both buffers to stop at event for 100 microseconds
- vk.waitForFences(vkDevice, 1, &fence.get(), 0u, 100000);
-
- // set event
- VK_CHECK(vk.setEvent(vkDevice, *eventOne));
-
- // wait for end of execution of queue
- VK_CHECK(vk.waitForFences(vkDevice, 1, &fence.get(), 0u, INFINITE_TIMEOUT));
-
- // TODO: this will be true if the command buffer was executed only once
- // TODO: add some test that will say if it was executed twice
-
- // check if secondary buffer has been executed
- VkResult result = vk.getEventStatus(vkDevice,*eventTwo);
- if (result == VK_EVENT_SET)
- return tcu::TestStatus::pass("Simultaneous Secondary Command Buffer Execution succeeded");
- else
- return tcu::TestStatus::fail("Simultaneous Secondary Command Buffer Execution FAILED");
-}
-
tcu::TestStatus simultaneousUseSecondaryBufferOnePrimaryBufferTest(Context& context)
{
const VkDevice vkDevice = context.getDevice();
addFunctionCase (commandBuffersTests.get(), "record_one_time_submit_secondary", "", checkEventSupport, oneTimeSubmitFlagSecondaryBufferTest);
addFunctionCase (commandBuffersTests.get(), "render_pass_continue", "", renderPassContinueTest, true);
addFunctionCase (commandBuffersTests.get(), "render_pass_continue_no_fb", "", renderPassContinueTest, false);
- addFunctionCase (commandBuffersTests.get(), "record_simul_use_primary", "", checkEventSupport, simultaneousUsePrimaryBufferTest);
- addFunctionCase (commandBuffersTests.get(), "record_simul_use_secondary", "", checkEventSupport, simultaneousUseSecondaryBufferTest);
addFunctionCaseWithPrograms (commandBuffersTests.get(), "record_simul_use_secondary_one_primary", "", genComputeIncrementSource, simultaneousUseSecondaryBufferOnePrimaryBufferTest);
addFunctionCaseWithPrograms (commandBuffersTests.get(), "record_simul_use_secondary_two_primary", "", genComputeIncrementSource, simultaneousUseSecondaryBufferTwoPrimaryBuffersTest);
addFunctionCase (commandBuffersTests.get(), "record_query_precise_w_flag", "", recordBufferQueryPreciseWithFlagTest);