Dov Grobgeld
Dov Grobgeld

Reputation: 4983

Render multiple vulkan passes in the same attachment

I wonder whether it is possible to render multiple passes into the same color and depth attachment in Vulkan? I need to do a headless rendering of a huge model that does not fit into the the GPU memory (I'm using Swiftshader that has only 1GB of memory). I'd like to do the following sequence of actions:

  1. Initialize an empty color attachment and depth buffer
  2. Setup the shader and graphics pipeline
  3. Loop over chunks of vertices from my huge model
  4. Upload the chunk of vertices from the CPU to the GPU
  5. Render into the color and depth buffers (on "top" of the previous values in the color and depth attachments)
  6. Repeat next chunk

I'm currently stuck on vkCmdBeginRenderPass() which takes a "clear value". But what if I don't want to clear the buffer. Can I just do clearValues = 0? What else is needed to get the scenario above to work?

Upvotes: 2

Views: 1279

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473437

Whether a render pass clears the buffer(s) on load is part of the render pass's setup. There is the loadOp field in every attachment which states how it should use any previous data in the attachment (if any).

In your case, because you're constantly accumulating distinct rendering processes into the same images, you want the loadOp to load the data, not clear it. You can explicitly clear the attachments the first time you execute the render pass with vkCmdClearAttachments.

Upvotes: 4

Related Questions