FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::vulkan::GarbageCollector Class Reference

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
 
GarbageCollectoroperator= (GarbageCollector const &r)=delete
 
GarbageCollectoroperator= (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
 

Detailed Description

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.

Member Function Documentation

◆ enable()

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.

Parameters
statfalse to disable the garbage collector, true to enable it

◆ free()

void fge::vulkan::GarbageCollector::free ( )

Free all the garbage objects in the current frame.

This method should not be called manually for normal use.

◆ freeAll()

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.

◆ push()

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.

Parameters
garbageThe garbage object

◆ setCurrentFrame()

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.

Parameters
frameThe current frame

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