diff --git a/Core/FileLoaders/CachingFileLoader.cpp b/Core/FileLoaders/CachingFileLoader.cpp index d787c97576..472d10973e 100644 --- a/Core/FileLoaders/CachingFileLoader.cpp +++ b/Core/FileLoaders/CachingFileLoader.cpp @@ -180,7 +180,7 @@ void CachingFileLoader::SaveIntoCache(s64 pos, size_t bytes, Flags flags, bool r // While blocksMutex_ was unlocked, another thread may have read. // If so, free the one we just read. if (blocks_.find(cacheStartPos) == blocks_.end()) { - blocks_[cacheStartPos] = BlockInfo(buf); + blocks_[cacheStartPos] = BlockInfo{buf}; } else { delete [] buf; } @@ -198,7 +198,7 @@ void CachingFileLoader::SaveIntoCache(s64 pos, size_t bytes, Flags flags, bool r } u8 *buf = new u8[BLOCK_SIZE]; memcpy(buf, wholeRead + (i << BLOCK_SHIFT), BLOCK_SIZE); - blocks_[cacheStartPos + i] = BlockInfo(buf); + blocks_[cacheStartPos + i] = BlockInfo{buf}; } delete[] wholeRead; } diff --git a/Core/FileLoaders/CachingFileLoader.h b/Core/FileLoaders/CachingFileLoader.h index a4299b567d..6a45424ff8 100644 --- a/Core/FileLoaders/CachingFileLoader.h +++ b/Core/FileLoaders/CachingFileLoader.h @@ -60,18 +60,13 @@ private: s64 filesize_ = 0; int exists_ = -1; int isDirectory_ = -1; - u64 generation_; - u64 oldestGeneration_; - size_t cacheSize_; + u64 generation_ = 0; + u64 oldestGeneration_ = 0; + size_t cacheSize_ = 0; struct BlockInfo { u8 *ptr; u64 generation; - - BlockInfo() : ptr(nullptr), generation(0) { - } - BlockInfo(u8 *p) : ptr(p), generation(0) { - } }; std::map blocks_; diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 838f052dea..e4ed600cf5 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -390,7 +390,11 @@ namespace Reporting return; } + bool reportingWasUnsupported = everUnsupported; Do(p, everUnsupported); + if (!reportingWasUnsupported && everUnsupported) { + INFO_LOG(Log::System, "Reporting became unsupported due to loading an old savestate."); + } } void UpdateConfig() { diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index b0f960af2c..da48a71458 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -799,14 +799,16 @@ void DrawEngineCommon::DecodeVerts(const VertexDecoder *dec, u8 *dest) { const int indexLowerBound = dv.indexLowerBound; drawVertexOffsets_[i] = numDecodedVerts - indexLowerBound; const int indexUpperBound = dv.indexUpperBound; - if (indexUpperBound + 1 - indexLowerBound + numDecodedVerts >= VERTEX_BUFFER_MAX) { + const int count = indexUpperBound - indexLowerBound + 1; + if (count + numDecodedVerts >= VERTEX_BUFFER_MAX) { // Hit our limit! Stop decoding in this draw. break; } // Decode the verts (and at the same time apply morphing/skinning). Simple. - dec->DecodeVerts(dest + numDecodedVerts * stride, dv.verts, &dv.uvScale, indexLowerBound, indexUpperBound); - numDecodedVerts += indexUpperBound - indexLowerBound + 1; + const u8 *startPos = (const u8 *)dv.verts + indexLowerBound * dec->VertexSize(); + dec->DecodeVerts(dest + numDecodedVerts * stride, startPos, &dv.uvScale, count); + numDecodedVerts += count; } numDecodedVerts_ = numDecodedVerts; decodeVertsCounter_ = i; diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 262779f6d9..6ef76f3fbf 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -935,7 +935,10 @@ bool SoftwareTransform::ExpandPoints(int vertexCount, int &maxIndex, int vertsSi u32 NormalizeVertices(SimpleVertex *sverts, u8 *bufPtr, const u8 *inPtr, int lowerBound, int upperBound, const VertexDecoder *dec, u32 vertType) { // First, decode the vertices into a GPU compatible format. This step can be eliminated but will need a separate // implementation of the vertex decoder. - dec->DecodeVerts(bufPtr, inPtr, &gstate_c.uv, lowerBound, upperBound); + // Actually if software transform is off, we could enforce it in the vertex decoder lookup before calling this, + // avoiding having to implement it again below. + const int count = upperBound + 1 - lowerBound; + dec->DecodeVerts(bufPtr, inPtr + lowerBound * dec->VertexSize(), &gstate_c.uv, count); // OK, morphing eliminated but bones still remain to be taken care of. // Let's do a partial software transform where we only do skinning. diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index 37756baf1c..49e527ec42 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -1442,15 +1442,9 @@ void VertexDecoder::SetVertexType(u32 fmt, const VertexDecoderOptions &options, } } -void VertexDecoder::DecodeVerts(u8 *decodedptr, const void *verts, const UVScale *uvScaleOffset, int indexLowerBound, int indexUpperBound) const { - // A single 0 is acceptable for point lists. - _dbg_assert_(indexLowerBound <= indexUpperBound); - +void VertexDecoder::DecodeVerts(u8 *decodedptr, const u8 *startPtr, const UVScale *uvScaleOffset, int count) const { // Decode the vertices within the found bounds, once each // decoded_ and ptr_ are used in the steps, so can't be turned into locals for speed. - const u8 *startPtr = (const u8*)verts + indexLowerBound * size; - - int count = indexUpperBound - indexLowerBound + 1; int stride = decFmt.stride; #ifdef _DEBUG @@ -1458,7 +1452,7 @@ void VertexDecoder::DecodeVerts(u8 *decodedptr, const void *verts, const UVScale #endif // Check alignment before running the decoder, as we may crash if it's bad (as should the real PSP but doesn't always) - if (((uintptr_t)verts & (biggest - 1)) != 0) { + if (((uintptr_t)startPtr & (biggest - 1)) != 0) { // Bad alignment. Not really sure what to do here... zero the verts to be safe? memset(decodedptr, 0, count * stride); return; @@ -1481,7 +1475,7 @@ void VertexDecoder::DecodeVerts(u8 *decodedptr, const void *verts, const UVScale decoded += stride; } if (jitted_ && validateJit) { - CompareToJit(startPtr, decodedptr, indexUpperBound - indexLowerBound + 1, uvScaleOffset); + CompareToJit(startPtr, decodedptr, count, uvScaleOffset); } } } diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index f21933aa65..1a8dcb8535 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -366,7 +366,7 @@ public: const DecVtxFormat &GetDecVtxFmt() const { return decFmt; } - void DecodeVerts(u8 *decoded, const void *verts, const UVScale *uvScaleOffset, int indexLowerBound, int indexUpperBound) const; + void DecodeVerts(u8 *decoded, const u8 *startPtr, const UVScale *uvScaleOffset, int count) const; int VertexSize() const { return size; } // PSP format size diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 001d21939e..8e999d5f52 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -330,7 +330,7 @@ protected: bool flushOnParams_ = true; GraphicsContext *gfxCtx_; - Draw::DrawContext *draw_; + Draw::DrawContext *draw_ = nullptr; typedef std::list DisplayListQueue; diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index abcba1bb0d..6364f2fe11 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -486,8 +486,10 @@ public: if (useIndices_) GetIndexBounds(indices, vertex_count, vertex_type, &lowerBound_, &upperBound_); - if (vertex_count != 0) - vdecoder.DecodeVerts(base, vertices, &gstate_c.uv, lowerBound_, upperBound_); + if (vertex_count != 0) { + const int count = upperBound_ - lowerBound_ + 1; + vdecoder.DecodeVerts(base, (const u8 *)vertices + vdecoder.VertexSize() * lowerBound_, &gstate_c.uv, count); + } // If we're only using a subset of verts, it's better to decode with random access (usually.) // However, if we're reusing a lot of verts, we should read and cache them. diff --git a/unittest/TestVertexJit.cpp b/unittest/TestVertexJit.cpp index cd6dc5625d..1646a67bf9 100644 --- a/unittest/TestVertexJit.cpp +++ b/unittest/TestVertexJit.cpp @@ -54,8 +54,6 @@ public: options_ = {}; delete dec_; dec_ = nullptr; - indexLowerBound_ = 0; - indexUpperBound_ = 0; srcPos_ = 0; dstPos_ = 0; needsReset_ = false; @@ -68,27 +66,20 @@ public: options_ = opts; } - void SetIndexLowerBound(const int lower) { - if (needsReset_) { - Reset(); - } - indexLowerBound_ = lower; - } - - void Execute(int vtype, int indexUpperBound, bool useJit) { + void Execute(int vtype, int count, bool useJit) { SetupExecute(vtype, useJit); - dec_->DecodeVerts(dst_, src_, &gstate_c.uv, indexLowerBound_, indexUpperBound); + dec_->DecodeVerts(dst_, src_, &gstate_c.uv, count); } - double ExecuteTimed(int vtype, int indexUpperBound, bool useJit) { + double ExecuteTimed(int vtype, int count, bool useJit) { SetupExecute(vtype, useJit); int total = 0; double st = time_now_d(); do { for (int j = 0; j < ROUNDS; ++j) { - dec_->DecodeVerts(dst_, src_, &gstate_c.uv, indexLowerBound_, indexUpperBound); + dec_->DecodeVerts(dst_, src_, &gstate_c.uv, count); ++total; } } while (time_now_d() - st < 0.5); @@ -300,7 +291,7 @@ static bool TestVertex8() { dec.Add8(127, 0, 128); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.AssertFloat("TestVertex8-TC", 127.0f / 128.0f, 1.0f); dec.Assert8("TestVertex8-Nrm", 127, 0, 128); dec.Skip(1); @@ -319,7 +310,7 @@ static bool TestVertex16() { dec.Add16(32767, 0, 32768); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.AssertFloat("TestVertex16-TC", 32767.0f / 32768.0f, 1.0f); dec.Assert16("TestVertex16-Nrm", 32767, 0, 32768); dec.Skip(2); @@ -338,7 +329,7 @@ static bool TestVertexFloat() { dec.AddFloat(1.0f, 0.5f, -1.0f); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.AssertFloat("TestVertexFloat-TC", 1.0f, -1.0f); dec.AssertFloat("TestVertexFloat-Nrm", 1.0f, 0.5f, -1.0f); dec.AssertFloat("TestVertexFloat-Pos", 1.0f, 0.5f, -1.0f); @@ -356,7 +347,7 @@ static bool TestVertex8Through() { dec.Add8(127, 0, 128); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); // Note: this is correct, even in through. dec.AssertFloat("TestVertex8Through-TC", 127.0f / 128.0f, 1.0f); dec.Assert8("TestVertex8Through-Nrm", 127, 0, 128); @@ -375,7 +366,7 @@ static bool TestVertex16Through() { dec.Add16(32767, 0, 32768); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.AssertFloat("TestVertex16Through-TC", 32767.0f, 32768.0f); dec.Assert16("TestVertex16Through-Nrm", 32767, 0, 32768); dec.Skip(2); @@ -394,7 +385,7 @@ static bool TestVertexFloatThrough() { dec.AddFloat(1.0f, 0.5f, -1.0f); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.AssertFloat("TestVertexFloatThrough-TC", 1.0f, -1.0f); dec.AssertFloat("TestVertexFloatThrough-Nrm", 1.0f, 0.5f, -1.0f); dec.AssertFloat("TestVertexFloatThrough-Pos", 1.0f, 0.5f, 0.0f); @@ -413,7 +404,7 @@ static bool TestVertexColor8888() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor8888-Col", 1, 2, 3, 4); dec.AssertFloat("TestVertexColor8888-Pos", 1.0f, 0.5f, -1.0f); @@ -428,7 +419,7 @@ static bool TestVertexColor8888() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor8888-Col", 255, 255, 255, 255); dec.AssertFloat("TestVertexColor8888-Pos", 1.0f, 0.5f, -1.0f); @@ -451,7 +442,7 @@ static bool TestVertexColor4444() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor4444-Col", 0x44, 0x33, 0x22, 0x11); dec.AssertFloat("TestVertexColor4444-Pos", 1.0f, 0.5f, -1.0f); @@ -466,7 +457,7 @@ static bool TestVertexColor4444() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor4444-Col", 255, 255, 255, 255); dec.AssertFloat("TestVertexColor4444-Pos", 1.0f, 0.5f, -1.0f); @@ -489,7 +480,7 @@ static bool TestVertexColor5551() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor5551-Col", 0x18, 0x10, 0x8, 0x0); dec.AssertFloat("TestVertexColor5551-Pos", 1.0f, 0.5f, -1.0f); @@ -504,7 +495,7 @@ static bool TestVertexColor5551() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor5551-Col", 255, 255, 255, 255); dec.AssertFloat("TestVertexColor5551-Pos", 1.0f, 0.5f, -1.0f); @@ -527,7 +518,7 @@ static bool TestVertexColor565() { for (int jit = 0; jit <= 1; ++jit) { gstate_c.vertexFullAlpha = true; - dec.Execute(vtype, 0, jit == 1); + dec.Execute(vtype, 1, jit == 1); dec.Assert8("TestVertexColor565-Col", 0x18, 0x8, 0x8, 255); dec.AssertFloat("TestVertexColor565-Pos", 1.0f, 0.5f, -1.0f); @@ -564,7 +555,7 @@ static bool TestVertex8Skin() { dec.Add8(127, 0, 128); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vertTypeID, 0, jit == 1); + dec.Execute(vertTypeID, 1, jit == 1); dec.AssertFloat("TestVertex8Skin-Nrm", (2.0f * 1.5f + 1.0f * 0.5f) * 127.0f / 128.0f, 0.0f, 2.0f * 5.0f * -1.0f); dec.AssertFloat("TestVertex8Skin-Pos", (2.0f * 1.5f + 1.0f * 0.5f) * 127.0f / 128.0f, 0.0f, 2.0f * 5.0f * -1.0f); } @@ -596,7 +587,7 @@ static bool TestVertex16Skin() { dec.Add16(32767, 0, 32768); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vertTypeID, 0, jit == 1); + dec.Execute(vertTypeID, 1, jit == 1); dec.AssertFloat("TestVertex16Skin-Nrm", (2.0f * 1.5f + 1.0f * 0.5f) * 32767.0f / 32768.0f, 0.0f, 2.0f * 5.0f * -1.0f); dec.AssertFloat("TestVertex16Skin-Pos", (2.0f * 1.5f + 1.0f * 0.5f) * 32767.0f / 32768.0f, 0.0f, 2.0f * 5.0f * -1.0f); } @@ -628,7 +619,7 @@ static bool TestVertexFloatSkin() { dec.AddFloat(1.0f, 0, -1.0f); for (int jit = 0; jit <= 1; ++jit) { - dec.Execute(vertTypeID, 0, jit == 1); + dec.Execute(vertTypeID, 1, jit == 1); dec.AssertFloat("TestVertexFloatSkin-Nrm", (2.0f * 1.5f + 1.0f * 0.5f) * 1.0f, 0.0f, 2.0f * 5.0f * -1.0f); dec.AssertFloat("TestVertexFloatSkin-Pos", (2.0f * 1.5f + 1.0f * 0.5f) * 1.0f, 0.0f, 2.0f * 5.0f * -1.0f); }