From a545d3074ffbb96d19765fd114c16300f5642575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 10 Sep 2024 15:20:44 +0200 Subject: [PATCH] Do some renaming, dedupe some strings (old commit resurrected), add an assert --- Common/GPU/OpenGL/GLMemory.cpp | 20 ++++++++++---------- Common/GPU/OpenGL/GLMemory.h | 4 ++-- GPU/Common/TextureReplacer.cpp | 1 + UI/GameSettingsScreen.cpp | 16 ++++++++-------- UI/GameSettingsScreen.h | 4 ++-- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Common/GPU/OpenGL/GLMemory.cpp b/Common/GPU/OpenGL/GLMemory.cpp index 6718bd23eb..5bbb40e9b5 100644 --- a/Common/GPU/OpenGL/GLMemory.cpp +++ b/Common/GPU/OpenGL/GLMemory.cpp @@ -62,7 +62,7 @@ bool GLRBuffer::Unmap() { return glUnmapBuffer(target_) == GL_TRUE; } -GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size, const char *tag) : render_(render), size_(size), target_(target), tag_(tag) { +GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size, const char *tag) : render_(render), nextBufferSize_(size), target_(target), tag_(tag) { AddBuffer(); RegisterGPUMemoryManager(this); } @@ -139,10 +139,10 @@ void GLPushBuffer::Flush() { void GLPushBuffer::AddBuffer() { // INFO_LOG(Log::G3D, "GLPushBuffer(%s): Allocating %d bytes", tag_, size_); BufInfo info; - info.localMemory = (uint8_t *)AllocateAlignedMemory(size_, 16); - _assert_msg_(info.localMemory != 0, "GLPushBuffer alloc fail: %d (%s)", (int)size_, tag_); - info.buffer = render_->CreateBuffer(target_, size_, GL_DYNAMIC_DRAW); - info.size = size_; + info.localMemory = (uint8_t *)AllocateAlignedMemory(nextBufferSize_, 16); + _assert_msg_(info.localMemory != 0, "GLPushBuffer alloc fail: %d (%s)", (int)nextBufferSize_, tag_); + info.buffer = render_->CreateBuffer(target_, nextBufferSize_, GL_DYNAMIC_DRAW); + info.size = nextBufferSize_; buf_ = buffers_.size(); buffers_.push_back(info); } @@ -169,10 +169,10 @@ void GLPushBuffer::NextBuffer(size_t minSize) { Unmap(); buf_++; - if (buf_ >= buffers_.size() || minSize > size_) { + if (buf_ >= buffers_.size() || minSize > nextBufferSize_) { // Before creating the buffer, adjust to the new size_ if necessary. - while (size_ < minSize) { - size_ <<= 1; + while (nextBufferSize_ < minSize) { + nextBufferSize_ <<= 1; } AddBuffer(); } @@ -208,7 +208,7 @@ void GLPushBuffer::Defragment() { Destroy(false); // Set some sane but very free limits. If there's another spike, we'll just allocate more anyway. - size_ = std::min(std::max(newSize, (size_t)65536), (size_t)(512 * 1024 * 1024)); + nextBufferSize_ = std::min(std::max(newSize, (size_t)65536), (size_t)(512 * 1024 * 1024)); AddBuffer(); } @@ -272,5 +272,5 @@ void GLPushBuffer::UnmapDevice() { } void GLPushBuffer::GetDebugString(char *buffer, size_t bufSize) const { - snprintf(buffer, bufSize, "%s: %s/%s (%d)", tag_, NiceSizeFormat(this->offset_).c_str(), NiceSizeFormat(this->size_).c_str(), (int)buffers_.size()); + snprintf(buffer, bufSize, "%s: %s/%s (%d)", tag_, NiceSizeFormat(this->offset_).c_str(), NiceSizeFormat(this->nextBufferSize_).c_str(), (int)buffers_.size()); } diff --git a/Common/GPU/OpenGL/GLMemory.h b/Common/GPU/OpenGL/GLMemory.h index fb1b27508f..4aa86217f5 100644 --- a/Common/GPU/OpenGL/GLMemory.h +++ b/Common/GPU/OpenGL/GLMemory.h @@ -116,7 +116,7 @@ public: // again, call Rewind (see below). uint8_t *Allocate(uint32_t numBytes, uint32_t alignment, GLRBuffer **buf, uint32_t *bindOffset) { uint32_t offset = ((uint32_t)offset_ + alignment - 1) & ~(alignment - 1); - if (offset + numBytes <= size_) { + if (offset + numBytes <= nextBufferSize_) { // Common path. offset_ = offset + numBytes; *buf = buffers_[buf_].buffer; @@ -175,7 +175,7 @@ private: std::vector buffers_; size_t buf_ = 0; size_t offset_ = 0; - size_t size_ = 0; + size_t nextBufferSize_ = 0; uint8_t *writePtr_ = nullptr; GLuint target_; GLBufferStrategy strategy_ = GLBufferStrategy::SUBDATA; diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 4274a5654a..1db43f0730 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -741,6 +741,7 @@ bool TextureReplacer::WillSave(const ReplacedTextureDecodeInfo &replacedInfo) co void TextureReplacer::NotifyTextureDecoded(ReplacedTexture *texture, const ReplacedTextureDecodeInfo &replacedInfo, const void *data, int srcPitch, int level, int origW, int origH, int scaledW, int scaledH) { _assert_msg_(saveEnabled_, "Texture saving not enabled"); _assert_(srcPitch >= 0); + _assert_(data); if (!WillSave(replacedInfo)) { // Ignore. diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index e1629f5479..9b6e22b844 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1144,7 +1144,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { #if PPSSPP_PLATFORM(ANDROID) if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_VR) { memstickDisplay_ = g_Config.memStickDirectory.ToVisualString(); - auto memstickPath = systemSettings->Add(new ChoiceWithValueDisplay(&memstickDisplay_, sy->T("Memory Stick folder", "Memory Stick folder"), I18NCat::NONE)); + auto memstickPath = systemSettings->Add(new ChoiceWithValueDisplay(&memstickDisplay_, sy->T("Memory Stick folder"), I18NCat::NONE)); memstickPath->SetEnabled(!PSP_IsInited()); memstickPath->OnClick.Handle(this, &GameSettingsScreen::OnShowMemstickScreen); @@ -1161,16 +1161,16 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { #elif defined(_WIN32) #if PPSSPP_PLATFORM(UWP) memstickDisplay_ = g_Config.memStickDirectory.ToVisualString(); - auto memstickPath = systemSettings->Add(new ChoiceWithValueDisplay(&memstickDisplay_, sy->T("Memory Stick folder", "Memory Stick folder"), I18NCat::NONE)); + auto memstickPath = systemSettings->Add(new ChoiceWithValueDisplay(&memstickDisplay_, sy->T("Memory Stick folder"), I18NCat::NONE)); memstickPath->SetEnabled(!PSP_IsInited()); memstickPath->OnClick.Handle(this, &GameSettingsScreen::OnShowMemstickScreen); #else - SavePathInMyDocumentChoice = systemSettings->Add(new CheckBox(&installed_, sy->T("Save path in My Documents", "Save path in My Documents"))); + SavePathInMyDocumentChoice = systemSettings->Add(new CheckBox(&installed_, sy->T("Memory Stick in My Documents"))); SavePathInMyDocumentChoice->SetEnabled(!PSP_IsInited()); - SavePathInMyDocumentChoice->OnClick.Handle(this, &GameSettingsScreen::OnSavePathMydoc); - SavePathInOtherChoice = systemSettings->Add(new CheckBox(&otherinstalled_, sy->T("Save path in installed.txt", "Save path in installed.txt"))); + SavePathInMyDocumentChoice->OnClick.Handle(this, &GameSettingsScreen::OnMemoryStickMyDoc); + SavePathInOtherChoice = systemSettings->Add(new CheckBox(&otherinstalled_, sy->T("Memory Stick in installed.txt"))); SavePathInOtherChoice->SetEnabled(false); - SavePathInOtherChoice->OnClick.Handle(this, &GameSettingsScreen::OnSavePathOther); + SavePathInOtherChoice->OnClick.Handle(this, &GameSettingsScreen::OnMemoryStickOther); const bool myDocsExists = W32Util::UserDocumentsPath().size() != 0; const Path &PPSSPPpath = File::GetExeDirectory(); @@ -1379,7 +1379,7 @@ UI::EventReturn GameSettingsScreen::OnShowMemstickScreen(UI::EventParams &e) { #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) -UI::EventReturn GameSettingsScreen::OnSavePathMydoc(UI::EventParams &e) { +UI::EventReturn GameSettingsScreen::OnMemoryStickMyDoc(UI::EventParams &e) { const Path &PPSSPPpath = File::GetExeDirectory(); const Path installedFile = PPSSPPpath / "installed.txt"; installed_ = File::Exists(installedFile); @@ -1406,7 +1406,7 @@ UI::EventReturn GameSettingsScreen::OnSavePathMydoc(UI::EventParams &e) { return UI::EVENT_DONE; } -UI::EventReturn GameSettingsScreen::OnSavePathOther(UI::EventParams &e) { +UI::EventReturn GameSettingsScreen::OnMemoryStickOther(UI::EventParams &e) { const Path &PPSSPPpath = File::GetExeDirectory(); if (otherinstalled_) { auto di = GetI18NCategory(I18NCat::DIALOG); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 216ba2c9c4..cc31d7c3ea 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -105,8 +105,8 @@ private: UI::EventReturn OnJitAffectingSetting(UI::EventParams &e); UI::EventReturn OnShowMemstickScreen(UI::EventParams &e); #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) - UI::EventReturn OnSavePathMydoc(UI::EventParams &e); - UI::EventReturn OnSavePathOther(UI::EventParams &e); + UI::EventReturn OnMemoryStickMyDoc(UI::EventParams &e); + UI::EventReturn OnMemoryStickOther(UI::EventParams &e); #endif UI::EventReturn OnScreenRotation(UI::EventParams &e); UI::EventReturn OnImmersiveModeChange(UI::EventParams &e);