17#ifndef _FGE_VULKAN_C_GARBAGECOLLECTOR_HPP_INCLUDED
18#define _FGE_VULKAN_C_GARBAGECOLLECTOR_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
22#include "FastEngine/vulkan/vulkanGlobal.hpp"
35 GARBAGE_DESCRIPTOR_SET,
36 GARBAGE_VERTEX_BUFFER,
37 GARBAGE_GRAPHIC_PIPELINE,
38 GARBAGE_PIPELINE_LAYOUT,
40 GARBAGE_COMMAND_BUFFER,
54 VkDescriptorPool descriptorPool,
55 VkDevice logicalDevice) :
56 _type(GarbageType::GARBAGE_DESCRIPTOR_SET),
57 _descriptorSet(descriptorSet),
58 _descriptorPool(descriptorPool),
59 _logicalDevice(logicalDevice)
63 VkDescriptorSet _descriptorSet;
64 VkDescriptorPool _descriptorPool;
65 VkDevice _logicalDevice;
69 constexpr GarbageBuffer(VkBuffer buffer, VmaAllocation bufferAllocation, VmaAllocator allocator) :
70 _type(GarbageType::GARBAGE_VERTEX_BUFFER),
72 _bufferAllocation(bufferAllocation),
78 VmaAllocation _bufferAllocation;
79 VmaAllocator _allocator;
84 _type(GarbageType::GARBAGE_GRAPHIC_PIPELINE),
86 _logicalDevice(logicalDevice)
91 VkDevice _logicalDevice;
96 _type(GarbageType::GARBAGE_PIPELINE_LAYOUT),
97 _pipelineLayout(pipelineLayout),
98 _logicalDevice(logicalDevice)
102 VkPipelineLayout _pipelineLayout;
103 VkDevice _logicalDevice;
108 _type(GarbageType::GARBAGE_COMMAND_POOL),
109 _commandPool(commandPool),
110 _logicalDevice(logicalDevice)
114 VkCommandPool _commandPool;
115 VkDevice _logicalDevice;
119 constexpr GarbageCommandBuffer(VkCommandPool commandPool, VkCommandBuffer commandBuffer, VkDevice logicalDevice) :
120 _type(GarbageType::GARBAGE_COMMAND_BUFFER),
121 _commandPool(commandPool),
122 _commandBuffer(commandBuffer),
123 _logicalDevice(logicalDevice)
127 VkCommandPool _commandPool;
128 VkCommandBuffer _commandBuffer;
129 VkDevice _logicalDevice;
134 _type(GarbageType::GARBAGE_FRAMEBUFFER),
135 _framebuffer(framebuffer),
136 _logicalDevice(logicalDevice)
140 VkFramebuffer _framebuffer;
141 VkDevice _logicalDevice;
146 _type(GarbageType::GARBAGE_RENDERPASS),
147 _renderPass(renderPass),
148 _logicalDevice(logicalDevice)
152 VkRenderPass _renderPass;
153 VkDevice _logicalDevice;
157 constexpr GarbageSampler(VkSampler sampler, VkDevice logicalDevice) :
158 _type(GarbageType::GARBAGE_SAMPLER),
160 _logicalDevice(logicalDevice)
165 VkDevice _logicalDevice;
170 VmaAllocation bufferAllocation,
171 VkImageView imageView,
173 _type(GarbageType::GARBAGE_IMAGE),
175 _allocation(bufferAllocation),
176 _imageView(imageView),
182 VmaAllocation _allocation;
183 VkImageView _imageView;
198 g_data(GarbageType::GARBAGE_EMPTY)
236 r.g_data._generic._type = GarbageType::GARBAGE_EMPTY;
246 explicit constexpr Data(GarbageType type) :
256 _graphicPipeline{data}
259 _pipelineLayout{data}
308 using ContainerType = std::vector<Garbage>;
328 [[nodiscard]] uint32_t getCurrentFrame()
const;
366 [[nodiscard]]
bool isEnabled()
const;
369 mutable std::array<ContainerType, FGE_MAX_FRAMES_IN_FLIGHT> g_containers;
370 uint32_t g_currentFrame = 0;
371 bool g_enabled =
false;
Vulkan context.
Definition C_context.hpp:70
A garbage collector for Vulkan objects.
Definition C_garbageCollector.hpp:306
void free()
Free all the garbage objects in the current frame.
void enable(bool stat)
Enable or disable the garbage collector.
void setCurrentFrame(uint32_t frame)
Set the current frame.
void freeAll()
Free all the garbage objects.
void push(Garbage garbage) const
Push a garbage object.
A class that holds a garbage object.
Definition C_garbageCollector.hpp:195
Definition C_garbageCollector.hpp:68
Definition C_garbageCollector.hpp:118
Definition C_garbageCollector.hpp:106
Definition C_garbageCollector.hpp:52
Definition C_garbageCollector.hpp:132
Definition C_garbageCollector.hpp:48
Definition C_garbageCollector.hpp:82
Definition C_garbageCollector.hpp:168
Definition C_garbageCollector.hpp:94
Definition C_garbageCollector.hpp:144
Definition C_garbageCollector.hpp:156