【发布时间】:2018-01-20 08:00:48
【问题描述】:
现在,我想做后处理并使用 subpass 方式来做。我创建了两个子通道,并在第二个子通道的屏幕上绘制了一个大三角形。
但问题是我不知道如何获取第一个子通道的渲染结果,因为我需要将它提供给第二个子通道的片段着色器,然后我可以在第二个子通道的片段着色器中做一些效果次通道。
我猜结果是swapchain_imageView。但我不能使用它。 Vulkan 告诉我
Cannot use image 0x8 with specific layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL that doesn't match the actual current layout VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL。
估计方法不对。
如何为下一个子通道获得正确的渲染结果?
【问题讨论】:
-
VkAttachmentReference inputAttachmentRef = {}; inputAttachmentRef.attachment = 0; inputAttachmentRef.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; VkSubpassDescription subpass2 = {}; subpass2.inputAttachmentCount = 1; subpass2.pInputAttachments = &inputAttachmentRef;因为我在 subpass 2 中设置了 inputAttachment,我猜系统应该自动将 subpass 1 的渲染结果发送到我的 subpass 2 的片段着色器。但我只是猜测。我真的不知道。