Do some renaming, dedupe some strings (old commit resurrected), add an assert

This commit is contained in:
Henrik Rydgård 2024-09-10 15:20:44 +02:00
parent f54d701a2e
commit a545d3074f
5 changed files with 23 additions and 22 deletions

View File

@ -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());
}

View File

@ -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<BufInfo> 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;

View File

@ -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.

View File

@ -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);

View File

@ -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);