This commit is contained in:
Zed A. Shaw 2025-11-25 13:45:08 -05:00
parent 55e38788b4
commit 40717cf8e4
9 changed files with 216 additions and 14 deletions

View file

@ -5,12 +5,30 @@
#include <vk_types.h>
struct DeletionQueue {
std::deque<std::function<void()>> deletors;
void push_function(std::function<void()>&& function) {
deletors.push_back(function);
}
void flush() {
// reverse itererate the deletion queue
for(auto it = deletors.rbegin(); it != deletors.rend(); it++) {
(*it)();
}
deletors.clear();
}
};
struct FrameData {
VkCommandPool _commandPool;
VkCommandBuffer _mainCommandBuffer;
VkSemaphore _swapchainSemaphore;
VkSemaphore _renderSemaphore;
VkFence _renderFence;
DeletionQueue _deletionQueue;
};
constexpr unsigned int FRAME_OVERLAP=2;
@ -32,6 +50,9 @@ public:
std::vector<VkImageView> _swapchainImageViews;
VkExtent2D _swapchainExtent;
// VMA stuff
VmaAllocator _allocator;
// frames/command buffer
unsigned int _frameNumber = 0;
FrameData _frames[FRAME_OVERLAP];
@ -43,12 +64,15 @@ public:
VkQueue _graphicsQueue;
uint32_t _graphicsQueueFamily;
// draw resources
AllocatedImage _drawImage;
VkExtent2D _drawExtent;
// internal data
bool _isInitialized{ false };
VkExtent2D _windowExtent{ 1700 , 900 };
struct SDL_Window* _window{ nullptr };
DeletionQueue _mainDeletionQueue;
static VulkanEngine& Get();
@ -72,4 +96,5 @@ private:
void create_swapchain(uint32_t width, uint32_t height);
void destroy_swapchain();
void draw_background(VkCommandBuffer cmd);
};