diff --git a/Common/Data/Collections/FastVec.h b/Common/Data/Collections/FastVec.h index 08e5176d4a..6622cbdeb8 100644 --- a/Common/Data/Collections/FastVec.h +++ b/Common/Data/Collections/FastVec.h @@ -69,7 +69,8 @@ public: void clear() { size_ = 0; } bool empty() const { return size_ == 0; } - const T *data() { return data_; } + const T *data() const { return data_; } + T *begin() { return data_; } T *end() { return data_ + size_; } const T *begin() const { return data_; } diff --git a/Common/Data/Collections/TinySet.h b/Common/Data/Collections/TinySet.h index 6521beab48..04911fddce 100644 --- a/Common/Data/Collections/TinySet.h +++ b/Common/Data/Collections/TinySet.h @@ -2,6 +2,8 @@ #include +#include "Common/Log.h" + // Insert-only small-set implementation. Performs no allocation unless MaxFastSize is exceeded. // Can also be used as a small vector, then use push_back (or push_in_place) instead of insert. // Duplicates are thus allowed if you use that, but not if you exclusively use insert. @@ -32,16 +34,18 @@ struct TinySet { } slowLookup_->push_back(t); } - inline T *add_back() { + inline T &push_uninitialized() { if (fastCount_ < MaxFastSize) { - return &fastLookup_[fastCount_++]; + return fastLookup_[fastCount_++]; } if (!slowLookup_) { slowLookup_ = new std::vector(); } + + // The slow lookup is also slow at adding. T t; slowLookup_->push_back(t); - return slowLookup_->back(); + return *slowLookup_->back(); } void append(const TinySet &other) { size_t otherSize = other.size(); @@ -136,8 +140,8 @@ private: }; template -struct FixedTinyVec { - ~FixedTinyVec() {} +struct FixedVec { + ~FixedVec() {} // WARNING: Can fail if you exceed MaxSize! inline bool push_back(const T &t) { if (count_ < MaxSize) { @@ -147,13 +151,16 @@ struct FixedTinyVec { return false; } } + // WARNING: Can fail if you exceed MaxSize! - inline T *add_back() { + inline T &push_uninitialized() { if (count_ < MaxSize) { return &data_[count_++]; } - return nullptr; + _dbg_assert_(false); + return *data_[MaxSize - 1]; // BAD } + // Invalid if empty(). void pop_back() { count_--; } @@ -184,7 +191,7 @@ struct FixedTinyVec { const T &back() const { return (*this)[size() - 1]; } const T &front() const { return (*this)[0]; } - bool operator == (const FixedTinyVec &other) const { + bool operator == (const FixedVec &other) const { if (count_ != other.count_) return false; for (int i = 0; i < count_; i++) { diff --git a/Common/GPU/Vulkan/VulkanBarrier.h b/Common/GPU/Vulkan/VulkanBarrier.h index 1fefb5adfa..9382f71166 100644 --- a/Common/GPU/Vulkan/VulkanBarrier.h +++ b/Common/GPU/Vulkan/VulkanBarrier.h @@ -5,6 +5,7 @@ #include "Common/Log.h" #include "Common/GPU/Vulkan/VulkanLoader.h" +#include "Common/Data/Collections/FastVec.h" class VulkanContext; @@ -13,6 +14,8 @@ class VulkanContext; // However, not thread safe in any way! class VulkanBarrier { public: + VulkanBarrier() : imageBarriers_(4) {} + void TransitionImage( VkImage image, int baseMip, int numMipLevels, int numLayers, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, @@ -25,7 +28,7 @@ public: dstStageMask_ |= dstStageMask; dependencyFlags_ |= VK_DEPENDENCY_BY_REGION_BIT; - VkImageMemoryBarrier imageBarrier; + VkImageMemoryBarrier &imageBarrier = imageBarriers_.push_uninitialized(); imageBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; imageBarrier.pNext = nullptr; imageBarrier.srcAccessMask = srcAccessMask; @@ -40,7 +43,6 @@ public: imageBarrier.subresourceRange.baseArrayLayer = 0; imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - imageBarriers_.push_back(imageBarrier); } // Automatically determines access and stage masks from layouts. @@ -93,7 +95,7 @@ public: break; } - VkImageMemoryBarrier imageBarrier; + VkImageMemoryBarrier &imageBarrier = imageBarriers_.push_uninitialized(); imageBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; imageBarrier.pNext = nullptr; imageBarrier.srcAccessMask = srcAccessMask; @@ -108,7 +110,6 @@ public: imageBarrier.subresourceRange.baseArrayLayer = 0; imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - imageBarriers_.push_back(imageBarrier); } void Flush(VkCommandBuffer cmd); @@ -116,6 +117,6 @@ public: private: VkPipelineStageFlags srcStageMask_ = 0; VkPipelineStageFlags dstStageMask_ = 0; - std::vector imageBarriers_; + FastVec imageBarriers_; VkDependencyFlags dependencyFlags_ = 0; }; diff --git a/Common/System/System.h b/Common/System/System.h index 48cfaa280a..1568e43ed5 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -188,6 +188,8 @@ enum SystemProperty { SYSPROP_SKIP_UI, SYSPROP_USER_DOCUMENTS_DIR, + + SYSPROP_OK_BUTTON_LEFT, }; enum class SystemNotification { diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 94c3c420f7..c49dee977c 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -1,6 +1,9 @@ #include + +#include "Common/Log.h" #include "Common/System/Display.h" #include "Common/System/System.h" +#include "Common/System/Request.h" #include "Common/Input/InputState.h" #include "Common/Input/KeyCodes.h" #include "Common/Math/curves.h" @@ -10,8 +13,6 @@ #include "Common/UI/Root.h" #include "Common/Data/Text/I18n.h" #include "Common/Render/DrawBuffer.h" -#include "Common/Log.h" -#include static const bool ClickDebug = false; @@ -393,10 +394,8 @@ void PopupScreen::TriggerFinish(DialogResult result) { OnCompleted(result); } -#if PPSSPP_PLATFORM(UWP) // Inform UI that popup close to hide OSK (if visible) System_NotifyUIState("popup_closed"); -#endif } void PopupScreen::CreateViews() { @@ -433,17 +432,17 @@ void PopupScreen::CreateViews() { Margins buttonMargins(5, 5); // Adjust button order to the platform default. -#if defined(_WIN32) - defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins))); - defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); - if (!button2_.empty()) - buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle(this, &UIScreen::OnCancel); -#else - if (!button2_.empty()) - buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle(this, &UIScreen::OnCancel); - defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f))); - defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); -#endif + if (System_GetPropertyBool(SYSPROP_OK_BUTTON_LEFT)) { + defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins))); + defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); + if (!button2_.empty()) + buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle(this, &UIScreen::OnCancel); + } else { + if (!button2_.empty()) + buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle(this, &UIScreen::OnCancel); + defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f))); + defaultButton_->OnClick.Handle(this, &UIScreen::OnOK); + } box_->Add(buttonRow); } diff --git a/Core/Config.cpp b/Core/Config.cpp index a5dcc32f35..22e1a7d86f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -184,7 +184,7 @@ static bool DefaultVSync() { } static bool DefaultEnableStateUndo() { -#ifdef MOBILE_DEVICE +#ifdef PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS) // Off on mobile to save disk space. return false; #endif diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index cbb81ed098..87cf486f4a 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1405,10 +1405,6 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load if (!module->isFake) { bool scan = true; -#if defined(MOBILE_DEVICE) - scan = g_Config.bFuncReplacements; -#endif - // If the ELF has debug symbols, don't add entries to the symbol table. bool insertSymbols = scan && !reader.LoadSymbols(); std::vector codeSections = reader.GetCodeSections(); diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index 7d46dfb515..5a9235d620 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -408,8 +408,8 @@ const KeyMap_IntStrPair psp_button_names[] = { {VIRTKEY_SPEED_CUSTOM2, "Alt speed 2"}, {VIRTKEY_SPEED_ANALOG, "Analog speed"}, {VIRTKEY_PAUSE, "Pause"}, -#ifndef MOBILE_DEVICE {VIRTKEY_FRAME_ADVANCE, "Frame Advance"}, +#if !defined(MOBILE_DEVICE) {VIRTKEY_RECORD, "Audio/Video Recording" }, #endif {VIRTKEY_REWIND, "Rewind"}, diff --git a/Core/KeyMap.h b/Core/KeyMap.h index 3459433b2d..976ed67e06 100644 --- a/Core/KeyMap.h +++ b/Core/KeyMap.h @@ -148,7 +148,7 @@ namespace KeyMap { return false; } - FixedTinyVec mappings; + FixedVec mappings; }; typedef std::map> KeyMapping; diff --git a/Core/System.cpp b/Core/System.cpp index 0c7bf42fb4..8421cb297e 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -566,11 +566,9 @@ void PSP_Shutdown() { if (coreState == CORE_RUNNING) Core_Stop(); -#ifndef MOBILE_DEVICE if (g_Config.bFuncHashMap) { MIPSAnalyst::StoreHashMap(); } -#endif if (pspIsIniting) Core_NotifyLifecycle(CoreLifecycle::START_COMPLETE); diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 52e1b37aca..b3a9ff0a4b 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -435,6 +435,8 @@ bool System_GetPropertyBool(SystemProperty prop) { } case SYSPROP_DEBUGGER_PRESENT: return IsDebuggerPresent(); + case SYSPROP_OK_BUTTON_LEFT: + return true; default: return false; } diff --git a/Windows/main.cpp b/Windows/main.cpp index 762d5a747e..05dd0b6018 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -383,6 +383,8 @@ bool System_GetPropertyBool(SystemProperty prop) { return !g_Config.bDisableHTTPS; case SYSPROP_DEBUGGER_PRESENT: return IsDebuggerPresent(); + case SYSPROP_OK_BUTTON_LEFT: + return true; default: return false; }