GCC 9 fixes: Replace all default equality operators

This commit is contained in:
Luke Street 2022-06-13 02:26:18 -04:00
parent c9e3065d12
commit 22417bcd75
7 changed files with 57 additions and 27 deletions

View File

@ -43,7 +43,9 @@ struct CTevOp {
, xc_scale(static_cast<GX::TevScale>(compressedDesc >> 6 & 3))
, x10_regId(static_cast<GX::TevRegID>(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<GX::TevColorArg>(compressedDesc >> 10 & 0x1F))
, xc_d(static_cast<GX::TevColorArg>(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<GX::TevAlphaArg>(compressedDesc >> 10 & 0x1F))
, xc_d(static_cast<GX::TevAlphaArg>(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;

View File

@ -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,

View File

@ -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 <typename T>
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 <typename T>
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 <typename T>
struct Mat3x2 {
@ -56,7 +56,7 @@ struct Mat3x2 {
constexpr Mat3x2() = default;
constexpr Mat3x2(const Vec2<T>& m0, const Vec2<T>& m1, const Vec2<T>& 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 <typename T>
struct Mat4x2 {
@ -69,7 +69,7 @@ struct Mat4x2 {
constexpr Mat4x2(const Vec2<T>& m0, const Vec2<T>& m1, const Vec2<T>& m2, const Vec2<T>& 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 <typename T>
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<float> Mat4x4_Identity{
Vec4<float>{1.f, 0.f, 0.f, 0.f},
@ -500,7 +500,7 @@ public:
[[nodiscard]] constexpr bool IsSet(Flags<BitType> const bit) const noexcept { return bool(*this & bit); }
// relational operators
bool operator==(Flags<BitType> const&) const noexcept = default;
bool operator==(Flags<BitType> const& rhs) const noexcept { return m_mask == rhs.m_mask; }
// logical operator
constexpr bool operator!() const noexcept { return !m_mask; }

View File

@ -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;

View File

@ -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<TevPass<GX::TevColorArg, GX::CC_ZERO>>);
static_assert(std::has_unique_object_representations_v<TevPass<GX::TevAlphaArg, GX::CA_ZERO>>);
@ -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<TevOp>);
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<TevStage>);
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<ColorChannelConfig>);
// 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<TcgConfig>);
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<TevSwap>);
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<AlphaCompare>);
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<TextureConfig>);
struct ShaderConfig {
GX::FogType fogType;
std::array<GX::AttrType, MaxVtxAttr> vtxAttrs;
@ -258,7 +272,8 @@ struct ShaderConfig {
AlphaCompare alphaCompare;
u32 indexedAttributeCount = 0;
std::array<TextureConfig, MaxTextures> 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<ShaderConfig>);

View File

@ -147,7 +147,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
}
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{

View File

@ -71,7 +71,7 @@ TextureWithSampler create_render_texture(bool multisampled);
namespace aurora::gpu::utils {
template <auto N>
static consteval std::array<wgpu::VertexAttribute, N>
static constexpr std::array<wgpu::VertexAttribute, N>
make_vertex_attributes(std::array<wgpu::VertexFormat, N> formats) {
std::array<wgpu::VertexAttribute, N> attributes;
uint64_t offset = 0;