diff --git a/Runtime/Graphics/CTevCombiners.hpp b/Runtime/Graphics/CTevCombiners.hpp index 18fe9072c..3abea61d2 100644 --- a/Runtime/Graphics/CTevCombiners.hpp +++ b/Runtime/Graphics/CTevCombiners.hpp @@ -43,7 +43,9 @@ struct CTevOp { , xc_scale(static_cast(compressedDesc >> 6 & 3)) , x10_regId(static_cast(compressedDesc >> 9 & 3)) {} - bool operator==(const CTevOp&) const = default; + bool operator==(const CTevOp& rhs) const { + return x0_clamp == rhs.x0_clamp && x4_op == rhs.x4_op && x8_bias == rhs.x8_bias && xc_scale == rhs.xc_scale; + } }; struct ColorPass { GX::TevColorArg x0_a; @@ -59,7 +61,7 @@ struct ColorPass { , x8_c(static_cast(compressedDesc >> 10 & 0x1F)) , xc_d(static_cast(compressedDesc >> 15 & 0x1F)) {} - bool operator==(const ColorPass&) const = default; + bool operator==(const ColorPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; struct AlphaPass { GX::TevAlphaArg x0_a; @@ -75,7 +77,7 @@ struct AlphaPass { , x8_c(static_cast(compressedDesc >> 10 & 0x1F)) , xc_d(static_cast(compressedDesc >> 15 & 0x1F)) {} - bool operator==(const AlphaPass&) const = default; + bool operator==(const AlphaPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; class CTevPass { u32 x0_id; @@ -96,7 +98,10 @@ public: void Execute(ERglTevStage stage) const; - bool operator==(const CTevPass&) const = default; + bool operator==(const CTevPass& rhs) const { + return x0_id == rhs.x0_id && x4_colorPass == rhs.x4_colorPass && x14_alphaPass == rhs.x14_alphaPass && + x24_colorOp == rhs.x24_colorOp && x38_alphaOp == rhs.x38_alphaOp; + } }; extern const CTevPass skPassThru; diff --git a/aurora/include/aurora/aurora.hpp b/aurora/include/aurora/aurora.hpp index aa1818ea5..609e4c2a4 100644 --- a/aurora/include/aurora/aurora.hpp +++ b/aurora/include/aurora/aurora.hpp @@ -178,7 +178,10 @@ struct WindowSize { uint32_t fb_height; float scale; - bool operator==(const WindowSize& rhs) const = default; + bool operator==(const WindowSize& rhs) const { + return width == rhs.width && height == rhs.height && fb_width == rhs.fb_width && fb_height == rhs.fb_height && + scale == rhs.scale; + } }; enum class MouseButton { None = 0, diff --git a/aurora/include/aurora/common.hpp b/aurora/include/aurora/common.hpp index 7d79c7d23..9710ac543 100644 --- a/aurora/include/aurora/common.hpp +++ b/aurora/include/aurora/common.hpp @@ -18,7 +18,7 @@ struct Vec2 { constexpr Vec2(T x, T y) : x(x), y(y) {} constexpr Vec2(const zeus::CVector2f& vec) : x(vec.x()), y(vec.y()) {} - bool operator==(const Vec2&) const = default; + bool operator==(const Vec2& rhs) const { return x == rhs.x && y == rhs.y; } }; template struct Vec3 { @@ -31,7 +31,7 @@ struct Vec3 { constexpr Vec3(const zeus::CVector3f& vec) : x(vec.x()), y(vec.y()), z(vec.z()) {} operator zeus::CVector3f() const { return {x, y, z}; } - bool operator==(const Vec3&) const = default; + bool operator==(const Vec3& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } }; template struct Vec4 { @@ -45,7 +45,7 @@ struct Vec4 { constexpr Vec4(const zeus::CVector4f& vec) : x(vec.x()), y(vec.y()), z(vec.z()), w(vec.w()) {} constexpr Vec4(const zeus::CColor& color) : x(color.r()), y(color.g()), z(color.b()), w(color.a()) {} - bool operator==(const Vec4&) const = default; + bool operator==(const Vec4& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; } }; template struct Mat3x2 { @@ -56,7 +56,7 @@ struct Mat3x2 { constexpr Mat3x2() = default; constexpr Mat3x2(const Vec2& m0, const Vec2& m1, const Vec2& m2) : m0(m0), m1(m1), m2(m2) {} - bool operator==(const Mat3x2&) const = default; + bool operator==(const Mat3x2& rhs) const { return m0 == rhs.m0 && m1 == rhs.m1 && m2 == rhs.m2; } }; template struct Mat4x2 { @@ -69,7 +69,7 @@ struct Mat4x2 { constexpr Mat4x2(const Vec2& m0, const Vec2& m1, const Vec2& m2, const Vec2& m3) : m0(m0), m1(m1), m2(m2), m3(m3) {} - bool operator==(const Mat4x2&) const = default; + bool operator==(const Mat4x2& rhs) const { return m0 == rhs.m0 && m1 == rhs.m1 && m2 == rhs.m2 && m3 == rhs.m3; } }; template struct Mat4x4 { @@ -84,7 +84,7 @@ struct Mat4x4 { constexpr Mat4x4(const zeus::CMatrix4f& m) : m0(m[0]), m1(m[1]), m2(m[2]), m3(m[3]) {} constexpr Mat4x4(const zeus::CTransform& m) : Mat4x4(m.toMatrix4f()) {} - bool operator==(const Mat4x4&) const = default; + bool operator==(const Mat4x4& rhs) const { return m0 == rhs.m0 && m1 == rhs.m1 && m2 == rhs.m2 && m3 == rhs.m3; } }; constexpr Mat4x4 Mat4x4_Identity{ Vec4{1.f, 0.f, 0.f, 0.f}, @@ -500,7 +500,7 @@ public: [[nodiscard]] constexpr bool IsSet(Flags const bit) const noexcept { return bool(*this & bit); } // relational operators - bool operator==(Flags const&) const noexcept = default; + bool operator==(Flags const& rhs) const noexcept { return m_mask == rhs.m_mask; } // logical operator constexpr bool operator!() const noexcept { return !m_mask; } diff --git a/aurora/lib/gfx/common.cpp b/aurora/lib/gfx/common.cpp index 25c3844a4..3c928d418 100644 --- a/aurora/lib/gfx/common.cpp +++ b/aurora/lib/gfx/common.cpp @@ -66,14 +66,21 @@ struct Command { float height; float znear; float zfar; - bool operator==(const SetViewportCommand& rhs) const = default; + + bool operator==(const SetViewportCommand& rhs) const { + return left == rhs.left && top == rhs.top && width == rhs.width && height == rhs.height && znear == rhs.znear && + zfar == rhs.zfar; + } } setViewport; struct SetScissorCommand { uint32_t x; uint32_t y; uint32_t w; uint32_t h; - bool operator==(const SetScissorCommand&) const = default; + + bool operator==(const SetScissorCommand& rhs) const { + return x == rhs.x && y == rhs.y && w == rhs.w && h == rhs.h; + } } setScissor; ShaderDrawCommand draw; } data; diff --git a/aurora/lib/gfx/gx.hpp b/aurora/lib/gfx/gx.hpp index 982363eed..cb827afae 100644 --- a/aurora/lib/gfx/gx.hpp +++ b/aurora/lib/gfx/gx.hpp @@ -26,7 +26,8 @@ struct TevPass { Arg b = Default; Arg c = Default; Arg d = Default; - bool operator==(const TevPass&) const = default; + + bool operator==(const TevPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; static_assert(std::has_unique_object_representations_v>); static_assert(std::has_unique_object_representations_v>); @@ -39,7 +40,8 @@ struct TevOp { u8 _p1 = 0; u8 _p2 = 0; u8 _p3 = 0; - bool operator==(const TevOp&) const = default; + + bool operator==(const TevOp& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; static_assert(std::has_unique_object_representations_v); struct TevStage { @@ -65,7 +67,8 @@ struct TevStage { bool indTexAddPrev = false; u8 _p1 = 0; u8 _p2 = 0; - bool operator==(const TevStage&) const = default; + + bool operator==(const TevStage& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; static_assert(std::has_unique_object_representations_v); struct IndStage { @@ -94,7 +97,8 @@ struct ColorChannelConfig { u8 _p1 = 0; u8 _p2 = 0; u8 _p3 = 0; - bool operator==(const ColorChannelConfig&) const = default; + + bool operator==(const ColorChannelConfig& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; static_assert(std::has_unique_object_representations_v); // For uniform generation @@ -115,7 +119,8 @@ struct TcgConfig { u8 _p1 = 0; u8 _p2 = 0; u8 _p3 = 0; - bool operator==(const TcgConfig&) const = default; + + bool operator==(const TcgConfig& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; static_assert(std::has_unique_object_representations_v); struct FogState { @@ -125,14 +130,20 @@ struct FogState { float nearZ = 0.f; float farZ = 0.f; zeus::CColor color; + + bool operator==(const FogState& rhs) const { + return type == rhs.type && startZ == rhs.startZ && endZ == rhs.endZ && nearZ == rhs.nearZ && farZ == rhs.farZ && + color == rhs.color; + } }; struct TevSwap { GX::TevColorChan red = GX::CH_RED; GX::TevColorChan green = GX::CH_GREEN; GX::TevColorChan blue = GX::CH_BLUE; GX::TevColorChan alpha = GX::CH_ALPHA; - bool operator==(const TevSwap&) const = default; - operator bool() const { return *this != TevSwap{}; } + + bool operator==(const TevSwap& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } + explicit operator bool() const { return *this != TevSwap{}; } }; static_assert(std::has_unique_object_representations_v); struct AlphaCompare { @@ -141,8 +152,9 @@ struct AlphaCompare { GX::AlphaOp op = GX::AOP_AND; GX::Compare comp1 = GX::ALWAYS; u32 ref1; - bool operator==(const AlphaCompare& other) const = default; - operator bool() const { return comp0 != GX::ALWAYS || comp1 != GX::ALWAYS; } + + bool operator==(const AlphaCompare& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } + explicit operator bool() const { return comp0 != GX::ALWAYS || comp1 != GX::ALWAYS; } }; static_assert(std::has_unique_object_representations_v); struct IndTexMtxInfo { @@ -245,8 +257,10 @@ struct TextureConfig { u8 _p1 = 0; u8 _p2 = 0; u8 _p3 = 0; - bool operator==(const TextureConfig&) const = default; + + bool operator==(const TextureConfig& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; +static_assert(std::has_unique_object_representations_v); struct ShaderConfig { GX::FogType fogType; std::array vtxAttrs; @@ -258,7 +272,8 @@ struct ShaderConfig { AlphaCompare alphaCompare; u32 indexedAttributeCount = 0; std::array textureConfig; - bool operator==(const ShaderConfig&) const = default; + + bool operator==(const ShaderConfig& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } }; static_assert(std::has_unique_object_representations_v); diff --git a/aurora/lib/gfx/movie_player/shader.cpp b/aurora/lib/gfx/movie_player/shader.cpp index ec1690e2e..5aa82413f 100644 --- a/aurora/lib/gfx/movie_player/shader.cpp +++ b/aurora/lib/gfx/movie_player/shader.cpp @@ -147,7 +147,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4 { } wgpu::RenderPipeline create_pipeline(const State& state, [[maybe_unused]] const PipelineConfig& config) { - const auto attributes = + constexpr auto attributes = make_vertex_attributes(std::array{wgpu::VertexFormat::Float32x3, wgpu::VertexFormat::Float32x2}); const std::array vertexBuffers{make_vertex_buffer_layout(sizeof(Vert), attributes)}; const auto depthStencil = wgpu::DepthStencilState{ diff --git a/aurora/lib/gpu.hpp b/aurora/lib/gpu.hpp index ba1653652..37eeefc1b 100644 --- a/aurora/lib/gpu.hpp +++ b/aurora/lib/gpu.hpp @@ -71,7 +71,7 @@ TextureWithSampler create_render_texture(bool multisampled); namespace aurora::gpu::utils { template -static consteval std::array +static constexpr std::array make_vertex_attributes(std::array formats) { std::array attributes; uint64_t offset = 0;