working on better command buffers management

This commit is contained in:
2023-12-20 16:35:52 +01:00
parent 66359574f9
commit b384ebec1b
12 changed files with 769 additions and 33 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:25:42 by maldavid #+# #+# */
/* Updated: 2023/12/16 18:44:48 by maldavid ### ########.fr */
/* Updated: 2023/12/17 20:01:55 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,6 +19,9 @@
namespace mlx
{
class Buffer;
class Image;
class CmdBuffer
{
public:
@@ -31,9 +34,15 @@ namespace mlx
submitted, // buffer has been submitted
};
enum class kind
{
single_time = 0,
long_time
};
public:
void init(class CmdManager* manager);
void init(class CmdPool* pool);
void init(kind type, class CmdManager* manager);
void init(kind type, class CmdPool* pool);
void destroy() noexcept;
void beginRecord(VkCommandBufferUsageFlags usage = 0);
@@ -43,6 +52,12 @@ namespace mlx
inline void reset() noexcept { vkResetCommandBuffer(_cmd_buffer, 0); }
void endRecord();
void bindVertexBuffer(Buffer& buffer) const noexcept;
void bindIndexBuffer(Buffer& buffer) const noexcept;
void copyBuffer(Buffer& dst, Buffer& src) const noexcept;
void copyBufferToImage(Buffer& buffer, Image& image) const noexcept;
void copyImagetoBuffer(Image& image, Buffer& buffer) const noexcept;
inline bool isInit() const noexcept { return _state != state::uninit; }
inline bool isReadyToBeUsed() const noexcept { return _state == state::ready; }
inline bool isRecording() const noexcept { return _state == state::recording; }
@@ -58,6 +73,7 @@ namespace mlx
VkCommandBuffer _cmd_buffer = VK_NULL_HANDLE;
class CmdPool* _pool = nullptr;
state _state = state::uninit;
kind _type;
};
}