mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-13 07:33:34 +00:00
fixing better vk command buffers management
This commit is contained in:
25
src/core/UUID.cpp
git.filemode.normal_file
25
src/core/UUID.cpp
git.filemode.normal_file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* UUID.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/06 11:26:37 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/06 11:28:15 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <core/UUID.h>
|
||||
#include <random>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
static std::random_device random_device;
|
||||
static std::mt19937_64 engine(random_device());
|
||||
static std::uniform_int_distribution<uint64_t> uniform_distribution;
|
||||
|
||||
UUID::UUID() : _uuid(uniform_distribution(engine)) {}
|
||||
UUID::UUID(uint64_t uuid) : _uuid(uuid) {}
|
||||
}
|
||||
48
src/core/UUID.h
git.filemode.normal_file
48
src/core/UUID.h
git.filemode.normal_file
@@ -0,0 +1,48 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* UUID.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/06 11:13:23 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/06 11:29:34 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_UUID__
|
||||
#define __MLX_UUID__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class UUID
|
||||
{
|
||||
public:
|
||||
UUID();
|
||||
UUID(uint64_t uuid);
|
||||
|
||||
inline operator uint64_t() const { return _uuid; }
|
||||
|
||||
private:
|
||||
uint64_t _uuid;
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename T> struct hash;
|
||||
|
||||
template<>
|
||||
struct hash<mlx::UUID>
|
||||
{
|
||||
std::size_t operator()(const mlx::UUID& uuid) const
|
||||
{
|
||||
return static_cast<uint64_t>(uuid);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/27 21:30:10 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/07 01:31:44 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -38,12 +38,19 @@ namespace mlx::core
|
||||
{
|
||||
_in->update();
|
||||
|
||||
Render_Core::get().getSingleTimeCmdManager().updateSingleTimesCmdBuffersSubmitState();
|
||||
|
||||
if(_loop_hook)
|
||||
_loop_hook(_param);
|
||||
|
||||
for(auto& gs : _graphics)
|
||||
gs->render();
|
||||
}
|
||||
for(auto& gs : _graphics)
|
||||
{
|
||||
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
|
||||
gs->getRenderer().getCmdBuffer(i).waitForExecution();
|
||||
}
|
||||
}
|
||||
|
||||
void* Application::newTexture(int w, int h)
|
||||
@@ -64,9 +71,16 @@ namespace mlx::core
|
||||
|
||||
void Application::destroyTexture(void* ptr)
|
||||
{
|
||||
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); // TODO : synchronize with another method than stopping all the GPU process
|
||||
if(ptr == nullptr)
|
||||
{
|
||||
core::error::report(e_kind::error, "wrong texture (NULL)");
|
||||
return;
|
||||
}
|
||||
Texture* texture = static_cast<Texture*>(ptr);
|
||||
texture->destroy();
|
||||
if(!texture->isInit())
|
||||
core::error::report(e_kind::error, "trying to destroy a texture that has already been destroyed");
|
||||
else
|
||||
texture->destroy();
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/24 08:56:14 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2024/01/07 01:27:09 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace mlx
|
||||
inline void texturePut(Texture* texture, int x, int y);
|
||||
inline void loadFont(const std::filesystem::path& filepath, float scale);
|
||||
|
||||
inline Renderer& getRenderer() { return *_renderer; }
|
||||
|
||||
~GraphicsSupport();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user