5

In an existing renderer which draws geometry in the swapchain, I need to render some parts of this geometry in a texture, others parts must remain on screen. All the geometry is recorded into one command buffer. I won't need to render this texture every time. I created destination image, image view and framebuffer, but I don't know what to do now. I dont think I need a specific pipeline, nor a new specific descriptor set, as everything is correctly rendered on screen. Do I need another render pass, or a subpass, or anything else?

Leon
  • 554
  • 4
  • 18

1 Answers1

6

Exactly, you need a separate renderpass that fills your destination images. As the renderpass stores a reference to the images (as attachments) a separate one is required.

Within that renderpass you then can use subpass dependencies to transition the destination images to the proper layout. Your first transition should be VK_ACCESS_SHADER_READ_BIT to VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT for writing to the destination image and once that's done you transition back from VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT to VK_ACCESS_SHADER_READ_BIT so you can e.g. render your destination images in the visual pass. An alternative would be blitting them to the swap chain if the device supports that.

If you need a reference, you can check out my offscreen rendering sample.

Sascha Willems
  • 5,280
  • 1
  • 14
  • 21
  • Thx Sascha. I had already read your sample, but I didn't understand it enough. I see only one call to vkCreateRenderPass(), I was naively waiting another one. And I have difficulties to tell which part is for the main render pass, and which part is for the subpass. Therefore, how to make the subpass optionnal? – Leon Apr 09 '20 at 15:25
  • The main render pass is created in the Vulkan Sample base class.The sample does not make use of sub passes. It uses two separate render passes. – Sascha Willems Apr 09 '20 at 17:36