| 25 | class PositiveSyncObject : public SyncObjectTest {}; |
| 26 | |
| 27 | TEST_F(PositiveSyncObject, Sync2OwnershipTransfersImage) { |
| 28 | TEST_DESCRIPTION("Valid image ownership transfers that shouldn't create errors"); |
| 29 | SetTargetApiVersion(VK_API_VERSION_1_2); |
| 30 | AddRequiredExtensions(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); |
| 31 | AddRequiredFeature(vkt::Feature::synchronization2); |
| 32 | RETURN_IF_SKIP(Init()); |
| 33 | |
| 34 | vkt::Queue* no_gfx_queue = m_device->NonGraphicsQueue(); |
| 35 | if (!no_gfx_queue) { |
| 36 | GTEST_SKIP() << "Required queue not present (non-graphics capable required)"; |
| 37 | } |
| 38 | |
| 39 | vkt::CommandPool no_gfx_pool(*m_device, no_gfx_queue->family_index, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); |
| 40 | vkt::CommandBuffer no_gfx_cb(*m_device, no_gfx_pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY); |
| 41 | |
| 42 | // Create an "exclusive" image owned by the graphics queue. |
| 43 | VkFlags image_use = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; |
| 44 | vkt::Image image(*m_device, 32, 32, VK_FORMAT_B8G8R8A8_UNORM, image_use); |
| 45 | image.SetLayout(VK_IMAGE_LAYOUT_GENERAL); |
| 46 | |
| 47 | VkImageMemoryBarrier2 image_barrier = vku::InitStructHelper(); |
| 48 | image_barrier.srcStageMask = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT; |
| 49 | image_barrier.srcAccessMask = 0; |
| 50 | image_barrier.dstStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT; |
| 51 | image_barrier.dstAccessMask = 0; |
| 52 | image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 53 | image_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 54 | image_barrier.srcQueueFamilyIndex = m_device->graphics_queue_node_index_; |
| 55 | image_barrier.dstQueueFamilyIndex = no_gfx_queue->family_index; |
| 56 | image_barrier.image = image; |
| 57 | image_barrier.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; |
| 58 | |
| 59 | ValidOwnershipTransfer(m_default_queue, m_command_buffer, no_gfx_queue, no_gfx_cb, nullptr, &image_barrier); |
| 60 | |
| 61 | // Change layouts while changing ownership |
| 62 | image_barrier.srcQueueFamilyIndex = no_gfx_queue->family_index; |
| 63 | image_barrier.dstQueueFamilyIndex = m_device->graphics_queue_node_index_; |
| 64 | image_barrier.srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT; |
| 65 | image_barrier.dstStageMask = VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT; |
| 66 | image_barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL; |
| 67 | // Make sure the new layout is different from the old |
| 68 | if (image_barrier.oldLayout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { |
| 69 | image_barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 70 | } else { |
| 71 | image_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 72 | } |
| 73 | |
| 74 | ValidOwnershipTransfer(no_gfx_queue, no_gfx_cb, m_default_queue, m_command_buffer, nullptr, &image_barrier); |
| 75 | } |
| 76 | |
| 77 | TEST_F(PositiveSyncObject, Sync2OwnershipTransfersBuffer) { |
| 78 | TEST_DESCRIPTION("Valid buffer ownership transfers that shouldn't create errors"); |
nothing calls this directly
no test coverage detected