starting to fix compilation issues

This commit is contained in:
2024-09-02 13:36:02 +02:00
parent a455d7704d
commit e0da415e86
29 changed files with 77 additions and 132 deletions

View File

@@ -27,7 +27,7 @@ MODE = "release"
CXX = clang++ 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 INCLUDES = -I./includes -I./runtime/Includes -I./runtime/Sources -I./third_party
LDLIBS = LDLIBS =

View File

@@ -19,7 +19,7 @@
Error("invalid image ptr (NULL)"); \ Error("invalid image ptr (NULL)"); \
retval; \ retval; \
} \ } \
else if(m_image_registry.Find(img)) \ else if(!m_image_registry.IsTextureKnown(img)) \
{ \ { \
Error("invalid image ptr"); \ Error("invalid image ptr"); \
retval; \ retval; \
@@ -29,8 +29,8 @@ namespace mlx
{ {
void Application::GetMousePos(int* x, int* y) noexcept void Application::GetMousePos(int* x, int* y) noexcept
{ {
*x = p_in->GetX(); *x = m_in.GetX();
*y = p_in->GetY(); *y = m_in.GetY();
} }
void Application::MouseMove(Handle win, int x, int y) noexcept 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) void* Application::NewGraphicsSuport(std::size_t w, std::size_t h, const char* title)
{ {
MLX_PROFILE_FUNCTION(); MLX_PROFILE_FUNCTION();
auto it = std::find_if(m_textures.begin(), m_textures.end(), [=](const Texture& texture) if(m_image_registry.IsTextureKnown(reinterpret_cast<Texture*>(const_cast<char*>(title))))
{
return &texture == reinterpret_cast<Texture*>(const_cast<char*>(title));
});
if(it != _textures.end())
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, reinterpret_cast<Texture*>(const_cast<char*>(title)), m_graphics.size())); m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, reinterpret_cast<Texture*>(const_cast<char*>(title)), m_graphics.size()));
else else
{ {
@@ -92,7 +88,7 @@ namespace mlx
{ {
MLX_PROFILE_FUNCTION(); MLX_PROFILE_FUNCTION();
CHECK_WINDOW_PTR(win); CHECK_WINDOW_PTR(win);
m_graphics[*static_cast<int*>(win)]->ClearRenderData(); m_graphics[*static_cast<int*>(win)]->ResetRenderData();
} }
void Application::DestroyGraphicsSupport(Handle win) void Application::DestroyGraphicsSupport(Handle win)
@@ -177,6 +173,6 @@ namespace mlx
void Application::LoopEnd() noexcept void Application::LoopEnd() noexcept
{ {
p_in->Finish(); m_in.Finish();
} }
} }

View File

@@ -7,7 +7,6 @@ namespace mlx
{ {
MLX_PROFILE_FUNCTION(); MLX_PROFILE_FUNCTION();
p_scene->ResetSprites(); p_scene->ResetSprites();
m_images_registry.Clear();
} }
void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept

View File

@@ -46,7 +46,7 @@ namespace mlx
std::shared_ptr<Texture> p_texture; std::shared_ptr<Texture> p_texture;
std::shared_ptr<Mesh> p_mesh; std::shared_ptr<Mesh> p_mesh;
Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f }; 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 };
}; };
} }

View File

@@ -1,11 +1,9 @@
#ifndef __SCOP_ANGLES__ #ifndef __MLX_ANGLES__
#define __SCOP_ANGLES__ #define __MLX_ANGLES__
#include <Maths/Enums.h> #include <Maths/Enums.h>
#include <utility>
#include <string>
namespace Scop namespace mlx
{ {
template<typename T> struct EulerAngles; template<typename T> struct EulerAngles;
template<typename T> struct Quat; template<typename T> struct Quat;

View File

@@ -1,13 +1,10 @@
#pragma once #pragma once
#include <Maths/Angles.h> #include <Maths/Angles.h>
#include <algorithm>
#include <sstream>
#include <Maths/Constants.h> #include <Maths/Constants.h>
#include <Maths/MathsUtils.h> #include <Maths/MathsUtils.h>
namespace Scop namespace mlx
{ {
namespace Internal namespace Internal
{ {

View File

@@ -1,11 +1,7 @@
#ifndef __SCOP_MATHS_CONSTANTS__ #ifndef __MLX_MATHS_CONSTANTS__
#define __SCOP_MATHS_CONSTANTS__ #define __MLX_MATHS_CONSTANTS__
#include <climits> namespace mlx
#include <limits>
#include <type_traits>
namespace Scop
{ {
template<typename T> constexpr std::size_t BitCount = CHAR_BIT * sizeof(T); template<typename T> constexpr std::size_t BitCount = CHAR_BIT * sizeof(T);

View File

@@ -1,9 +1,7 @@
#ifndef __SCOPE_MATHS_ENUMS__ #ifndef __MLX_MATHS_ENUMS__
#define __SCOPE_MATHS_ENUMS__ #define __MLX_MATHS_ENUMS__
#include <cstddef> namespace mlx
namespace Scop
{ {
enum class AngleUnit enum class AngleUnit
{ {

View File

@@ -1,11 +1,9 @@
#ifndef __SCOP_EULER_ANGLES__ #ifndef __MLX_EULER_ANGLES__
#define __SCOP_EULER_ANGLES__ #define __MLX_EULER_ANGLES__
#include <string>
#include <Maths/Angles.h> #include <Maths/Angles.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
struct EulerAngles struct EulerAngles

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <Maths/EulerAngles.h> #include <Maths/EulerAngles.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
constexpr EulerAngles<T>::EulerAngles(DegreeAngle<T> P, DegreeAngle<T> Y, DegreeAngle<T> R) : constexpr EulerAngles<T>::EulerAngles(DegreeAngle<T> P, DegreeAngle<T> Y, DegreeAngle<T> R) :

View File

@@ -1,13 +1,9 @@
#ifndef __SCOP_MAT4__ #ifndef __MLX_MAT4__
#define __SCOP_MAT4__ #define __MLX_MAT4__
#include <cstddef>
#include <limits>
#include <string>
#include <Maths/Angles.h> #include <Maths/Angles.h>
namespace Scop namespace mlx
{ {
template<typename T> struct Vec2; template<typename T> struct Vec2;
template<typename T> struct Vec3; template<typename T> struct Vec3;

View File

@@ -1,7 +1,6 @@
#pragma once #pragma once
#include <Maths/Mat4.h> #include <Maths/Mat4.h>
#include <Core/Logs.h>
#include <Maths/EulerAngles.h> #include <Maths/EulerAngles.h>
#include <Maths/Quaternions.h> #include <Maths/Quaternions.h>
#include <Maths/Vec2.h> #include <Maths/Vec2.h>
@@ -9,10 +8,7 @@
#include <Maths/Vec4.h> #include <Maths/Vec4.h>
#include <Maths/MathsUtils.h> #include <Maths/MathsUtils.h>
#include <cstring> namespace mlx
#include <sstream>
namespace Scop
{ {
template<typename T> template<typename T>
constexpr Mat4<T>::Mat4(T r11, T r12, T r13, T r14, constexpr Mat4<T>::Mat4(T r11, T r12, T r13, T r14,

View File

@@ -1,9 +1,7 @@
#ifndef __SCOP_MATHS_UTILS__ #ifndef __MLX_MATHS_UTILS__
#define __SCOP_MATHS_UTILS__ #define __MLX_MATHS_UTILS__
#include <concepts> namespace mlx
namespace Scop
{ {
template<typename T> template<typename T>
[[nodiscard]] constexpr T Mod(T x, T y) noexcept; [[nodiscard]] constexpr T Mod(T x, T y) noexcept;

View File

@@ -1,12 +1,9 @@
#pragma once #pragma once
#include <Maths/MathsUtils.h> #include <Maths/MathsUtils.h>
#include <type_traits>
#include <cmath>
#include <Maths/Constants.h> #include <Maths/Constants.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
[[nodiscard]] constexpr T Mod(T x, T y) noexcept [[nodiscard]] constexpr T Mod(T x, T y) noexcept

View File

@@ -1,10 +1,10 @@
#ifndef __SCOP_QUATERNIONS__ #ifndef __MLX_QUATERNIONS__
#define __SCOP_QUATERNIONS__ #define __MLX_QUATERNIONS__
#include <Maths/Angles.h> #include <Maths/Angles.h>
#include <Maths/Vec3.h> #include <Maths/Vec3.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
struct Quat struct Quat

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <Maths/Quaternions.h> #include <Maths/Quaternions.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
constexpr Quat<T>::Quat(T W, T X, T Y, T Z) : w(W), x(X), y(Y), z(Z) constexpr Quat<T>::Quat(T W, T X, T Y, T Z) : w(W), x(X), y(Y), z(Z)
@@ -46,7 +46,7 @@ namespace Scop
RadianAngle<T> Quat<T>::AngleBetween(const Quat& quat) const RadianAngle<T> Quat<T>::AngleBetween(const Quat& quat) const
{ {
T alpha = Vec3<T>::DotProduct(Vec3<T>(x, y, z), Vec3<T>(quat.x, quat.y, quat.z)); T alpha = Vec3<T>::DotProduct(Vec3<T>(x, y, z), Vec3<T>(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<typename T> template<typename T>
@@ -366,10 +366,10 @@ namespace Scop
constexpr Quat<T> Quat<T>::Lerp(const Quat& from, const Quat& to, T interpolation) constexpr Quat<T> Quat<T>::Lerp(const Quat& from, const Quat& to, T interpolation)
{ {
Quat interpolated; Quat interpolated;
interpolated.w = Scop::Lerp(from.w, to.w, interpolation); interpolated.w = mlx::Lerp(from.w, to.w, interpolation);
interpolated.x = Scop::Lerp(from.x, to.x, interpolation); interpolated.x = mlx::Lerp(from.x, to.x, interpolation);
interpolated.y = Scop::Lerp(from.y, to.y, interpolation); interpolated.y = mlx::Lerp(from.y, to.y, interpolation);
interpolated.z = Scop::Lerp(from.z, to.z, interpolation); interpolated.z = mlx::Lerp(from.z, to.z, interpolation);
return interpolated; return interpolated;
} }

View File

@@ -1,17 +1,10 @@
#ifndef __SCOP_VEC2__ #ifndef __MLX_VEC2__
#define __SCOP_VEC2__ #define __MLX_VEC2__
#include <string> namespace mlx
#include <limits>
#include <cstdint>
#include <cmath>
#include <Core/Logs.h>
namespace Scop
{ {
template <typename T> class Vec3; template <typename T> struct Vec3;
template <typename T> class Vec4; template <typename T> struct Vec4;
template <typename T> template <typename T>
struct Vec2 struct Vec2

View File

@@ -1,8 +1,7 @@
#pragma once #pragma once
#include <Maths/Vec2.h> #include <Maths/Vec2.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
constexpr Vec2<T>::Vec2(T X, T Y) : x(X), y(Y) {} constexpr Vec2<T>::Vec2(T X, T Y) : x(X), y(Y) {}
@@ -116,14 +115,14 @@ namespace Scop
template<typename T> template<typename T>
constexpr T& Vec2<T>::operator[](std::size_t i) constexpr T& Vec2<T>::operator[](std::size_t i)
{ {
Scop::Assert(i < 2, "index out of range"); mlx::Assert(i < 2, "index out of range");
return *(&x + i); return *(&x + i);
} }
template<typename T> template<typename T>
constexpr T Vec2<T>::operator[](std::size_t i) const constexpr T Vec2<T>::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); return *(&x + i);
} }

View File

@@ -1,17 +1,10 @@
#ifndef __SCOP_VEC3__ #ifndef __MLX_VEC3__
#define __SCOP_VEC3__ #define __MLX_VEC3__
#include <string> namespace mlx
#include <limits>
#include <cstdint>
#include <cmath>
#include <Core/Logs.h>
namespace Scop
{ {
template<typename T> class Vec2; template<typename T> struct Vec2;
template<typename T> class Vec4; template<typename T> struct Vec4;
template<typename T> template<typename T>
struct Vec3 struct Vec3

View File

@@ -1,8 +1,7 @@
#pragma once #pragma once
#include <Maths/Vec3.h> #include <Maths/Vec3.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
constexpr Vec3<T>::Vec3(T X, T Y, T Z) : x(X), y(Y), z(Z) {} constexpr Vec3<T>::Vec3(T X, T Y, T Z) : x(X), y(Y), z(Z) {}
@@ -145,14 +144,14 @@ namespace Scop
template<typename T> template<typename T>
constexpr T& Vec3<T>::operator[](std::size_t i) constexpr T& Vec3<T>::operator[](std::size_t i)
{ {
Scop::Assert(i < 3, "index out of range"); mlx::Assert(i < 3, "index out of range");
return *(&x + i); return *(&x + i);
} }
template<typename T> template<typename T>
constexpr const T& Vec3<T>::operator[](std::size_t i) const constexpr const T& Vec3<T>::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); return *(&x + i);
} }

View File

@@ -1,17 +1,10 @@
#ifndef __SCOP_VEC4__ #ifndef __MLX_VEC4__
#define __SCOP_VEC4__ #define __MLX_VEC4__
#include <string> namespace mlx
#include <limits>
#include <cstdint>
#include <cmath>
#include <Core/Logs.h>
namespace Scop
{ {
template<typename T> class Vec2; template<typename T> struct Vec2;
template<typename T> class Vec3; template<typename T> struct Vec3;
template<typename T> template<typename T>
struct Vec4 struct Vec4

View File

@@ -1,8 +1,7 @@
#pragma once #pragma once
#include <Maths/Vec4.h> #include <Maths/Vec4.h>
namespace Scop namespace mlx
{ {
template<typename T> template<typename T>
constexpr Vec4<T>::Vec4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {} constexpr Vec4<T>::Vec4(T X, T Y, T Z, T W) : x(X), y(Y), z(Z), w(W) {}
@@ -120,14 +119,14 @@ namespace Scop
template<typename T> template<typename T>
constexpr T& Vec4<T>::operator[](std::size_t i) constexpr T& Vec4<T>::operator[](std::size_t i)
{ {
Scop::Assert(i < 4, "index out of range"); mlx::Assert(i < 4, "index out of range");
return *(&x + i); return *(&x + i);
} }
template<typename T> template<typename T>
constexpr const T& Vec4<T>::operator[](std::size_t i) const constexpr const T& Vec4<T>::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); return *(&x + i);
} }

View File

@@ -2,6 +2,7 @@
#define __MLX_WINDOW__ #define __MLX_WINDOW__
#include <Maths/Vec2.h> #include <Maths/Vec2.h>
#include <Core/SDLManager.h>
namespace mlx namespace mlx
{ {

View File

@@ -6,6 +6,7 @@
#define Window X11Window // f*ck X11 #define Window X11Window // f*ck X11
#include <mlx_profile.h> #include <mlx_profile.h>
#include <mlx.h>
#include <cstdio> #include <cstdio>
#include <cstdarg> #include <cstdarg>
#include <iostream> #include <iostream>
@@ -38,6 +39,7 @@
#include <cstddef> #include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <random> #include <random>
#include <concepts>
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>

View File

@@ -19,11 +19,11 @@ namespace mlx
void Swap(GPUBuffer& buffer) noexcept; 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 VkBuffer Get() const noexcept { return m_buffer; }
[[nodiscard]] MLX_FORCEINLINE VkDeviceMemory GetMemory() const noexcept { return m_memory.memory; } [[nodiscard]] MLX_FORCEINLINE VmaAllocation GetAllocation() const noexcept { return m_allocation; }
[[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetSize() const noexcept { return m_memory.size; } [[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetSize() const noexcept { return m_size; }
[[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetOffset() const noexcept { return 0; } [[nodiscard]] MLX_FORCEINLINE VkDeviceSize GetOffset() const noexcept { return m_offset; }
[[nodiscard]] inline bool IsInit() const noexcept { return m_buffer != VK_NULL_HANDLE; } [[nodiscard]] inline bool IsInit() const noexcept { return m_buffer != VK_NULL_HANDLE; }

View File

@@ -34,7 +34,7 @@ namespace mlx
virtual void Destroy() noexcept; virtual void Destroy() noexcept;
[[nodiscard]] MLX_FORCEINLINE VkImage Get() const noexcept { return m_image; } [[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 VkImageView GetImageView() const noexcept { return m_image_view; }
[[nodiscard]] MLX_FORCEINLINE VkFormat GetFormat() const noexcept { return m_format; } [[nodiscard]] MLX_FORCEINLINE VkFormat GetFormat() const noexcept { return m_format; }
[[nodiscard]] MLX_FORCEINLINE VkImageTiling GetTiling() const noexcept { return m_tiling; } [[nodiscard]] MLX_FORCEINLINE VkImageTiling GetTiling() const noexcept { return m_tiling; }

View File

@@ -30,7 +30,7 @@ namespace mlx
[[nodiscard]] inline std::size_t& GetPolygonDrawnCounterRef() noexcept { return m_polygons_drawn; } [[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 GetSwapchainImageIndex() const noexcept { return m_swapchain_image_index; }
[[nodiscard]] inline std::size_t GetCurrentFrameIndex() const noexcept { return m_current_frame_index; } [[nodiscard]] inline std::size_t GetCurrentFrameIndex() const noexcept { return m_current_frame_index; }
[[nodiscard]] inline NonOwningPtr<Window> GetWindow() const noexcept { return m_window_ptr; } [[nodiscard]] inline NonOwningPtr<Window> GetWindow() const noexcept { return p_window; }
MLX_FORCEINLINE constexpr void RequireFramebufferResize() noexcept { m_framebuffers_resize = true; } MLX_FORCEINLINE constexpr void RequireFramebufferResize() noexcept { m_framebuffers_resize = true; }

View File

@@ -14,7 +14,7 @@ namespace mlx
std::array<VkVertexInputAttributeDescription, 2> Vertex::GetAttributeDescriptions() std::array<VkVertexInputAttributeDescription, 2> Vertex::GetAttributeDescriptions()
{ {
std::array<VkVertexInputAttributeDescription, 3> attribute_descriptions; std::array<VkVertexInputAttributeDescription, 2> attribute_descriptions;
attribute_descriptions[0].binding = 0; attribute_descriptions[0].binding = 0;
attribute_descriptions[0].location = 0; attribute_descriptions[0].location = 0;

View File

@@ -1,13 +1,10 @@
#include <PreCompiled.h> #include <PreCompiled.h>
#include <Core/Application.h> #include <Core/Application.h>
#include <Renderer/Texts/TextLibrary.h> #include <Renderer/Image.h>
#include <Renderer/Texts/FontLibrary.h> #include <Renderer/RenderCore.h>
#include <Renderer/Images/Texture.h>
#include <Renderer/Core/RenderCore.h>
#include <Core/Memory.h> #include <Core/Memory.h>
#include <Core/EventBus.h> #include <Core/EventBus.h>
#include <Core/SDLManager.h>
namespace mlx namespace mlx
{ {
@@ -15,7 +12,7 @@ namespace mlx
{ {
EventBus::RegisterListener({[](const EventBase& event) EventBus::RegisterListener({[](const EventBase& event)
{ {
}, "__internal_application" }); }, "__Application" });
m_fps.init(); m_fps.init();
SDLManager::Get().Init(); SDLManager::Get().Init();
@@ -76,7 +73,7 @@ namespace mlx
void Application::DestroyTexture(void* ptr) void Application::DestroyTexture(void* ptr)
{ {
MLX_PROFILE_FUNCTION(); 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)) if(!m_image_registry.Find(ptr))
{ {
Error("invalid image ptr"); Error("invalid image ptr");