mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-13 15:43:34 +00:00
cleaning renderpass, framebuffers and swapchain code, setting all vulkan resources to NULL after destroy
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/06 18:23:27 by maldavid #+# #+# */
|
||||
/* Updated: 2022/12/18 22:08:36 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/11/18 17:15:18 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,15 +15,12 @@
|
||||
|
||||
#include <vector>
|
||||
#include <volk.h>
|
||||
#include "vk_imageview.h"
|
||||
#include "vk_framebuffer.h"
|
||||
#include <renderer/images/vk_image.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class SwapChain
|
||||
{
|
||||
friend class FrameBuffer;
|
||||
friend class ImageView;
|
||||
friend class GraphicPipeline;
|
||||
friend class RenderPass;
|
||||
friend class Renderer;
|
||||
@@ -33,32 +30,36 @@ namespace mlx
|
||||
{
|
||||
VkSurfaceCapabilitiesKHR capabilities;
|
||||
std::vector<VkSurfaceFormatKHR> formats;
|
||||
std::vector<VkPresentModeKHR> presentModes;
|
||||
};
|
||||
|
||||
public:
|
||||
SwapChain() = default;
|
||||
|
||||
void init(class Renderer* renderer);
|
||||
void initFB();
|
||||
void destroy() noexcept;
|
||||
void destroyFB() noexcept;
|
||||
|
||||
void recreate();
|
||||
void destroy() noexcept;
|
||||
|
||||
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
|
||||
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
|
||||
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
|
||||
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
|
||||
VkPresentModeKHR chooseSwapPresentMode([[maybe_unused]] const std::vector<VkPresentModeKHR> &availablePresentModes);
|
||||
|
||||
inline SwapChainSupportDetails getSupport() noexcept { return _swapChainSupport; }
|
||||
inline VkSwapchainKHR& operator()() noexcept { return _swapChain; }
|
||||
inline VkSwapchainKHR& get() noexcept { return _swapChain; }
|
||||
inline FrameBuffer& getFrameBuffer(int i) { return _framebuffers[i]; }
|
||||
inline size_t getImagesNumber() const noexcept { return _swapChainImages.size(); }
|
||||
inline VkSwapchainKHR get() noexcept { return _swapChain; }
|
||||
inline VkSwapchainKHR operator()() noexcept { return _swapChain; }
|
||||
inline size_t getImagesNumber() const noexcept { return _images.size(); }
|
||||
inline Image& getImage(std::size_t i) noexcept { return _images[i]; }
|
||||
inline SwapChainSupportDetails getSupport() noexcept { return _swapChainSupport; }
|
||||
inline VkExtent2D getExtent() noexcept { return _extent; }
|
||||
inline VkFormat getImagesFormat() const noexcept { return _swapChainImageFormat; }
|
||||
|
||||
~SwapChain() = default;
|
||||
|
||||
private:
|
||||
SwapChainSupportDetails _swapChainSupport;
|
||||
std::vector<VkImage> _swapChainImages;
|
||||
std::vector<FrameBuffer> _framebuffers;
|
||||
std::vector<ImageView> _imageViews;
|
||||
VkSwapchainKHR _swapChain;
|
||||
VkFormat _swapChainImageFormat;
|
||||
VkExtent2D _swapChainExtent;
|
||||
SwapChainSupportDetails _swapChainSupport;
|
||||
VkSwapchainKHR _swapChain;
|
||||
std::vector<Image> _images;
|
||||
VkFormat _swapChainImageFormat;
|
||||
VkExtent2D _extent;
|
||||
class Renderer* _renderer = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user