Vireo  0.0
Vireo 3D Rendering Hardware Interface
Render pass

A render pass is the process of recording then executing multiple command lists and using pipelines.

Executing a render pass

There is no "render pass object" or data structure : a render pass consists of a series of commands that ends with a submission.

In a render pass we generally find :

Starting and stopping the commands recording session is done with vireo::CommandList::begin and vireo::CommandList::end, barriers are recorded with vireo::CommandList::barrier and submission of command lists is done with vireo::SubmitQueue::submit. A graphic rendering pass starts with vireo::CommandList::beginRendering and ends with vireo::CommandList::endRendering :

// Start the recording session
cmdList->begin();
// Ensure that the color attachment is available and in the correct layout
// Start a graphic rendering pass
cmdList->beginRendering(renderingConfig);
...
// Records commands
...
// End the graphic rendering pass
cmdList->endRendering();
// Ensure that all the writes in the color attachment are done
// End the recording session
cmdList->end();
// Submit commands to the GPU
graphicQueue->submit(frame.inFlightFence, swapChain, {cmdList});

You can have multiple graphic rendering pass in a render pass, in this case you need to synchronize the color and depth attachments with pipeline barriers.

If you have multiple render passes (multiple command submissions) you need to synchronize them with semaphores.

Configuration of a graphic rendering pass

The graphic rendering pass must be configured with a vireo::RenderingConfiguration structure with the following parameters :

  • colorRenderTargets : an array of vireo::RenderTargetDesc with the descriptions of the images used as color attachments. Must have the same number of elements and the same image formats as the colorRenderFormats of the corresponding graphic pipeline.
  • depthStencilRenderTarget : the depth and stencil attachment. Must have the same format as the depthStencilImageFormat of the corresponding graphic pipeline.
  • multisampledDepthStencilRenderTarget : the multisampled depth and stencil attachment if the msaa field of the graphic pipeline is different from vireo::MSAA::NONE.
  • depthTestEnable : true if the depth and stencil attachment is used for depth testing.
  • stencilTestEnable : true if the depth and stencil attachment is used for stencil testing.
  • clearDepthStencil : set to true to clear the depth and stencil attachment at the start of the pass.
  • depthStencilClearValue : values used to clear the depth and stencil attachment.
  • discardDepthStencilAfterRender : if true the depth and stencil attachment content can be discarded by the driver if needed.

For each color attachment of the colorRenderTargets array the parameters are described in a vireo::RenderTargetDesc structure :

  • swapChain : if set, use the swap chain as color attachment.
  • renderTarget : if set, use this image as color attachment. The swapchain field is evaluated first.
  • multisampledRenderTarget : the multisampled color attachment if the msaa field of the graphic pipeline is different from vireo::MSAA::NONE.
  • clear : set to true to clear the color attachment at the start of the pass.
  • clearValue : values used to clear the color attachment.
  • discardAfterRender : if true the color attachment content can be discarded by the driver if needed.
// Configuration of the graphic rendering pass
.clear = true,
.clearValue = {0.0f, 0.2f, 0.4f, 1.0f}
}}
};
...
// Set the color attachment
renderingConfig.colorRenderTargets[0].swapChain = swapChain;
...
// Render
cmdList->beginRendering(renderingConfig);
...
cmdList->endRendering();