GSdx: Compiler check for const initialization of vectors

Make sure we don't accidentally end up with a vector-based non-const initialization
This commit is contained in:
TellowKrinkle 2021-03-12 21:58:56 -06:00 committed by Kojin
parent 5ac4b41281
commit f8b8b5db13
6 changed files with 56 additions and 44 deletions

View File

@ -23,26 +23,26 @@
#include "GSBlock.h"
#if _M_SSE >= 0x501
const GSVector8i GSBlock::m_r16mask(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15, 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15);
CONSTINIT const GSVector8i GSBlock::m_r16mask(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15, 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15);
#else
const GSVector4i GSBlock::m_r16mask(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15);
CONSTINIT const GSVector4i GSBlock::m_r16mask(0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15);
#endif
const GSVector4i GSBlock::m_r8mask(0, 4, 2, 6, 8, 12, 10, 14, 1, 5, 3, 7, 9, 13, 11, 15);
const GSVector4i GSBlock::m_r4mask(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, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15);
#if _M_SSE >= 0x501
const GSVector8i GSBlock::m_xxxa(GSVector8i::cxpr_set1_epi32(0x00008000));
const GSVector8i GSBlock::m_xxbx(GSVector8i::cxpr_set1_epi32(0x00007c00));
const GSVector8i GSBlock::m_xgxx(GSVector8i::cxpr_set1_epi32(0x000003e0));
const GSVector8i GSBlock::m_rxxx(GSVector8i::cxpr_set1_epi32(0x0000001f));
CONSTINIT const GSVector8i GSBlock::m_xxxa(GSVector8i::cxpr_set1_epi32(0x00008000));
CONSTINIT const GSVector8i GSBlock::m_xxbx(GSVector8i::cxpr_set1_epi32(0x00007c00));
CONSTINIT const GSVector8i GSBlock::m_xgxx(GSVector8i::cxpr_set1_epi32(0x000003e0));
CONSTINIT const GSVector8i GSBlock::m_rxxx(GSVector8i::cxpr_set1_epi32(0x0000001f));
#else
const GSVector4i GSBlock::m_xxxa(GSVector4i::cxpr_set1_epi32(0x00008000));
const GSVector4i GSBlock::m_xxbx(GSVector4i::cxpr_set1_epi32(0x00007c00));
const GSVector4i GSBlock::m_xgxx(GSVector4i::cxpr_set1_epi32(0x000003e0));
const GSVector4i GSBlock::m_rxxx(GSVector4i::cxpr_set1_epi32(0x0000001f));
CONSTINIT const GSVector4i GSBlock::m_xxxa(GSVector4i::cxpr_set1_epi32(0x00008000));
CONSTINIT const GSVector4i GSBlock::m_xxbx(GSVector4i::cxpr_set1_epi32(0x00007c00));
CONSTINIT const GSVector4i GSBlock::m_xgxx(GSVector4i::cxpr_set1_epi32(0x000003e0));
CONSTINIT const GSVector4i GSBlock::m_rxxx(GSVector4i::cxpr_set1_epi32(0x0000001f));
#endif
const GSVector4i GSBlock::m_uw8hmask0(0, 0, 0, 0, 1, 1, 1, 1, 8, 8, 8, 8, 9, 9, 9, 9);
const GSVector4i GSBlock::m_uw8hmask1(2, 2, 2, 2, 3, 3, 3, 3, 10, 10, 10, 10, 11, 11, 11, 11);
const GSVector4i GSBlock::m_uw8hmask2(4, 4, 4, 4, 5, 5, 5, 5, 12, 12, 12, 12, 13, 13, 13, 13);
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);

View File

@ -731,9 +731,9 @@ __forceinline void GSClut::ExpandCLUT64_T16(const GSVector4i& hi, const GSVector
// TODO
const GSVector4i GSClut::m_bm(GSVector4i::cxpr_set1_epi32(0x00007c00));
const GSVector4i GSClut::m_gm(GSVector4i::cxpr_set1_epi32(0x000003e0));
const GSVector4i GSClut::m_rm(GSVector4i::cxpr_set1_epi32(0x0000001f));
CONSTINIT const GSVector4i GSClut::m_bm(GSVector4i::cxpr_set1_epi32(0x00007c00));
CONSTINIT const GSVector4i GSClut::m_gm(GSVector4i::cxpr_set1_epi32(0x000003e0));
CONSTINIT const GSVector4i GSClut::m_rm(GSVector4i::cxpr_set1_epi32(0x0000001f));
void GSClut::Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int w, const GIFRegTEXA& TEXA)
{

View File

@ -22,7 +22,7 @@
#include "stdafx.h"
#include "GSVector.h"
const GSVector4i GSVector4i::m_xff[17] =
CONSTINIT const GSVector4i GSVector4i::m_xff[17] =
{
GSVector4i(0x00000000, 0x00000000, 0x00000000, 0x00000000),
GSVector4i(0x000000ff, 0x00000000, 0x00000000, 0x00000000),
@ -43,7 +43,7 @@ const GSVector4i GSVector4i::m_xff[17] =
GSVector4i(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff),
};
const GSVector4i GSVector4i::m_x0f[17] =
CONSTINIT const GSVector4i GSVector4i::m_x0f[17] =
{
GSVector4i(0x00000000, 0x00000000, 0x00000000, 0x00000000),
GSVector4i(0x0000000f, 0x00000000, 0x00000000, 0x00000000),
@ -64,32 +64,32 @@ const GSVector4i GSVector4i::m_x0f[17] =
GSVector4i(0x0f0f0f0f, 0x0f0f0f0f, 0x0f0f0f0f, 0x0f0f0f0f),
};
const GSVector4 GSVector4::m_ps0123(cxpr_setr_ps(0.0f, 1.0f, 2.0f, 3.0f));
const GSVector4 GSVector4::m_ps4567(cxpr_setr_ps(4.0f, 5.0f, 6.0f, 7.0f));
const GSVector4 GSVector4::m_half(cxpr_set1_ps(0.5f));
const GSVector4 GSVector4::m_one(cxpr_set1_ps(1.0f));
const GSVector4 GSVector4::m_two(cxpr_set1_ps(2.0f));
const GSVector4 GSVector4::m_four(cxpr_set1_ps(4.0f));
const GSVector4 GSVector4::m_x4b000000(cxpr_set1_epi32(0x4b000000));
const GSVector4 GSVector4::m_x4f800000(cxpr_set1_epi32(0x4f800000));
const GSVector4 GSVector4::m_max(cxpr_set1_ps(FLT_MAX));
const GSVector4 GSVector4::m_min(cxpr_set1_ps(FLT_MIN));
CONSTINIT const GSVector4 GSVector4::m_ps0123(cxpr_setr_ps(0.0f, 1.0f, 2.0f, 3.0f));
CONSTINIT const GSVector4 GSVector4::m_ps4567(cxpr_setr_ps(4.0f, 5.0f, 6.0f, 7.0f));
CONSTINIT const GSVector4 GSVector4::m_half(cxpr_set1_ps(0.5f));
CONSTINIT const GSVector4 GSVector4::m_one(cxpr_set1_ps(1.0f));
CONSTINIT const GSVector4 GSVector4::m_two(cxpr_set1_ps(2.0f));
CONSTINIT const GSVector4 GSVector4::m_four(cxpr_set1_ps(4.0f));
CONSTINIT const GSVector4 GSVector4::m_x4b000000(cxpr_set1_epi32(0x4b000000));
CONSTINIT const GSVector4 GSVector4::m_x4f800000(cxpr_set1_epi32(0x4f800000));
CONSTINIT const GSVector4 GSVector4::m_max(cxpr_set1_ps(FLT_MAX));
CONSTINIT const GSVector4 GSVector4::m_min(cxpr_set1_ps(FLT_MIN));
#if _M_SSE >= 0x500
const GSVector8 GSVector8::m_half(cxpr_set1_ps(0.5f));
const GSVector8 GSVector8::m_one(cxpr_set1_ps(1.0f));
const GSVector8 GSVector8::m_x7fffffff(cxpr_set1_epi32(0x7fffffff));
const GSVector8 GSVector8::m_x80000000(cxpr_set1_epi32(0x80000000));
const GSVector8 GSVector8::m_x4b000000(cxpr_set1_epi32(0x4b000000));
const GSVector8 GSVector8::m_x4f800000(cxpr_set1_epi32(0x4f800000));
const GSVector8 GSVector8::m_max(cxpr_set1_ps(FLT_MAX));
const GSVector8 GSVector8::m_min(cxpr_set1_ps(FLT_MAX));
CONSTINIT const GSVector8 GSVector8::m_half(cxpr_set1_ps(0.5f));
CONSTINIT const GSVector8 GSVector8::m_one(cxpr_set1_ps(1.0f));
CONSTINIT const GSVector8 GSVector8::m_x7fffffff(cxpr_set1_epi32(0x7fffffff));
CONSTINIT const GSVector8 GSVector8::m_x80000000(cxpr_set1_epi32(0x80000000));
CONSTINIT const GSVector8 GSVector8::m_x4b000000(cxpr_set1_epi32(0x4b000000));
CONSTINIT const GSVector8 GSVector8::m_x4f800000(cxpr_set1_epi32(0x4f800000));
CONSTINIT const GSVector8 GSVector8::m_max(cxpr_set1_ps(FLT_MAX));
CONSTINIT const GSVector8 GSVector8::m_min(cxpr_set1_ps(FLT_MAX));
#endif
#if _M_SSE >= 0x501
const GSVector8i GSVector8i::m_xff[33] =
CONSTINIT const GSVector8i GSVector8i::m_xff[33] =
{
GSVector8i(0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000),
GSVector8i(0x000000ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000),
@ -126,7 +126,7 @@ const GSVector8i GSVector8i::m_xff[33] =
GSVector8i(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff),
};
const GSVector8i GSVector8i::m_x0f[33] =
CONSTINIT const GSVector8i GSVector8i::m_x0f[33] =
{
GSVector8i(0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000),
GSVector8i(0x0000000f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000),

View File

@ -24,7 +24,7 @@
#include "GSUtil.h"
#include "GSState.h"
const GSVector4 GSVertexTrace::s_minmax(FLT_MAX, -FLT_MAX, 0.f, 0.f);
CONSTINIT const GSVector4 GSVertexTrace::s_minmax(FLT_MAX, -FLT_MAX, 0.f, 0.f);
GSVertexTrace::GSVertexTrace(const GSState* state)
: m_accurate_stq(false), m_state(state), m_primclass(GS_INVALID_CLASS)

View File

@ -26,9 +26,9 @@
static FILE* s_fp = LOG ? fopen("c:\\temp1\\_.txt", "w") : NULL;
const GSVector4 GSRendererSW::m_pos_scale(1.0f / 16, 1.0f / 16, 1.0f, 128.0f);
CONSTINIT const GSVector4 GSRendererSW::m_pos_scale(1.0f / 16, 1.0f / 16, 1.0f, 128.0f);
#if _M_SSE >= 0x501
const GSVector8 GSRendererSW::m_pos_scale2(1.0f / 16, 1.0f / 16, 1.0f, 128.0f, 1.0f / 16, 1.0f / 16, 1.0f, 128.0f);
CONSTINIT const GSVector8 GSRendererSW::m_pos_scale2(1.0f / 16, 1.0f / 16, 1.0f, 128.0f, 1.0f / 16, 1.0f / 16, 1.0f, 128.0f);
#endif
GSRendererSW::GSRendererSW(int threads)

View File

@ -426,3 +426,15 @@ struct GLAutoPop {
// Helper path to dump texture
extern const std::string root_sw;
extern const std::string root_hw;
#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