![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
A garbage collector for Vulkan objects. More...
#include <C_garbageCollector.hpp>
Public Types | |
using | ContainerType = std::vector<Garbage> |
Public Member Functions | |
GarbageCollector (GarbageCollector const &r)=delete | |
GarbageCollector (GarbageCollector &&r) noexcept | |
GarbageCollector & | operator= (GarbageCollector const &r)=delete |
GarbageCollector & | operator= (GarbageCollector &&r) noexcept=delete |
void | setCurrentFrame (uint32_t frame) |
Set the current frame. | |
uint32_t | getCurrentFrame () const |
void | push (Garbage garbage) const |
Push a garbage object. | |
void | free () |
Free all the garbage objects in the current frame. | |
void | freeAll () |
Free all the garbage objects. | |
void | enable (bool stat) |
Enable or disable the garbage collector. | |
bool | isEnabled () const |
A garbage collector for Vulkan objects.
In Vulkan when recording a command buffer, you can't destroy a resource that is used by it. In order to address this problem, a garbage collector is used. It will collect all the unused resources and free them when the command buffer is done.
void fge::vulkan::GarbageCollector::enable | ( | bool | stat | ) |
Enable or disable the garbage collector.
When the garbage collector is disabled, all the garbage objects will be freed immediately.
By default, the garbage collector is disabled.
When the user disable the garbage collector, the freeAll() method is called automatically.
stat | false to disable the garbage collector, true to enable it |
void fge::vulkan::GarbageCollector::free | ( | ) |
Free all the garbage objects in the current frame.
This method should not be called manually for normal use.
void fge::vulkan::GarbageCollector::freeAll | ( | ) |
Free all the garbage objects.
This method should be only called when the application is closing just after the scene has been destroyed.
void fge::vulkan::GarbageCollector::push | ( | Garbage | garbage | ) | const |
Push a garbage object.
Push a garbage object associated with the current frame. The garbage will be freed when switching to a new frame.
garbage | The garbage object |
void fge::vulkan::GarbageCollector::setCurrentFrame | ( | uint32_t | frame | ) |
Set the current frame.
Set the current frame respecting the maximum number of frames in flight. When switching to a new frame, the garbage collector will free all the resources that were collected previously.
frame | The current frame |