![]() |
VPP
0.7
A high-level modern C++ API for Vulkan
|
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 Device & | device () const |
Retrieves the device. | |
const Surface & | surface () const |
Retrieves the target surface. | |
const Queue & | queue () const |
Retrieves the command queue into which the commands are sent. More... | |
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:
CACHE_CMDS
value. The last created buffer will be reused, which saves time.REBUILD_CMDS
. The buffer will be reset and the commands re-recorded.This object is reference counted and can be passed by value.
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.
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.
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.
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.
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.