Merge pull request #11 from 420verfl0w/indev

merge dev to master
This commit is contained in:
kbz_8
2023-12-11 23:53:56 +01:00
committed by GitHub
62 changed files with 195 additions and 3323 deletions

View File

@@ -35,7 +35,7 @@ jobs:
# Build the lib
- name: Build MacroLibX
run: make -j
run: make -j && make fclean && make -j DEBUG=true
# Build the test
- name: Build Test

View File

@@ -35,7 +35,7 @@ jobs:
# Build the lib
- name: Build MacroLibX
run: make TOOLCHAIN=gcc -j
run: make TOOLCHAIN=gcc -j && make fclean && make TOOLCHAIN=gcc DEBUG=true -j
# Build the test
- name: Build Test

View File

@@ -41,7 +41,7 @@ jobs:
# Build the lib
- name: Build MacroLibX
run: make -j
run: make -j && make fclean && make DEBUG=true -j
# Build the test
- name: Build Test

View File

@@ -6,14 +6,13 @@
# By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/10/04 16:43:41 by maldavid #+# #+# #
# Updated: 2023/12/07 15:25:52 by kbz_8 ### ########.fr #
# Updated: 2023/12/10 23:15:03 by kbz_8 ### ########.fr #
# #
# **************************************************************************** #
NAME = libmlx.so
SRCS = $(wildcard $(addsuffix /*.cpp, ./src/core))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/core/**))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/platform))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer/**))
@@ -32,15 +31,18 @@ MODE = "release"
CXX = clang++
ifeq ($(TOOLCHAIN), gcc)
CXX = g++
endif
CXXFLAGS = -std=c++17 -O3 -fPIC
CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Werror
INCLUDES = -I./includes -I./src -I./third_party
LDLIBS =
ifeq ($(TOOLCHAIN), gcc)
CXX = g++
CXXFLAGS += -Wno-error=cpp
else
CXXFLAGS += -Wno-error=#warning
endif
ifeq ($(OS), Darwin)
LDLIBS += -lSDL2
endif

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
/* Updated: 2023/12/08 18:07:40 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 20:35:41 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,19 +15,7 @@
#ifndef __MACRO_LIB_X_H__
#define __MACRO_LIB_X_H__
#if defined(_WIN32) || defined(_WIN64)
#define MLX_EXPORT __declspec(dllexport)
#define MLX_IMPORT __declspec(dllimport)
#else
#define MLX_EXPORT
#define MLX_IMPORT
#endif
#ifdef MLX_BUILD
#define MLX_API MLX_EXPORT
#else
#define MLX_API MLX_IMPORT
#endif
#include "mlx_profile.h"
#ifdef __cplusplus
extern "C" {

View File

@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* profile.h :+: :+: :+: */
/* mlx_profile.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */
/* Updated: 2023/12/08 18:49:38 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 20:35:57 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -53,21 +53,48 @@
#error "Unknown environment!"
#endif
#ifdef MLX_COMPILER_MSVC
#ifdef MLX_BUILD
#define MLX_API __declspec(dllexport)
#else
#define MLX_API __declspec(dllimport)
#endif
#else
#define MLX_API
#endif
// Checking common assumptions
#include <climits>
#include <cstdint>
#ifdef __cplusplus
#include <climits>
#include <cstdint>
static_assert(CHAR_BIT == 8, "CHAR_BIT is expected to be 8");
static_assert(CHAR_BIT == 8, "CHAR_BIT is expected to be 8");
static_assert(sizeof(int8_t) == 1, "int8_t is not of the correct size" );
static_assert(sizeof(int16_t) == 2, "int16_t is not of the correct size");
static_assert(sizeof(int32_t) == 4, "int32_t is not of the correct size");
static_assert(sizeof(int64_t) == 8, "int64_t is not of the correct size");
static_assert(sizeof(int8_t) == 1, "int8_t is not of the correct size" );
static_assert(sizeof(int16_t) == 2, "int16_t is not of the correct size");
static_assert(sizeof(int32_t) == 4, "int32_t is not of the correct size");
static_assert(sizeof(int64_t) == 8, "int64_t is not of the correct size");
static_assert(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" );
static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size");
static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size");
static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size");
static_assert(sizeof(uint8_t) == 1, "uint8_t is not of the correct size" );
static_assert(sizeof(uint16_t) == 2, "uint16_t is not of the correct size");
static_assert(sizeof(uint32_t) == 4, "uint32_t is not of the correct size");
static_assert(sizeof(uint64_t) == 8, "uint64_t is not of the correct size");
#else
#define STATIC_ASSERT(COND, MSG) typedef char static_assertion___##MSG[(COND)?1:-1]
#include <limits.h>
#include <stdint.h>
STATIC_ASSERT(CHAR_BIT == 8, CHAR_BIT_is_expected_to_be_8);
STATIC_ASSERT(sizeof(int8_t) == 1, int8_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(int16_t) == 2, int16_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(int32_t) == 4, int32_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(int64_t) == 8, int64_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(uint8_t) == 1, uint8_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(uint16_t) == 2, uint16_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(uint32_t) == 4, uint32_t_is_not_of_the_correct_size);
STATIC_ASSERT(sizeof(uint64_t) == 8, uint64_t_is_not_of_the_correct_size);
#endif
#endif

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2023/12/09 17:44:13 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:46:13 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,12 +15,14 @@
#include <renderer/core/render_core.h>
#include <array>
#include <core/errors.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <core/memory.h>
namespace mlx::core
{
Application::Application() : _in(std::make_unique<Input>())
{
SDL_SetMemoryFunctions(MemManager::malloc, MemManager::calloc, MemManager::realloc, MemManager::free);
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
error::report(e_kind::fatal_error, "SDL error : unable to init all subsystems : %s", SDL_GetError());
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2023/12/08 18:52:47 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:46:49 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,7 +24,7 @@
#include <core/graphics.h>
#include <platform/inputs.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx::core
{
@@ -69,7 +69,6 @@ namespace mlx::core
std::function<int(void*)> _loop_hook;
std::unique_ptr<Input> _in;
void* _param = nullptr;
bool _is_loop_running = false;
};
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
/* Updated: 2023/12/07 23:05:05 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 15:56:18 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <renderer/core/render_core.h>
#include <filesystem>
#include <mlx.h>
#include <core/memory.h>
extern "C"
{
@@ -25,8 +26,9 @@ extern "C"
if(init)
{
mlx::core::error::report(e_kind::error, "MLX cannot be initialized multiple times");
return NULL;
return NULL; // not nullptr for the C compatibility
}
mlx::MemManager::get(); // just to initialize the C garbage collector
mlx::core::Application* app = new mlx::core::Application;
mlx::Render_Core::get().init();
if(app == nullptr)
@@ -219,4 +221,4 @@ extern "C"
static_cast<mlx::core::Application*>(mlx)->getScreenSize(w, h);
return 0;
}
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:42:32 by maldavid #+# #+# */
/* Updated: 2023/12/08 18:53:11 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:46:57 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,7 +14,7 @@
#define __MLX_ERRORS__
#include <string>
#include <core/profile.h>
#include <mlx_profile.h>
enum class e_kind
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */
/* Updated: 2023/12/09 16:52:08 by kbz_8 ### ########.fr */
/* Updated: 2023/12/10 22:20:38 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,7 +16,8 @@ namespace mlx
{
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, const std::string& title, int id) :
_window(std::make_shared<MLX_Window>(w, h, title)),
_renderer(std::make_unique<Renderer>()), _text_put_pipeline(std::make_unique<TextPutPipeline>()),
_text_put_pipeline(std::make_unique<TextPutPipeline>()),
_renderer(std::make_unique<Renderer>()),
_id(id)
{
_renderer->setWindow(_window.get());

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:04:59 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:47:03 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,7 +26,7 @@
#include <renderer/text_pipeline.h>
#include <utils/non_copyable.h>
#include <renderer/images/texture.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/07 16:32:01 by kbz_8 #+# #+# */
/* Updated: 2023/12/08 12:56:14 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 15:25:02 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,7 +17,7 @@
namespace mlx
{
void* MemManager::alloc(std::size_t size)
void* MemManager::malloc(std::size_t size)
{
void* ptr = std::malloc(size);
if(ptr != nullptr)
@@ -25,6 +25,25 @@ namespace mlx
return ptr;
}
void* MemManager::calloc(std::size_t n, std::size_t size)
{
void* ptr = std::calloc(n, size);
if(ptr != nullptr)
_blocks.push_back(ptr);
return ptr;
}
void* MemManager::realloc(void* ptr, std::size_t size)
{
void* ptr2 = std::realloc(ptr, size);
if(ptr2 != nullptr)
_blocks.push_back(ptr2);
auto it = std::find(_blocks.begin(), _blocks.end(), ptr);
if(it != _blocks.end())
_blocks.erase(it);
return ptr2;
}
void MemManager::free(void* ptr)
{
auto it = std::find(_blocks.begin(), _blocks.end(), ptr);

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/07 16:31:51 by kbz_8 #+# #+# */
/* Updated: 2023/12/08 19:05:15 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:47:13 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,7 +14,7 @@
#define __MLX_MEMORY__
#include <utils/singleton.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <list>
namespace mlx
@@ -24,15 +24,17 @@ namespace mlx
friend class Singleton<MemManager>;
public:
void* alloc(std::size_t size);
void free(void* ptr);
static void* malloc(std::size_t size);
static void* calloc(std::size_t n, std::size_t size);
static void* realloc(void* ptr, std::size_t size);
static void free(void* ptr);
private:
MemManager() = default;
~MemManager();
private:
std::list<void*> _blocks;
inline static std::list<void*> _blocks;
};
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 16:30:19 by maldavid #+# #+# */
/* Updated: 2023/12/08 12:17:40 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:01:14 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,12 +16,6 @@
namespace mlx
{
Input::Input()
{
std::memset(_keys.data(), 0, SDL_NUM_SCANCODES);
std::memset(_mouse.data(), 0, 8);
}
void Input::update()
{
_xRel = 0;
@@ -47,7 +41,6 @@ namespace mlx
{
case SDL_KEYDOWN:
{
_keys[_event.key.keysym.scancode] = static_cast<uint8_t>(action::down);
if(hooks[MLX_KEYDOWN].hook)
hooks[MLX_KEYDOWN].hook(_event.key.keysym.scancode, hooks[MLX_KEYDOWN].param);
break;
@@ -55,7 +48,6 @@ namespace mlx
case SDL_KEYUP:
{
_keys[_event.key.keysym.scancode] = static_cast<uint8_t>(action::up);
if(hooks[MLX_KEYUP].hook)
hooks[MLX_KEYUP].hook(_event.key.keysym.scancode, hooks[MLX_KEYUP].param);
break;
@@ -63,7 +55,6 @@ namespace mlx
case SDL_MOUSEBUTTONDOWN:
{
_mouse[_event.button.button] = static_cast<uint8_t>(action::down);
if(hooks[MLX_MOUSEDOWN].hook)
hooks[MLX_MOUSEDOWN].hook(_event.button.button, hooks[MLX_MOUSEDOWN].param);
break;
@@ -71,7 +62,6 @@ namespace mlx
case SDL_MOUSEBUTTONUP:
{
_mouse[_event.button.button] = static_cast<uint8_t>(action::up);
if(hooks[MLX_MOUSEUP].hook)
hooks[MLX_MOUSEUP].hook(_event.button.button, hooks[MLX_MOUSEUP].param);
break;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */
/* Updated: 2023/12/08 18:54:03 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:47:20 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,14 +18,12 @@
#include <SDL2/SDL.h>
#include <unordered_map>
#include <core/profile.h>
#include <mlx_profile.h>
#include "window.h"
namespace mlx
{
enum class action : uint8_t { up = (1 << 1), down = (1 << 2) };
struct Hook
{
std::function<int(int, void*)> hook;
@@ -35,13 +33,10 @@ namespace mlx
class Input
{
public:
Input();
Input() = default;
void update();
inline bool getInKey(const SDL_Scancode key, action type = action::down) const noexcept { return _keys[key] & static_cast<uint8_t>(type); }
inline bool getInMouse(const uint8_t button, action type = action::down) const noexcept { return _mouse[button] & static_cast<uint8_t>(type); }
inline bool isMouseMoving() const noexcept { return _xRel || _yRel; }
inline int getX() const noexcept { return _x; }
@@ -68,11 +63,9 @@ namespace mlx
~Input() = default;
private:
std::array<uint8_t, SDL_NUM_SCANCODES> _keys;
std::unordered_map<uint32_t, std::shared_ptr<MLX_Window>> _windows;
std::unordered_map<uint32_t, std::array<Hook, 6>> _events_hooks;
SDL_Event _event;
std::array<uint8_t, 8> _mouse;
int _x = 0;
int _y = 0;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
/* Updated: 2023/12/09 16:52:29 by kbz_8 ### ########.fr */
/* Updated: 2023/12/10 22:49:11 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -41,7 +41,6 @@ namespace mlx
void MLX_Window::destroy() noexcept
{
std::cout << "prout" << std::endl;
if(_win != nullptr)
{
SDL_DestroyWindow(_win);

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:53:12 by maldavid #+# #+# */
/* Updated: 2023/12/09 16:35:57 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:47:26 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,7 +15,7 @@
#include <SDL2/SDL.h>
#include <string>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 18:55:57 by maldavid #+# #+# */
/* Updated: 2023/11/16 13:54:25 by maldavid ### ########.fr */
/* Updated: 2023/12/10 23:05:14 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -59,7 +59,7 @@ namespace mlx
_buffer = VK_NULL_HANDLE;
}
void Buffer::createBuffer(VkBufferUsageFlags usage, VmaAllocationCreateInfo info, VkDeviceSize size, const char* name)
void Buffer::createBuffer(VkBufferUsageFlags usage, VmaAllocationCreateInfo info, VkDeviceSize size, [[maybe_unused]] const char* name)
{
VkBufferCreateInfo bufferInfo{};
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
@@ -74,7 +74,7 @@ namespace mlx
alloc_name.append("_index_buffer");
else if(usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)
alloc_name.append("_vertex_buffer");
else if((usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) != 1)
else if(!(usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT))
alloc_name.append("_buffer");
_allocation = Render_Core::get().getAllocator().createBuffer(&bufferInfo, &info, _buffer, alloc_name.c_str());
#else

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 23:18:52 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:05:50 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:47:39 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,7 +15,7 @@
#include <volk.h>
#include <renderer/core/render_core.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 15:05:05 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:06:07 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 19:47:47 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,7 +16,7 @@
#include <volk.h>
#include "vk_buffer.h"
#include <renderer/renderer.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:45:52 by maldavid #+# #+# */
/* Updated: 2023/11/16 13:57:42 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:22:28 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,7 +16,7 @@
namespace mlx
{
void UBO::create(Renderer* renderer, uint32_t size, const char* name)
void UBO::create(Renderer* renderer, uint32_t size, [[maybe_unused]] const char* name)
{
_renderer = renderer;

View File

@@ -16,7 +16,7 @@
#include "vk_buffer.h"
#include <array>
#include <cstddef>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -15,7 +15,7 @@
#include "vk_buffer.h"
#include <renderer/renderer.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -16,7 +16,7 @@
#include <array>
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <renderer/core/render_core.h>
#include <renderer/command/vk_cmd_pool.h>
#include <renderer/command/vk_cmd_buffer.h>

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <renderer/core/vk_fence.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -14,7 +14,7 @@
#define __MLX_VK_CMD_POOL__
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,11 +6,11 @@
/* By: kbz_8 <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */
/* Updated: 2023/11/14 12:45:29 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:44:55 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
#include <core/profile.h>
#include <mlx_profile.h>
#include <core/errors.h>
#include <cstdio>
@@ -22,9 +22,18 @@
#ifdef MLX_COMPILER_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-completeness"
#pragma clang diagnostic ignored "-Weverything"
#include <renderer/core/memory.h>
#pragma clang diagnostic pop
#elif defined(MLX_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wparentheses"
#include <renderer/core/memory.h>
#pragma GCC diagnostic pop
#else
#include <renderer/core/memory.h>
#endif

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <vma.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
/* Updated: 2023/11/20 12:04:51 by maldavid ### ########.fr */
/* Updated: 2023/12/10 23:14:18 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */

View File

@@ -24,7 +24,7 @@
#include <utils/singleton.h>
#include <core/errors.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include "vk_queues.h"
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 17:53:06 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:07:21 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:45:21 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,9 +16,6 @@ namespace mlx
{
void Fence::init()
{
VkSemaphoreCreateInfo semaphoreInfo{};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
VkFenceCreateInfo fenceInfo{};
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;

View File

@@ -14,7 +14,7 @@
#define __MLX_VK_FENCE__
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <renderer/core/render_core.h>
namespace mlx

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <vector>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -16,7 +16,7 @@
#include <volk.h>
#include <optional>
#include <cstdint>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <vector>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <vector>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 14:05:25 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:21:57 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:25:36 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -83,7 +83,7 @@ namespace mlx
createInfo.pfnUserCallback = ValidationLayers::debugCallback;
}
VKAPI_ATTR VkBool32 VKAPI_CALL ValidationLayers::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)
VKAPI_ATTR VkBool32 VKAPI_CALL ValidationLayers::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, [[maybe_unused]] VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, [[maybe_unused]] void* pUserData)
{
if(messageSeverity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
{

View File

@@ -14,7 +14,7 @@
#define __VK_VALIDATION_LAYERS__
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <cstddef>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -15,7 +15,7 @@
#include <volk.h>
#include <array>
#include <core/profile.h>
#include <mlx_profile.h>
#include <renderer/core/render_core.h>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:37:28 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:23:16 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:25:59 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,7 +18,7 @@ namespace mlx
void DescriptorSetLayout::init(std::vector<std::pair<int, VkDescriptorType>> binds, VkShaderStageFlagBits stage)
{
std::vector<VkDescriptorSetLayoutBinding> bindings(binds.size());
for(int i = 0; i < binds.size(); i++)
for(std::size_t i = 0; i < binds.size(); i++)
{
bindings[i].binding = binds[i].first;
bindings[i].descriptorCount = 1;

View File

@@ -17,7 +17,7 @@
#include <cstddef>
#include <vector>
#include <map>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/31 18:03:35 by maldavid #+# #+# */
/* Updated: 2023/11/16 14:01:47 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:46:08 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -69,7 +69,7 @@ namespace mlx
void Texture::setPixel(int x, int y, uint32_t color) noexcept
{
if(x < 0 || y < 0 || x > getWidth() || y > getHeight())
if(x < 0 || y < 0 || static_cast<uint32_t>(x) > getWidth() || static_cast<uint32_t>(y) > getHeight())
return;
if(_map == nullptr)
openCPUmap();
@@ -79,7 +79,7 @@ namespace mlx
int Texture::getPixel(int x, int y) noexcept
{
if(x < 0 || y < 0 || x > getWidth() || y > getHeight())
if(x < 0 || y < 0 || static_cast<uint32_t>(x) > getWidth() || static_cast<uint32_t>(y) > getHeight())
return 0;
if(_map == nullptr)
openCPUmap();

View File

@@ -21,7 +21,7 @@
#include <renderer/descriptors/vk_descriptor_set.h>
#include <renderer/buffers/vk_ibo.h>
#include <renderer/buffers/vk_vbo.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -16,7 +16,7 @@
#include <renderer/images/texture.h>
#include <array>
#include <glm/glm.hpp>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -18,7 +18,7 @@
#include <vector>
#include <renderer/command/vk_cmd_buffer.h>
#include <renderer/command/vk_cmd_pool.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -14,7 +14,7 @@
#define __PIPELINE__
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <renderer/command/vk_cmd_buffer.h>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/31 15:14:50 by maldavid #+# #+# */
/* Updated: 2023/11/16 13:44:58 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:33:59 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -29,7 +29,7 @@ namespace mlx
void PixelPutPipeline::setPixel(uint32_t x, uint32_t y, uint32_t color) noexcept
{
if(x < 0 || y < 0 || x > _width || y > _height)
if(x > _width || y > _height)
return;
_cpu_map[(y * _width) + x] = color;
_has_been_modified = true;

View File

@@ -13,7 +13,7 @@
#ifndef __MLX_PIXEL_PUT__
#define __MLX_PIXEL_PUT__
#include <core/profile.h>
#include <mlx_profile.h>
#include <renderer/images/texture.h>
#include <renderer/descriptors/vk_descriptor_set.h>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 17:25:16 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:25:47 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:21:10 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -23,9 +23,9 @@ namespace mlx
_pass.init(_swapchain.getImagesFormat());
_cmd.init();
for(int i = 0; i < _swapchain.getImagesNumber(); i++)
for(std::size_t i = 0; i < _swapchain.getImagesNumber(); i++)
_framebuffers.emplace_back().init(_pass, _swapchain.getImage(i));
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
for(std::size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
_semaphores[i].init();
_uniform_buffer.reset(new UBO);

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */
/* Updated: 2023/12/08 19:12:06 by kbz_8 ### ########.fr */
/* Updated: 2023/12/10 22:19:41 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -31,7 +31,7 @@
#include <renderer/descriptors/vk_descriptor_set_layout.h>
#include <core/errors.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <glm/glm.hpp>
@@ -109,7 +109,7 @@ namespace mlx
inline uint32_t getActiveImageIndex() noexcept { return _current_frame_index; }
inline uint32_t getImageIndex() noexcept { return _image_index; }
constexpr inline void requireFrameBufferResize(int index) noexcept { _framebufferResized = true; }
constexpr inline void requireFrameBufferResize() noexcept { _framebufferResized = true; }
~Renderer() = default;

View File

@@ -14,7 +14,7 @@
#define __MLX_VK_FRAMEBUFFER__
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:21:36 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:24:40 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:32:27 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,7 +18,7 @@
namespace mlx
{
static const VkClearValue clearColor = { 0.0f, 0.0f, 0.0f, 1.0f };
static const VkClearValue clearColor = {{{ 0.0f, 0.0f, 0.0f, 1.0f }}}; // wtf, this mess to satisfy a warning
void RenderPass::init(VkFormat attachement_format)
{

View File

@@ -14,7 +14,7 @@
#define __MLX_VK_RENDER_PASS__
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:22:28 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:15:10 by maldavid ### ########.fr */
/* Updated: 2023/12/10 22:32:54 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -68,7 +68,7 @@ namespace mlx
tmp.resize(imageCount);
vkGetSwapchainImagesKHR(device, _swapChain, &imageCount, tmp.data());
for(int i = 0; i < imageCount; i++)
for(std::size_t i = 0; i < imageCount; i++)
{
_images[i].create(tmp[i], surfaceFormat.format, _extent.width, _extent.height);
_images[i].transitionLayout(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);

View File

@@ -15,7 +15,7 @@
#include <vector>
#include <volk.h>
#include <core/profile.h>
#include <mlx_profile.h>
#include <renderer/images/vk_image.h>
namespace mlx

View File

@@ -20,7 +20,7 @@
#include <memory>
#include <vector>
#include <cstdint>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/06 16:41:13 by maldavid #+# #+# */
/* Updated: 2023/12/07 22:29:45 by kbz_8 ### ########.fr */
/* Updated: 2023/12/11 15:12:02 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -23,8 +23,8 @@
#include <core/memory.h>
#define STB_TRUETYPE_IMPLEMENTATION
#define STB_malloc(x, u) ((void)(u), MemManager::get().alloc(x))
#define STB_free(x, u) ((void)(u), MemManager::get().free(x))
#define STB_malloc(x, u) ((void)(u), MemManager::malloc(x))
#define STB_free(x, u) ((void)(u), MemManager::free(x))
#include <stb_truetype.h>
constexpr const int RANGE = 1024;
@@ -46,7 +46,7 @@ namespace mlx
for(char c : text)
{
if(c < 32 || c > 127)
if(c < 32)
continue;
stbtt_aligned_quad q;

View File

@@ -20,7 +20,7 @@
#include <cstdint>
#include <unordered_set>
#include <renderer/text_library.h>
#include <core/profile.h>
#include <mlx_profile.h>
namespace mlx
{

File diff suppressed because it is too large Load Diff