Last active
September 18, 2025 14:07
-
-
Save lolzballs/cccf7d7efe8804b16321e2616b44b41b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 9db0fab93d64dcfd4c93729c9084a3adc2228856 Mon Sep 17 00:00:00 2001 | |
| From: Benjamin Cheng <[email protected]> | |
| Date: Fri, 12 Sep 2025 13:57:47 -0400 | |
| Subject: [PATCH] wip: tests: Add positive sync val tests for secondary layout | |
| transitions | |
| --- | |
| tests/unit/sync_val_wsi_positive.cpp | 123 +++++++++++++++++++++++++++ | |
| 1 file changed, 123 insertions(+) | |
| diff --git a/tests/unit/sync_val_wsi_positive.cpp b/tests/unit/sync_val_wsi_positive.cpp | |
| index 867ddccb5..826efe1f7 100644 | |
| --- a/tests/unit/sync_val_wsi_positive.cpp | |
| +++ b/tests/unit/sync_val_wsi_positive.cpp | |
| @@ -20,6 +20,129 @@ | |
| struct PositiveSyncValWsi : public VkSyncValTest {}; | |
| +TEST_F(PositiveSyncValWsi, PresentWithSecondaryLayoutTransitions) { | |
| + SetTargetApiVersion(VK_API_VERSION_1_3); | |
| + AddSurfaceExtension(); | |
| + AddRequiredFeature(vkt::Feature::synchronization2); | |
| + RETURN_IF_SKIP(InitSyncValFramework()); | |
| + RETURN_IF_SKIP(InitState()); | |
| + RETURN_IF_SKIP(InitSwapchain()); | |
| + vkt::Semaphore acquire_semaphore(*m_device); | |
| + vkt::Semaphore submit_semaphore(*m_device); | |
| + const auto swapchain_images = m_swapchain.GetImages(); | |
| + const uint32_t image_index = m_swapchain.AcquireNextImage(acquire_semaphore, kWaitTimeout); | |
| + | |
| + VkImageMemoryBarrier2 layout_transition_write = vku::InitStructHelper(); | |
| + layout_transition_write.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_write.srcAccessMask = VK_ACCESS_2_NONE; | |
| + | |
| + layout_transition_write.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_write.dstAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT; | |
| + | |
| + layout_transition_write.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; | |
| + layout_transition_write.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | |
| + layout_transition_write.image = swapchain_images[image_index]; | |
| + layout_transition_write.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | |
| + layout_transition_write.subresourceRange.baseMipLevel = 0; | |
| + layout_transition_write.subresourceRange.levelCount = 1; | |
| + layout_transition_write.subresourceRange.baseArrayLayer = 0; | |
| + layout_transition_write.subresourceRange.layerCount = 1; | |
| + | |
| + VkImageMemoryBarrier2 layout_transition_present = vku::InitStructHelper(); | |
| + layout_transition_present.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_present.srcAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT; | |
| + | |
| + layout_transition_present.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_present.dstAccessMask = VK_ACCESS_2_NONE; | |
| + | |
| + layout_transition_present.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | |
| + layout_transition_present.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; | |
| + layout_transition_present.image = swapchain_images[image_index]; | |
| + layout_transition_present.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | |
| + layout_transition_present.subresourceRange.baseMipLevel = 0; | |
| + layout_transition_present.subresourceRange.levelCount = 1; | |
| + layout_transition_present.subresourceRange.baseArrayLayer = 0; | |
| + layout_transition_present.subresourceRange.layerCount = 1; | |
| + | |
| + vkt::CommandBuffer cmd_barrier_write(*m_device, m_command_pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); | |
| + cmd_barrier_write.SetName(*m_device, "Write command buffer"); | |
| + cmd_barrier_write.Begin(); | |
| + cmd_barrier_write.Barrier(layout_transition_write); | |
| + cmd_barrier_write.End(); | |
| + | |
| + vkt::CommandBuffer cmd_barrier_present(*m_device, m_command_pool, VK_COMMAND_BUFFER_LEVEL_SECONDARY); | |
| + cmd_barrier_present.SetName(*m_device, "Present command buffer"); | |
| + cmd_barrier_present.Begin(); | |
| + cmd_barrier_present.Barrier(layout_transition_present); | |
| + cmd_barrier_present.End(); | |
| + | |
| + m_command_buffer.Begin(); | |
| + m_command_buffer.ExecuteCommands(cmd_barrier_write); | |
| + m_command_buffer.ExecuteCommands(cmd_barrier_present); | |
| + m_command_buffer.End(); | |
| + | |
| + m_default_queue->Submit2(m_command_buffer, vkt::Wait(acquire_semaphore, VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT), | |
| + vkt::Signal(submit_semaphore, VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT)); | |
| + m_default_queue->Present(m_swapchain, image_index, submit_semaphore); | |
| + m_default_queue->Wait(); | |
| +}; | |
| + | |
| + | |
| +TEST_F(PositiveSyncValWsi, PresentWithPrimaryLayoutTransitions) { | |
| + SetTargetApiVersion(VK_API_VERSION_1_3); | |
| + AddSurfaceExtension(); | |
| + AddRequiredFeature(vkt::Feature::synchronization2); | |
| + RETURN_IF_SKIP(InitSyncValFramework()); | |
| + RETURN_IF_SKIP(InitState()); | |
| + RETURN_IF_SKIP(InitSwapchain()); | |
| + vkt::Semaphore acquire_semaphore(*m_device); | |
| + vkt::Semaphore submit_semaphore(*m_device); | |
| + const auto swapchain_images = m_swapchain.GetImages(); | |
| + const uint32_t image_index = m_swapchain.AcquireNextImage(acquire_semaphore, kWaitTimeout); | |
| + | |
| + VkImageMemoryBarrier2 layout_transition_write = vku::InitStructHelper(); | |
| + layout_transition_write.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_write.srcAccessMask = VK_ACCESS_2_NONE; | |
| + | |
| + layout_transition_write.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_write.dstAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT; | |
| + | |
| + layout_transition_write.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; | |
| + layout_transition_write.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | |
| + layout_transition_write.image = swapchain_images[image_index]; | |
| + layout_transition_write.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | |
| + layout_transition_write.subresourceRange.baseMipLevel = 0; | |
| + layout_transition_write.subresourceRange.levelCount = 1; | |
| + layout_transition_write.subresourceRange.baseArrayLayer = 0; | |
| + layout_transition_write.subresourceRange.layerCount = 1; | |
| + | |
| + VkImageMemoryBarrier2 layout_transition_present = vku::InitStructHelper(); | |
| + layout_transition_present.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_present.srcAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT; | |
| + | |
| + layout_transition_present.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; | |
| + layout_transition_present.dstAccessMask = VK_ACCESS_2_NONE; | |
| + | |
| + layout_transition_present.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | |
| + layout_transition_present.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; | |
| + layout_transition_present.image = swapchain_images[image_index]; | |
| + layout_transition_present.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | |
| + layout_transition_present.subresourceRange.baseMipLevel = 0; | |
| + layout_transition_present.subresourceRange.levelCount = 1; | |
| + layout_transition_present.subresourceRange.baseArrayLayer = 0; | |
| + layout_transition_present.subresourceRange.layerCount = 1; | |
| + | |
| + m_command_buffer.Begin(); | |
| + m_command_buffer.Barrier(layout_transition_write); | |
| + m_command_buffer.Barrier(layout_transition_present); | |
| + m_command_buffer.End(); | |
| + | |
| + m_default_queue->Submit2(m_command_buffer, vkt::Wait(acquire_semaphore, VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT), | |
| + vkt::Signal(submit_semaphore, VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT)); | |
| + m_default_queue->Present(m_swapchain, image_index, submit_semaphore); | |
| + m_default_queue->Wait(); | |
| +}; | |
| + | |
| TEST_F(PositiveSyncValWsi, PresentAfterSubmit2AutomaticVisibility) { | |
| TEST_DESCRIPTION("Waiting on the semaphore makes available image accesses visible to the presentation engine."); | |
| SetTargetApiVersion(VK_API_VERSION_1_3); | |
| -- | |
| 2.51.0.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment