From bc1e0fbba9fdf30b0f8228fdd40f97a37ac5b7aa Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sun, 25 Feb 2024 08:04:44 +0100 Subject: [PATCH] adding std namespace to all libstd provided primitive types --- src/core/UUID.cpp | 4 +-- src/core/UUID.h | 6 ++-- src/core/application.cpp | 4 +-- src/core/application.h | 8 +++--- src/core/application.inl | 8 +++--- src/core/bridge.cpp | 2 +- src/core/fps.cpp | 6 ++-- src/core/fps.h | 12 ++++---- src/core/graphics.cpp | 2 +- src/core/graphics.h | 4 +-- src/core/graphics.inl | 4 +-- src/platform/inputs.cpp | 2 +- src/platform/inputs.h | 10 +++---- src/platform/window.cpp | 16 +++++------ src/platform/window.h | 4 +-- src/renderer/buffers/vk_ibo.h | 2 +- src/renderer/buffers/vk_ubo.cpp | 10 +++---- src/renderer/buffers/vk_ubo.h | 6 ++-- src/renderer/buffers/vk_vbo.cpp | 6 ++-- src/renderer/buffers/vk_vbo.h | 10 +++---- .../command/single_time_cmd_manager.h | 2 +- src/renderer/command/vk_cmd_buffer.cpp | 2 +- src/renderer/core/memory.cpp | 6 ++-- src/renderer/core/memory.h | 4 +-- src/renderer/core/render_core.cpp | 4 +-- src/renderer/core/render_core.h | 2 +- src/renderer/core/vk_device.cpp | 14 +++++----- src/renderer/core/vk_fence.cpp | 2 +- src/renderer/core/vk_instance.cpp | 8 +++--- src/renderer/core/vk_queues.cpp | 2 +- src/renderer/core/vk_queues.h | 4 +-- src/renderer/core/vk_validation_layers.cpp | 6 ++-- src/renderer/core/vk_validation_layers.h | 2 +- .../descriptors/vk_descriptor_set.cpp | 2 +- src/renderer/images/texture.cpp | 28 +++++++++---------- src/renderer/images/texture.h | 6 ++-- src/renderer/images/texture_atlas.cpp | 6 ++-- src/renderer/images/texture_atlas.h | 4 +-- src/renderer/images/vk_image.cpp | 12 ++++---- src/renderer/images/vk_image.h | 16 +++++------ src/renderer/pipeline/pipeline.cpp | 12 ++++---- src/renderer/pixel_put.cpp | 10 +++---- src/renderer/pixel_put.h | 10 +++---- src/renderer/renderer.cpp | 2 +- src/renderer/renderer.h | 8 +++--- src/renderer/renderpass/vk_framebuffer.h | 8 +++--- src/renderer/renderpass/vk_render_pass.cpp | 2 +- src/renderer/swapchain/vk_swapchain.cpp | 12 ++++---- src/renderer/swapchain/vk_swapchain.h | 2 +- src/renderer/texts/font.cpp | 10 +++---- src/renderer/texts/font.h | 4 +-- src/renderer/texts/font_library.h | 2 +- src/renderer/texts/text.cpp | 6 ++-- src/renderer/texts/text.h | 4 +-- src/renderer/texts/text_descriptor.cpp | 6 ++-- src/renderer/texts/text_descriptor.h | 6 ++-- src/renderer/texts/text_library.cpp | 4 ++- src/renderer/texts/text_library.h | 2 +- src/renderer/texts/text_manager.cpp | 6 ++-- src/renderer/texts/text_manager.h | 6 ++-- src/utils/icon_mlx.h | 2 +- 61 files changed, 193 insertions(+), 189 deletions(-) diff --git a/src/core/UUID.cpp b/src/core/UUID.cpp index 060f6ba..c7f2bb2 100644 --- a/src/core/UUID.cpp +++ b/src/core/UUID.cpp @@ -18,8 +18,8 @@ namespace mlx { static std::random_device random_device; static std::mt19937_64 engine(random_device()); - static std::uniform_int_distribution uniform_distribution; + static std::uniform_int_distribution uniform_distribution; UUID::UUID() : _uuid(uniform_distribution(engine)) {} - UUID::UUID(uint64_t uuid) : _uuid(uuid) {} + UUID::UUID(std::uint64_t uuid) : _uuid(uuid) {} } diff --git a/src/core/UUID.h b/src/core/UUID.h index aab3dc5..b26df3b 100644 --- a/src/core/UUID.h +++ b/src/core/UUID.h @@ -21,12 +21,12 @@ namespace mlx { public: UUID(); - UUID(uint64_t uuid); + UUID(std::uint64_t uuid); - inline operator uint64_t() const { return _uuid; } + inline operator std::uint64_t() const { return _uuid; } private: - uint64_t _uuid; + std::uint64_t _uuid; }; } diff --git a/src/core/application.cpp b/src/core/application.cpp index eb5ff83..7ae629b 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */ -/* Updated: 2024/01/26 11:56:34 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 07:52:04 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,7 +40,7 @@ namespace mlx::core void Application::run() noexcept { - while(_in->is_running()) + while(_in->isRunning()) { if(!_fps.update()) continue; diff --git a/src/core/application.h b/src/core/application.h index 0f0d00a..48717dc 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -40,20 +40,20 @@ namespace mlx::core inline void getScreenSize(void* win, int* w, int* h) noexcept; - inline void setFPSCap(uint32_t fps) noexcept; + inline void setFPSCap(std::uint32_t fps) noexcept; inline void* newGraphicsSuport(std::size_t w, std::size_t h, const char* title); inline void clearGraphicsSupport(void* win); inline void destroyGraphicsSupport(void* win); - inline void pixelPut(void* win, int x, int y, uint32_t color) const noexcept; - inline void stringPut(void* win, int x, int y, uint32_t color, char* str); + inline void pixelPut(void* win, int x, int y, std::uint32_t color) const noexcept; + inline void stringPut(void* win, int x, int y, std::uint32_t color, char* str); void* newTexture(int w, int h); void* newStbTexture(char* file, int* w, int* h); // stb textures are format managed by stb image (png, jpg, bpm, ...) inline void texturePut(void* win, void* img, int x, int y); inline int getTexturePixel(void* img, int x, int y); - inline void setTexturePixel(void* img, int x, int y, uint32_t color); + inline void setTexturePixel(void* img, int x, int y, std::uint32_t color); void destroyTexture(void* ptr); inline void loopHook(int (*f)(void*), void* param); diff --git a/src/core/application.inl b/src/core/application.inl index d5ff094..a3ccec1 100644 --- a/src/core/application.inl +++ b/src/core/application.inl @@ -79,7 +79,7 @@ namespace mlx::core *h = DM.h; } - void Application::setFPSCap(uint32_t fps) noexcept + void Application::setFPSCap(std::uint32_t fps) noexcept { _fps.setMaxFPS(fps); } @@ -120,14 +120,14 @@ namespace mlx::core _graphics[*static_cast(win)].reset(); } - void Application::pixelPut(void* win, int x, int y, uint32_t color) const noexcept + void Application::pixelPut(void* win, int x, int y, std::uint32_t color) const noexcept { MLX_PROFILE_FUNCTION(); CHECK_WINDOW_PTR(win); _graphics[*static_cast(win)]->pixelPut(x, y, color); } - void Application::stringPut(void* win, int x, int y, uint32_t color, char* str) + void Application::stringPut(void* win, int x, int y, std::uint32_t color, char* str) { MLX_PROFILE_FUNCTION(); CHECK_WINDOW_PTR(win); @@ -176,7 +176,7 @@ namespace mlx::core return texture->getPixel(x, y); } - void Application::setTexturePixel(void* img, int x, int y, uint32_t color) + void Application::setTexturePixel(void* img, int x, int y, std::uint32_t color) { MLX_PROFILE_FUNCTION(); CHECK_IMAGE_PTR(img, return); diff --git a/src/core/bridge.cpp b/src/core/bridge.cpp index f980141..9fb6b5a 100644 --- a/src/core/bridge.cpp +++ b/src/core/bridge.cpp @@ -300,7 +300,7 @@ extern "C" mlx::core::error::report(e_kind::error, "You cannot set a FPS cap to 0 (nice try)"); return 0; } - static_cast(mlx)->setFPSCap(static_cast(fps)); + static_cast(mlx)->setFPSCap(static_cast(fps)); return 0; } } diff --git a/src/core/fps.cpp b/src/core/fps.cpp index db76414..3c809cb 100644 --- a/src/core/fps.cpp +++ b/src/core/fps.cpp @@ -20,14 +20,14 @@ namespace mlx void FpsManager::init() { _timer = SDL_GetTicks64(); - _fps_before = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); - _fps_now = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); + _fps_before = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); + _fps_now = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); } bool FpsManager::update() { using namespace std::chrono_literals; - _fps_now = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); + _fps_now = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); if(SDL_GetTicks64() - _timer > 1000) _timer += 1000; diff --git a/src/core/fps.h b/src/core/fps.h index 80f25db..4433f07 100644 --- a/src/core/fps.h +++ b/src/core/fps.h @@ -24,17 +24,17 @@ namespace mlx void init(); bool update(); - inline void setMaxFPS(uint32_t fps) noexcept { _max_fps = fps; _ns = 1000000000.0 / fps; } + inline void setMaxFPS(std::uint32_t fps) noexcept { _max_fps = fps; _ns = 1000000000.0 / fps; } ~FpsManager() = default; private: double _ns = 1000000000.0 / 1'337'000.0; - uint64_t _timer = 0; - uint64_t _fps_before = 0; - uint64_t _fps_now = 0; - uint32_t _max_fps = 1'337'000; - uint32_t _fps_elapsed_time = 0; + std::uint64_t _timer = 0; + std::uint64_t _fps_before = 0; + std::uint64_t _fps_now = 0; + std::uint32_t _max_fps = 1'337'000; + std::uint32_t _fps_elapsed_time = 0; }; } diff --git a/src/core/graphics.cpp b/src/core/graphics.cpp index 5092c88..063a363 100644 --- a/src/core/graphics.cpp +++ b/src/core/graphics.cpp @@ -69,7 +69,7 @@ namespace mlx #ifdef GRAPHICS_MEMORY_DUMP // dump memory to file every two seconds - static uint64_t timer = SDL_GetTicks64(); + static std::uint64_t timer = SDL_GetTicks64(); if(SDL_GetTicks64() - timer > 2000) { Render_Core::get().getAllocator().dumpMemoryToJson(); diff --git a/src/core/graphics.h b/src/core/graphics.h index a2c18e7..204b4f3 100644 --- a/src/core/graphics.h +++ b/src/core/graphics.h @@ -45,8 +45,8 @@ namespace mlx void render() noexcept; inline void clearRenderData() noexcept; - inline void pixelPut(int x, int y, uint32_t color) noexcept; - inline void stringPut(int x, int y, uint32_t color, std::string str); + inline void pixelPut(int x, int y, std::uint32_t color) noexcept; + inline void stringPut(int x, int y, std::uint32_t color, std::string str); inline void texturePut(Texture* texture, int x, int y); inline void loadFont(const std::filesystem::path& filepath, float scale); diff --git a/src/core/graphics.inl b/src/core/graphics.inl index b485309..7fd7a94 100644 --- a/src/core/graphics.inl +++ b/src/core/graphics.inl @@ -27,13 +27,13 @@ namespace mlx _texture_manager.clear(); } - void GraphicsSupport::pixelPut(int x, int y, uint32_t color) noexcept + void GraphicsSupport::pixelPut(int x, int y, std::uint32_t color) noexcept { MLX_PROFILE_FUNCTION(); _pixel_put_pipeline.setPixel(x, y, color); } - void GraphicsSupport::stringPut(int x, int y, uint32_t color, std::string str) + void GraphicsSupport::stringPut(int x, int y, std::uint32_t color, std::string str) { MLX_PROFILE_FUNCTION(); std::pair res = _text_manager.registerText(x, y, color, str); diff --git a/src/platform/inputs.cpp b/src/platform/inputs.cpp index cc826f9..40adb8f 100644 --- a/src/platform/inputs.cpp +++ b/src/platform/inputs.cpp @@ -33,7 +33,7 @@ namespace mlx _yRel = _event.motion.yrel; } - uint32_t id = _event.window.windowID; + std::uint32_t id = _event.window.windowID; if(_events_hooks.find(id) == _events_hooks.end()) continue; auto& hooks = _events_hooks[id]; diff --git a/src/platform/inputs.h b/src/platform/inputs.h index e550009..6a575bb 100644 --- a/src/platform/inputs.h +++ b/src/platform/inputs.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */ -/* Updated: 2024/01/16 07:59:08 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 07:51:55 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,7 +44,7 @@ namespace mlx inline int getXRel() const noexcept { return _xRel; } inline int getYRel() const noexcept { return _yRel; } - inline bool is_running() const noexcept { return !_end; } + inline bool isRunning() const noexcept { return !_end; } inline constexpr void finish() noexcept { _end = true; } inline void addWindow(std::shared_ptr window) @@ -53,7 +53,7 @@ namespace mlx _events_hooks[window->getID()] = {}; } - inline void onEvent(uint32_t id, int event, int (*funct_ptr)(int, void*), void* param) noexcept + inline void onEvent(std::uint32_t id, int event, int (*funct_ptr)(int, void*), void* param) noexcept { _events_hooks[id][event].hook = funct_ptr; _events_hooks[id][event].param = param; @@ -62,8 +62,8 @@ namespace mlx ~Input() = default; private: - std::unordered_map> _windows; - std::unordered_map> _events_hooks; + std::unordered_map> _windows; + std::unordered_map> _events_hooks; SDL_Event _event; int _x = 0; diff --git a/src/platform/window.cpp b/src/platform/window.cpp index 44827ac..65e94d9 100644 --- a/src/platform/window.cpp +++ b/src/platform/window.cpp @@ -17,15 +17,15 @@ namespace mlx { #if SDL_BYTEORDER == SDL_BIG_ENDIAN - constexpr const uint32_t rmask = 0xff000000; - constexpr const uint32_t gmask = 0x00ff0000; - constexpr const uint32_t bmask = 0x0000ff00; - constexpr const uint32_t amask = 0x000000ff; + constexpr const std::uint32_t rmask = 0xff000000; + constexpr const std::uint32_t gmask = 0x00ff0000; + constexpr const std::uint32_t bmask = 0x0000ff00; + constexpr const std::uint32_t amask = 0x000000ff; #else - constexpr const uint32_t rmask = 0x000000ff; - constexpr const uint32_t gmask = 0x0000ff00; - constexpr const uint32_t bmask = 0x00ff0000; - constexpr const uint32_t amask = 0xff000000; + constexpr const std::uint32_t rmask = 0x000000ff; + constexpr const std::uint32_t gmask = 0x0000ff00; + constexpr const std::uint32_t bmask = 0x00ff0000; + constexpr const std::uint32_t amask = 0xff000000; #endif MLX_Window::MLX_Window(std::size_t w, std::size_t h, const std::string& title) : _width(w), _height(h) diff --git a/src/platform/window.h b/src/platform/window.h index 876c14b..dfe0924 100644 --- a/src/platform/window.h +++ b/src/platform/window.h @@ -27,7 +27,7 @@ namespace mlx inline SDL_Window* getNativeWindow() const noexcept { return _win; } inline int getWidth() const noexcept { return _width; } inline int getHeight() const noexcept { return _height; } - inline uint32_t getID() const noexcept { return _id; } + inline std::uint32_t getID() const noexcept { return _id; } void destroy() noexcept; @@ -38,7 +38,7 @@ namespace mlx SDL_Window* _win = nullptr; int _width = 0; int _height = 0; - uint32_t _id = -1; + std::uint32_t _id = -1; }; } diff --git a/src/renderer/buffers/vk_ibo.h b/src/renderer/buffers/vk_ibo.h index f368e13..7acc988 100644 --- a/src/renderer/buffers/vk_ibo.h +++ b/src/renderer/buffers/vk_ibo.h @@ -23,7 +23,7 @@ namespace mlx class C_IBO : public Buffer { public: - inline void create(uint32_t size, const uint16_t* data, const char* name) { Buffer::create(Buffer::kind::constant, size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, name, data); } + inline void create(std::uint32_t size, const std::uint16_t* data, const char* name) { Buffer::create(Buffer::kind::constant, size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, name, data); } inline void bind(Renderer& renderer) noexcept { renderer.getActiveCmdBuffer().bindIndexBuffer(*this); } }; } diff --git a/src/renderer/buffers/vk_ubo.cpp b/src/renderer/buffers/vk_ubo.cpp index 686663f..996516c 100644 --- a/src/renderer/buffers/vk_ubo.cpp +++ b/src/renderer/buffers/vk_ubo.cpp @@ -17,7 +17,7 @@ namespace mlx { - void UBO::create(Renderer* renderer, uint32_t size, [[maybe_unused]] const char* name) + void UBO::create(Renderer* renderer, std::uint32_t size, [[maybe_unused]] const char* name) { MLX_PROFILE_FUNCTION(); _renderer = renderer; @@ -37,16 +37,16 @@ namespace mlx } } - void UBO::setData(uint32_t size, const void* data) + void UBO::setData(std::uint32_t size, const void* data) { MLX_PROFILE_FUNCTION(); - std::memcpy(_maps[_renderer->getActiveImageIndex()], data, static_cast(size)); + std::memcpy(_maps[_renderer->getActiveImageIndex()], data, static_cast(size)); } - void UBO::setDynamicData(uint32_t size, const void* data) + void UBO::setDynamicData(std::uint32_t size, const void* data) { MLX_PROFILE_FUNCTION(); - std::memcpy(_maps[_renderer->getActiveImageIndex()], data, static_cast(size)); + std::memcpy(_maps[_renderer->getActiveImageIndex()], data, static_cast(size)); _buffers[_renderer->getActiveImageIndex()].flush(); } diff --git a/src/renderer/buffers/vk_ubo.h b/src/renderer/buffers/vk_ubo.h index 6dcdc21..74a7fd9 100644 --- a/src/renderer/buffers/vk_ubo.h +++ b/src/renderer/buffers/vk_ubo.h @@ -23,10 +23,10 @@ namespace mlx class UBO { public: - void create(class Renderer* renderer, uint32_t size, const char* name); + void create(class Renderer* renderer, std::uint32_t size, const char* name); - void setData(uint32_t size, const void* data); - void setDynamicData(uint32_t size, const void* data); + void setData(std::uint32_t size, const void* data); + void setDynamicData(std::uint32_t size, const void* data); void destroy() noexcept; diff --git a/src/renderer/buffers/vk_vbo.cpp b/src/renderer/buffers/vk_vbo.cpp index 8ceab7d..ec17a88 100644 --- a/src/renderer/buffers/vk_vbo.cpp +++ b/src/renderer/buffers/vk_vbo.cpp @@ -15,7 +15,7 @@ namespace mlx { - void VBO::setData(uint32_t size, const void* data) + void VBO::setData(std::uint32_t size, const void* data) { if(size > getSize()) { @@ -28,11 +28,11 @@ namespace mlx void* temp = nullptr; mapMem(&temp); - std::memcpy(temp, data, static_cast(size)); + std::memcpy(temp, data, static_cast(size)); unmapMem(); } - void D_VBO::setData(uint32_t size, const void* data) + void D_VBO::setData(std::uint32_t size, const void* data) { if(size > getSize()) { diff --git a/src/renderer/buffers/vk_vbo.h b/src/renderer/buffers/vk_vbo.h index 9079eea..88d0023 100644 --- a/src/renderer/buffers/vk_vbo.h +++ b/src/renderer/buffers/vk_vbo.h @@ -22,23 +22,23 @@ namespace mlx class VBO : public Buffer { public: - inline void create(uint32_t size, const void* data, const char* name) { Buffer::create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, name, data); } - void setData(uint32_t size, const void* data); + inline void create(std::uint32_t size, const void* data, const char* name) { Buffer::create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, name, data); } + void setData(std::uint32_t size, const void* data); inline void bind(Renderer& renderer) noexcept { renderer.getActiveCmdBuffer().bindVertexBuffer(*this); } }; class D_VBO : public Buffer { public: - inline void create(uint32_t size, const void* data, const char* name) { Buffer::create(Buffer::kind::dynamic_device_local, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, name, data); } - void setData(uint32_t size, const void* data); + inline void create(std::uint32_t size, const void* data, const char* name) { Buffer::create(Buffer::kind::dynamic_device_local, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, name, data); } + void setData(std::uint32_t size, const void* data); inline void bind(Renderer& renderer) noexcept { renderer.getActiveCmdBuffer().bindVertexBuffer(*this); } }; class C_VBO : public Buffer { public: - inline void create(uint32_t size, const void* data, const char* name) { Buffer::create(Buffer::kind::constant, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, name, data); } + inline void create(std::uint32_t size, const void* data, const char* name) { Buffer::create(Buffer::kind::constant, size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, name, data); } inline void bind(Renderer& renderer) noexcept { renderer.getActiveCmdBuffer().bindVertexBuffer(*this); } }; } diff --git a/src/renderer/command/single_time_cmd_manager.h b/src/renderer/command/single_time_cmd_manager.h index ea7330c..271fdf9 100644 --- a/src/renderer/command/single_time_cmd_manager.h +++ b/src/renderer/command/single_time_cmd_manager.h @@ -39,7 +39,7 @@ namespace mlx ~SingleTimeCmdManager() = default; - inline static constexpr const uint8_t BASE_POOL_SIZE = 16; + inline static constexpr const std::uint8_t BASE_POOL_SIZE = 16; private: std::vector _buffers; diff --git a/src/renderer/command/vk_cmd_buffer.cpp b/src/renderer/command/vk_cmd_buffer.cpp index 1ffc118..d1b208b 100644 --- a/src/renderer/command/vk_cmd_buffer.cpp +++ b/src/renderer/command/vk_cmd_buffer.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:26:06 by maldavid #+# #+# */ -/* Updated: 2024/01/10 18:30:04 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 08:02:26 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/renderer/core/memory.cpp b/src/renderer/core/memory.cpp index ccb8ed0..8a5c317 100644 --- a/src/renderer/core/memory.cpp +++ b/src/renderer/core/memory.cpp @@ -94,7 +94,7 @@ namespace mlx core::error::report(e_kind::fatal_error, "Graphics allocator : failed to allocate a buffer, %s", RCore::verbaliseResultVk(res)); if(name != nullptr) { - Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_BUFFER, (uint64_t)buffer, name); + Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_BUFFER, (std::uint64_t)buffer, name); vmaSetAllocationName(_allocator, allocation, name); } #ifdef DEBUG @@ -124,7 +124,7 @@ namespace mlx core::error::report(e_kind::fatal_error, "Graphics allocator : failed to allocate an image, %s", RCore::verbaliseResultVk(res)); if(name != nullptr) { - Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_IMAGE, (uint64_t)image, name); + Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_IMAGE, (std::uint64_t)image, name); vmaSetAllocationName(_allocator, allocation, name); } #ifdef DEBUG @@ -161,7 +161,7 @@ namespace mlx void GPUallocator::dumpMemoryToJson() { - static uint32_t id = 0; + static std::uint32_t id = 0; std::string name("memory_dump"); name.append(std::to_string(id) + ".json"); std::ofstream file(name); diff --git a/src/renderer/core/memory.h b/src/renderer/core/memory.h index f977ace..077fd1b 100644 --- a/src/renderer/core/memory.h +++ b/src/renderer/core/memory.h @@ -44,8 +44,8 @@ namespace mlx private: VmaAllocator _allocator; - uint32_t _active_buffers_allocations = 0; - uint32_t _active_images_allocations = 0; + std::uint32_t _active_buffers_allocations = 0; + std::uint32_t _active_images_allocations = 0; }; } diff --git a/src/renderer/core/render_core.cpp b/src/renderer/core/render_core.cpp index 9341f6e..1de3720 100644 --- a/src/renderer/core/render_core.cpp +++ b/src/renderer/core/render_core.cpp @@ -28,12 +28,12 @@ namespace mlx { namespace RCore { - std::optional findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties, bool error) + std::optional findMemoryType(std::uint32_t typeFilter, VkMemoryPropertyFlags properties, bool error) { VkPhysicalDeviceMemoryProperties memProperties; vkGetPhysicalDeviceMemoryProperties(Render_Core::get().getDevice().getPhysicalDevice(), &memProperties); - for(uint32_t i = 0; i < memProperties.memoryTypeCount; i++) + for(std::uint32_t i = 0; i < memProperties.memoryTypeCount; i++) { if((typeFilter & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & properties) == properties) return i; diff --git a/src/renderer/core/render_core.h b/src/renderer/core/render_core.h index aa279f9..cf4aae5 100644 --- a/src/renderer/core/render_core.h +++ b/src/renderer/core/render_core.h @@ -33,7 +33,7 @@ namespace mlx { namespace RCore { - std::optional findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties, bool error = true); + std::optional findMemoryType(std::uint32_t typeFilter, VkMemoryPropertyFlags properties, bool error = true); const char* verbaliseResultVk(VkResult result); VkPipelineStageFlags accessFlagsToPipelineStage(VkAccessFlags accessFlags, VkPipelineStageFlags stageFlags); } diff --git a/src/renderer/core/vk_device.cpp b/src/renderer/core/vk_device.cpp index befcba2..37d5ae1 100644 --- a/src/renderer/core/vk_device.cpp +++ b/src/renderer/core/vk_device.cpp @@ -31,10 +31,10 @@ namespace mlx Queues::QueueFamilyIndices indices = Render_Core::get().getQueue().getFamilies(); std::vector queueCreateInfos; - std::set uniqueQueueFamilies = { indices.graphicsFamily.value(), indices.presentFamily.value() }; + std::set uniqueQueueFamilies = { indices.graphicsFamily.value(), indices.presentFamily.value() }; float queuePriority = 1.0f; - for(uint32_t queueFamily : uniqueQueueFamilies) + for(std::uint32_t queueFamily : uniqueQueueFamilies) { VkDeviceQueueCreateInfo queueCreateInfo{}; queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; @@ -49,12 +49,12 @@ namespace mlx VkDeviceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; - createInfo.queueCreateInfoCount = static_cast(queueCreateInfos.size()); + createInfo.queueCreateInfoCount = static_cast(queueCreateInfos.size()); createInfo.pQueueCreateInfos = queueCreateInfos.data(); createInfo.pEnabledFeatures = &deviceFeatures; - createInfo.enabledExtensionCount = static_cast(deviceExtensions.size()); + createInfo.enabledExtensionCount = static_cast(deviceExtensions.size()); createInfo.ppEnabledExtensionNames = deviceExtensions.data(); createInfo.enabledLayerCount = 0; @@ -68,7 +68,7 @@ namespace mlx void Device::pickPhysicalDevice() { - uint32_t deviceCount = 0; + std::uint32_t deviceCount = 0; vkEnumeratePhysicalDevices(Render_Core::get().getInstance().get(), &deviceCount, nullptr); if(deviceCount == 0) @@ -113,7 +113,7 @@ namespace mlx Queues::QueueFamilyIndices indices = Render_Core::get().getQueue().findQueueFamilies(device, surface); bool extensionsSupported = checkDeviceExtensionSupport(device); - uint32_t formatCount = 0; + std::uint32_t formatCount = 0; if(extensionsSupported) vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount, nullptr); @@ -144,7 +144,7 @@ namespace mlx bool Device::checkDeviceExtensionSupport(VkPhysicalDevice device) { - uint32_t extensionCount; + std::uint32_t extensionCount; vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionCount, nullptr); std::vector availableExtensions(extensionCount); diff --git a/src/renderer/core/vk_fence.cpp b/src/renderer/core/vk_fence.cpp index 2e2d5a4..f63df12 100644 --- a/src/renderer/core/vk_fence.cpp +++ b/src/renderer/core/vk_fence.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/02 17:53:06 by maldavid #+# #+# */ -/* Updated: 2024/01/06 16:57:26 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 08:02:45 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/renderer/core/vk_instance.cpp b/src/renderer/core/vk_instance.cpp index 013e387..040f9d8 100644 --- a/src/renderer/core/vk_instance.cpp +++ b/src/renderer/core/vk_instance.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:04:21 by maldavid #+# #+# */ -/* Updated: 2024/02/24 04:31:00 by maldavid ### ########.fr */ +/* Updated: 2024/02/24 21:10:32 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ namespace mlx VkApplicationInfo appInfo{}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.pEngineName = "MacroLibX"; - appInfo.engineVersion = VK_MAKE_VERSION(1, 2, 1); + appInfo.engineVersion = VK_MAKE_VERSION(1, 3, 1); appInfo.apiVersion = VK_API_VERSION_1_2; auto extensions = getRequiredExtensions(); @@ -30,7 +30,7 @@ namespace mlx VkInstanceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; createInfo.pApplicationInfo = &appInfo; - createInfo.enabledExtensionCount = static_cast(extensions.size()); + createInfo.enabledExtensionCount = static_cast(extensions.size()); createInfo.ppEnabledExtensionNames = extensions.data(); createInfo.enabledLayerCount = 0; // will be replaced if validation layers are enabled createInfo.pNext = nullptr; @@ -40,7 +40,7 @@ namespace mlx { if(Render_Core::get().getLayers().checkValidationLayerSupport()) { - createInfo.enabledLayerCount = static_cast(validationLayers.size()); + createInfo.enabledLayerCount = static_cast(validationLayers.size()); createInfo.ppEnabledLayerNames = validationLayers.data(); Render_Core::get().getLayers().populateDebugMessengerCreateInfo(debugCreateInfo); createInfo.pNext = static_cast(&debugCreateInfo); diff --git a/src/renderer/core/vk_queues.cpp b/src/renderer/core/vk_queues.cpp index 7928cc3..89cfb3d 100644 --- a/src/renderer/core/vk_queues.cpp +++ b/src/renderer/core/vk_queues.cpp @@ -18,7 +18,7 @@ namespace mlx { Queues::QueueFamilyIndices Queues::findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface) { - uint32_t queueFamilyCount = 0; + std::uint32_t queueFamilyCount = 0; vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, nullptr); std::vector queueFamilies(queueFamilyCount); diff --git a/src/renderer/core/vk_queues.h b/src/renderer/core/vk_queues.h index 4def156..d3d1c28 100644 --- a/src/renderer/core/vk_queues.h +++ b/src/renderer/core/vk_queues.h @@ -26,8 +26,8 @@ namespace mlx public: struct QueueFamilyIndices { - std::optional graphicsFamily; - std::optional presentFamily; + std::optional graphicsFamily; + std::optional presentFamily; inline bool isComplete() { return graphicsFamily.has_value() && presentFamily.has_value(); } }; diff --git a/src/renderer/core/vk_validation_layers.cpp b/src/renderer/core/vk_validation_layers.cpp index 5b0cbea..e19553a 100644 --- a/src/renderer/core/vk_validation_layers.cpp +++ b/src/renderer/core/vk_validation_layers.cpp @@ -25,7 +25,7 @@ namespace mlx if constexpr(!enableValidationLayers) return; - uint32_t extensionCount; + std::uint32_t extensionCount; vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr); std::vector extensions(extensionCount); vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions.data()); @@ -56,7 +56,7 @@ namespace mlx bool ValidationLayers::checkValidationLayerSupport() { - uint32_t layerCount; + std::uint32_t layerCount; vkEnumerateInstanceLayerProperties(&layerCount, nullptr); std::vector availableLayers(layerCount); @@ -73,7 +73,7 @@ namespace mlx }); } - VkResult ValidationLayers::setDebugUtilsObjectNameEXT(VkObjectType object_type, uint64_t object_handle, const char* object_name) + VkResult ValidationLayers::setDebugUtilsObjectNameEXT(VkObjectType object_type, std::uint64_t object_handle, const char* object_name) { if(!real_vkSetDebugUtilsObjectNameEXT) return VK_ERROR_EXTENSION_NOT_PRESENT; diff --git a/src/renderer/core/vk_validation_layers.h b/src/renderer/core/vk_validation_layers.h index 5ea19b8..7247ede 100644 --- a/src/renderer/core/vk_validation_layers.h +++ b/src/renderer/core/vk_validation_layers.h @@ -29,7 +29,7 @@ namespace mlx bool checkValidationLayerSupport(); void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo); - VkResult setDebugUtilsObjectNameEXT(VkObjectType object_type, uint64_t object_handle, const char* object_name); + VkResult setDebugUtilsObjectNameEXT(VkObjectType object_type, std::uint64_t object_handle, const char* object_name); ~ValidationLayers() = default; diff --git a/src/renderer/descriptors/vk_descriptor_set.cpp b/src/renderer/descriptors/vk_descriptor_set.cpp index ae4662b..819ba25 100644 --- a/src/renderer/descriptors/vk_descriptor_set.cpp +++ b/src/renderer/descriptors/vk_descriptor_set.cpp @@ -36,7 +36,7 @@ namespace mlx VkDescriptorSetAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; allocInfo.descriptorPool = _pool->get(); - allocInfo.descriptorSetCount = static_cast(MAX_FRAMES_IN_FLIGHT); + allocInfo.descriptorSetCount = static_cast(MAX_FRAMES_IN_FLIGHT); allocInfo.pSetLayouts = layouts.data(); VkResult res = vkAllocateDescriptorSets(device, &allocInfo, _desc_set.data()); diff --git a/src/renderer/images/texture.cpp b/src/renderer/images/texture.cpp index 1fe116f..cded232 100644 --- a/src/renderer/images/texture.cpp +++ b/src/renderer/images/texture.cpp @@ -30,7 +30,7 @@ namespace mlx { - void Texture::create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format, const char* name, bool dedicated_memory) + void Texture::create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory) { MLX_PROFILE_FUNCTION(); Image::create(width, height, format, TILING, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, name, dedicated_memory); @@ -45,15 +45,15 @@ namespace mlx {{0, height}, {1.f, 1.f, 1.f, 1.f}, {0.0f, 1.0f}} }; - std::vector indexData = { 0, 1, 2, 2, 3, 0 }; + std::vector indexData = { 0, 1, 2, 2, 3, 0 }; #ifdef DEBUG _vbo.create(sizeof(Vertex) * vertexData.size(), vertexData.data(), name); - _ibo.create(sizeof(uint16_t) * indexData.size(), indexData.data(), name); + _ibo.create(sizeof(std::uint16_t) * indexData.size(), indexData.data(), name); _name = name; #else _vbo.create(sizeof(Vertex) * vertexData.size(), vertexData.data(), nullptr); - _ibo.create(sizeof(uint16_t) * indexData.size(), indexData.data(), nullptr); + _ibo.create(sizeof(std::uint16_t) * indexData.size(), indexData.data(), nullptr); #endif Buffer staging_buffer; @@ -68,7 +68,7 @@ namespace mlx } else { - std::vector default_pixels(width * height, 0x00000000); + std::vector default_pixels(width * height, 0x00000000); #ifdef DEBUG staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, name, default_pixels.data()); #else @@ -79,10 +79,10 @@ namespace mlx staging_buffer.destroy(); } - void Texture::setPixel(int x, int y, uint32_t color) noexcept + void Texture::setPixel(int x, int y, std::uint32_t color) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > getWidth() || static_cast(y) > getHeight()) + if(x < 0 || y < 0 || static_cast(x) > getWidth() || static_cast(y) > getHeight()) return; if(_map == nullptr) openCPUmap(); @@ -93,13 +93,13 @@ namespace mlx int Texture::getPixel(int x, int y) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > getWidth() || static_cast(y) > getHeight()) + if(x < 0 || y < 0 || static_cast(x) > getWidth() || static_cast(y) > getHeight()) return 0; if(_map == nullptr) openCPUmap(); - uint32_t color = _cpu_map[(y * getWidth()) + x]; - uint8_t* bytes = reinterpret_cast(&color); - uint8_t tmp = bytes[0]; + std::uint32_t color = _cpu_map[(y * getWidth()) + x]; + std::uint8_t* bytes = reinterpret_cast(&color); + std::uint8_t tmp = bytes[0]; bytes[0] = bytes[2]; bytes[2] = tmp; return *reinterpret_cast(bytes); @@ -123,7 +123,7 @@ namespace mlx #endif Image::copyToBuffer(*_buf_map); _buf_map->mapMem(&_map); - _cpu_map = std::vector(getWidth() * getHeight(), 0); + _cpu_map = std::vector(getWidth() * getHeight(), 0); std::memcpy(_cpu_map.data(), _map, size); #ifdef DEBUG core::error::report(e_kind::message, "Texture : mapped CPU memory using staging buffer"); @@ -152,7 +152,7 @@ namespace mlx vkCmdPushConstants(cmd.get(), renderer.getPipeline().getPipelineLayout(), VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(translate), &translate); sets[1] = _set.get(); vkCmdBindDescriptorSets(renderer.getActiveCmdBuffer().get(), VK_PIPELINE_BIND_POINT_GRAPHICS, renderer.getPipeline().getPipelineLayout(), 0, sets.size(), sets.data(), 0, nullptr); - vkCmdDrawIndexed(cmd.get(), static_cast(_ibo.getSize() / sizeof(uint16_t)), 1, 0, 0, 0); + vkCmdDrawIndexed(cmd.get(), static_cast(_ibo.getSize() / sizeof(std::uint16_t)), 1, 0, 0, 0); } void Texture::destroy() noexcept @@ -171,7 +171,7 @@ namespace mlx MLX_PROFILE_FUNCTION(); Texture texture; int channels; - uint8_t* data = nullptr; + std::uint8_t* data = nullptr; std::string filename = file.string(); if(!std::filesystem::exists(std::move(file))) diff --git a/src/renderer/images/texture.h b/src/renderer/images/texture.h index 5558886..be48db0 100644 --- a/src/renderer/images/texture.h +++ b/src/renderer/images/texture.h @@ -31,11 +31,11 @@ namespace mlx public: Texture() = default; - void create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false); + void create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false); void render(std::array& sets, class Renderer& renderer, int x, int y); void destroy() noexcept override; - void setPixel(int x, int y, uint32_t color) noexcept; + void setPixel(int x, int y, std::uint32_t color) noexcept; int getPixel(int x, int y) noexcept; inline void setDescriptor(DescriptorSet&& set) noexcept { _set = set; } @@ -56,7 +56,7 @@ namespace mlx std::string _name; #endif DescriptorSet _set; - std::vector _cpu_map; + std::vector _cpu_map; std::optional _buf_map = std::nullopt; void* _map = nullptr; bool _has_been_modified = false; diff --git a/src/renderer/images/texture_atlas.cpp b/src/renderer/images/texture_atlas.cpp index c03d712..fc06315 100644 --- a/src/renderer/images/texture_atlas.cpp +++ b/src/renderer/images/texture_atlas.cpp @@ -20,7 +20,7 @@ namespace mlx { - void TextureAtlas::create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format, const char* name, bool dedicated_memory) + void TextureAtlas::create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory) { Image::create(width, height, format, TILING, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, name, dedicated_memory); Image::createImageView(VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT); @@ -39,13 +39,13 @@ namespace mlx staging_buffer.destroy(); } - void TextureAtlas::render(Renderer& renderer, int x, int y, uint32_t ibo_size) const + void TextureAtlas::render(Renderer& renderer, int x, int y, std::uint32_t ibo_size) const { auto cmd = renderer.getActiveCmdBuffer().get(); glm::vec2 translate(x, y); vkCmdPushConstants(cmd, renderer.getPipeline().getPipelineLayout(), VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(translate), &translate); - vkCmdDrawIndexed(cmd, ibo_size / sizeof(uint16_t), 1, 0, 0, 0); + vkCmdDrawIndexed(cmd, ibo_size / sizeof(std::uint16_t), 1, 0, 0, 0); } void TextureAtlas::destroy() noexcept diff --git a/src/renderer/images/texture_atlas.h b/src/renderer/images/texture_atlas.h index bc465d7..2165879 100644 --- a/src/renderer/images/texture_atlas.h +++ b/src/renderer/images/texture_atlas.h @@ -25,8 +25,8 @@ namespace mlx public: TextureAtlas() = default; - void create(uint8_t* pixels, uint32_t width, uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false); - void render(class Renderer& renderer, int x, int y, uint32_t ibo_size) const; + void create(std::uint8_t* pixels, std::uint32_t width, std::uint32_t height, VkFormat format, const char* name, bool dedicated_memory = false); + void render(class Renderer& renderer, int x, int y, std::uint32_t ibo_size) const; void destroy() noexcept override; inline void setDescriptor(DescriptorSet&& set) noexcept { _set = set; } diff --git a/src/renderer/images/vk_image.cpp b/src/renderer/images/vk_image.cpp index 412387e..3eecbf2 100644 --- a/src/renderer/images/vk_image.cpp +++ b/src/renderer/images/vk_image.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/01/25 11:59:07 by maldavid #+# #+# */ -/* Updated: 2024/01/18 09:47:26 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 08:03:47 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ namespace mlx } } - VkFormat bitsToFormat(uint32_t bits) + VkFormat bitsToFormat(std::uint32_t bits) { switch(bits) { @@ -99,7 +99,7 @@ namespace mlx return accessMask; } - void Image::create(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, const char* name, bool dedicated_memory) + void Image::create(std::uint32_t width, std::uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, const char* name, bool dedicated_memory) { _width = width; _height = height; @@ -153,7 +153,7 @@ namespace mlx core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image view, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG else - Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)_image_view, _name.c_str()); + Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_IMAGE_VIEW, (std::uint64_t)_image_view, _name.c_str()); #endif } @@ -177,7 +177,7 @@ namespace mlx core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image sampler, %s", RCore::verbaliseResultVk(res)); #ifdef DEBUG else - Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_SAMPLER, (uint64_t)_sampler, _name.c_str()); + Render_Core::get().getLayers().setDebugUtilsObjectNameEXT(VK_OBJECT_TYPE_SAMPLER, (std::uint64_t)_sampler, _name.c_str()); #endif } @@ -264,7 +264,7 @@ namespace mlx //CmdResource::requireDestroy(); } - uint32_t formatSize(VkFormat format) + std::uint32_t formatSize(VkFormat format) { switch(format) { diff --git a/src/renderer/images/vk_image.h b/src/renderer/images/vk_image.h index 76c2108..017ec41 100644 --- a/src/renderer/images/vk_image.h +++ b/src/renderer/images/vk_image.h @@ -26,10 +26,10 @@ namespace mlx { - uint32_t formatSize(VkFormat format); + std::uint32_t formatSize(VkFormat format); bool isStencilFormat(VkFormat format); bool isDepthFormat(VkFormat format); - VkFormat bitsToFormat(uint32_t bits); + VkFormat bitsToFormat(std::uint32_t bits); VkPipelineStageFlags layoutToAccessMask(VkImageLayout layout, bool isDestination); class Image : public CmdResource @@ -39,7 +39,7 @@ namespace mlx public: Image() = default; - inline void create(VkImage image, VkFormat format, uint32_t width, uint32_t height, VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED) noexcept + inline void create(VkImage image, VkFormat format, std::uint32_t width, std::uint32_t height, VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED) noexcept { _image = image; _format = format; @@ -47,7 +47,7 @@ namespace mlx _height = height; _layout = layout; } - void create(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, const char* name, bool decated_memory = false); + void create(std::uint32_t width, std::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); @@ -62,8 +62,8 @@ namespace mlx inline VkImageTiling getTiling() const noexcept { return _tiling; } inline VkImageLayout getLayout() const noexcept { return _layout; } inline VkSampler getSampler() const noexcept { return _sampler; } - inline uint32_t getWidth() const noexcept { return _width; } - inline uint32_t getHeight() const noexcept { return _height; } + inline std::uint32_t getWidth() const noexcept { return _width; } + inline std::uint32_t getHeight() const noexcept { return _height; } inline bool isInit() const noexcept { return _image != VK_NULL_HANDLE; } virtual ~Image() = default; @@ -83,8 +83,8 @@ namespace mlx VkFormat _format; VkImageTiling _tiling; VkImageLayout _layout = VK_IMAGE_LAYOUT_UNDEFINED; - uint32_t _width = 0; - uint32_t _height = 0; + std::uint32_t _width = 0; + std::uint32_t _height = 0; }; } diff --git a/src/renderer/pipeline/pipeline.cpp b/src/renderer/pipeline/pipeline.cpp index 06ebfd3..00291fc 100644 --- a/src/renderer/pipeline/pipeline.cpp +++ b/src/renderer/pipeline/pipeline.cpp @@ -49,7 +49,7 @@ namespace mlx gl_Position = uProj.mat * vec4(pos.x, pos.y, 0.0, 1.0); } */ - const std::vector vertex_shader = { // precompiled vertex shader + const std::vector vertex_shader = { // precompiled vertex shader 0x07230203,0x00010000,0x0008000b,0x0000003b,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, 0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015, @@ -124,7 +124,7 @@ namespace mlx fColor = process_color; } */ - const std::vector fragment_shader = { // pre compiled fragment shader + const std::vector fragment_shader = { // pre compiled fragment shader 0x07230203,0x00010000,0x0008000b,0x0000002c,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x0000002a,0x00030010, @@ -164,7 +164,7 @@ namespace mlx { VkShaderModuleCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - createInfo.codeSize = vertex_shader.size() * sizeof(uint32_t); + createInfo.codeSize = vertex_shader.size() * sizeof(std::uint32_t); createInfo.pCode = vertex_shader.data(); VkShaderModule vshader; if(vkCreateShaderModule(Render_Core::get().getDevice().get(), &createInfo, nullptr, &vshader) != VK_SUCCESS) @@ -176,7 +176,7 @@ namespace mlx push_constant.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - createInfo.codeSize = fragment_shader.size() * sizeof(uint32_t); + createInfo.codeSize = fragment_shader.size() * sizeof(std::uint32_t); createInfo.pCode = fragment_shader.data(); VkShaderModule fshader; if(vkCreateShaderModule(Render_Core::get().getDevice().get(), &createInfo, nullptr, &fshader) != VK_SUCCESS) @@ -203,7 +203,7 @@ namespace mlx vertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInputStateCreateInfo.vertexBindingDescriptionCount = 1; vertexInputStateCreateInfo.pVertexBindingDescriptions = &bindingDescription; - vertexInputStateCreateInfo.vertexAttributeDescriptionCount = static_cast(attributeDescriptions.size()); + vertexInputStateCreateInfo.vertexAttributeDescriptionCount = static_cast(attributeDescriptions.size()); vertexInputStateCreateInfo.pVertexAttributeDescriptions = attributeDescriptions.data(); VkPipelineInputAssemblyStateCreateInfo inputAssembly{}; @@ -213,7 +213,7 @@ namespace mlx VkDynamicState states[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; - constexpr size_t statesCount = sizeof(states) / sizeof(VkDynamicState); + constexpr std::size_t statesCount = sizeof(states) / sizeof(VkDynamicState); VkPipelineDynamicStateCreateInfo dynamicStates{}; dynamicStates.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; dynamicStates.dynamicStateCount = statesCount; diff --git a/src/renderer/pixel_put.cpp b/src/renderer/pixel_put.cpp index 17ba007..ef2b911 100644 --- a/src/renderer/pixel_put.cpp +++ b/src/renderer/pixel_put.cpp @@ -16,20 +16,20 @@ namespace mlx { - void PixelPutPipeline::init(uint32_t width, uint32_t height, Renderer& renderer) noexcept + void PixelPutPipeline::init(std::uint32_t width, std::uint32_t height, Renderer& renderer) noexcept { MLX_PROFILE_FUNCTION(); _texture.create(nullptr, width, height, VK_FORMAT_R8G8B8A8_UNORM, "__mlx_pixel_put_pipeline_texture", true); _texture.setDescriptor(renderer.getFragDescriptorSet().duplicate()); - _buffer.create(Buffer::kind::dynamic, sizeof(uint32_t) * (width * height), VK_BUFFER_USAGE_TRANSFER_SRC_BIT, "__mlx_pixel_put_pipeline_texture"); + _buffer.create(Buffer::kind::dynamic, sizeof(std::uint32_t) * (width * height), VK_BUFFER_USAGE_TRANSFER_SRC_BIT, "__mlx_pixel_put_pipeline_texture"); _buffer.mapMem(&_buffer_map); - _cpu_map = std::vector(height * width + 1, 0); + _cpu_map = std::vector(height * width + 1, 0); _width = width; _height = height; } - void PixelPutPipeline::setPixel(int x, int y, uint32_t color) noexcept + void PixelPutPipeline::setPixel(int x, int y, std::uint32_t color) noexcept { MLX_PROFILE_FUNCTION(); if(x < 0 || y < 0 || x > static_cast(_width) || y > static_cast(_height)) @@ -50,7 +50,7 @@ namespace mlx MLX_PROFILE_FUNCTION(); if(_has_been_modified) { - std::memcpy(_buffer_map, _cpu_map.data(), sizeof(uint32_t) * _cpu_map.size()); + std::memcpy(_buffer_map, _cpu_map.data(), sizeof(std::uint32_t) * _cpu_map.size()); _texture.copyFromBuffer(_buffer); _has_been_modified = false; } diff --git a/src/renderer/pixel_put.h b/src/renderer/pixel_put.h index b413132..1de58cd 100644 --- a/src/renderer/pixel_put.h +++ b/src/renderer/pixel_put.h @@ -24,9 +24,9 @@ namespace mlx public: PixelPutPipeline() = default; - void init(uint32_t width, uint32_t height, class Renderer& renderer) noexcept; + void init(std::uint32_t width, std::uint32_t height, class Renderer& renderer) noexcept; - void setPixel(int x, int y, uint32_t color) noexcept; + void setPixel(int x, int y, std::uint32_t color) noexcept; void render(std::array& sets, class Renderer& renderer) noexcept; void clear(); @@ -38,10 +38,10 @@ namespace mlx Texture _texture; Buffer _buffer; // using vector as CPU map and not directly writting to mapped buffer to improve performances - std::vector _cpu_map; + std::vector _cpu_map; void* _buffer_map = nullptr; - uint32_t _width = 0; - uint32_t _height = 0; + std::uint32_t _width = 0; + std::uint32_t _height = 0; bool _has_been_modified = true; }; } diff --git a/src/renderer/renderer.cpp b/src/renderer/renderer.cpp index 2a0e1d4..cfe4d42 100644 --- a/src/renderer/renderer.cpp +++ b/src/renderer/renderer.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/12/18 17:25:16 by maldavid #+# #+# */ -/* Updated: 2024/01/20 08:19:46 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 08:02:05 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/renderer/renderer.h b/src/renderer/renderer.h index 007a5ce..219ff03 100644 --- a/src/renderer/renderer.h +++ b/src/renderer/renderer.h @@ -106,8 +106,8 @@ namespace mlx inline DescriptorSet& getFragDescriptorSet() noexcept { return _frag_set; } inline DescriptorSetLayout& getVertDescriptorSetLayout() noexcept { return _vert_layout; } inline DescriptorSetLayout& getFragDescriptorSetLayout() noexcept { return _frag_layout; } - inline uint32_t getActiveImageIndex() noexcept { return _current_frame_index; } - inline uint32_t getImageIndex() noexcept { return _image_index; } + inline std::uint32_t getActiveImageIndex() noexcept { return _current_frame_index; } + inline std::uint32_t getImageIndex() noexcept { return _image_index; } constexpr inline void requireFrameBufferResize() noexcept { _framebufferResized = true; } @@ -136,8 +136,8 @@ namespace mlx class MLX_Window* _window = nullptr; class Texture* _render_target = nullptr; - uint32_t _current_frame_index = 0; - uint32_t _image_index = 0; + std::uint32_t _current_frame_index = 0; + std::uint32_t _image_index = 0; bool _framebufferResized = false; }; } diff --git a/src/renderer/renderpass/vk_framebuffer.h b/src/renderer/renderpass/vk_framebuffer.h index b4db929..275c3e6 100644 --- a/src/renderer/renderpass/vk_framebuffer.h +++ b/src/renderer/renderpass/vk_framebuffer.h @@ -26,13 +26,13 @@ namespace mlx inline VkFramebuffer& operator()() noexcept { return _framebuffer; } inline VkFramebuffer& get() noexcept { return _framebuffer; } - inline uint32_t getWidth() const noexcept { return _width; } - inline uint32_t getHeight() const noexcept { return _height; } + inline std::uint32_t getWidth() const noexcept { return _width; } + inline std::uint32_t getHeight() const noexcept { return _height; } private: VkFramebuffer _framebuffer = VK_NULL_HANDLE; - uint32_t _width = 0; - uint32_t _height = 0; + std::uint32_t _width = 0; + std::uint32_t _height = 0; }; } diff --git a/src/renderer/renderpass/vk_render_pass.cpp b/src/renderer/renderpass/vk_render_pass.cpp index a4a08a1..13a9c01 100644 --- a/src/renderer/renderpass/vk_render_pass.cpp +++ b/src/renderer/renderpass/vk_render_pass.cpp @@ -68,7 +68,7 @@ namespace mlx renderPassInfo.pAttachments = &colorAttachment; renderPassInfo.subpassCount = sizeof(subpasses) / sizeof(VkSubpassDescription); renderPassInfo.pSubpasses = subpasses; - renderPassInfo.dependencyCount = static_cast(subpassesDeps.size()); + renderPassInfo.dependencyCount = static_cast(subpassesDeps.size()); renderPassInfo.pDependencies = subpassesDeps.data(); VkResult res = vkCreateRenderPass(Render_Core::get().getDevice().get(), &renderPassInfo, nullptr, &_renderPass); diff --git a/src/renderer/swapchain/vk_swapchain.cpp b/src/renderer/swapchain/vk_swapchain.cpp index ccd0620..b6b65c7 100644 --- a/src/renderer/swapchain/vk_swapchain.cpp +++ b/src/renderer/swapchain/vk_swapchain.cpp @@ -29,12 +29,12 @@ namespace mlx VkPresentModeKHR presentMode = chooseSwapPresentMode(_swapChainSupport.presentModes); _extent = chooseSwapExtent(_swapChainSupport.capabilities); - uint32_t imageCount = _swapChainSupport.capabilities.minImageCount + 1; + std::uint32_t imageCount = _swapChainSupport.capabilities.minImageCount + 1; if(_swapChainSupport.capabilities.maxImageCount > 0 && imageCount > _swapChainSupport.capabilities.maxImageCount) imageCount = _swapChainSupport.capabilities.maxImageCount; Queues::QueueFamilyIndices indices = Render_Core::get().getQueue().findQueueFamilies(Render_Core::get().getDevice().getPhysicalDevice(), renderer->getSurface().get()); - uint32_t queueFamilyIndices[] = { indices.graphicsFamily.value(), indices.presentFamily.value() }; + std::uint32_t queueFamilyIndices[] = { indices.graphicsFamily.value(), indices.presentFamily.value() }; VkSwapchainCreateInfoKHR createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; @@ -90,7 +90,7 @@ namespace mlx if(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &details.capabilities) != VK_SUCCESS) core::error::report(e_kind::fatal_error, "Vulkan : unable to retrieve surface capabilities"); - uint32_t formatCount = 0; + std::uint32_t formatCount = 0; vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount, nullptr); if(formatCount != 0) @@ -99,7 +99,7 @@ namespace mlx vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount, details.formats.data()); } - uint32_t presentModeCount; + std::uint32_t presentModeCount; vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &presentModeCount, nullptr); if(presentModeCount != 0) @@ -119,13 +119,13 @@ namespace mlx VkExtent2D SwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities) { - if(capabilities.currentExtent.width != std::numeric_limits::max()) + if(capabilities.currentExtent.width != std::numeric_limits::max()) return capabilities.currentExtent; int width, height; SDL_Vulkan_GetDrawableSize(_renderer->getWindow()->getNativeWindow(), &width, &height); - VkExtent2D actualExtent = { static_cast(width), static_cast(height) }; + VkExtent2D actualExtent = { static_cast(width), static_cast(height) }; actualExtent.width = std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width); actualExtent.height = std::clamp(actualExtent.height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height); diff --git a/src/renderer/swapchain/vk_swapchain.h b/src/renderer/swapchain/vk_swapchain.h index 5fd8827..998ae78 100644 --- a/src/renderer/swapchain/vk_swapchain.h +++ b/src/renderer/swapchain/vk_swapchain.h @@ -47,7 +47,7 @@ namespace mlx inline VkSwapchainKHR get() noexcept { return _swapChain; } inline VkSwapchainKHR operator()() noexcept { return _swapChain; } - inline size_t getImagesNumber() const noexcept { return _images.size(); } + inline std::size_t getImagesNumber() const noexcept { return _images.size(); } inline Image& getImage(std::size_t i) noexcept { return _images[i]; } inline SwapChainSupportDetails getSupport() noexcept { return _swapChainSupport; } inline VkExtent2D getExtent() noexcept { return _extent; } diff --git a/src/renderer/texts/font.cpp b/src/renderer/texts/font.cpp index d025e12..37f2d0a 100644 --- a/src/renderer/texts/font.cpp +++ b/src/renderer/texts/font.cpp @@ -24,7 +24,7 @@ namespace mlx _build_data = path; } - Font::Font(class Renderer& renderer, const std::string& name, const std::vector& ttf_data, float scale) : _name(name), _renderer(renderer), _scale(scale) + Font::Font(class Renderer& renderer, const std::string& name, const std::vector& ttf_data, float scale) : _name(name), _renderer(renderer), _scale(scale) { _build_data = ttf_data; } @@ -32,7 +32,7 @@ namespace mlx void Font::buildFont() { MLX_PROFILE_FUNCTION(); - std::vector file_bytes; + std::vector file_bytes; if(std::holds_alternative(_build_data)) { std::ifstream file(std::get(_build_data), std::ios::binary); @@ -48,14 +48,14 @@ namespace mlx file.close(); } - std::vector tmp_bitmap(RANGE * RANGE); - std::vector vulkan_bitmap(RANGE * RANGE * 4); + std::vector tmp_bitmap(RANGE * RANGE); + std::vector vulkan_bitmap(RANGE * RANGE * 4); stbtt_pack_context pc; stbtt_PackBegin(&pc, tmp_bitmap.data(), RANGE, RANGE, RANGE, 1, nullptr); if(std::holds_alternative(_build_data)) stbtt_PackFontRange(&pc, file_bytes.data(), 0, _scale, 32, 96, _cdata.data()); else - stbtt_PackFontRange(&pc, std::get>(_build_data).data(), 0, _scale, 32, 96, _cdata.data()); + stbtt_PackFontRange(&pc, std::get>(_build_data).data(), 0, _scale, 32, 96, _cdata.data()); stbtt_PackEnd(&pc); for(int i = 0, j = 0; i < RANGE * RANGE; i++, j += 4) { diff --git a/src/renderer/texts/font.h b/src/renderer/texts/font.h index 9e39cde..0c898a8 100644 --- a/src/renderer/texts/font.h +++ b/src/renderer/texts/font.h @@ -27,7 +27,7 @@ namespace mlx public: Font() = delete; Font(class Renderer& renderer, const std::filesystem::path& path, float scale); - Font(class Renderer& renderer, const std::string& name, const std::vector& ttf_data, float scale); + Font(class Renderer& renderer, const std::string& name, const std::vector& ttf_data, float scale); inline const std::string& getName() const { return _name; } inline float getScale() const noexcept { return _scale; } @@ -45,7 +45,7 @@ namespace mlx private: std::array _cdata; TextureAtlas _atlas; - std::variant> _build_data; + std::variant> _build_data; std::string _name; class Renderer& _renderer; float _scale = 0; diff --git a/src/renderer/texts/font_library.h b/src/renderer/texts/font_library.h index 9a1d4dc..3019ea1 100644 --- a/src/renderer/texts/font_library.h +++ b/src/renderer/texts/font_library.h @@ -24,7 +24,7 @@ namespace mlx { - using FontID = uint32_t; + using FontID = std::uint32_t; constexpr FontID nullfont = 0; class FontLibrary : public Singleton diff --git a/src/renderer/texts/text.cpp b/src/renderer/texts/text.cpp index b26c01c..f08eea9 100644 --- a/src/renderer/texts/text.cpp +++ b/src/renderer/texts/text.cpp @@ -16,7 +16,7 @@ namespace mlx { - void Text::init(std::string text, FontID font, std::vector vbo_data, std::vector ibo_data) + void Text::init(std::string text, FontID font, std::vector vbo_data, std::vector ibo_data) { MLX_PROFILE_FUNCTION(); _text = std::move(text); @@ -30,11 +30,11 @@ namespace mlx } for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) _vbo[i].create(sizeof(Vertex) * vbo_data.size(), static_cast(vbo_data.data()), debug_name.c_str()); - _ibo.create(sizeof(uint16_t) * ibo_data.size(), ibo_data.data(), debug_name.c_str()); + _ibo.create(sizeof(std::uint16_t) * ibo_data.size(), ibo_data.data(), debug_name.c_str()); #else for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) _vbo[i].create(sizeof(Vertex) * vbo_data.size(), static_cast(vbo_data.data()), nullptr); - _ibo.create(sizeof(uint16_t) * ibo_data.size(), ibo_data.data(), nullptr); + _ibo.create(sizeof(std::uint16_t) * ibo_data.size(), ibo_data.data(), nullptr); #endif } diff --git a/src/renderer/texts/text.h b/src/renderer/texts/text.h index 44bd7a1..8abaedc 100644 --- a/src/renderer/texts/text.h +++ b/src/renderer/texts/text.h @@ -27,11 +27,11 @@ namespace mlx public: Text() = default; - void init(std::string text, FontID font, std::vector vbo_data, std::vector ibo_data); + void init(std::string text, FontID font, std::vector vbo_data, std::vector ibo_data); void bind(class Renderer& renderer) noexcept; inline FontID getFontInUse() const noexcept { return _font; } void updateVertexData(int frame, std::vector vbo_data); - inline uint32_t getIBOsize() noexcept { return _ibo.getSize(); } + inline std::uint32_t getIBOsize() noexcept { return _ibo.getSize(); } inline const std::string& getText() const { return _text; } void destroy() noexcept; diff --git a/src/renderer/texts/text_descriptor.cpp b/src/renderer/texts/text_descriptor.cpp index 4db185a..752e736 100644 --- a/src/renderer/texts/text_descriptor.cpp +++ b/src/renderer/texts/text_descriptor.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 00:23:11 by maldavid #+# #+# */ -/* Updated: 2024/01/18 09:44:54 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 07:58:21 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,14 +30,14 @@ constexpr const int RANGE = 1024; namespace mlx { - TextDrawDescriptor::TextDrawDescriptor(std::string text, uint32_t _color, int _x, int _y) : color(_color), x(_x), y(_y), _text(std::move(text)) + TextDrawDescriptor::TextDrawDescriptor(std::string text, std::uint32_t _color, int _x, int _y) : color(_color), x(_x), y(_y), _text(std::move(text)) {} void TextDrawDescriptor::init(FontID font) noexcept { MLX_PROFILE_FUNCTION(); std::vector vertexData; - std::vector indexData; + std::vector indexData; float stb_x = 0.0f; float stb_y = 0.0f; diff --git a/src/renderer/texts/text_descriptor.h b/src/renderer/texts/text_descriptor.h index bc8d239..27a89cd 100644 --- a/src/renderer/texts/text_descriptor.h +++ b/src/renderer/texts/text_descriptor.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 00:13:34 by maldavid #+# #+# */ -/* Updated: 2024/01/18 09:40:06 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 07:58:13 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,12 +30,12 @@ namespace mlx public: TextID id; - uint32_t color; + std::uint32_t color; int x; int y; public: - TextDrawDescriptor(std::string text, uint32_t _color, int _x, int _y); + TextDrawDescriptor(std::string text, std::uint32_t _color, int _x, int _y); void init(FontID font) noexcept; bool operator==(const TextDrawDescriptor& rhs) const { return _text == rhs._text && x == rhs.x && y == rhs.y && color == rhs.color; } diff --git a/src/renderer/texts/text_library.cpp b/src/renderer/texts/text_library.cpp index 4a61b38..ae52ba4 100644 --- a/src/renderer/texts/text_library.cpp +++ b/src/renderer/texts/text_library.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/10 11:59:57 by maldavid #+# #+# */ -/* Updated: 2024/01/18 08:02:31 by maldavid ### ########.fr */ +/* Updated: 2024/02/24 21:38:11 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ #include #include #include +#include namespace mlx { @@ -49,6 +50,7 @@ namespace mlx core::error::report(e_kind::warning, "Text Library : trying to remove a text with an unkown or invalid ID '%d'", id); return; } + std::cout << _cache[id]->getText() << std::endl; _cache[id]->destroy(); _invalid_ids.push_back(id); } diff --git a/src/renderer/texts/text_library.h b/src/renderer/texts/text_library.h index 9bdef36..d7dab98 100644 --- a/src/renderer/texts/text_library.h +++ b/src/renderer/texts/text_library.h @@ -26,7 +26,7 @@ namespace mlx { - using TextID = uint32_t; + using TextID = std::uint32_t; constexpr TextID nulltext = 0; class TextLibrary : public Singleton diff --git a/src/renderer/texts/text_manager.cpp b/src/renderer/texts/text_manager.cpp index 81dffd7..3588c78 100644 --- a/src/renderer/texts/text_manager.cpp +++ b/src/renderer/texts/text_manager.cpp @@ -6,10 +6,11 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */ -/* Updated: 2024/01/18 09:45:24 by maldavid ### ########.fr */ +/* Updated: 2024/02/24 21:39:12 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ +#include #include #include #include @@ -38,7 +39,7 @@ namespace mlx _font_in_use = FontLibrary::get().addFontToLibrary(font); } - std::pair TextManager::registerText(int x, int y, uint32_t color, std::string str) + std::pair TextManager::registerText(int x, int y, std::uint32_t color, std::string str) { MLX_PROFILE_FUNCTION(); auto res = _text_descriptors.emplace(std::move(str), color, x, y); @@ -52,6 +53,7 @@ namespace mlx if(_font_in_use != text_ptr->getFontInUse()) { // TODO : update text vertex buffers rather than destroying it and recreating it + std::cout << "test" << std::endl; TextLibrary::get().removeTextFromLibrary(res.first->id); const_cast(*res.first).init(_font_in_use); } diff --git a/src/renderer/texts/text_manager.h b/src/renderer/texts/text_manager.h index 8198b66..4a3c998 100644 --- a/src/renderer/texts/text_manager.h +++ b/src/renderer/texts/text_manager.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */ -/* Updated: 2024/01/18 13:52:01 by maldavid ### ########.fr */ +/* Updated: 2024/02/25 07:58:36 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,8 +34,8 @@ namespace mlx TextManager() = default; void init(Renderer& renderer) noexcept; - std::pair registerText(int x, int y, uint32_t color, std::string str); - inline void clear() { _text_descriptors.clear(); TextLibrary::get().clearLibrary(); } + std::pair registerText(int x, int y, std::uint32_t color, std::string str); + inline void clear() { _text_descriptors.clear(); } void loadFont(Renderer& renderer, const std::filesystem::path& filepath, float scale); void destroy() noexcept; diff --git a/src/utils/icon_mlx.h b/src/utils/icon_mlx.h index a5450fb..04f0029 100644 --- a/src/utils/icon_mlx.h +++ b/src/utils/icon_mlx.h @@ -19,7 +19,7 @@ constexpr const int logo_mlx_height = 125; constexpr const int logo_mlx_width = 125; constexpr const int logo_mlx_size = logo_mlx_height * logo_mlx_width * 4; -inline static uint8_t logo_mlx[logo_mlx_size] = { +inline static std::uint8_t logo_mlx[logo_mlx_size] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,