diff --git a/Makefile b/Makefile index cb43f27..93a6343 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ MODE = "release" CXX = clang++ -CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Wno-deprecated -DSDL_MAIN_HANDLED +CXXFLAGS = -std=c++20 -O3 -fPIC -Wall -Wextra -Wno-deprecated -DSDL_MAIN_HANDLED INCLUDES = -I./includes -I./runtime/Includes -I./runtime/Sources -I./third_party LDLIBS = diff --git a/runtime/Includes/Core/Application.inl b/runtime/Includes/Core/Application.inl index f00c206..41d4006 100644 --- a/runtime/Includes/Core/Application.inl +++ b/runtime/Includes/Core/Application.inl @@ -19,7 +19,7 @@ Error("invalid image ptr (NULL)"); \ retval; \ } \ - else if(m_image_registry.Find(img)) \ + else if(!m_image_registry.IsTextureKnown(img)) \ { \ Error("invalid image ptr"); \ retval; \ @@ -29,8 +29,8 @@ namespace mlx { void Application::GetMousePos(int* x, int* y) noexcept { - *x = p_in->GetX(); - *y = p_in->GetY(); + *x = m_in.GetX(); + *y = m_in.GetY(); } void Application::MouseMove(Handle win, int x, int y) noexcept @@ -69,11 +69,7 @@ namespace mlx void* Application::NewGraphicsSuport(std::size_t w, std::size_t h, const char* title) { MLX_PROFILE_FUNCTION(); - auto it = std::find_if(m_textures.begin(), m_textures.end(), [=](const Texture& texture) - { - return &texture == reinterpret_cast(const_cast(title)); - }); - if(it != _textures.end()) + if(m_image_registry.IsTextureKnown(reinterpret_cast(const_cast(title)))) m_graphics.emplace_back(std::make_unique(w, h, reinterpret_cast(const_cast(title)), m_graphics.size())); else { @@ -92,7 +88,7 @@ namespace mlx { MLX_PROFILE_FUNCTION(); CHECK_WINDOW_PTR(win); - m_graphics[*static_cast(win)]->ClearRenderData(); + m_graphics[*static_cast(win)]->ResetRenderData(); } void Application::DestroyGraphicsSupport(Handle win) @@ -177,6 +173,6 @@ namespace mlx void Application::LoopEnd() noexcept { - p_in->Finish(); + m_in.Finish(); } } diff --git a/runtime/Includes/Core/Graphics.inl b/runtime/Includes/Core/Graphics.inl index 7d866bb..e025e03 100644 --- a/runtime/Includes/Core/Graphics.inl +++ b/runtime/Includes/Core/Graphics.inl @@ -7,7 +7,6 @@ namespace mlx { MLX_PROFILE_FUNCTION(); p_scene->ResetSprites(); - m_images_registry.Clear(); } void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept diff --git a/runtime/Includes/Graphics/Sprite.h b/runtime/Includes/Graphics/Sprite.h index 3f4b426..ce7c7bd 100644 --- a/runtime/Includes/Graphics/Sprite.h +++ b/runtime/Includes/Graphics/Sprite.h @@ -46,7 +46,7 @@ namespace mlx std::shared_ptr p_texture; std::shared_ptr p_mesh; Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f }; - Vec3f m_position = Vec4f{ 0.0f, 0.0f, 0.0f }; + Vec3f m_position = Vec3f{ 0.0f, 0.0f, 0.0f }; }; } diff --git a/runtime/Includes/Maths/Angles.h b/runtime/Includes/Maths/Angles.h index 801d71e..1aa9b3c 100644 --- a/runtime/Includes/Maths/Angles.h +++ b/runtime/Includes/Maths/Angles.h @@ -1,11 +1,9 @@ -#ifndef __SCOP_ANGLES__ -#define __SCOP_ANGLES__ +#ifndef __MLX_ANGLES__ +#define __MLX_ANGLES__ #include -#include -#include -namespace Scop +namespace mlx { template struct EulerAngles; template struct Quat; diff --git a/runtime/Includes/Maths/Angles.inl b/runtime/Includes/Maths/Angles.inl index 5c2631e..7b1cceb 100644 --- a/runtime/Includes/Maths/Angles.inl +++ b/runtime/Includes/Maths/Angles.inl @@ -1,13 +1,10 @@ #pragma once #include -#include -#include - #include #include -namespace Scop +namespace mlx { namespace Internal { diff --git a/runtime/Includes/Maths/Constants.h b/runtime/Includes/Maths/Constants.h index 015346f..29c9a64 100644 --- a/runtime/Includes/Maths/Constants.h +++ b/runtime/Includes/Maths/Constants.h @@ -1,11 +1,7 @@ -#ifndef __SCOP_MATHS_CONSTANTS__ -#define __SCOP_MATHS_CONSTANTS__ +#ifndef __MLX_MATHS_CONSTANTS__ +#define __MLX_MATHS_CONSTANTS__ -#include -#include -#include - -namespace Scop +namespace mlx { template constexpr std::size_t BitCount = CHAR_BIT * sizeof(T); diff --git a/runtime/Includes/Maths/Enums.h b/runtime/Includes/Maths/Enums.h index df12fbd..b74e833 100644 --- a/runtime/Includes/Maths/Enums.h +++ b/runtime/Includes/Maths/Enums.h @@ -1,9 +1,7 @@ -#ifndef __SCOPE_MATHS_ENUMS__ -#define __SCOPE_MATHS_ENUMS__ +#ifndef __MLX_MATHS_ENUMS__ +#define __MLX_MATHS_ENUMS__ -#include - -namespace Scop +namespace mlx { enum class AngleUnit { diff --git a/runtime/Includes/Maths/EulerAngles.h b/runtime/Includes/Maths/EulerAngles.h index 8a873cb..54171c9 100644 --- a/runtime/Includes/Maths/EulerAngles.h +++ b/runtime/Includes/Maths/EulerAngles.h @@ -1,11 +1,9 @@ -#ifndef __SCOP_EULER_ANGLES__ -#define __SCOP_EULER_ANGLES__ - -#include +#ifndef __MLX_EULER_ANGLES__ +#define __MLX_EULER_ANGLES__ #include -namespace Scop +namespace mlx { template struct EulerAngles diff --git a/runtime/Includes/Maths/EulerAngles.inl b/runtime/Includes/Maths/EulerAngles.inl index 97fab12..23a9a57 100644 --- a/runtime/Includes/Maths/EulerAngles.inl +++ b/runtime/Includes/Maths/EulerAngles.inl @@ -1,7 +1,7 @@ #pragma once #include -namespace Scop +namespace mlx { template constexpr EulerAngles::EulerAngles(DegreeAngle P, DegreeAngle Y, DegreeAngle R) : diff --git a/runtime/Includes/Maths/Mat4.h b/runtime/Includes/Maths/Mat4.h index 4151ba9..722f5cd 100644 --- a/runtime/Includes/Maths/Mat4.h +++ b/runtime/Includes/Maths/Mat4.h @@ -1,13 +1,9 @@ -#ifndef __SCOP_MAT4__ -#define __SCOP_MAT4__ - -#include -#include -#include +#ifndef __MLX_MAT4__ +#define __MLX_MAT4__ #include -namespace Scop +namespace mlx { template struct Vec2; template struct Vec3; diff --git a/runtime/Includes/Maths/Mat4.inl b/runtime/Includes/Maths/Mat4.inl index 7f67930..b15e0d4 100644 --- a/runtime/Includes/Maths/Mat4.inl +++ b/runtime/Includes/Maths/Mat4.inl @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include #include @@ -9,10 +8,7 @@ #include #include -#include -#include - -namespace Scop +namespace mlx { template constexpr Mat4::Mat4(T r11, T r12, T r13, T r14, diff --git a/runtime/Includes/Maths/MathsUtils.h b/runtime/Includes/Maths/MathsUtils.h index c17d0da..fb211d9 100644 --- a/runtime/Includes/Maths/MathsUtils.h +++ b/runtime/Includes/Maths/MathsUtils.h @@ -1,9 +1,7 @@ -#ifndef __SCOP_MATHS_UTILS__ -#define __SCOP_MATHS_UTILS__ +#ifndef __MLX_MATHS_UTILS__ +#define __MLX_MATHS_UTILS__ -#include - -namespace Scop +namespace mlx { template [[nodiscard]] constexpr T Mod(T x, T y) noexcept; diff --git a/runtime/Includes/Maths/MathsUtils.inl b/runtime/Includes/Maths/MathsUtils.inl index d47a421..509d2ad 100644 --- a/runtime/Includes/Maths/MathsUtils.inl +++ b/runtime/Includes/Maths/MathsUtils.inl @@ -1,12 +1,9 @@ #pragma once #include -#include -#include - #include -namespace Scop +namespace mlx { template [[nodiscard]] constexpr T Mod(T x, T y) noexcept diff --git a/runtime/Includes/Maths/Quaternions.h b/runtime/Includes/Maths/Quaternions.h index 5937268..dfa1809 100644 --- a/runtime/Includes/Maths/Quaternions.h +++ b/runtime/Includes/Maths/Quaternions.h @@ -1,10 +1,10 @@ -#ifndef __SCOP_QUATERNIONS__ -#define __SCOP_QUATERNIONS__ +#ifndef __MLX_QUATERNIONS__ +#define __MLX_QUATERNIONS__ #include #include -namespace Scop +namespace mlx { template struct Quat diff --git a/runtime/Includes/Maths/Quaternions.inl b/runtime/Includes/Maths/Quaternions.inl index bea9a95..3905510 100644 --- a/runtime/Includes/Maths/Quaternions.inl +++ b/runtime/Includes/Maths/Quaternions.inl @@ -1,7 +1,7 @@ #pragma once #include -namespace Scop +namespace mlx { template constexpr Quat::Quat(T W, T X, T Y, T Z) : w(W), x(X), y(Y), z(Z) @@ -46,7 +46,7 @@ namespace Scop RadianAngle Quat::AngleBetween(const Quat& quat) const { T alpha = Vec3::DotProduct(Vec3(x, y, z), Vec3(quat.x, quat.y, quat.z)); - return std::acos(Scop::Clamp(alpha, T(-1.0), T(1.0))); + return std::acos(mlx::Clamp(alpha, T(-1.0), T(1.0))); } template @@ -366,10 +366,10 @@ namespace Scop constexpr Quat Quat::Lerp(const Quat& from, const Quat& to, T interpolation) { Quat interpolated; - interpolated.w = Scop::Lerp(from.w, to.w, interpolation); - interpolated.x = Scop::Lerp(from.x, to.x, interpolation); - interpolated.y = Scop::Lerp(from.y, to.y, interpolation); - interpolated.z = Scop::Lerp(from.z, to.z, interpolation); + interpolated.w = mlx::Lerp(from.w, to.w, interpolation); + interpolated.x = mlx::Lerp(from.x, to.x, interpolation); + interpolated.y = mlx::Lerp(from.y, to.y, interpolation); + interpolated.z = mlx::Lerp(from.z, to.z, interpolation); return interpolated; } diff --git a/runtime/Includes/Maths/Vec2.h b/runtime/Includes/Maths/Vec2.h index ec6f7a5..a08706d 100755 --- a/runtime/Includes/Maths/Vec2.h +++ b/runtime/Includes/Maths/Vec2.h @@ -1,17 +1,10 @@ -#ifndef __SCOP_VEC2__ -#define __SCOP_VEC2__ +#ifndef __MLX_VEC2__ +#define __MLX_VEC2__ -#include -#include -#include -#include - -#include - -namespace Scop +namespace mlx { - template class Vec3; - template class Vec4; + template struct Vec3; + template struct Vec4; template struct Vec2 diff --git a/runtime/Includes/Maths/Vec2.inl b/runtime/Includes/Maths/Vec2.inl index 1671da8..f31c2f8 100755 --- a/runtime/Includes/Maths/Vec2.inl +++ b/runtime/Includes/Maths/Vec2.inl @@ -1,8 +1,7 @@ #pragma once - #include -namespace Scop +namespace mlx { template constexpr Vec2::Vec2(T X, T Y) : x(X), y(Y) {} @@ -116,14 +115,14 @@ namespace Scop template constexpr T& Vec2::operator[](std::size_t i) { - Scop::Assert(i < 2, "index out of range"); + mlx::Assert(i < 2, "index out of range"); return *(&x + i); } template constexpr T Vec2::operator[](std::size_t i) const { - Scop::Assert(i < 2, "index out of range"); + mlx::Assert(i < 2, "index out of range"); return *(&x + i); } diff --git a/runtime/Includes/Maths/Vec3.h b/runtime/Includes/Maths/Vec3.h index 775431f..ef7fdd5 100755 --- a/runtime/Includes/Maths/Vec3.h +++ b/runtime/Includes/Maths/Vec3.h @@ -1,17 +1,10 @@ -#ifndef __SCOP_VEC3__ -#define __SCOP_VEC3__ +#ifndef __MLX_VEC3__ +#define __MLX_VEC3__ -#include -#include -#include -#include - -#include - -namespace Scop +namespace mlx { - template class Vec2; - template class Vec4; + template struct Vec2; + template struct Vec4; template struct Vec3 diff --git a/runtime/Includes/Maths/Vec3.inl b/runtime/Includes/Maths/Vec3.inl index 73c73ff..158c1d0 100755 --- a/runtime/Includes/Maths/Vec3.inl +++ b/runtime/Includes/Maths/Vec3.inl @@ -1,8 +1,7 @@ #pragma once - #include -namespace Scop +namespace mlx { template constexpr Vec3::Vec3(T X, T Y, T Z) : x(X), y(Y), z(Z) {} @@ -145,14 +144,14 @@ namespace Scop template constexpr T& Vec3::operator[](std::size_t i) { - Scop::Assert(i < 3, "index out of range"); + mlx::Assert(i < 3, "index out of range"); return *(&x + i); } template constexpr const T& Vec3::operator[](std::size_t i) const { - Scop::Assert(i < 3, "index out of range"); + mlx::Assert(i < 3, "index out of range"); return *(&x + i); } diff --git a/runtime/Includes/Maths/Vec4.h b/runtime/Includes/Maths/Vec4.h index e8bff3a..a7e40ee 100755 --- a/runtime/Includes/Maths/Vec4.h +++ b/runtime/Includes/Maths/Vec4.h @@ -1,17 +1,10 @@ -#ifndef __SCOP_VEC4__ -#define __SCOP_VEC4__ +#ifndef __MLX_VEC4__ +#define __MLX_VEC4__ -#include -#include -#include -#include - -#include - -namespace Scop +namespace mlx { - template class Vec2; - template class Vec3; + template struct Vec2; + template struct Vec3; template struct Vec4 diff --git a/runtime/Includes/Maths/Vec4.inl b/runtime/Includes/Maths/Vec4.inl index 7f016d7..deeb5c6 100755 --- a/runtime/Includes/Maths/Vec4.inl +++ b/runtime/Includes/Maths/Vec4.inl @@ -1,8 +1,7 @@ #pragma once - #include -namespace Scop +namespace mlx { template constexpr Vec4::Vec4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {} @@ -120,14 +119,14 @@ namespace Scop template constexpr T& Vec4::operator[](std::size_t i) { - Scop::Assert(i < 4, "index out of range"); + mlx::Assert(i < 4, "index out of range"); return *(&x + i); } template constexpr const T& Vec4::operator[](std::size_t i) const { - Scop::Assert(i < 4, "index out of range"); + mlx::Assert(i < 4, "index out of range"); return *(&x + i); } diff --git a/runtime/Includes/Platform/Window.h b/runtime/Includes/Platform/Window.h index 04ef60e..24adacf 100644 --- a/runtime/Includes/Platform/Window.h +++ b/runtime/Includes/Platform/Window.h @@ -2,6 +2,7 @@ #define __MLX_WINDOW__ #include +#include namespace mlx { diff --git a/runtime/Includes/PreCompiled.h b/runtime/Includes/PreCompiled.h index 0284a51..231ca2f 100644 --- a/runtime/Includes/PreCompiled.h +++ b/runtime/Includes/PreCompiled.h @@ -6,6 +6,7 @@ #define Window X11Window // f*ck X11 #include +#include #include #include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/runtime/Includes/Renderer/Buffer.h b/runtime/Includes/Renderer/Buffer.h index 24d7f31..8d0b489 100644 --- a/runtime/Includes/Renderer/Buffer.h +++ b/runtime/Includes/Renderer/Buffer.h @@ -19,11 +19,11 @@ namespace mlx void Swap(GPUBuffer& buffer) noexcept; - [[nodiscard]] MLX_FORCEINLINE void* GetMap() const noexcept { return m_memory.map; } + [[nodiscard]] MLX_FORCEINLINE void* GetMap() const noexcept { return p_map; } [[nodiscard]] MLX_FORCEINLINE VkBuffer Get() const noexcept { return m_buffer; } - [[nodiscard]] MLX_FORCEINLINE VkDeviceMemory GetMemory() const noexcept { return m_memory.memory; } - [[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetSize() const noexcept { return m_memory.size; } - [[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetOffset() const noexcept { return 0; } + [[nodiscard]] MLX_FORCEINLINE VmaAllocation GetAllocation() const noexcept { return m_allocation; } + [[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetSize() const noexcept { return m_size; } + [[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetOffset() const noexcept { return m_offset; } [[nodiscard]] inline bool IsInit() const noexcept { return m_buffer != VK_NULL_HANDLE; } diff --git a/runtime/Includes/Renderer/Image.h b/runtime/Includes/Renderer/Image.h index fb9952e..86bff31 100644 --- a/runtime/Includes/Renderer/Image.h +++ b/runtime/Includes/Renderer/Image.h @@ -34,7 +34,7 @@ namespace mlx virtual void Destroy() noexcept; [[nodiscard]] MLX_FORCEINLINE VkImage Get() const noexcept { return m_image; } - [[nodiscard]] MLX_FORCEINLINE VkDeviceMemory GetDeviceMemory() const noexcept { return m_memory.memory; } + [[nodiscard]] MLX_FORCEINLINE VmaAllocation GetAllocation() const noexcept { return m_allocation; } [[nodiscard]] MLX_FORCEINLINE VkImageView GetImageView() const noexcept { return m_image_view; } [[nodiscard]] MLX_FORCEINLINE VkFormat GetFormat() const noexcept { return m_format; } [[nodiscard]] MLX_FORCEINLINE VkImageTiling GetTiling() const noexcept { return m_tiling; } diff --git a/runtime/Includes/Renderer/Renderer.h b/runtime/Includes/Renderer/Renderer.h index 9502fbe..a2df8cd 100644 --- a/runtime/Includes/Renderer/Renderer.h +++ b/runtime/Includes/Renderer/Renderer.h @@ -30,7 +30,7 @@ namespace mlx [[nodiscard]] inline std::size_t& GetPolygonDrawnCounterRef() noexcept { return m_polygons_drawn; } [[nodiscard]] inline std::size_t GetSwapchainImageIndex() const noexcept { return m_swapchain_image_index; } [[nodiscard]] inline std::size_t GetCurrentFrameIndex() const noexcept { return m_current_frame_index; } - [[nodiscard]] inline NonOwningPtr GetWindow() const noexcept { return m_window_ptr; } + [[nodiscard]] inline NonOwningPtr GetWindow() const noexcept { return p_window; } MLX_FORCEINLINE constexpr void RequireFramebufferResize() noexcept { m_framebuffers_resize = true; } diff --git a/runtime/Includes/Renderer/Vertex.inl b/runtime/Includes/Renderer/Vertex.inl index f23eb77..fb09f95 100644 --- a/runtime/Includes/Renderer/Vertex.inl +++ b/runtime/Includes/Renderer/Vertex.inl @@ -14,7 +14,7 @@ namespace mlx std::array Vertex::GetAttributeDescriptions() { - std::array attribute_descriptions; + std::array attribute_descriptions; attribute_descriptions[0].binding = 0; attribute_descriptions[0].location = 0; diff --git a/runtime/Sources/Core/Application.cpp b/runtime/Sources/Core/Application.cpp index 3becaf4..9ed05fa 100644 --- a/runtime/Sources/Core/Application.cpp +++ b/runtime/Sources/Core/Application.cpp @@ -1,13 +1,10 @@ #include #include -#include -#include -#include -#include +#include +#include #include #include -#include namespace mlx { @@ -15,7 +12,7 @@ namespace mlx { EventBus::RegisterListener({[](const EventBase& event) { - }, "__internal_application" }); + }, "__Application" }); m_fps.init(); SDLManager::Get().Init(); @@ -76,7 +73,7 @@ namespace mlx void Application::DestroyTexture(void* ptr) { MLX_PROFILE_FUNCTION(); - vkDeviceWaitIdle(RenderCore::Get().GetDevice().Get()); // TODO : synchronize with another method than waiting for GPU to be idle + RenderCore::Get().WaitDeviceIdle(); // TODO : synchronize with another method than waiting for GPU to be idle if(!m_image_registry.Find(ptr)) { Error("invalid image ptr");