mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 07:03:34 +00:00
fixing better vk command buffers management
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/16 20:44:29 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/05 23:12:45 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/07 01:19:10 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#define __MLX_COMMAND_RESOURCE__
|
||||
|
||||
#include <function.h>
|
||||
#include <core/UUID.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -28,18 +29,18 @@ namespace mlx
|
||||
};
|
||||
|
||||
public:
|
||||
CmdResource() = default;
|
||||
CmdResource() : _uuid() {}
|
||||
inline void recordedInCmdBuffer() noexcept { _state = state::in_cmd_buffer; }
|
||||
inline void removedFromCmdBuffer() noexcept
|
||||
{
|
||||
_state = state::out_cmd_buffer;
|
||||
if(_destroy_required && _destroy_required)
|
||||
if(_destroy_required && _destroyer)
|
||||
{
|
||||
_destroyer();
|
||||
_destroy_required = false;
|
||||
}
|
||||
}
|
||||
inline void setDestroyer(func::function<void(void)>&& functor) { _destroyer = functor; }
|
||||
inline void setDestroyer(func::function<void(void)> functor) { _destroyer = functor; }
|
||||
inline void requireDestroy() noexcept
|
||||
{
|
||||
if(_state == state::out_cmd_buffer && _destroyer)
|
||||
@@ -47,30 +48,15 @@ namespace mlx
|
||||
else
|
||||
_destroy_required = true;
|
||||
}
|
||||
inline uint64_t getUUID() const noexcept { return _uuid; }
|
||||
inline UUID getUUID() const noexcept { return _uuid; }
|
||||
virtual ~CmdResource() = default;
|
||||
|
||||
private:
|
||||
void realDestroy();
|
||||
|
||||
private:
|
||||
uint64_t _uuid = 0;
|
||||
UUID _uuid;
|
||||
state _state = state::out_cmd_buffer;
|
||||
func::function<void(void)> _destroyer;
|
||||
bool _destroy_required = false;
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<mlx::CmdResource>
|
||||
{
|
||||
std::size_t operator()(const mlx::CmdResource& res) const noexcept
|
||||
{
|
||||
return res.getUUID();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user