2020-05-31 08:53:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vk_device.h"
|
|
|
|
|
|
|
|
class VulkanSemaphore;
|
|
|
|
class VulkanFence;
|
|
|
|
class VulkanFramebuffer;
|
|
|
|
|
|
|
|
class VulkanSwapChain
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VulkanSwapChain(VulkanDevice *device);
|
|
|
|
~VulkanSwapChain();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
uint32_t AcquireImage(int width, int height, bool vsync, VulkanSemaphore *semaphore = nullptr, VulkanFence *fence = nullptr);
|
2020-05-31 08:53:11 +00:00
|
|
|
void QueuePresent(uint32_t imageIndex, VulkanSemaphore *semaphore = nullptr);
|
|
|
|
|
|
|
|
bool IsHdrModeActive() const;
|
|
|
|
|
|
|
|
VkSwapchainKHR swapChain = VK_NULL_HANDLE;
|
|
|
|
VkSurfaceFormatKHR swapChainFormat;
|
|
|
|
VkPresentModeKHR swapChainPresentMode;
|
|
|
|
|
|
|
|
std::vector<VkImage> swapChainImages;
|
|
|
|
std::vector<VkImageView> swapChainImageViews;
|
|
|
|
std::vector<std::unique_ptr<VulkanFramebuffer>> framebuffers;
|
|
|
|
|
|
|
|
VkExtent2D actualExtent;
|
|
|
|
|
|
|
|
private:
|
2022-07-02 08:09:59 +00:00
|
|
|
void Recreate(bool vsync);
|
2020-05-31 08:53:11 +00:00
|
|
|
void SelectFormat();
|
2022-07-02 08:09:59 +00:00
|
|
|
void SelectPresentMode(bool vsync);
|
|
|
|
bool CreateSwapChain(bool vsync, VkSwapchainKHR oldSwapChain = VK_NULL_HANDLE);
|
2020-05-31 08:53:11 +00:00
|
|
|
void CreateViews();
|
|
|
|
void GetImages();
|
|
|
|
void ReleaseResources();
|
|
|
|
void ReleaseViews();
|
|
|
|
|
|
|
|
VkSurfaceCapabilitiesKHR GetSurfaceCapabilities();
|
|
|
|
std::vector<VkSurfaceFormatKHR> GetSurfaceFormats();
|
|
|
|
std::vector<VkPresentModeKHR> GetPresentModes();
|
|
|
|
|
|
|
|
VulkanDevice *device = nullptr;
|
|
|
|
|
|
|
|
int lastSwapWidth = 0;
|
|
|
|
int lastSwapHeight = 0;
|
|
|
|
bool lastVsync = false;
|
|
|
|
bool lastHdr = false;
|
|
|
|
|
|
|
|
VulkanSwapChain(const VulkanSwapChain &) = delete;
|
|
|
|
VulkanSwapChain &operator=(const VulkanSwapChain &) = delete;
|
|
|
|
};
|