Render passes

The render pass is a concept in the Vulkan API intended to pre-compile a portion of the rendering process for later use. Specifically, the inputs and outputs for the pass and several of its subpasses.

A render pass specifies a list of attachments: Color- or depth-stencil targets that can be written to in any of the subpasses of the render pass being constructed. Each of these subpasses can then specify a subset of these attachments as input targets and a subset as output targets. These attachments are then used when rendering using the render pass at a later stage.

The main advantage of this method is for tiled renderer GPUs, commonly found in mobile and low-power devices. A tiled renderer will process a single block of pixels (tile) through several stages of the pipeline and only when this tile is done move on to the next tile. This is done in order to cope with low-bandwidth memory commonly found in mobile devices, allowing portions of each of the render targets to be kept in a local cache for rapid access.

In addition, certain resources - such as those rendered using the memory in a heap marked as lazily allocated with VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT - may no longer be required as soon as the render pass is finished. Vulkan allows the driver to either temporarily allocate the memory, or allocate the memory in small blocks in cache if it does not interfere with results. This reduces memory and bandwidth strain on the GPU, allowing more resources to be available for rendering.

While desktop GPUs commonly do not share the problem of low bandwidth to the same extent, these commonly do not use this type of rendering, and therefore benefit a lot less from the render pass concept. Still, depending upon the driver implementation, using render passes may still result in performance benefits. This may be because barriers can either be more optimized, delayed or outright ignored depending upon whether or not the GPU requires these barriers to operate as expected. The usage of render passes is therefore encouraged in all scenarios.

Render passes are created using vkCreateRenderPass. Render passes are used by calling vkCmdBeginRenderPass, subpasses are invoked by calling vkCmdNextSubpass, and the subpass is ended with vkCmdEndRenderPass.