diff --git a/Common/Data/Collections/FixedSizeQueue.h b/Common/Data/Collections/FixedSizeQueue.h index 621f4f0035..7d0b0998e7 100644 --- a/Common/Data/Collections/FixedSizeQueue.h +++ b/Common/Data/Collections/FixedSizeQueue.h @@ -38,6 +38,10 @@ public: delete [] storage_; } + // Disallow copies. + FixedSizeQueue(FixedSizeQueue &other) = delete; + FixedSizeQueue& operator=(const FixedSizeQueue &other) = delete; + void clear() { head_ = 0; tail_ = 0; @@ -149,6 +153,7 @@ public: ERROR_LOG(COMMON, "Savestate failure: Incompatible queue size."); return; } + // TODO: This is quite wasteful, could just store the actual data. Would be slightly more complex though. DoArray(p, storage_, N); Do(p, head_); Do(p, tail_); @@ -161,10 +166,6 @@ private: int head_; int tail_; int count_; // sacrifice 4 bytes for a simpler implementation. may optimize away in the future. - - // Make copy constructor private for now. - FixedSizeQueue(FixedSizeQueue &other); - FixedSizeQueue& operator=(const FixedSizeQueue &other); }; diff --git a/Common/Render/DrawBuffer.h b/Common/Render/DrawBuffer.h index f16ab1e62c..c8ac2815f4 100644 --- a/Common/Render/DrawBuffer.h +++ b/Common/Render/DrawBuffer.h @@ -13,11 +13,6 @@ struct Atlas; -enum { - // Enough? - MAX_VERTS = 65536, -}; - enum { ALIGN_LEFT = 0, ALIGN_RIGHT = 16, @@ -186,6 +181,11 @@ public: saturation_ = saturation; } + enum { + // TODO: Can probably shrink this. Currently consumes 1.5MB. + MAX_VERTS = 65536, + }; + private: struct Vertex { float x, y, z; diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index 31b59419ed..24b12d203d 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -24,14 +24,13 @@ UIContext::~UIContext() { delete textDrawer_; } -void UIContext::Init(Draw::DrawContext *thin3d, Draw::Pipeline *uipipe, Draw::Pipeline *uipipenotex, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) { +void UIContext::Init(Draw::DrawContext *thin3d, Draw::Pipeline *uipipe, Draw::Pipeline *uipipenotex, DrawBuffer *uidrawbuffer) { using namespace Draw; draw_ = thin3d; sampler_ = draw_->CreateSamplerState({ TextureFilter::LINEAR, TextureFilter::LINEAR, TextureFilter::LINEAR, 0.0, TextureAddressMode::CLAMP_TO_EDGE, TextureAddressMode::CLAMP_TO_EDGE, TextureAddressMode::CLAMP_TO_EDGE, }); ui_pipeline_ = uipipe; ui_pipeline_notex_ = uipipenotex; uidrawbuffer_ = uidrawbuffer; - uidrawbufferTop_ = uidrawbufferTop; textDrawer_ = TextDrawer::Create(thin3d); // May return nullptr if no implementation is available for this platform. } @@ -59,14 +58,12 @@ void UIContext::BeginFrame() { } } } - uidrawbufferTop_->SetCurZ(0.0f); uidrawbuffer_->SetCurZ(0.0f); ActivateTopScissor(); } void UIContext::SetTintSaturation(float tint, float sat) { uidrawbuffer_->SetTintSaturation(tint, sat); - uidrawbufferTop_->SetTintSaturation(tint, sat); } void UIContext::Begin() { @@ -106,14 +103,10 @@ void UIContext::Flush() { if (uidrawbuffer_) { uidrawbuffer_->Flush(); } - if (uidrawbufferTop_) { - uidrawbufferTop_->Flush(); - } } void UIContext::SetCurZ(float curZ) { ui_draw2d.SetCurZ(curZ); - ui_draw2d_front.SetCurZ(curZ); } // TODO: Support transformed bounds using stencil instead. diff --git a/Common/UI/Context.h b/Common/UI/Context.h index f555fffa99..328596d7c3 100644 --- a/Common/UI/Context.h +++ b/Common/UI/Context.h @@ -50,7 +50,7 @@ public: UIContext(); ~UIContext(); - void Init(Draw::DrawContext *thin3d, Draw::Pipeline *uipipe, Draw::Pipeline *uipipenotex, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop); + void Init(Draw::DrawContext *thin3d, Draw::Pipeline *uipipe, Draw::Pipeline *uipipenotex, DrawBuffer *uidrawbuffer); void BeginFrame(); @@ -70,7 +70,6 @@ public: void ActivateTopScissor(); DrawBuffer *Draw() const { return uidrawbuffer_; } - DrawBuffer *DrawTop() const { return uidrawbufferTop_; } // Utility methods TextDrawer *Text() const { return textDrawer_; } @@ -137,7 +136,6 @@ private: std::unique_ptr fontTexture_; DrawBuffer *uidrawbuffer_ = nullptr; - DrawBuffer *uidrawbufferTop_ = nullptr; std::vector scissorStack_; std::vector transformStack_; diff --git a/Common/UI/UI.cpp b/Common/UI/UI.cpp index 826c6f77a4..6d897b2cf8 100644 --- a/Common/UI/UI.cpp +++ b/Common/UI/UI.cpp @@ -13,10 +13,8 @@ DrawBuffer ui_draw2d_front; void UIBegin(Draw::Pipeline *pipeline) { ui_draw2d.Begin(pipeline); - ui_draw2d_front.Begin(pipeline); } void UIFlush() { ui_draw2d.Flush(); - ui_draw2d_front.Flush(); } diff --git a/Common/UI/UI.h b/Common/UI/UI.h index 4357693d16..f73ab0a7a6 100644 --- a/Common/UI/UI.h +++ b/Common/UI/UI.h @@ -36,7 +36,6 @@ struct Atlas; // This is the drawbuffer used for UI. Remember to flush it at the end of the frame. // TODO: One should probably pass it in through UIInit. extern DrawBuffer ui_draw2d; -extern DrawBuffer ui_draw2d_front; // for things that need to be on top of the rest // TODO: These don't really belong here. diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 6ebac93d38..b60f6ac88d 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -99,7 +99,6 @@ View::~View() { // Could use unique_ptr, but then we have to include tween everywhere. for (auto &tween : tweens_) delete tween; - tweens_.clear(); } void View::Update() { diff --git a/Core/HLE/sceAudio.cpp b/Core/HLE/sceAudio.cpp index b518c8fc61..4b805ea6aa 100644 --- a/Core/HLE/sceAudio.cpp +++ b/Core/HLE/sceAudio.cpp @@ -35,6 +35,7 @@ const int AUDIO_ROUTING_SPEAKER_ON = 1; int defaultRoutingMode = AUDIO_ROUTING_SPEAKER_ON; int defaultRoutingVolMode = AUDIO_ROUTING_SPEAKER_ON; +// TODO: These are way oversized and together consume 4MB of memory. extern FixedSizeQueue chanSampleQueues[PSP_AUDIO_CHANNEL_MAX + 1]; // The extra channel is for SRC/Output2/Vaudio. diff --git a/Core/Util/GameDB.cpp b/Core/Util/GameDB.cpp index 8e688e34aa..538ca9205f 100644 --- a/Core/Util/GameDB.cpp +++ b/Core/Util/GameDB.cpp @@ -34,8 +34,7 @@ static void SplitCSVLine(const std::string_view str, std::vector splitSV(std::string_view strv, char delim, bool removeWhiteSpace) { - std::vector output; +static void SplitSV(std::string_view strv, char delim, bool removeWhiteSpace, std::vector *output) { size_t first = 0; while (first < strv.size()) { const auto second = strv.find(delim, first); @@ -47,13 +46,12 @@ static std::vector splitSV(std::string_view strv, char delim, if (removeWhiteSpace) { line = StripSpaces(line); } - output.emplace_back(line); + output->emplace_back(line); } if (second == std::string_view::npos) break; first = second + 1; } - return output; } bool GameDB::LoadFromVFS(VFSInterface &vfs, const char *filename) { @@ -64,9 +62,12 @@ bool GameDB::LoadFromVFS(VFSInterface &vfs, const char *filename) { contents_ = std::string((const char *)data, size); delete[] data; - // Split the string into views of each line, keeping the original. - std::vector lines = splitSV(contents_, '\n', false); + const size_t RESERVE_COUNT = 2820; // ~ known current line count + // Split the string into views of each line, keeping the original. + std::vector lines; + lines.reserve(RESERVE_COUNT); + SplitSV(contents_, '\n', false, &lines); SplitCSVLine(lines[0], columns_); const size_t titleColumn = GetColumnIndex("Title"); @@ -76,6 +77,8 @@ bool GameDB::LoadFromVFS(VFSInterface &vfs, const char *filename) { const size_t sizeColumn = GetColumnIndex("Size"); std::vector items; + items.reserve(8); + lines_.reserve(RESERVE_COUNT); for (size_t i = 1; i < lines.size(); i++) { auto &lineString = lines[i]; SplitCSVLine(lineString, items); @@ -88,7 +91,7 @@ bool GameDB::LoadFromVFS(VFSInterface &vfs, const char *filename) { Line line; line.title = items[titleColumn]; line.foreignTitle = items[foreignTitleColumn]; - line.serials = splitSV(items[serialColumn], ',', true); + SplitSV(items[serialColumn], ',', true, &line.serials); line.crc = items[crcColumn]; line.size = items[sizeColumn]; lines_.push_back(line); diff --git a/UI/BackgroundAudio.h b/UI/BackgroundAudio.h index 178ea2e1d6..3c869485dc 100644 --- a/UI/BackgroundAudio.h +++ b/UI/BackgroundAudio.h @@ -67,7 +67,8 @@ private: void Clear(bool hard); enum { - BUFSIZE = 44100, + // 0.5 ms buffer at 44.1 khz should be enough. + BUFSIZE = 22050, }; std::mutex mutex_; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 329ed9e67f..891f71f47f 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -128,10 +128,13 @@ void DevMenuScreen::CreatePopupContents(UI::ViewGroup *parent) { #endif items->Add(new Choice(dev->T("Logging Channels")))->OnClick.Handle(this, &DevMenuScreen::OnLogConfig); items->Add(new Choice(sy->T("Developer Tools")))->OnClick.Handle(this, &DevMenuScreen::OnDeveloperTools); + + // Debug overlay + AddOverlayList(items, screenManager()); + items->Add(new Choice(dev->T("Jit Compare")))->OnClick.Handle(this, &DevMenuScreen::OnJitCompare); items->Add(new Choice(dev->T("Shader Viewer")))->OnClick.Handle(this, &DevMenuScreen::OnShaderView); - AddOverlayList(items, screenManager()); items->Add(new Choice(dev->T("Toggle Freeze")))->OnClick.Add([](UI::EventParams &e) { if (PSP_CoreParameter().frozen) { PSP_CoreParameter().frozen = false; diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 2733dd8a20..fcca47a348 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -764,7 +764,7 @@ void GameInfoCache::WaitUntilDone(std::shared_ptr &info) { std::shared_ptr GameInfoCache::GetInfo(Draw::DrawContext *draw, const Path &gamePath, int wantFlags) { std::shared_ptr info; - std::string pathStr = gamePath.ToString(); + const std::string &pathStr = gamePath.ToString(); auto iter = info_.find(pathStr); if (iter != info_.end()) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 01e9dc027c..22059e4ec5 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -853,17 +853,14 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) { ui_draw2d.SetAtlas(GetUIAtlas()); ui_draw2d.SetFontAtlas(GetFontAtlas()); - ui_draw2d_front.SetAtlas(GetUIAtlas()); - ui_draw2d_front.SetFontAtlas(GetFontAtlas()); uiContext = new UIContext(); uiContext->theme = GetTheme(); UpdateTheme(uiContext); ui_draw2d.Init(g_draw, texColorPipeline); - ui_draw2d_front.Init(g_draw, texColorPipeline); - uiContext->Init(g_draw, texColorPipeline, colorPipeline, &ui_draw2d, &ui_draw2d_front); + uiContext->Init(g_draw, texColorPipeline, colorPipeline, &ui_draw2d); if (uiContext->Text()) uiContext->Text()->SetFont("Tahoma", 20, 0); @@ -990,7 +987,6 @@ void NativeShutdownGraphics() { uiContext = nullptr; ui_draw2d.Shutdown(); - ui_draw2d_front.Shutdown(); if (colorPipeline) { colorPipeline->Release(); @@ -1141,7 +1137,6 @@ void NativeFrame(GraphicsContext *graphicsContext) { g_draw->BeginFrame(debugFlags); ui_draw2d.PushDrawMatrix(ortho); - ui_draw2d_front.PushDrawMatrix(ortho); g_screenManager->getUIContext()->SetTintSaturation(g_Config.fUITint, g_Config.fUISaturation); @@ -1152,7 +1147,6 @@ void NativeFrame(GraphicsContext *graphicsContext) { } ui_draw2d.PopDrawMatrix(); - ui_draw2d_front.PopDrawMatrix(); g_draw->EndFrame();