cleaning renderpass, framebuffers and swapchain code, setting all vulkan resources to NULL after destroy

This commit is contained in:
Kbz-8
2023-11-18 17:25:30 +01:00
parent c583f1abc8
commit f6201014aa
23 changed files with 435 additions and 299 deletions

View File

@@ -6,12 +6,12 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 11:54:21 by maldavid #+# #+# */
/* Updated: 2023/11/14 03:15:18 by maldavid ### ########.fr */
/* Updated: 2023/11/18 17:10:05 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __VK_IMAGE__
#define __VK_IMAGE__
#ifndef __MLX_VK_IMAGE__
#define __MLX_VK_IMAGE__
#include <volk.h>
#include <cstddef>
@@ -25,14 +25,26 @@ namespace mlx
class Image
{
friend class SwapChain;
public:
Image() = default;
inline void create(VkImage image, VkFormat format, uint32_t width, uint32_t height, VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED) noexcept
{
_image = image;
_format = format;
_width = width;
_height = height;
_layout = layout;
_pool.init();
}
void create(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, const char* name, bool decated_memory = false);
void createImageView(VkImageViewType type, VkImageAspectFlags aspectFlags) noexcept;
void createSampler() noexcept;
void copyFromBuffer(class Buffer& buffer);
void copyToBuffer(class Buffer& buffer);
void transitionLayout(VkImageLayout new_layout);
virtual void destroy() noexcept;
inline VkImage get() noexcept { return _image; }
@@ -46,6 +58,11 @@ namespace mlx
virtual ~Image() = default;
private:
void destroySampler() noexcept;
void destroyImageView() noexcept;
inline void destroyCmdPool() noexcept { _transfer_cmd.destroy(); _pool.destroy(); }
private:
CmdBuffer _transfer_cmd;
CmdPool _pool;
@@ -55,6 +72,7 @@ namespace mlx
VkSampler _sampler = VK_NULL_HANDLE;
VkFormat _format;
VkImageTiling _tiling;
VkImageLayout _layout = VK_IMAGE_LAYOUT_UNDEFINED;
uint32_t _width = 0;
uint32_t _height = 0;
};