diff --git a/Common/Data/Encoding/Shiftjis.h b/Common/Data/Encoding/Shiftjis.h index 5f77f7665db9..7d73ea381aee 100644 --- a/Common/Data/Encoding/Shiftjis.h +++ b/Common/Data/Encoding/Shiftjis.h @@ -20,6 +20,7 @@ struct ShiftJIS { return INVALID; } // Intentional fall-through. + [[fallthrough]]; case 0x9: case 0xE: row = ((j & 0x3F) << 1) - 0x01; diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index 3ed417466a8a..75e9451dfcf2 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -363,7 +363,7 @@ void RingbufferLogListener::Log(const LogMessage &message) { #ifdef _WIN32 void OutputDebugStringUTF8(const char *p) { - wchar_t temp[16384*4]; + wchar_t *temp = new wchar_t[65536]; int len = std::min(16383*4, (int)strlen(p)); int size = (int)MultiByteToWideChar(CP_UTF8, 0, p, len, NULL, 0); @@ -371,6 +371,7 @@ void OutputDebugStringUTF8(const char *p) { temp[size] = 0; OutputDebugString(temp); + delete[] temp; } #else diff --git a/Common/UI/Tween.h b/Common/UI/Tween.h index c3e4c1181e18..f290c0e49753 100644 --- a/Common/UI/Tween.h +++ b/Common/UI/Tween.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -65,7 +65,7 @@ template class TweenBase: public Tween { public: TweenBase(float duration, float (*curve)(float) = [](float f) { return f; }) - : Tween(duration, curve) { + : Tween(duration, curve), from_{}, to_{} { } TweenBase(Value from, Value to, float duration, float (*curve)(float) = [](float f) { return f; }) : Tween(duration, curve), from_(from), to_(to) { @@ -77,8 +77,9 @@ class TweenBase: public Tween { void Divert(const Value &newTo, float newDuration = -1.0f) { const Value newFrom = valid_ ? Current(Position()) : newTo; + double now = time_now_d(); // Are we already part way through another transition? - if (time_now_d() < start_ + delay_ + duration_ && valid_) { + if (now < start_ + delay_ + duration_ && valid_) { if (newTo == to_) { // Already on course. Don't change. return; @@ -88,17 +89,17 @@ class TweenBase: public Tween { if (newDuration >= 0.0f) { newOffset *= newDuration / duration_; } - start_ = time_now_d() - newOffset - delay_; - } else if (time_now_d() <= start_ + delay_) { + start_ = now - newOffset - delay_; + } else if (now <= start_ + delay_) { // Start the delay over again. - start_ = time_now_d(); + start_ = now; } else { // Since we've partially animated to the other value, skip delay. - start_ = time_now_d() - delay_; + start_ = now - delay_; } } else { // Already finished, so restart. - start_ = time_now_d(); + start_ = now; finishApplied_ = false; } diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 82a7fa532e52..26c0a4949e7d 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -883,7 +883,7 @@ std::set SavedataParam::GetSecureFileNames(const std::string &dirPa std::set secureFileNames; for (const auto &entry : entries) { - char temp[14]; + char temp[14]{}; truncate_cpy(temp, entry.filename); secureFileNames.insert(temp); } diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 6b6049a64bba..0715a40dc7a6 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -1208,7 +1208,7 @@ static int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCode if (PSP_CoreParameter().compat.flags().Fontltn12Hack && requestedStyle->fontLanguage == 2) { for (size_t j = 0; j < internalFonts.size(); j++) { - const auto tempmatchStyle = internalFonts[j]->GetFontStyle(); + const auto &tempmatchStyle = internalFonts[j]->GetFontStyle(); const std::string str(tempmatchStyle.fontFileName); if (str == "ltn12.pgf") { optimumFont = internalFonts[j]; diff --git a/Core/MIPS/IR/IRInst.h b/Core/MIPS/IR/IRInst.h index 0dbfa6790520..4348d527e554 100644 --- a/Core/MIPS/IR/IRInst.h +++ b/Core/MIPS/IR/IRInst.h @@ -379,7 +379,7 @@ class IRWriter { insts_ = w.insts_; return *this; } - IRWriter &operator =(IRWriter &&w) { + IRWriter &operator =(IRWriter &&w) noexcept { insts_ = std::move(w.insts_); return *this; } diff --git a/Core/MIPS/IR/IRJit.h b/Core/MIPS/IR/IRJit.h index c8ef2d5192c3..063bb40c9c2a 100644 --- a/Core/MIPS/IR/IRJit.h +++ b/Core/MIPS/IR/IRJit.h @@ -51,7 +51,7 @@ class IRBlock { IRBlock() {} IRBlock(u32 emAddr, u32 origSize, int instOffset, u32 numInstructions) : origAddr_(emAddr), origSize_(origSize), arenaOffset_(instOffset), numIRInstructions_(numInstructions) {} - IRBlock(IRBlock &&b) { + IRBlock(IRBlock &&b) noexcept { arenaOffset_ = b.arenaOffset_; hash_ = b.hash_; origAddr_ = b.origAddr_; diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index a5e522ce6b04..3993962999c0 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -207,6 +207,8 @@ void MIPSState::Init() { nextPC = 0; downcount = 0; + memset(vcmpResult, 0, sizeof(vcmpResult)); + std::lock_guard guard(MIPSComp::jitLock); if (PSP_CoreParameter().cpuCore == CPUCore::JIT || PSP_CoreParameter().cpuCore == CPUCore::JIT_IR) { MIPSComp::jit = MIPSComp::CreateNativeJit(this, PSP_CoreParameter().cpuCore == CPUCore::JIT_IR); diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index c5d712beff9d..f0ae68a799a3 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -961,9 +961,11 @@ namespace MIPSInt case V_Triple: sz = V_Pair; // Intentional fallthrough. + [[fallthrough]]; case V_Pair: oz = V_Quad; // Intentional fallthrough. + [[fallthrough]]; case V_Single: for (int i = 0; i < GetNumVectorElements(sz); i++) { u32 value = s[i]; @@ -985,9 +987,11 @@ namespace MIPSInt case V_Triple: sz = V_Pair; // Intentional fallthrough. + [[fallthrough]]; case V_Pair: oz = V_Quad; // Intentional fallthrough. + [[fallthrough]]; case V_Single: for (int i = 0; i < GetNumVectorElements(sz); i++) { u32 value = s[i]; diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 72907d7aea9c..e580c2eb7a3f 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -27,10 +27,6 @@ // Slow freaking thing but works (eventually) :) -BlockAllocator::BlockAllocator(int grain) : bottom_(NULL), top_(NULL), grain_(grain) -{ -} - BlockAllocator::~BlockAllocator() { Shutdown(); diff --git a/Core/Util/BlockAllocator.h b/Core/Util/BlockAllocator.h index 91e9642462bf..51a4038ca114 100644 --- a/Core/Util/BlockAllocator.h +++ b/Core/Util/BlockAllocator.h @@ -24,7 +24,7 @@ class PointerWrap; class BlockAllocator { public: - BlockAllocator(int grain = 16); // 16 byte granularity by default. + BlockAllocator(int grain = 16) : grain_(grain) {} // 16 byte granularity by default. ~BlockAllocator(); void Init(u32 _rangeStart, u32 _rangeSize, bool suballoc); @@ -59,8 +59,7 @@ class BlockAllocator private: void CheckBlocks() const; - struct Block - { + struct Block { Block(u32 _start, u32 _size, bool _taken, Block *_prev, Block *_next); void SetAllocated(const char *_tag, bool suballoc); void DoState(PointerWrap &p); @@ -72,13 +71,13 @@ class BlockAllocator Block *next; }; - Block *bottom_; - Block *top_; - u32 rangeStart_; - u32 rangeSize_; + Block *bottom_ = nullptr; + Block *top_ = nullptr; + u32 rangeStart_ = 0; + u32 rangeSize_ = 0; u32 grain_; - bool suballoc_; + bool suballoc_ = false; void MergeFreeBlocks(Block *fromBlock); Block *GetBlockFromAddress(u32 addr); diff --git a/Core/Util/DisArm64.cpp b/Core/Util/DisArm64.cpp index aa49af09cd9b..2414eec4093a 100644 --- a/Core/Util/DisArm64.cpp +++ b/Core/Util/DisArm64.cpp @@ -418,7 +418,7 @@ static void DataProcessingRegister(uint32_t w, uint64_t addr, Instruction *instr int opcode2 = (w >> 16) & 0x1F; int opcode = (w >> 10) & 0x3F; // Data-processing (1 source) - const char *opname[8] = { "rbit", "rev16", "rev32", "(unk)", "clz", "cls" }; + const char *opname[64] = { "rbit", "rev16", "rev32", "(unk)", "clz", "cls" }; const char *op = opcode2 >= 8 ? "unk" : opname[opcode]; snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d", op, r, Rd, r, Rn); } else if (((w >> 21) & 0x2FF) == 0x0D6) { @@ -749,7 +749,7 @@ static void FPandASIMD1(uint32_t w, uint64_t addr, Instruction *instr) { int dst_index = imm5 >> (size + 1); int src_index = imm4 >> size; int op = (w >> 29) & 1; - char s; + char s = '_'; switch (size) { case 0x00: s = 'b'; break; case 0x01: s = 'h'; break; diff --git a/Core/Util/GameDB.h b/Core/Util/GameDB.h index 5d211da72495..babf63e244f1 100644 --- a/Core/Util/GameDB.h +++ b/Core/Util/GameDB.h @@ -12,8 +12,8 @@ class VFSInterface; struct GameDBInfo { std::string title; std::string foreignTitle; - uint32_t crc; - uint64_t size; + uint32_t crc = 0; + uint64_t size = 0; }; class GameDB { diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 14d8bfbb0c91..0f84d22b1581 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -44,6 +44,7 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) { transformedExpanded_ = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); decoded_ = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); decIndex_ = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); + indexGen.Setup(decIndex_); } DrawEngineCommon::~DrawEngineCommon() { diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 5d8399e48c2f..9291f2d1ed74 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1911,8 +1911,8 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, struct CopyCandidate { VirtualFramebuffer *vfb = nullptr; - int y; - int h; + int y = 0; + int h = 0; std::string ToString(RasterChannel channel) const { return StringFromFormat("%08x %s %dx%d y=%d h=%d", vfb->Address(channel), GeBufferFormatToString(vfb->Format(channel)), vfb->width, vfb->height, y, h); diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index f4a7abba97d8..710264d9589f 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -91,7 +91,7 @@ bool IsAlphaTestTriviallyTrue() { return false; } // Fallthrough on purpose - + [[fallthrough]]; case GE_COMP_GREATER: { // If the texture and vertex only use 1.0 alpha, then the ref value doesn't matter. diff --git a/GPU/Common/IndexGenerator.cpp b/GPU/Common/IndexGenerator.cpp index 482b78f569fb..e3ae7e161936 100644 --- a/GPU/Common/IndexGenerator.cpp +++ b/GPU/Common/IndexGenerator.cpp @@ -48,11 +48,6 @@ const u8 IndexGenerator::indexedPrimitiveType[7] = { GE_PRIM_RECTANGLES, }; -void IndexGenerator::Setup(u16 *inds) { - this->indsBase_ = inds; - Reset(); -} - void IndexGenerator::AddPrim(int prim, int vertexCount, int indexOffset, bool clockwise) { switch (prim) { case GE_PRIM_POINTS: AddPoints(vertexCount, indexOffset); break; diff --git a/GPU/Common/IndexGenerator.h b/GPU/Common/IndexGenerator.h index 9e77c2591f1a..723f4caabd7c 100644 --- a/GPU/Common/IndexGenerator.h +++ b/GPU/Common/IndexGenerator.h @@ -24,9 +24,12 @@ class IndexGenerator { public: - void Setup(u16 *indexptr); + void Setup(u16 *indexptr) { + indsBase_ = indexptr; + inds_ = indexptr; + } void Reset() { - this->inds_ = indsBase_; + inds_ = indsBase_; } static bool PrimCompatible(int prim1, int prim2) { diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index a4a979126d0a..f17b29ea22b6 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -194,6 +194,7 @@ void TextureShaderCache::Decimate() { ++tex; } } + gpuStats.numClutTextures = (int)texCache_.size(); } Draw2DPipeline *TextureShaderCache::GetDepalettizeShader(uint32_t clutMode, GETextureFormat textureFormat, GEBufferFormat bufferFormat, bool smoothedDepal, u32 depthUpperBits) { diff --git a/GPU/Common/TextureShaderCommon.h b/GPU/Common/TextureShaderCommon.h index 37d2c32a528a..991d1ac35fc8 100644 --- a/GPU/Common/TextureShaderCommon.h +++ b/GPU/Common/TextureShaderCommon.h @@ -27,7 +27,6 @@ #include "GPU/Common/Draw2D.h" #include "GPU/Common/ShaderCommon.h" - class ClutTexture { public: enum { MAX_RAMPS = 3 }; diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index db0440c6c48b..f941e4d17074 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -80,16 +80,7 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, decOptions_.expandAllWeightsToFloat = true; decOptions_.expand8BitNormalsToFloat = true; - // Allocate nicely aligned memory. Maybe graphics drivers will - // appreciate it. - // All this is a LOT of memory, need to see if we can cut down somehow. - indexGen.Setup(decIndex_); - InitDeviceObjects(); - - // Vertex pushing buffers. For uniforms we use short DISCARD buffers, but we could use - // this kind of buffer there as well with D3D11.1. We might be able to use the same buffer - // for both vertices and indices, and possibly all three data types. } DrawEngineD3D11::~DrawEngineD3D11() { diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 5c9e3c17b17f..6b8e8bdca002 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -89,8 +89,6 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : draw_(draw), vertexDeclM decOptions_.expandAllWeightsToFloat = true; decOptions_.expand8BitNormalsToFloat = true; - indexGen.Setup(decIndex_); - InitDeviceObjects(); tessDataTransferDX9 = new TessellationDataTransferDX9(); diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 8fc2f75d7729..0e3090752b1e 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -67,8 +67,6 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : inputLayoutMap_(16), d decOptions_.expandAllWeightsToFloat = false; decOptions_.expand8BitNormalsToFloat = false; - indexGen.Setup(decIndex_); - InitDeviceObjects(); tessDataTransferGLES = new TessellationDataTransferGLES(render_); diff --git a/GPU/GPU.h b/GPU/GPU.h index ae60d2ba30f9..d0de86246605 100644 --- a/GPU/GPU.h +++ b/GPU/GPU.h @@ -105,6 +105,7 @@ struct GPUStatistics { numBlockTransfers = 0; numReplacerTrackedTex = 0; numCachedReplacedTextures = 0; + numClutTextures = 0; msProcessingDisplayLists = 0; vertexGPUCycles = 0; otherGPUCycles = 0; @@ -142,6 +143,7 @@ struct GPUStatistics { int numBlockTransfers; int numReplacerTrackedTex; int numCachedReplacedTextures; + int numClutTextures; double msProcessingDisplayLists; int vertexGPUCycles; int otherGPUCycles; diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index 9dcbc9cc3aad..678ec52428b7 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -1756,7 +1756,7 @@ size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) { "Draw: %d (%d dec, %d culled), flushes %d, clears %d, bbox jumps %d (%d updates)\n" "Vertices: %d dec: %d drawn: %d\n" "FBOs active: %d (evaluations: %d)\n" - "Textures: %d, dec: %d, invalidated: %d, hashed: %d kB\n" + "Textures: %d, dec: %d, invalidated: %d, hashed: %d kB, clut %d\n" "readbacks %d (%d non-block), upload %d (cached %d), depal %d\n" "block transfers: %d\n" "replacer: tracks %d references, %d unique textures\n" @@ -1781,6 +1781,7 @@ size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) { gpuStats.numTexturesDecoded, gpuStats.numTextureInvalidations, gpuStats.numTextureDataBytesHashed / 1024, + gpuStats.numClutTextures, gpuStats.numBlockingReadbacks, gpuStats.numReadbacks, gpuStats.numUploads, diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index e20c5d05353b..66f146e662b5 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -62,7 +62,6 @@ DrawEngineVulkan::DrawEngineVulkan(Draw::DrawContext *draw) : draw_(draw) { decOptions_.expandAllWeightsToFloat = false; decOptions_.expand8BitNormalsToFloat = false; - indexGen.Setup(decIndex_); } void DrawEngineVulkan::InitDeviceObjects() { @@ -167,6 +166,10 @@ void DrawEngineVulkan::DeviceRestore(Draw::DrawContext *draw) { void DrawEngineVulkan::BeginFrame() { lastPipeline_ = nullptr; + // These will be re-bound if needed, let's not let old bindings linger around too long. + boundDepal_ = VK_NULL_HANDLE; + boundSecondary_ = VK_NULL_HANDLE; + // pushUBO is the thin3d push pool, don't need to BeginFrame again. pushVertex_->BeginFrame(); pushIndex_->BeginFrame(); diff --git a/ext/riscv-disas.cpp b/ext/riscv-disas.cpp index 816c985cca43..a4868ae50dad 100644 --- a/ext/riscv-disas.cpp +++ b/ext/riscv-disas.cpp @@ -2233,7 +2233,7 @@ static void decode_inst_operands(rv_decode *dec) static void decode_inst_decompress(rv_decode *dec, rv_isa isa) { - int decomp_op; + int decomp_op = 0; switch (isa) { case rv32: decomp_op = opcode_data[dec->op].decomp_rv32; break; case rv64: decomp_op = opcode_data[dec->op].decomp_rv64; break;