2023-03-12 16:14:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <tuple>
|
2023-03-13 20:27:47 +00:00
|
|
|
#include <vector>
|
2023-03-12 16:14:55 +00:00
|
|
|
|
|
|
|
#include <SDL2/SDL_vulkan.h>
|
|
|
|
|
2023-03-13 17:35:22 +00:00
|
|
|
#include <volk.h>
|
2023-03-12 16:14:55 +00:00
|
|
|
|
2023-03-13 20:27:47 +00:00
|
|
|
#include <vk_mem_alloc.h>
|
|
|
|
|
2024-04-26 22:31:34 +00:00
|
|
|
#include "gfx.h"
|
|
|
|
|
2023-03-12 16:14:55 +00:00
|
|
|
namespace engine {
|
|
|
|
|
2023-03-15 01:49:03 +00:00
|
|
|
struct DepthStencil {
|
|
|
|
VkImage image = VK_NULL_HANDLE;
|
|
|
|
VmaAllocation allocation = VK_NULL_HANDLE;
|
|
|
|
VkImageView view = VK_NULL_HANDLE;
|
|
|
|
};
|
|
|
|
|
2023-03-12 16:14:55 +00:00
|
|
|
struct Swapchain {
|
|
|
|
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
|
|
|
|
VkDevice device = VK_NULL_HANDLE; // the associated device
|
2023-03-13 20:27:47 +00:00
|
|
|
VmaAllocator allocator = VK_NULL_HANDLE; // the associated allocator
|
2023-03-12 16:14:55 +00:00
|
|
|
VkSurfaceFormatKHR surfaceFormat{};
|
|
|
|
VkSurfaceCapabilitiesKHR surfaceCapabilities{};
|
|
|
|
VkPresentModeKHR presentMode{};
|
|
|
|
VkExtent2D extent{};
|
2024-03-25 17:49:52 +00:00
|
|
|
//VkRenderPass renderpass = VK_NULL_HANDLE;
|
2023-03-21 14:18:59 +00:00
|
|
|
VkFormat depthStencilFormat;
|
2023-03-15 01:49:03 +00:00
|
|
|
std::vector<std::pair<VkImage, VkImageView>> swapchainImages{};
|
|
|
|
std::vector<DepthStencil> depthImages{};
|
2024-03-25 17:49:52 +00:00
|
|
|
//std::vector<VkFramebuffer> framebuffers{};
|
2023-03-12 16:14:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SwapchainInfo {
|
|
|
|
VkDevice device;
|
|
|
|
VkPhysicalDevice physicalDevice;
|
|
|
|
VkSurfaceKHR surface;
|
|
|
|
SDL_Window* window;
|
2023-03-13 20:27:47 +00:00
|
|
|
VmaAllocator allocator;
|
2024-04-26 22:31:34 +00:00
|
|
|
gfx::PresentMode requested_present_mode;
|
2023-03-12 16:14:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void createSwapchain(Swapchain* sc, const SwapchainInfo& info);
|
|
|
|
void destroySwapchain(const Swapchain& sc);
|
|
|
|
|
2023-03-13 17:35:22 +00:00
|
|
|
}
|