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?