diff --git a/Common/UI/IconCache.cpp b/Common/UI/IconCache.cpp index 0dfb2615b9..6b2db7f201 100644 --- a/Common/UI/IconCache.cpp +++ b/Common/UI/IconCache.cpp @@ -14,7 +14,7 @@ #define MAX_RUNTIME_CACHE_SIZE (1024 * 1024 * 4) #define MAX_SAVED_CACHE_SIZE (1024 * 1024 * 1) -const uint32_t ICON_CACHE_MAGIC = MK_FOURCC("pICN"); +constexpr uint32_t ICON_CACHE_MAGIC = MK_FOURCC("pICN"); IconCache g_iconCache; diff --git a/GPU/Debugger/Breakpoints.cpp b/GPU/Debugger/Breakpoints.cpp index d22c6e11ee..1fefa29590 100644 --- a/GPU/Debugger/Breakpoints.cpp +++ b/GPU/Debugger/Breakpoints.cpp @@ -28,7 +28,7 @@ // These are commands we run before breaking on a texture. // They are commands that affect the decoding of the texture. -const static u8 textureRelatedCmds[] = { +static constexpr u8 textureRelatedCmds[] = { GE_CMD_TEXADDR0, GE_CMD_TEXADDR1, GE_CMD_TEXADDR2, GE_CMD_TEXADDR3, GE_CMD_TEXADDR4, GE_CMD_TEXADDR5, GE_CMD_TEXADDR6, GE_CMD_TEXADDR7, GE_CMD_TEXBUFWIDTH0, GE_CMD_TEXBUFWIDTH1, GE_CMD_TEXBUFWIDTH2, GE_CMD_TEXBUFWIDTH3, GE_CMD_TEXBUFWIDTH4, GE_CMD_TEXBUFWIDTH5, GE_CMD_TEXBUFWIDTH6, GE_CMD_TEXBUFWIDTH7, GE_CMD_TEXSIZE0, GE_CMD_TEXSIZE1, GE_CMD_TEXSIZE2, GE_CMD_TEXSIZE3, GE_CMD_TEXSIZE4, GE_CMD_TEXSIZE5, GE_CMD_TEXSIZE6, GE_CMD_TEXSIZE7, diff --git a/GPU/Debugger/State.cpp b/GPU/Debugger/State.cpp index 99700796dd..7996594602 100644 --- a/GPU/Debugger/State.cpp +++ b/GPU/Debugger/State.cpp @@ -231,11 +231,11 @@ void FormatStateRow(GPUDebugInterface *gpudebug, char *dest, size_t destSize, Cm case CMD_FMT_STENCILOP: { - static const char *stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT" }; + static constexpr const char *stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT" }; const u8 sfail = (value >> 0) & 0xFF; const u8 zfail = (value >> 8) & 0xFF; const u8 pass = (value >> 16) & 0xFF; - const u8 totalValid = (u8)ARRAY_SIZE(stencilOps); + constexpr u8 totalValid = (u8)ARRAY_SIZE(stencilOps); if (sfail < totalValid && zfail < totalValid && pass < totalValid) { snprintf(dest, destSize, "fail=%s, pass/depthfail=%s, pass=%s", stencilOps[sfail], stencilOps[zfail], stencilOps[pass]); } else { @@ -431,13 +431,13 @@ void FormatStateRow(GPUDebugInterface *gpudebug, char *dest, size_t destSize, Cm case CMD_FMT_TEXMAPMODE: { - static const char *const uvGenModes[] = { + static constexpr const char * uvGenModes[] = { "tex coords", "tex matrix", "tex env map", "unknown (tex coords?)", }; - static const char *const uvProjModes[] = { + static constexpr const char * uvProjModes[] = { "pos", "uv", "normalized normal", @@ -475,13 +475,13 @@ void FormatStateRow(GPUDebugInterface *gpudebug, char *dest, size_t destSize, Cm case CMD_FMT_LIGHTTYPE: { - static const char * const lightComputations[] = { + static constexpr const char * lightComputations[] = { "diffuse", "diffuse + spec", "pow(diffuse)", "unknown (diffuse?)", }; - static const char * const lightTypes[] = { + static constexpr const char * lightTypes[] = { "directional", "point", "spot", @@ -509,7 +509,7 @@ void FormatStateRow(GPUDebugInterface *gpudebug, char *dest, size_t destSize, Cm case CMD_FMT_PATCHPRIMITIVE: { - static const char * const patchPrims[] = { + static constexpr const char * patchPrims[] = { "triangles", "lines", "points", @@ -844,7 +844,7 @@ bool GetPrimPreview(u32 op, GEPrimitiveType &prim, std::vector & prim_type = (op >> 16) & 0x7; count = op & 0xFFFF; } else { - const GEPrimitiveType primLookup[] = { GE_PRIM_TRIANGLES, GE_PRIM_LINES, GE_PRIM_POINTS, GE_PRIM_POINTS }; + constexpr GEPrimitiveType primLookup[] = { GE_PRIM_TRIANGLES, GE_PRIM_LINES, GE_PRIM_POINTS, GE_PRIM_POINTS }; prim_type = primLookup[gstate.getPatchPrimitiveType()]; count_u = (op & 0x00FF) >> 0; count_v = (op & 0xFF00) >> 8; diff --git a/GPU/GLES/FragmentTestCacheGLES.cpp b/GPU/GLES/FragmentTestCacheGLES.cpp index b1443b01a5..e5ef804410 100644 --- a/GPU/GLES/FragmentTestCacheGLES.cpp +++ b/GPU/GLES/FragmentTestCacheGLES.cpp @@ -22,8 +22,8 @@ #include "GPU/Common/GPUStateUtils.h" // These are small, let's give them plenty of frames. -static const int FRAGTEST_TEXTURE_OLD_AGE = 307; -static const int FRAGTEST_DECIMATION_INTERVAL = 113; +static constexpr int FRAGTEST_TEXTURE_OLD_AGE = 307; +static constexpr int FRAGTEST_DECIMATION_INTERVAL = 113; FragmentTestCacheGLES::FragmentTestCacheGLES(Draw::DrawContext *draw) { render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index c233d80e97..d1d49f2076 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -247,7 +247,7 @@ void GPU_GLES::BeginHostFrame(const DisplayLayoutConfig &config) { // Save the cache from time to time. TODO: How often? We save on exit, so shouldn't need to do this all that often. - const int saveShaderCacheFrameInterval = 32767; // power of 2 - 1. About every 10 minutes at 60fps. + constexpr int saveShaderCacheFrameInterval = 32767; // power of 2 - 1. About every 10 minutes at 60fps. if (shaderCachePath_.Valid() && !(gpuStats.numFlips & saveShaderCacheFrameInterval) && coreState == CORE_RUNNING_CPU) { shaderManagerGL_->SaveCache(shaderCachePath_, &drawEngine_); } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 87d744aaa1..3f521fed94 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -137,7 +137,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, #ifdef USE_BONE_ARRAY queries.push_back({ &u_bone, "u_bone" }); #else - static const char * const boneNames[8] = { "u_bone0", "u_bone1", "u_bone2", "u_bone3", "u_bone4", "u_bone5", "u_bone6", "u_bone7", }; + static constexpr const char * boneNames[8] = { "u_bone0", "u_bone1", "u_bone2", "u_bone3", "u_bone4", "u_bone5", "u_bone6", "u_bone7", }; for (int i = 0; i < 8; i++) { queries.push_back({ &u_bone[i], boneNames[i] }); } @@ -156,20 +156,20 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, queries.push_back({ &u_lightControl, "u_lightControl" }); for (int i = 0; i < 4; i++) { - static const char * const lightPosNames[4] = { "u_lightpos0", "u_lightpos1", "u_lightpos2", "u_lightpos3", }; + static constexpr const char * lightPosNames[4] = { "u_lightpos0", "u_lightpos1", "u_lightpos2", "u_lightpos3", }; queries.push_back({ &u_lightpos[i], lightPosNames[i] }); - static const char * const lightdir_names[4] = { "u_lightdir0", "u_lightdir1", "u_lightdir2", "u_lightdir3", }; + static constexpr const char * lightdir_names[4] = { "u_lightdir0", "u_lightdir1", "u_lightdir2", "u_lightdir3", }; queries.push_back({ &u_lightdir[i], lightdir_names[i] }); - static const char * const lightatt_names[4] = { "u_lightatt0", "u_lightatt1", "u_lightatt2", "u_lightatt3", }; + static constexpr const char * lightatt_names[4] = { "u_lightatt0", "u_lightatt1", "u_lightatt2", "u_lightatt3", }; queries.push_back({ &u_lightatt[i], lightatt_names[i] }); - static const char * const lightangle_spotCoef_names[4] = { "u_lightangle_spotCoef0", "u_lightangle_spotCoef1", "u_lightangle_spotCoef2", "u_lightangle_spotCoef3", }; + static constexpr const char * lightangle_spotCoef_names[4] = { "u_lightangle_spotCoef0", "u_lightangle_spotCoef1", "u_lightangle_spotCoef2", "u_lightangle_spotCoef3", }; queries.push_back({ &u_lightangle_spotCoef[i], lightangle_spotCoef_names[i] }); - static const char * const lightambient_names[4] = { "u_lightambient0", "u_lightambient1", "u_lightambient2", "u_lightambient3", }; + static constexpr const char * lightambient_names[4] = { "u_lightambient0", "u_lightambient1", "u_lightambient2", "u_lightambient3", }; queries.push_back({ &u_lightambient[i], lightambient_names[i] }); - static const char * const lightdiffuse_names[4] = { "u_lightdiffuse0", "u_lightdiffuse1", "u_lightdiffuse2", "u_lightdiffuse3", }; + static constexpr const char * lightdiffuse_names[4] = { "u_lightdiffuse0", "u_lightdiffuse1", "u_lightdiffuse2", "u_lightdiffuse3", }; queries.push_back({ &u_lightdiffuse[i], lightdiffuse_names[i] }); - static const char * const lightspecular_names[4] = { "u_lightspecular0", "u_lightspecular1", "u_lightspecular2", "u_lightspecular3", }; + static constexpr const char * lightspecular_names[4] = { "u_lightspecular0", "u_lightspecular1", "u_lightspecular2", "u_lightspecular3", }; queries.push_back({ &u_lightspecular[i], lightspecular_names[i] }); } diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index d234b2fe6c..c8ee875298 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -31,7 +31,7 @@ #include "GPU/GLES/GPU_GLES.h" #include "GPU/GLES/FramebufferManagerGLES.h" -static const GLushort glBlendFactorLookup[(size_t)BlendFactor::COUNT] = { +static constexpr GLushort glBlendFactorLookup[(size_t)BlendFactor::COUNT] = { GL_ZERO, GL_ONE, GL_SRC_COLOR, @@ -65,7 +65,7 @@ static const GLushort glBlendFactorLookup[(size_t)BlendFactor::COUNT] = { GL_INVALID_ENUM, }; -static const GLushort glBlendEqLookup[(size_t)BlendEq::COUNT] = { +static constexpr GLushort glBlendEqLookup[(size_t)BlendEq::COUNT] = { GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, @@ -73,17 +73,17 @@ static const GLushort glBlendEqLookup[(size_t)BlendEq::COUNT] = { GL_MAX, }; -static const GLushort cullingMode[] = { +static constexpr GLushort cullingMode[] = { GL_FRONT, GL_BACK, }; -static const GLushort compareOps[] = { +static constexpr GLushort compareOps[] = { GL_NEVER, GL_ALWAYS, GL_EQUAL, GL_NOTEQUAL, GL_LESS, GL_LEQUAL, GL_GREATER, GL_GEQUAL, }; -static const GLushort stencilOps[] = { +static constexpr GLushort stencilOps[] = { GL_KEEP, GL_ZERO, GL_REPLACE, @@ -95,7 +95,7 @@ static const GLushort stencilOps[] = { }; #if !defined(USING_GLES2) -static const GLushort logicOps[] = { +static constexpr GLushort logicOps[] = { GL_CLEAR, GL_AND, GL_AND_REVERSE, diff --git a/GPU/GLES/StencilBufferGLES.cpp b/GPU/GLES/StencilBufferGLES.cpp index 441aa8bad2..e4a287c9e7 100644 --- a/GPU/GLES/StencilBufferGLES.cpp +++ b/GPU/GLES/StencilBufferGLES.cpp @@ -24,7 +24,7 @@ #include "GPU/GLES/FramebufferManagerGLES.h" #include "Common/GPU/ShaderWriter.h" -static const InputDef vs_inputs[] = { +static constexpr InputDef vs_inputs[] = { { "vec2", "a_position", Draw::SEM_POSITION }, }; @@ -34,7 +34,7 @@ struct DepthUB { float u_depthTo8[4]; }; -const UniformDef depthUniforms[] = { +constexpr UniformDef depthUniforms[] = { { "vec4", "u_depthFactor", 0 }, { "vec4", "u_depthShift", 1}, { "vec4", "u_depthTo8", 2}, @@ -46,15 +46,15 @@ const UniformBufferDesc depthUBDesc{ sizeof(DepthUB), { { "u_depthTo8", -1, -1, UniformType::FLOAT4, 32 }, } }; -static const SamplerDef samplers[] = { +static constexpr SamplerDef samplers[] = { { 0, "tex" }, }; -static const VaryingDef varyings[] = { +static constexpr VaryingDef varyings[] = { { "vec2", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" }, }; -static const char * const stencil_dl_fs = R"( +static constexpr const char * stencil_dl_fs = R"( #ifdef GL_ES #ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; @@ -77,7 +77,7 @@ void main() { } )"; -static const char * const stencil_vs = R"( +static constexpr const char * stencil_vs = R"( #ifdef GL_ES precision highp float; #endif @@ -141,7 +141,7 @@ bool FramebufferManagerGLES::ReadbackStencilbuffer(Draw::Framebuffer *fbo, int x draw_->BindPipeline(stencilReadbackPipeline_); // Fullscreen triangle coordinates. - static const float positions[6] = { + static constexpr float positions[6] = { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 8ca5ca602f..fd93d9a55a 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -77,7 +77,7 @@ static Draw::DataFormat getClutDestFormat(GEPaletteFormat format) { return Draw::DataFormat::UNDEFINED; } -static const GLuint MinFiltGL[8] = { +static constexpr GLuint MinFiltGL[8] = { GL_NEAREST, GL_LINEAR, GL_NEAREST, @@ -88,7 +88,7 @@ static const GLuint MinFiltGL[8] = { GL_LINEAR_MIPMAP_LINEAR, }; -static const GLuint MagFiltGL[2] = { +static constexpr GLuint MagFiltGL[2] = { GL_NEAREST, GL_LINEAR }; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index f6321102a5..7b0b363efe 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1457,8 +1457,8 @@ void GPUCommon::DoState(PointerWrap &p) { } else if (s >= 3) { // This may have been saved with or without padding, depending on platform. // We need to upconvert it to our consistently-padded struct. - static const size_t DisplayList_v3_size = 452; - static const size_t DisplayList_v4_size = 456; + static constexpr size_t DisplayList_v3_size = 452; + static constexpr size_t DisplayList_v4_size = 456; static_assert(DisplayList_v4_size == sizeof(DisplayList), "Make sure to change here when updating DisplayList"); p.DoVoid(&dls[0], DisplayList_v3_size); diff --git a/GPU/GPUState.cpp b/GPU/GPUState.cpp index b181154511..6d418f8d3b 100644 --- a/GPU/GPUState.cpp +++ b/GPU/GPUState.cpp @@ -362,7 +362,7 @@ void GPUStateCache::DoState(PointerWrap &p) { gstate_c.Dirty(DIRTY_WORLD_VIEW_PROJ_MATRIX | DIRTY_VIEW_PROJ_MATRIX); } -static const char *const g_gpuUseFlagNames[32] = { +static constexpr const char * g_gpuUseFlagNames[32] = { "GPU_USE_DUALSOURCE_BLEND", "GPU_USE_LIGHT_UBERSHADER", "GPU_USE_FRAGMENT_TEST_CACHE", diff --git a/GPU/GeDisasm.cpp b/GPU/GeDisasm.cpp index c4d4613356..5c41ffebd3 100644 --- a/GPU/GeDisasm.cpp +++ b/GPU/GeDisasm.cpp @@ -34,7 +34,7 @@ void GeDescribeVertexType(u32 op, char *buffer, int len) { int morphCount = (op & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT; int idx = (op & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT; - static const char * const colorNames[] = { + static constexpr const char * colorNames[] = { NULL, "unsupported1", "unsupported2", @@ -44,19 +44,19 @@ void GeDescribeVertexType(u32 op, char *buffer, int len) { "ABGR 4444", "ABGR 8888", }; - static const char * const typeNames[] = { + static constexpr const char * typeNames[] = { NULL, "u8", "u16", "float", }; - static const char * const typeNamesI[] = { + static constexpr const char * typeNamesI[] = { NULL, "u8", "u16", "u32", }; - static const char * const typeNamesS[] = { + static constexpr const char * typeNamesS[] = { NULL, "s8", "s16", @@ -94,7 +94,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { u32 cmd = op >> 24; u32 data = op & 0xFFFFFF; - static const char * const primTypes[8] = { + static constexpr const char * primTypes[8] = { "POINTS", "LINES", "LINE_STRIP", @@ -474,13 +474,13 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_TEXMAPMODE: { - static const char * const uvgen[] = { + static constexpr const char * uvgen[] = { "texcoords", "texgen matrix", "env map", "invalid" }; - static const char * const uvproj[] = { + static constexpr const char * uvproj[] = { "pos", "uv", "normalized normal", @@ -767,7 +767,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { float g = (float)((data>>8) & 0xff)/255.0f; float b = (float)(data>>16)/255.0f; - static const char * const lightColorTypes[] = { + static constexpr const char * lightColorTypes[] = { "ambient", "diffuse", "specular", @@ -1006,7 +1006,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_TEXFUNC: { - const char * const texfuncs[] = { + constexpr const char * texfuncs[] = { "modulate", "decal", "blend", @@ -1025,7 +1025,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_TEXFILTER: { - static const char * const textureFilters[] = { + static constexpr const char * textureFilters[] = { "nearest", "linear", "nearest, invalid", @@ -1057,7 +1057,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_TEXFORMAT: { - static const char * const texformats[] = { + static constexpr const char * texformats[] = { "5650", "5551", "4444", @@ -1105,7 +1105,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_TEXLEVEL: { - static const char * const mipLevelModes[] = { + static constexpr const char * mipLevelModes[] = { "auto + bias", "bias", "slope + bias", @@ -1149,14 +1149,14 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_STENCILOP: { - static const char * const stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT", "unsupported1", "unsupported2" }; + static constexpr const char * stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT", "unsupported1", "unsupported2" }; snprintf(buffer, bufsize, "Stencil op: fail=%s, pass/depthfail=%s, pass=%s", stencilOps[data & 7], stencilOps[(data >> 8) & 7], stencilOps[(data >> 16) & 7]); } break; case GE_CMD_STENCILTEST: { - static const char * const zTestFuncs[] = { " NEVER ", " ALWAYS ", " == ", " != ", " < ", " <= ", " > ", " >= " }; + static constexpr const char * zTestFuncs[] = { " NEVER ", " ALWAYS ", " == ", " != ", " < ", " <= ", " > ", " >= " }; if (data & ~0xFFFF07) snprintf(buffer, bufsize, "Stencil test: %02x%s(dst.a & %02x) (extra %06x)", (data >> 8) & 0xFF, zTestFuncs[data & 7], (data >> 16) & 0xFF, data & ~0xFFFF07); else @@ -1170,7 +1170,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_ZTEST: { - static const char * const zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; + static constexpr const char * zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; if (data & ~7) snprintf(buffer, bufsize, "Z test mode: %s (extra %06x)", zTestFuncs[data & 7], data & ~7); else @@ -1202,7 +1202,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { case GE_CMD_LOGICOP: { - const char * const logicOps[] = { + constexpr const char * logicOps[] = { "clear", "and", "reverse and", diff --git a/GPU/Software/RasterizerRegCache.cpp b/GPU/Software/RasterizerRegCache.cpp index 52ef2ae667..3f04dfe6a2 100644 --- a/GPU/Software/RasterizerRegCache.cpp +++ b/GPU/Software/RasterizerRegCache.cpp @@ -109,8 +109,8 @@ void RegCache::SetupABI(const std::vector &args, bool forceRetain) { Add(r, GEN_INVALID); #else // Okay, first, allocate args. SystemV gives to the first of each usable pool. - static const Reg genArgs[] = { RDI, RSI, RDX, RCX, R8, R9 }; - static const Reg vecArgs[] = { XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7 }; + static constexpr Reg genArgs[] = { RDI, RSI, RDX, RCX, R8, R9 }; + static constexpr Reg vecArgs[] = { XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7 }; size_t genIndex = 0; size_t vecIndex = 0; @@ -138,10 +138,10 @@ void RegCache::SetupABI(const std::vector &args, bool forceRetain) { // Add all other caller saved regs without purposes yet. // Must save: RBX, RSP, RBP, R12-R15 - static const Reg genTemps[] = { RAX, R10, R11 }; + static constexpr Reg genTemps[] = { RAX, R10, R11 }; for (Reg r : genTemps) Add(r, GEN_INVALID); - static const Reg vecTemps[] = { XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15 }; + static constexpr Reg vecTemps[] = { XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15 }; for (Reg r : vecTemps) Add(r, VEC_INVALID); #endif diff --git a/GPU/Software/Sampler.cpp b/GPU/Software/Sampler.cpp index 284bbb747d..5d95927661 100644 --- a/GPU/Software/Sampler.cpp +++ b/GPU/Software/Sampler.cpp @@ -269,9 +269,9 @@ static inline int GetPixelDataOffset(uint32_t row_pitch_pixels, uint32_t u, uint if (!swizzled) return (v * (row_pitch_pixels * texel_size_bits >> 3)) + (u * texel_size_bits >> 3); - const uint32_t tile_size_bits = 32; - const uint32_t tiles_in_block_horizontal = 4; - const uint32_t tiles_in_block_vertical = 8; + constexpr uint32_t tile_size_bits = 32; + constexpr uint32_t tiles_in_block_horizontal = 4; + constexpr uint32_t tiles_in_block_vertical = 8; constexpr uint32_t texels_per_tile = tile_size_bits / texel_size_bits; uint32_t tile_u = u / texels_per_tile; @@ -554,11 +554,11 @@ Vec4IntResult SOFTRAST_CALL GetTextureFunctionOutput(Vec4IntArg prim_color_in, V case GE_TEXFUNC_BLEND: { - const Vec3 const255(255, 255, 255); + constexpr Vec3 const255(255, 255, 255); const Vec3 texenv = Vec3::FromRGB(samplerID.cached.texBlendColor); // Unlike the others (and even alpha), this one simply always rounds up. - const Vec3 roundup = Vec3::AssignToAll(255); + constexpr Vec3 roundup = Vec3::AssignToAll(255); out_rgb = ((const255 - texcolor.rgb()) * prim_color.rgb() + texcolor.rgb() * texenv + roundup); // Must divide by less to keep the precision for doubling to be accurate. if (samplerID.useColorDoubling) diff --git a/GPU/Software/SamplerX86.cpp b/GPU/Software/SamplerX86.cpp index 31a607ef64..46172d19e7 100644 --- a/GPU/Software/SamplerX86.cpp +++ b/GPU/Software/SamplerX86.cpp @@ -678,12 +678,12 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { static const X64Reg srcArgReg = R8; static const X64Reg bufwArgReg = R9; #else - static const X64Reg uArgReg = RDI; - static const X64Reg vArgReg = RSI; - static const X64Reg srcArgReg = RDX; - static const X64Reg bufwArgReg = RCX; + static constexpr X64Reg uArgReg = RDI; + static constexpr X64Reg vArgReg = RSI; + static constexpr X64Reg srcArgReg = RDX; + static constexpr X64Reg bufwArgReg = RCX; #endif - static const X64Reg resultReg = RAX; + static constexpr X64Reg resultReg = RAX; X64Reg uReg = regCache_.Find(level1 ? RegCache::VEC_U1 : RegCache::VEC_ARG_U); X64Reg vReg = regCache_.Find(level1 ? RegCache::VEC_V1 : RegCache::VEC_ARG_V); @@ -3528,7 +3528,7 @@ bool SamplerJitCache::Jit_Decode4444Quad(const SamplerID &id, Rasterizer::RegCac return true; } -alignas(16) static const u32 color4444mask[4] = { 0xf00ff00f, 0xf00ff00f, 0xf00ff00f, 0xf00ff00f, }; +alignas(16) static constexpr u32 color4444mask[4] = { 0xf00ff00f, 0xf00ff00f, 0xf00ff00f, 0xf00ff00f, }; bool SamplerJitCache::Jit_Decode4444(const SamplerID &id) { Describe("4444"); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 35b991eca4..02848f4bc9 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -49,8 +49,8 @@ #include "GPU/Common/SplineCommon.h" #include "GPU/Debugger/Record.h" -const int FB_WIDTH = 480; -const int FB_HEIGHT = 272; +constexpr int FB_WIDTH = 480; +constexpr int FB_HEIGHT = 272; uint8_t clut[1024]; FormatBuffer fb; diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 20f905f3a7..cdabe8a1f9 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -157,7 +157,7 @@ static ScreenCoords ClipToScreenInternal(Vec3f scaled, const ClipCoords &coords, // Account for rounding for X and Y. // TODO: Validate actual rounding range. - const float SCREEN_BOUND = 4095.0f + (15.5f / 16.0f); + constexpr float SCREEN_BOUND = 4095.0f + (15.5f / 16.0f); // This matches hardware tests - depth is clamped when this flag is on. if constexpr (depthClamp) { diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index a0c00bf9fd..cb44051fdb 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -422,7 +422,7 @@ std::vector PipelineManagerVulkan::DebugGetObjectIDs(DebugShaderTyp return ids; } -static const char *const topologies[8] = { +static constexpr const char * topologies[8] = { "POINTS", "LINES", "LINESTRIP", @@ -431,7 +431,7 @@ static const char *const topologies[8] = { "TRIFAN", }; -static const char *const blendOps[8] = { +static constexpr const char * blendOps[8] = { "ADD", "SUB", "RSUB", @@ -439,7 +439,7 @@ static const char *const blendOps[8] = { "MAX", }; -static const char *const compareOps[8] = { +static constexpr const char * compareOps[8] = { "NEVER", "<", "==", @@ -450,7 +450,7 @@ static const char *const compareOps[8] = { "ALWAYS", }; -static const char *const logicOps[] = { +static constexpr const char * logicOps[] = { "CLEAR", "AND", "AND_REV", @@ -469,7 +469,7 @@ static const char *const logicOps[] = { "SET", }; -static const char *const stencilOps[8] = { +static constexpr const char * stencilOps[8] = { "KEEP", "ZERO", "REPL", @@ -480,7 +480,7 @@ static const char *const stencilOps[8] = { "DEC_WRAP", }; -static const char *const blendFactors[19] = { +static constexpr const char * blendFactors[19] = { "ZERO", "ONE", "SRC_COL", diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index 19353279ff..d3fc37b02e 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -28,7 +28,7 @@ #include "GPU/Vulkan/DrawEngineVulkan.h" // These tables all fit into u8s. -static const VkBlendFactor vkBlendFactorLookup[(size_t)BlendFactor::COUNT] = { +static constexpr VkBlendFactor vkBlendFactorLookup[(size_t)BlendFactor::COUNT] = { VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_SRC_COLOR, @@ -50,7 +50,7 @@ static const VkBlendFactor vkBlendFactorLookup[(size_t)BlendFactor::COUNT] = { VK_BLEND_FACTOR_MAX_ENUM, }; -static const VkBlendOp vkBlendEqLookup[(size_t)BlendEq::COUNT] = { +static constexpr VkBlendOp vkBlendEqLookup[(size_t)BlendEq::COUNT] = { VK_BLEND_OP_ADD, VK_BLEND_OP_SUBTRACT, VK_BLEND_OP_REVERSE_SUBTRACT, @@ -58,12 +58,12 @@ static const VkBlendOp vkBlendEqLookup[(size_t)BlendEq::COUNT] = { VK_BLEND_OP_MAX, }; -static const VkCullModeFlagBits cullingMode[] = { +static constexpr VkCullModeFlagBits cullingMode[] = { VK_CULL_MODE_BACK_BIT, VK_CULL_MODE_FRONT_BIT, }; -static const VkCompareOp compareOps[] = { +static constexpr VkCompareOp compareOps[] = { VK_COMPARE_OP_NEVER, VK_COMPARE_OP_ALWAYS, VK_COMPARE_OP_EQUAL, @@ -74,7 +74,7 @@ static const VkCompareOp compareOps[] = { VK_COMPARE_OP_GREATER_OR_EQUAL, }; -static const VkStencilOp stencilOps[] = { +static constexpr VkStencilOp stencilOps[] = { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_ZERO, VK_STENCIL_OP_REPLACE, @@ -85,7 +85,7 @@ static const VkStencilOp stencilOps[] = { VK_STENCIL_OP_KEEP, // reserved }; -static const VkPrimitiveTopology primToVulkan[8] = { +static constexpr VkPrimitiveTopology primToVulkan[8] = { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // We convert points to triangles. VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // We convert lines to triangles. VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // We convert line strips to triangles. @@ -96,7 +96,7 @@ static const VkPrimitiveTopology primToVulkan[8] = { }; // These are actually the same exact values/order/etc. as the GE ones, but for clarity... -static const VkLogicOp logicOps[] = { +static constexpr VkLogicOp logicOps[] = { VK_LOGIC_OP_CLEAR, VK_LOGIC_OP_AND, VK_LOGIC_OP_AND_REVERSE, diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index ab67da1f11..b3a4659d7e 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -27,9 +27,9 @@ // Disable this on x64 android, causes problems. #if defined(_DEBUG) && !(PPSSPP_PLATFORM(ANDROID) && PPSSPP_ARCH(AMD64)) -static const bool g_Validate = true; +static constexpr bool g_Validate = true; #else -static const bool g_Validate = false; +static constexpr bool g_Validate = false; #endif using namespace PPSSPP_VK; @@ -39,7 +39,7 @@ const VkComponentMapping VULKAN_1555_SWIZZLE = { VK_COMPONENT_SWIZZLE_B, VK_COMP const VkComponentMapping VULKAN_565_SWIZZLE = { VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_IDENTITY }; const VkComponentMapping VULKAN_8888_SWIZZLE = { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY }; -static const BindingType g_bindingTypes[] = { +static constexpr BindingType g_bindingTypes[] = { BindingType::STORAGE_IMAGE_COMPUTE, BindingType::STORAGE_BUFFER_COMPUTE, BindingType::STORAGE_BUFFER_COMPUTE,