|
1 | 1 | /* |
2 | | - * Copyright (c) 2024-2025 Valve Corporation |
3 | | - * Copyright (c) 2024-2025 LunarG, Inc. |
| 2 | + * Copyright (c) 2024-2026 Valve Corporation |
| 3 | + * Copyright (c) 2024-2026 LunarG, Inc. |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
@@ -802,6 +802,78 @@ TEST_F(PositiveImageLayout, TransitionAll3dImageSlices) { |
802 | 802 | m_command_buffer.End(); |
803 | 803 | } |
804 | 804 |
|
| 805 | +TEST_F(PositiveImageLayout, TransitionAll3dImageSlicesUsing2DArrayView) { |
| 806 | + // https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/11578 |
| 807 | + SetTargetApiVersion(VK_API_VERSION_1_3); |
| 808 | + AddRequiredFeature(vkt::Feature::dynamicRendering); |
| 809 | + AddRequiredFeature(vkt::Feature::synchronization2); |
| 810 | + RETURN_IF_SKIP(Init()); |
| 811 | + |
| 812 | + const uint32_t image_depth = 10; |
| 813 | + |
| 814 | + VkImageCreateInfo image_ci = vku::InitStructHelper(); |
| 815 | + image_ci.flags = VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; |
| 816 | + image_ci.imageType = VK_IMAGE_TYPE_3D; |
| 817 | + image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 818 | + image_ci.extent = {64, 64, image_depth}; |
| 819 | + image_ci.mipLevels = 1; |
| 820 | + image_ci.arrayLayers = 1; |
| 821 | + image_ci.samples = VK_SAMPLE_COUNT_1_BIT; |
| 822 | + image_ci.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 823 | + image_ci.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 824 | + image_ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 825 | + vkt::Image image(*m_device, image_ci); |
| 826 | + |
| 827 | + VkImageViewCreateInfo image_view_ci = vku::InitStructHelper(); |
| 828 | + image_view_ci.image = image; |
| 829 | + image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; |
| 830 | + image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 831 | + image_view_ci.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, image_depth}; |
| 832 | + vkt::ImageView image_view(*m_device, image_view_ci); |
| 833 | + |
| 834 | + RenderPassSingleSubpass rp(*this); |
| 835 | + rp.AddAttachmentDescription(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL); |
| 836 | + rp.AddAttachmentReference({0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}); |
| 837 | + rp.CreateRenderPass(); |
| 838 | + |
| 839 | + VkFramebufferCreateInfo framebuffer_ci = vku::InitStructHelper(); |
| 840 | + framebuffer_ci.renderPass = rp; |
| 841 | + framebuffer_ci.width = 64; |
| 842 | + framebuffer_ci.height = 64; |
| 843 | + framebuffer_ci.layers = image_depth; |
| 844 | + framebuffer_ci.attachmentCount = 1; |
| 845 | + framebuffer_ci.pAttachments = &image_view.handle(); |
| 846 | + vkt::Framebuffer framebuffer(*m_device, framebuffer_ci); |
| 847 | + |
| 848 | + VkImageMemoryBarrier2 layout_transition = vku::InitStructHelper(); |
| 849 | + layout_transition.dstStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT; |
| 850 | + layout_transition.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT | VK_ACCESS_2_MEMORY_WRITE_BIT; |
| 851 | + layout_transition.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 852 | + layout_transition.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 853 | + layout_transition.image = image; |
| 854 | + layout_transition.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; |
| 855 | + |
| 856 | + vkt::Buffer buffer(*m_device, 64 * 64 * 64, VK_BUFFER_USAGE_TRANSFER_SRC_BIT); |
| 857 | + |
| 858 | + VkBufferImageCopy region{}; |
| 859 | + region.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; |
| 860 | + region.imageExtent = {64, 64, 1}; |
| 861 | + |
| 862 | + m_command_buffer.Begin(); |
| 863 | + |
| 864 | + // Transition image to VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL |
| 865 | + m_command_buffer.Barrier(layout_transition); |
| 866 | + |
| 867 | + // Transition image to VK_IMAGE_LAYOUT_GENERAL |
| 868 | + m_command_buffer.BeginRenderPass(rp, framebuffer, 64, 64); |
| 869 | + m_command_buffer.EndRenderPass(); |
| 870 | + |
| 871 | + // Expect GENERAL layout. The original issue reported layout mismatch |
| 872 | + vk::CmdCopyBufferToImage(m_command_buffer, buffer, image, VK_IMAGE_LAYOUT_GENERAL, 1, ®ion); |
| 873 | + |
| 874 | + m_command_buffer.End(); |
| 875 | +} |
| 876 | + |
805 | 877 | TEST_F(PositiveImageLayout, DepthSliceTransitionCriteriaNotMet) { |
806 | 878 | // https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/10453 |
807 | 879 | TEST_DESCRIPTION("Enabled maintenance9 but do not set image flag VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT"); |
|
0 commit comments