Writing to the same color and depth attachements in multiple passes

I would like to render a huge static scene with Vulkan which is too large to fit into the GPU memory. What I would like to do is to do the following scenario:

  1. Create and clear color and depth attachments
  2. Take a fixed chunk of triangles from my model and transfer them to GPU memory.
  3. Draw the triangles into the color and the depth attachments
  4. Repeat until the end of the model
  5. Transfer color images to host memory

In order to practice this scenario I’m meanwhile trying to do something much simpler:

  1. Create and clear the color and depth attachments during my first render pass.
  2. Create a dummy second render pass.

My problem is that whenever I create a second render pass and submit it to the graphics queue, the background that I created in render pass 1 “disappears”. It seems that the second render pass clears the color and depth attachments. And this is in spite of having set up the loadOp for both the depth and the render buffer to VK_ATTACHMENT_LOAD_OP.

My non-working efforts, which is based on Sascha Willems renderheadless.cpp example, can be found here:

My immediate question is why, when changing

to run a second renderpass, the color attachment is cleared? What changes do I need to do to the program so that the 2nd renderpass is a noop, i.e. it leaves the color and the depth attachment exactly as it found them on entry.

Once I have that figured out, I will turn the second render pass into my chunk loop as I described in the beginning of this post.

Did you properly synchronize the renderpasses?

I finally solved the issue, and the only change that I needed to do to my referenced program to make it not clear the framebuffer when entering the second pass was to change the initialLayout of the color image and the depth attachements to VK_IMAGE_LAYOUT_GENERAL. This is necessary for the 2nd pass since I’m writing to the same image, so I do care. Since I’m reusing the same attachment for all passes passes, I heuristically found that VK_IMAGE_LAYOUT_GENERAL works.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.