From a69977c62ba6bb4e204741f565eb757bb924a89a Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 22 Dec 2023 19:48:11 +1000 Subject: [PATCH] Misc: Always use C++20 constinit --- common/Pcsx2Defs.h | 12 ----------- pcsx2/GS/GSBlock.cpp | 30 +++++++++++++-------------- pcsx2/GS/GSClut.cpp | 6 +++--- pcsx2/GS/GSTables.cpp | 10 ++++----- pcsx2/GS/GSVector.cpp | 48 +++++++++++++++++++++---------------------- 5 files changed, 47 insertions(+), 59 deletions(-) diff --git a/common/Pcsx2Defs.h b/common/Pcsx2Defs.h index af3940eb70..f143248784 100644 --- a/common/Pcsx2Defs.h +++ b/common/Pcsx2Defs.h @@ -131,18 +131,6 @@ static constexpr unsigned int __pagemask = __pagesize - 1; #endif #endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif - -#ifdef __cpp_constinit - #define CONSTINIT constinit -#elif __has_attribute(require_constant_initialization) - #define CONSTINIT __attribute__((require_constant_initialization)) -#else - #define CONSTINIT -#endif - #define ASSERT assert ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/pcsx2/GS/GSBlock.cpp b/pcsx2/GS/GSBlock.cpp index c4e735a6d6..08fe5cd0df 100644 --- a/pcsx2/GS/GSBlock.cpp +++ b/pcsx2/GS/GSBlock.cpp @@ -18,20 +18,20 @@ MULTI_ISA_UNSHARED_IMPL; -CONSTINIT const GSVector4i GSBlock::m_r16mask(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15); -CONSTINIT const GSVector4i GSBlock::m_r8mask(0, 4, 2, 6, 8, 12, 10, 14, 1, 5, 3, 7, 9, 13, 11, 15); -CONSTINIT const GSVector4i GSBlock::m_r4mask(0, 8, 4, 12, 1, 9, 5, 13, 2, 10, 6, 14, 3, 11, 7, 15); -CONSTINIT const GSVector4i GSBlock::m_w4mask(0, 4, 8, 12, 2, 6, 10, 14, 1, 5, 9, 13, 3, 7, 11, 15); -CONSTINIT const GSVector4i GSBlock::m_r4hmask(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15); -CONSTINIT const GSVector4i GSBlock::m_r4hmask_avx2(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15); -CONSTINIT const GSVector4i GSBlock::m_palvec_mask(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); +constinit const GSVector4i GSBlock::m_r16mask(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15); +constinit const GSVector4i GSBlock::m_r8mask(0, 4, 2, 6, 8, 12, 10, 14, 1, 5, 3, 7, 9, 13, 11, 15); +constinit const GSVector4i GSBlock::m_r4mask(0, 8, 4, 12, 1, 9, 5, 13, 2, 10, 6, 14, 3, 11, 7, 15); +constinit const GSVector4i GSBlock::m_w4mask(0, 4, 8, 12, 2, 6, 10, 14, 1, 5, 9, 13, 3, 7, 11, 15); +constinit const GSVector4i GSBlock::m_r4hmask(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15); +constinit const GSVector4i GSBlock::m_r4hmask_avx2(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15); +constinit const GSVector4i GSBlock::m_palvec_mask(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); -CONSTINIT const GSVector4i GSBlock::m_avx2_r8mask1(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); -CONSTINIT const GSVector4i GSBlock::m_avx2_r8mask2(1, 5, 9, 13, 0, 4, 8, 12, 3, 7, 11, 15, 2, 6, 10, 14); -CONSTINIT const GSVector4i GSBlock::m_avx2_w8mask1(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); -CONSTINIT const GSVector4i GSBlock::m_avx2_w8mask2(4, 0, 12, 8, 5, 1, 13, 9, 6, 2, 14, 10, 7, 3, 15, 11); +constinit const GSVector4i GSBlock::m_avx2_r8mask1(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); +constinit const GSVector4i GSBlock::m_avx2_r8mask2(1, 5, 9, 13, 0, 4, 8, 12, 3, 7, 11, 15, 2, 6, 10, 14); +constinit const GSVector4i GSBlock::m_avx2_w8mask1(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); +constinit const GSVector4i GSBlock::m_avx2_w8mask2(4, 0, 12, 8, 5, 1, 13, 9, 6, 2, 14, 10, 7, 3, 15, 11); -CONSTINIT const GSVector4i GSBlock::m_uw8hmask0(0, 0, 0, 0, 1, 1, 1, 1, 8, 8, 8, 8, 9, 9, 9, 9); -CONSTINIT const GSVector4i GSBlock::m_uw8hmask1(2, 2, 2, 2, 3, 3, 3, 3, 10, 10, 10, 10, 11, 11, 11, 11); -CONSTINIT const GSVector4i GSBlock::m_uw8hmask2(4, 4, 4, 4, 5, 5, 5, 5, 12, 12, 12, 12, 13, 13, 13, 13); -CONSTINIT const GSVector4i GSBlock::m_uw8hmask3(6, 6, 6, 6, 7, 7, 7, 7, 14, 14, 14, 14, 15, 15, 15, 15); +constinit const GSVector4i GSBlock::m_uw8hmask0(0, 0, 0, 0, 1, 1, 1, 1, 8, 8, 8, 8, 9, 9, 9, 9); +constinit const GSVector4i GSBlock::m_uw8hmask1(2, 2, 2, 2, 3, 3, 3, 3, 10, 10, 10, 10, 11, 11, 11, 11); +constinit const GSVector4i GSBlock::m_uw8hmask2(4, 4, 4, 4, 5, 5, 5, 5, 12, 12, 12, 12, 13, 13, 13, 13); +constinit const GSVector4i GSBlock::m_uw8hmask3(6, 6, 6, 6, 7, 7, 7, 7, 14, 14, 14, 14, 15, 15, 15, 15); diff --git a/pcsx2/GS/GSClut.cpp b/pcsx2/GS/GSClut.cpp index d95421bd26..c0274d7538 100644 --- a/pcsx2/GS/GSClut.cpp +++ b/pcsx2/GS/GSClut.cpp @@ -823,9 +823,9 @@ __forceinline void GSClut::ExpandCLUT64_T16(const GSVector4i& hi, const GSVector // TODO -CONSTINIT const GSVector4i GSClut::m_bm = GSVector4i::cxpr(0x00007c00); -CONSTINIT const GSVector4i GSClut::m_gm = GSVector4i::cxpr(0x000003e0); -CONSTINIT const GSVector4i GSClut::m_rm = GSVector4i::cxpr(0x0000001f); +constinit const GSVector4i GSClut::m_bm = GSVector4i::cxpr(0x00007c00); +constinit const GSVector4i GSClut::m_gm = GSVector4i::cxpr(0x000003e0); +constinit const GSVector4i GSClut::m_rm = GSVector4i::cxpr(0x0000001f); void GSClut::Expand16(const u16* RESTRICT src, u32* RESTRICT dst, int w, const GIFRegTEXA& TEXA) { diff --git a/pcsx2/GS/GSTables.cpp b/pcsx2/GS/GSTables.cpp index 35a3c03550..e27649ac66 100644 --- a/pcsx2/GS/GSTables.cpp +++ b/pcsx2/GS/GSTables.cpp @@ -298,15 +298,15 @@ constexpr GSPixelColOffsetTable< 64> pixelColOffset16S = makeColOffsetTable(_bl constexpr GSPixelColOffsetTable< 64> pixelColOffset8 = makeColOffsetTable(_blockTable8, columnTable8); constexpr GSPixelColOffsetTable<128> pixelColOffset4 = makeColOffsetTable(_blockTable4, columnTable4); // These can't be constexpr due to a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99901 -CONSTINIT const GSSizedPixelRowOffsetTable< 64> GSTables::_pixelRowOffset32 = makeRowOffsetTable(_blockTable32, columnTable32, 0); -CONSTINIT const GSSizedPixelRowOffsetTable< 64> GSTables::_pixelRowOffset16 = makeRowOffsetTable(_blockTable16, columnTable16, 0); -CONSTINIT const GSSizedPixelRowOffsetTable< 64> GSTables::_pixelRowOffset16S = makeRowOffsetTable(_blockTable16S, columnTable16, 0); -CONSTINIT const GSSizedPixelRowOffsetTable<128> GSTables::_pixelRowOffset8[2] = +constinit const GSSizedPixelRowOffsetTable< 64> GSTables::_pixelRowOffset32 = makeRowOffsetTable(_blockTable32, columnTable32, 0); +constinit const GSSizedPixelRowOffsetTable< 64> GSTables::_pixelRowOffset16 = makeRowOffsetTable(_blockTable16, columnTable16, 0); +constinit const GSSizedPixelRowOffsetTable< 64> GSTables::_pixelRowOffset16S = makeRowOffsetTable(_blockTable16S, columnTable16, 0); +constinit const GSSizedPixelRowOffsetTable<128> GSTables::_pixelRowOffset8[2] = { makeRowOffsetTable(_blockTable8, columnTable8, 0), makeRowOffsetTable(_blockTable8, columnTable8, 2), }; -CONSTINIT const GSSizedPixelRowOffsetTable<128> GSTables::_pixelRowOffset4[2] = +constinit const GSSizedPixelRowOffsetTable<128> GSTables::_pixelRowOffset4[2] = { makeRowOffsetTable(_blockTable4, columnTable4, 0), makeRowOffsetTable(_blockTable4, columnTable4, 2), diff --git a/pcsx2/GS/GSVector.cpp b/pcsx2/GS/GSVector.cpp index dab402d2b1..016f91a50e 100644 --- a/pcsx2/GS/GSVector.cpp +++ b/pcsx2/GS/GSVector.cpp @@ -17,7 +17,7 @@ #include "GSVector.h" #include -CONSTINIT const GSVector4i GSVector4i::m_xff[17] = +constinit const GSVector4i GSVector4i::m_xff[17] = { cxpr(0x00000000, 0x00000000, 0x00000000, 0x00000000), cxpr(0x000000ff, 0x00000000, 0x00000000, 0x00000000), @@ -38,7 +38,7 @@ CONSTINIT const GSVector4i GSVector4i::m_xff[17] = cxpr(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), }; -CONSTINIT const GSVector4i GSVector4i::m_x0f[17] = +constinit const GSVector4i GSVector4i::m_x0f[17] = { cxpr(0x00000000, 0x00000000, 0x00000000, 0x00000000), cxpr(0x0000000f, 0x00000000, 0x00000000, 0x00000000), @@ -59,29 +59,29 @@ CONSTINIT const GSVector4i GSVector4i::m_x0f[17] = cxpr(0x0f0f0f0f, 0x0f0f0f0f, 0x0f0f0f0f, 0x0f0f0f0f), }; -CONSTINIT const GSVector4 GSVector4::m_ps0123 = cxpr(0.0f, 1.0f, 2.0f, 3.0f); -CONSTINIT const GSVector4 GSVector4::m_ps4567 = cxpr(4.0f, 5.0f, 6.0f, 7.0f); -CONSTINIT const GSVector4 GSVector4::m_half = cxpr(0.5f); -CONSTINIT const GSVector4 GSVector4::m_one = cxpr(1.0f); -CONSTINIT const GSVector4 GSVector4::m_two = cxpr(2.0f); -CONSTINIT const GSVector4 GSVector4::m_four = cxpr(4.0f); -CONSTINIT const GSVector4 GSVector4::m_x4b000000 = cxpr(0x4b000000); -CONSTINIT const GSVector4 GSVector4::m_x4f800000 = cxpr(0x4f800000); -CONSTINIT const GSVector4 GSVector4::m_xc1e00000000fffff = cxpr64(0xc1e00000000fffffull); -CONSTINIT const GSVector4 GSVector4::m_max = cxpr(FLT_MAX); -CONSTINIT const GSVector4 GSVector4::m_min = cxpr(FLT_MIN); +constinit const GSVector4 GSVector4::m_ps0123 = cxpr(0.0f, 1.0f, 2.0f, 3.0f); +constinit const GSVector4 GSVector4::m_ps4567 = cxpr(4.0f, 5.0f, 6.0f, 7.0f); +constinit const GSVector4 GSVector4::m_half = cxpr(0.5f); +constinit const GSVector4 GSVector4::m_one = cxpr(1.0f); +constinit const GSVector4 GSVector4::m_two = cxpr(2.0f); +constinit const GSVector4 GSVector4::m_four = cxpr(4.0f); +constinit const GSVector4 GSVector4::m_x4b000000 = cxpr(0x4b000000); +constinit const GSVector4 GSVector4::m_x4f800000 = cxpr(0x4f800000); +constinit const GSVector4 GSVector4::m_xc1e00000000fffff = cxpr64(0xc1e00000000fffffull); +constinit const GSVector4 GSVector4::m_max = cxpr(FLT_MAX); +constinit const GSVector4 GSVector4::m_min = cxpr(FLT_MIN); -CONSTINIT const GSVector8 GSVector8::m_half = cxpr(0.5f); -CONSTINIT const GSVector8 GSVector8::m_one = cxpr(1.0f); -CONSTINIT const GSVector8 GSVector8::m_x7fffffff = cxpr(0x7fffffff); -CONSTINIT const GSVector8 GSVector8::m_x80000000 = cxpr(0x80000000); -CONSTINIT const GSVector8 GSVector8::m_x4b000000 = cxpr(0x4b000000); -CONSTINIT const GSVector8 GSVector8::m_x4f800000 = cxpr(0x4f800000); -CONSTINIT const GSVector8 GSVector8::m_xc1e00000000fffff = cxpr64(0xc1e00000000fffffull); -CONSTINIT const GSVector8 GSVector8::m_max = cxpr(FLT_MAX); -CONSTINIT const GSVector8 GSVector8::m_min = cxpr(FLT_MAX); +constinit const GSVector8 GSVector8::m_half = cxpr(0.5f); +constinit const GSVector8 GSVector8::m_one = cxpr(1.0f); +constinit const GSVector8 GSVector8::m_x7fffffff = cxpr(0x7fffffff); +constinit const GSVector8 GSVector8::m_x80000000 = cxpr(0x80000000); +constinit const GSVector8 GSVector8::m_x4b000000 = cxpr(0x4b000000); +constinit const GSVector8 GSVector8::m_x4f800000 = cxpr(0x4f800000); +constinit const GSVector8 GSVector8::m_xc1e00000000fffff = cxpr64(0xc1e00000000fffffull); +constinit const GSVector8 GSVector8::m_max = cxpr(FLT_MAX); +constinit const GSVector8 GSVector8::m_min = cxpr(FLT_MAX); -CONSTINIT const GSVector8i GSVector8i::m_xff[33] = +constinit const GSVector8i GSVector8i::m_xff[33] = { cxpr(0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000), cxpr(0x000000ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000), @@ -118,7 +118,7 @@ CONSTINIT const GSVector8i GSVector8i::m_xff[33] = cxpr(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), }; -CONSTINIT const GSVector8i GSVector8i::m_x0f[33] = +constinit const GSVector8i GSVector8i::m_x0f[33] = { cxpr(0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000), cxpr(0x0000000f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000),