working on better command buffers management

This commit is contained in:
Kbz-8
2023-12-20 16:35:52 +01:00
parent b7424e7f92
commit 536cf4c420
12 changed files with 769 additions and 33 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/08 02:24:58 by maldavid #+# #+# */
/* Updated: 2023/12/14 14:37:08 by maldavid ### ########.fr */
/* Updated: 2023/12/17 17:23:56 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -38,7 +38,7 @@ namespace mlx
void setPixel(int x, int y, uint32_t color) noexcept;
int getPixel(int x, int y) noexcept;
inline void setDescriptor(DescriptorSet set) noexcept { _set = std::move(set); }
inline void setDescriptor(DescriptorSet&& set) noexcept { _set = set; }
inline VkDescriptorSet getSet() noexcept { return _set.isInit() ? _set.get() : VK_NULL_HANDLE; }
inline void updateSet(int binding) noexcept { _set.writeDescriptor(binding, getImageView(), getSampler()); _has_been_updated = true; }
inline bool hasBeenUpdated() const noexcept { return _has_been_updated; }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 11:59:07 by maldavid #+# #+# */
/* Updated: 2023/12/16 17:10:33 by maldavid ### ########.fr */
/* Updated: 2023/12/17 17:16:15 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -138,6 +138,16 @@ namespace mlx
void Image::create(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, const char* name, bool dedicated_memory)
{
CmdResource::setDestroyer([this]()
{
this->destroySampler();
this->destroyImageView();
if(_image != VK_NULL_HANDLE)
Render_Core::get().getAllocator().destroyImage(_allocation, _image);
_image = VK_NULL_HANDLE;
});
_width = width;
_height = height;
_format = format;
@@ -367,12 +377,7 @@ namespace mlx
void Image::destroy() noexcept
{
destroySampler();
destroyImageView();
if(_image != VK_NULL_HANDLE)
Render_Core::get().getAllocator().destroyImage(_allocation, _image);
_image = VK_NULL_HANDLE;
CmdResource::requireDestroy();
}
uint32_t formatSize(VkFormat format)

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 11:54:21 by maldavid #+# #+# */
/* Updated: 2023/12/15 21:44:30 by maldavid ### ########.fr */
/* Updated: 2023/12/17 17:13:23 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,6 +17,7 @@
#include <cstddef>
#include <vector>
#include <vma.h>
#include <renderer/core/cmd_resource.h>
#include <renderer/command/vk_cmd_buffer.h>
#include <renderer/command/vk_cmd_pool.h>
#include <mlx_profile.h>
@@ -25,7 +26,7 @@ namespace mlx
{
uint32_t formatSize(VkFormat format);
class Image
class Image : public CmdResource
{
friend class SwapChain;