diff options
author | unknown <locke@lunarg.com> | 2019-07-15 17:38:51 -0600 |
---|---|---|
committer | Locke Lin <47329816+locke-lunarg@users.noreply.github.com> | 2019-08-19 13:06:39 -0600 |
commit | 3d058cb6c03e18f32709e04b4382bd4fc8505c8d (patch) | |
tree | b2732106df8535729025f3426bf07136e1153a07 /tests | |
parent | 5cd0069f4e281d2b599717a7d859fcad76a49aa9 (diff) | |
download | vulkan-validation-layers-3d058cb6c03e18f32709e04b4382bd4fc8505c8d.tar.gz |
tests: Test subpass with read-only layout
Change-Id: Ife383fb7e8e68b8ac60cb2ccbe4a6a86738bc2db
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vkpositivelayertests.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/vkpositivelayertests.cpp b/tests/vkpositivelayertests.cpp index 03c6c8a64..a9e01dac0 100644 --- a/tests/vkpositivelayertests.cpp +++ b/tests/vkpositivelayertests.cpp @@ -8019,3 +8019,76 @@ TEST_F(VkPositiveLayerTest, NotPointSizeGeometryShaderSuccess) { pipe.CreateGraphicsPipeline(); m_errorMonitor->VerifyNotFound(); } + +TEST_F(VkPositiveLayerTest, SubpassWithReadOnlyLayoutWithoutDependency) { + TEST_DESCRIPTION("When both subpasses' attachments are the same and layouts are read-only, they don't need dependency."); + ASSERT_NO_FATAL_FAILURE(Init()); + + auto depth_format = FindSupportedDepthStencilFormat(gpu()); + if (!depth_format) { + printf("%s No Depth + Stencil format found. Skipped.\n", kSkipPrefix); + return; + } + + // A renderpass with one color attachment. + VkAttachmentDescription attachment = {0, + depth_format, + VK_SAMPLE_COUNT_1_BIT, + VK_ATTACHMENT_LOAD_OP_DONT_CARE, + VK_ATTACHMENT_STORE_OP_STORE, + VK_ATTACHMENT_LOAD_OP_DONT_CARE, + VK_ATTACHMENT_STORE_OP_DONT_CARE, + VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL}; + const int size = 2; + std::array<VkAttachmentDescription, size> attachments = {attachment, attachment}; + + VkAttachmentReference att_ref_depth_stencil = {0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL}; + + std::array<VkSubpassDescription, size> subpasses; + subpasses[0] = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, 0, 0, nullptr, nullptr, &att_ref_depth_stencil, 0, nullptr}; + subpasses[1] = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, 0, 0, nullptr, nullptr, &att_ref_depth_stencil, 0, nullptr}; + + VkRenderPassCreateInfo rpci = { + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, 0, size, attachments.data(), size, subpasses.data(), 0, nullptr}; + + VkRenderPass rp; + VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); + ASSERT_VK_SUCCESS(err); + + // A compatible framebuffer. + VkImageObj image(m_device); + image.Init(32, 32, 1, depth_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR, 0); + ASSERT_TRUE(image.initialized()); + + VkImageViewCreateInfo ivci = {VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + nullptr, + 0, + image.handle(), + VK_IMAGE_VIEW_TYPE_2D, + depth_format, + {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, + VK_COMPONENT_SWIZZLE_IDENTITY}, + {VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, 0, 1, 0, 1}}; + + VkImageView view; + err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); + ASSERT_VK_SUCCESS(err); + std::array<VkImageView, size> views = {view, view}; + + VkFramebufferCreateInfo fci = {VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, 0, rp, size, views.data(), 32, 32, 1}; + VkFramebuffer fb; + err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); + ASSERT_VK_SUCCESS(err); + + VkRenderPassBeginInfo rpbi = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, rp, fb, {{0, 0}, {32, 32}}, 0, nullptr}; + m_commandBuffer->begin(); + vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, VK_SUBPASS_CONTENTS_INLINE); + vkCmdNextSubpass(m_commandBuffer->handle(), VK_SUBPASS_CONTENTS_INLINE); + vkCmdEndRenderPass(m_commandBuffer->handle()); + m_commandBuffer->end(); + + vkDestroyFramebuffer(m_device->device(), fb, nullptr); + vkDestroyRenderPass(m_device->device(), rp, nullptr); + vkDestroyImageView(m_device->device(), view, nullptr); +} |