mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-10-14 21:23:10 +03:00
Initial commit
This commit is contained in:
58
desktop/graphics/vulkan_swap_chain.h
Normal file
58
desktop/graphics/vulkan_swap_chain.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "vulkan_adapter.h"
|
||||
#include "vulkan_common.h"
|
||||
|
||||
namespace progressia {
|
||||
namespace desktop {
|
||||
|
||||
class SwapChain : public VkObjectWrapper {
|
||||
|
||||
public:
|
||||
struct SupportDetails {
|
||||
VkSurfaceCapabilitiesKHR capabilities;
|
||||
std::vector<VkSurfaceFormatKHR> formats;
|
||||
std::vector<VkPresentModeKHR> presentModes;
|
||||
};
|
||||
|
||||
static SupportDetails querySwapChainSupport(VkPhysicalDevice device,
|
||||
Vulkan &vulkan);
|
||||
static bool isSwapChainSuitable(const SupportDetails &details);
|
||||
|
||||
private:
|
||||
VkSwapchainKHR vk;
|
||||
|
||||
Attachment *colorBuffer;
|
||||
std::vector<VkImageView> colorBufferViews;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
Image *depthBuffer;
|
||||
|
||||
std::vector<VkFramebuffer> framebuffers;
|
||||
|
||||
Vulkan &vulkan;
|
||||
|
||||
void create();
|
||||
void destroy();
|
||||
|
||||
VkSurfaceFormatKHR
|
||||
chooseSurfaceFormat(const std::vector<VkSurfaceFormatKHR> &);
|
||||
bool isTripleBufferingSupported(const std::vector<VkPresentModeKHR> &);
|
||||
VkPresentModeKHR choosePresentMode(const std::vector<VkPresentModeKHR> &,
|
||||
bool avoidVsync);
|
||||
VkExtent2D chooseExtent(const VkSurfaceCapabilitiesKHR &);
|
||||
|
||||
public:
|
||||
SwapChain(Vulkan &);
|
||||
~SwapChain();
|
||||
|
||||
void recreate();
|
||||
|
||||
VkSwapchainKHR getVk() const;
|
||||
VkFramebuffer getFramebuffer(std::size_t index) const;
|
||||
VkExtent2D getExtent() const;
|
||||
};
|
||||
|
||||
} // namespace desktop
|
||||
} // namespace progressia
|
Reference in New Issue
Block a user