VPP  0.7
A high-level modern C++ API for Vulkan
Public Types | Public Member Functions | List of all members
vpp::RenderManager Class Reference

Simple rendering manager. More...

#include <vppRenderManager.hpp>

Public Types

enum  ECommandsCaching { CACHE_CMDS, REBUILD_CMDS }
 Selects the caching behavior for command buffers. More...
 

Public Member Functions

 RenderManager ()
 Constructs a null reference.
 
 RenderManager (const SwapChain &hSwapChain)
 Constructs the render manager with specified swap chain.
 
 RenderManager (Device hDevice, Surface hSurface, std::uint32_t imageCount=0, VkPresentModeKHR imageQueuingMode=VK_PRESENT_MODE_MAILBOX_KHR)
 Constructs the render manager with specified surface. More...
 
void beginFrame ()
 Initializes rendering of current frame. More...
 
void endFrame ()
 Finalizes rendering of current frame. More...
 
void render (const RenderPass &hRenderPass, ECommandsCaching caching=CACHE_CMDS)
 Renders current frame. More...
 
const Devicedevice () const
 Retrieves the device.
 
const Surfacesurface () const
 Retrieves the target surface.
 
const Queuequeue () const
 Retrieves the command queue into which the commands are sent. More...
 

Detailed Description

Simple rendering manager.

This class provides a (very) simple rendering engine working with a SwapChain. It is suitable for examples, demos or quick experiments.

Place a RenderManager object inside your rendering engine class. It takes a SwapChain reference in the constructor. Optionally you may specify custom Queue (if not, the manager will use default queue of the device, which is recommended).

The pattern of using RenderManager is based on frames (which must be timed externally). For each frame:

Rendering work is done by the manager in render() method on provided RenderPass. It gathers commands from the render graph, records them into internally maintained command buffer and submits to the device for execution.

Additional parameter controls whether to cache the command buffer. There are two possible cases:

This object is reference counted and can be passed by value.

Member Enumeration Documentation

◆ ECommandsCaching

Selects the caching behavior for command buffers.

Enumerator
CACHE_CMDS 

Retrieve buffer from cache if possible.

REBUILD_CMDS 

Rebuild the buffer.

Constructor & Destructor Documentation

◆ RenderManager()

vpp::RenderManager::RenderManager ( Device  hDevice,
Surface  hSurface,
std::uint32_t  imageCount = 0,
VkPresentModeKHR  imageQueuingMode = VK_PRESENT_MODE_MAILBOX_KHR 
)

Constructs the render manager with specified surface.

This constructor automatically creates a swap chain for provided device and surface.

It is recommended to leave default values of imageCount and imageQueuingMode. Many devices have limitations regarding selection of these, so it is best to rely on automatic detection.

Member Function Documentation

◆ beginFrame()

void vpp::RenderManager::beginFrame ( )

Initializes rendering of current frame.

Call before rendering a frame.

This method ensures that rendering of previous frame has finished (waits if needed) and acquires a target image from the swapchain.

◆ endFrame()

void vpp::RenderManager::endFrame ( )

Finalizes rendering of current frame.

Call after rendering a frame.

This method sends currently rendered target image back to the swapchain for presentation.

◆ queue()

const Queue& vpp::RenderManager::queue ( ) const

Retrieves the command queue into which the commands are sent.

This is the first queue of default graphics queue family on the device.

◆ render()

void vpp::RenderManager::render ( const RenderPass hRenderPass,
ECommandsCaching  caching = CACHE_CMDS 
)

Renders current frame.

This method renders the frame by using provided render pass.

By default, it will cache and reuse commands. Specify REBUILD_CMDS as the second parameter to regenerate command sequences.


The documentation for this class was generated from the following file: