diff --git a/.gitignore b/.gitignore index 5c6ef0569f..b52bbe8e1b 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,7 @@ android/assets/lang android/assets/flash0 ppge_atlas.zim.png local.properties +r.sh # For vim *.swp diff --git a/Common/KeyMap.cpp b/Common/KeyMap.cpp index ead9f63573..99be29b104 100644 --- a/Common/KeyMap.cpp +++ b/Common/KeyMap.cpp @@ -15,23 +15,24 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include + #if defined(SDL) #include #elif defined(USING_WIN_UI) #include "CommonWindows.h" #endif -#include #include "base/logging.h" #include "base/NativeApp.h" #include "file/ini_file.h" #include "input/input_state.h" +#include "ppsspp_config.h" #include "KeyMap.h" -#include "../Core/HLE/sceUtility.h" -#include "../Core/Config.h" - -#include +#include "Core/HLE/sceUtility.h" +#include "Core/Config.h" namespace KeyMap { @@ -188,6 +189,27 @@ static const DefMappingStruct defaultShieldKeyMap[] = { {VIRTKEY_PAUSE, NKCODE_BACK }, }; +static const DefMappingStruct defaultMOQI7SKeyMap[] = { + {CTRL_CROSS, NKCODE_BUTTON_A}, + {CTRL_CIRCLE, NKCODE_BUTTON_B}, + {CTRL_SQUARE, NKCODE_BUTTON_X}, + {CTRL_TRIANGLE, NKCODE_BUTTON_Y}, + {CTRL_START, JOYSTICK_AXIS_Z, +1}, + {CTRL_SELECT, JOYSTICK_AXIS_Z, -1}, + {CTRL_LTRIGGER, NKCODE_BUTTON_L1}, + {CTRL_RTRIGGER, NKCODE_BUTTON_R1}, + {VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1}, + {VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1}, + {VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1}, + {VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1}, + {CTRL_LEFT, JOYSTICK_AXIS_HAT_X, -1}, + {CTRL_RIGHT, JOYSTICK_AXIS_HAT_X, +1}, + {CTRL_UP, JOYSTICK_AXIS_HAT_Y, -1}, + {CTRL_DOWN, JOYSTICK_AXIS_HAT_Y, +1}, + {VIRTKEY_UNTHROTTLE, JOYSTICK_AXIS_RZ, +1 }, + {VIRTKEY_PAUSE, NKCODE_BACK }, +}; + static const DefMappingStruct defaultPadMap[] = { #if defined(__ANDROID__) {CTRL_CROSS , NKCODE_BUTTON_A}, @@ -388,6 +410,9 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) { case DEFAULT_MAPPING_SHIELD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace); break; + case DEFAULT_MAPPING_MOQI_I7S: + SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultMOQI7SKeyMap, ARRAY_SIZE(defaultMOQI7SKeyMap), replace); + break; case DEFAULT_MAPPING_PAD: SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace); break; @@ -857,20 +882,24 @@ void SetAxisMapping(int btn, int deviceId, int axisId, int direction, bool repla // Note that it's easy to add other defaults if desired. void RestoreDefault() { g_controllerMap.clear(); -#if defined(_WIN32) +#if PPSSPP_PLATFORM(WINDOWS) SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true); SetDefaultKeyMap(DEFAULT_MAPPING_X360, false); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false); -#elif defined(__ANDROID__) - // Autodetect a few common devices +#elif PPSSPP_PLATFORM(ANDROID) + // Autodetect a few common (and less common) devices std::string name = System_GetProperty(SYSPROP_NAME); if (IsNvidiaShield(name) || IsNvidiaShieldTV(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_SHIELD, true); - } else if (IsOuya(name)) { // TODO: check! + } else if (IsOuya(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_OUYA, true); } else if (IsXperiaPlay(name)) { SetDefaultKeyMap(DEFAULT_MAPPING_XPERIA_PLAY, true); + } else if (IsMOQII7S(name)) { + ILOG("MOQI pad map"); + SetDefaultKeyMap(DEFAULT_MAPPING_MOQI_I7S, true); } else { + ILOG("Default pad map"); SetDefaultKeyMap(DEFAULT_MAPPING_PAD, true); } #else @@ -948,8 +977,12 @@ bool IsXperiaPlay(const std::string &name) { return name == "Sony Ericsson:R800a" || name == "Sony Ericsson:R800i" || name == "Sony Ericsson:R800x" || name == "Sony Ericsson:R800at" || name == "Sony Ericsson:SO-01D" || name == "Sony Ericsson:zeus"; } +bool IsMOQII7S(const std::string &name) { + return name == "MOQI:I7S"; +} + bool HasBuiltinController(const std::string &name) { - return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name); + return IsOuya(name) || IsXperiaPlay(name) || IsNvidiaShield(name) || IsMOQII7S(name); } void NotifyPadConnected(const std::string &name) { @@ -957,7 +990,7 @@ void NotifyPadConnected(const std::string &name) { } void AutoConfForPad(const std::string &name) { - ILOG("Autoconfiguring pad for %s", name.c_str()); + ILOG("Autoconfiguring pad for '%s'", name.c_str()); if (name == "Xbox 360 Pad") { SetDefaultKeyMap(DEFAULT_MAPPING_X360, true); } else { diff --git a/Common/KeyMap.h b/Common/KeyMap.h index 345cff9a57..6b39cbd4de 100644 --- a/Common/KeyMap.h +++ b/Common/KeyMap.h @@ -68,6 +68,7 @@ enum DefaultMaps { DEFAULT_MAPPING_SHIELD, DEFAULT_MAPPING_OUYA, DEFAULT_MAPPING_XPERIA_PLAY, + DEFAULT_MAPPING_MOQI_I7S, }; const float AXIS_BIND_THRESHOLD = 0.75f; @@ -140,6 +141,7 @@ namespace KeyMap { bool IsNvidiaShieldTV(const std::string &name); bool IsXperiaPlay(const std::string &name); bool IsOuya(const std::string &name); + bool IsMOQII7S(const std::string &name); bool HasBuiltinController(const std::string &name); const std::set &GetSeenPads(); diff --git a/Common/MemArenaPosix.cpp b/Common/MemArenaPosix.cpp index d550d5aaab..5ee371ed17 100644 --- a/Common/MemArenaPosix.cpp +++ b/Common/MemArenaPosix.cpp @@ -103,9 +103,25 @@ void MemArena::ReleaseView(void* view, size_t size) { u8* MemArena::Find4GBBase() { // Now, create views in high memory where there's plenty of space. #if PPSSPP_ARCH(64BIT) && !defined(USE_ADDRESS_SANITIZER) - // Very precarious - mmap cannot return an error when trying to map already used pages. - // This makes the Windows approach above unusable on Linux, so we will simply pray... - return reinterpret_cast(0x2300000000ULL); + // We should probably just go look in /proc/self/maps for some free space. + // But let's try the anonymous mmap trick, just like on 32-bit, but bigger and + // aligned to 4GB for the movk trick. We can ensure that we get an aligned 4GB + // address by grabbing 8GB and aligning the pointer. + const uint64_t EIGHT_GIGS = 0x200000000ULL; + void *base = mmap(0, EIGHT_GIGS, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); + if (base) { + INFO_LOG(MEMMAP, "base: %p", base); + uint64_t aligned_base = ((uint64_t)base + 0xFFFFFFFF) & ~0xFFFFFFFFULL; + INFO_LOG(MEMMAP, "aligned_base: %p", (void *)aligned_base); + munmap(base, EIGHT_GIGS); + return reinterpret_cast(aligned_base); + } else { + u8 *hardcoded_ptr = reinterpret_cast(0x2300000000ULL); + INFO_LOG(MEMMAP, "Failed to anonymously map 8GB. Fall back to the hardcoded pointer %p.", hardcoded_ptr); + // Just grab some random 4GB... + // This has been known to fail lately though, see issue #12249. + return hardcoded_ptr; + } #else size_t size = 0x10000000; void* base = mmap(0, size, PROT_READ | PROT_WRITE, diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index dc87073214..955039de51 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -84,19 +84,7 @@ const char *PresentModeString(VkPresentModeKHR presentMode) { } VulkanContext::VulkanContext() { -#if SIMULATE_VULKAN_FAILURE == 1 - return; -#endif - if (!VulkanLoad()) { - init_error_ = "Failed to load Vulkan driver library"; - // No DLL? - return; - } - - // We can get the list of layers and extensions without an instance so we can use this information - // to enable the extensions we need that are available. - GetInstanceLayerProperties(); - GetInstanceLayerExtensionList(nullptr, instance_extension_properties_); + // Do nothing here. } VkResult VulkanContext::CreateInstance(const CreateInfo &info) { @@ -105,6 +93,11 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { return VK_ERROR_INITIALIZATION_FAILED; } + // We can get the list of layers and extensions without an instance so we can use this information + // to enable the extensions we need that are available. + GetInstanceLayerProperties(); + GetInstanceLayerExtensionList(nullptr, instance_extension_properties_); + if (!IsInstanceExtensionAvailable(VK_KHR_SURFACE_EXTENSION_NAME)) { // Cannot create a Vulkan display without VK_KHR_SURFACE_EXTENSION. init_error_ = "Vulkan not loaded - no surface extension"; @@ -932,12 +925,6 @@ bool VulkanContext::InitSwapchain() { swapChainExtent_.width = clamp(surfCapabilities_.currentExtent.width, surfCapabilities_.minImageExtent.width, surfCapabilities_.maxImageExtent.width); swapChainExtent_.height = clamp(surfCapabilities_.currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height); - if (physicalDeviceProperties_[physical_device_].properties.vendorID == VULKAN_VENDOR_IMGTEC) { - // Swap chain width hack to avoid issue #11743 (PowerVR driver bug). - // TODO: Check if still broken if pretransform is used! - swapChainExtent_.width &= ~31; - } - ILOG("swapChainExtent: %dx%d", swapChainExtent_.width, swapChainExtent_.height); // TODO: Find a better way to specify the prioritized present mode while being able @@ -1024,6 +1011,14 @@ bool VulkanContext::InitSwapchain() { std::string preTransformStr = surface_transforms_to_string(preTransform); ILOG("Chosen pretransform transform: %s", preTransformStr.c_str()); + if (physicalDeviceProperties_[physical_device_].properties.vendorID == VULKAN_VENDOR_IMGTEC) { + ILOG("Applying PowerVR hack (rounding off the width!)"); + // Swap chain width hack to avoid issue #11743 (PowerVR driver bug). + // To keep the size consistent even with pretransform, do this after the swap. Should be fine. + // This is fixed in newer PowerVR drivers but I don't know the cutoff. + swapChainExtent_.width &= ~31; + } + VkSwapchainCreateInfoKHR swap_chain_info{ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; swap_chain_info.surface = surface_; swap_chain_info.minImageCount = desiredNumberOfSwapChainImages; diff --git a/Common/Vulkan/VulkanLoader.cpp b/Common/Vulkan/VulkanLoader.cpp index 4f4c25feb0..683f56a7f6 100644 --- a/Common/Vulkan/VulkanLoader.cpp +++ b/Common/Vulkan/VulkanLoader.cpp @@ -247,12 +247,14 @@ void VulkanSetAvailable(bool available) { } bool VulkanMayBeAvailable() { - if (g_vulkanAvailabilityChecked) + if (g_vulkanAvailabilityChecked) { return g_vulkanMayBeAvailable; + } std::string name = System_GetProperty(SYSPROP_NAME); for (const char *blacklisted_name : device_name_blacklist) { if (!strcmp(name.c_str(), blacklisted_name)) { + ILOG("VulkanMayBeAvailable: Device blacklisted ('%s')", name.c_str()); g_vulkanAvailabilityChecked = true; g_vulkanMayBeAvailable = false; return false; @@ -334,25 +336,30 @@ bool VulkanMayBeAvailable() { ELOG("Enumerating VK extensions failed."); goto bail; } - - if (platformSurfaceExtension) { - for (auto iter : instanceExts) { - ILOG("VulkanMaybeAvailable: Instance extension found: %s (%08x)", iter.extensionName, iter.specVersion); - if (!strcmp(iter.extensionName, platformSurfaceExtension)) { - ILOG("VulkanMayBeAvailable: Found platform surface extension '%s'", platformSurfaceExtension); - instanceExtensions[ci.enabledExtensionCount++] = platformSurfaceExtension; - platformSurfaceExtensionFound = true; - break; - } else if (!strcmp(iter.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) { - instanceExtensions[ci.enabledExtensionCount++] = VK_KHR_SURFACE_EXTENSION_NAME; - surfaceExtensionFound = true; - } + for (auto iter : instanceExts) { + ILOG("VulkanMaybeAvailable: Instance extension found: %s (%08x)", iter.extensionName, iter.specVersion); + if (platformSurfaceExtension && !strcmp(iter.extensionName, platformSurfaceExtension)) { + ILOG("VulkanMayBeAvailable: Found platform surface extension '%s'", platformSurfaceExtension); + instanceExtensions[ci.enabledExtensionCount++] = platformSurfaceExtension; + platformSurfaceExtensionFound = true; + break; + } else if (!strcmp(iter.extensionName, VK_KHR_SURFACE_EXTENSION_NAME)) { + instanceExtensions[ci.enabledExtensionCount++] = VK_KHR_SURFACE_EXTENSION_NAME; + surfaceExtensionFound = true; } + } + if (platformSurfaceExtension) { if (!platformSurfaceExtensionFound || !surfaceExtensionFound) { ELOG("Platform surface extension not found"); goto bail; } + } else { + if (!surfaceExtensionFound) { + ELOG("Surface extension not found"); + goto bail; + } } + // This can't happen unless the driver is double-reporting a surface extension. if (ci.enabledExtensionCount > 2) { ELOG("Unexpected number of enabled instance extensions"); @@ -382,7 +389,7 @@ bool VulkanMayBeAvailable() { goto bail; } if (physicalDeviceCount == 0) { - ELOG("VulkanMayBeAvailable: No physical Vulkan devices."); + ELOG("VulkanMayBeAvailable: No physical Vulkan devices (count = 0)."); goto bail; } devices.resize(physicalDeviceCount); @@ -402,6 +409,7 @@ bool VulkanMayBeAvailable() { anyGood = true; break; default: + ILOG("VulkanMayBeAvailable: Ineligible device found and ignored: '%s'", props.deviceName); break; } // TODO: Should also check queuefamilyproperties for a GRAPHICS queue family? Oh well. diff --git a/Core/Config.cpp b/Core/Config.cpp index 3aacba4d15..b8fd0923c0 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -515,15 +515,6 @@ static ConfigSetting cpuSettings[] = { ConfigSetting(false), }; -static int DefaultRenderingMode() { - // Workaround for ancient device. Can probably be removed now as we do no longer - // support Froyo (Android 2.2)... - if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") { - return 0; // Non-buffered - } - return 1; -} - static int DefaultInternalResolution() { // Auto on Windows, 2x on large screens, 1x elsewhere. #if defined(USING_WIN_UI) @@ -583,9 +574,9 @@ static int DefaultGPUBackend() { return (int)GPUBackend::DIRECT3D11; } #elif PPSSPP_PLATFORM(ANDROID) - // Default to Vulkan only on Pie (level 28) devices or newer. Drivers before Pie + // Default to Vulkan only on Oreo 8.1 (level 27) devices or newer. Drivers before // were generally too unreliable to default to (with some exceptions, of course). - if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 28) { + if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 27) { return (int)GPUBackend::VULKAN; } #endif @@ -636,10 +627,14 @@ int Config::NextValidBackend() { } #endif - // They've all failed. Let them try the default. + // They've all failed. Let them try the default - or on Android, OpenGL. sFailedGPUBackends += ",ALL"; ERROR_LOG(LOADER, "All graphics backends failed"); +#if PPSSPP_PLATFORM(ANDROID) + return (int)GPUBackend::OPENGL; +#else return DefaultGPUBackend(); +#endif } return iGPUBackend; @@ -721,7 +716,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false), #endif ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), - ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true), + ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), ReportedConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true, true, true), diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 0d001f32ad..ddf6e5cf20 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -629,13 +629,19 @@ int main(int argc, char *argv[]) { case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: // better than RESIZED, more general + case SDL_WINDOWEVENT_MAXIMIZED: + case SDL_WINDOWEVENT_RESTORED: { + windowHidden = false; + Core_NotifyWindowHidden(windowHidden); + Uint32 window_flags = SDL_GetWindowFlags(window); bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN); - if (UpdateScreenScale(event.window.data1, event.window.data2)) { - NativeMessageReceived("gpu_resized", ""); + if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { + UpdateScreenScale(event.window.data1, event.window.data2); } + NativeMessageReceived("gpu_resized", ""); // Set variable here in case fullscreen was toggled by hotkey g_Config.bFullScreen = fullscreen; @@ -656,12 +662,9 @@ int main(int argc, char *argv[]) { break; case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_SHOWN: - case SDL_WINDOWEVENT_MAXIMIZED: - case SDL_WINDOWEVENT_RESTORED: windowHidden = false; Core_NotifyWindowHidden(windowHidden); break; - default: break; } diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index 123c016ef7..3cf55a78c5 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -24,14 +24,12 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, Version gitVer(PPSSPP_GIT_VERSION); - vulkan_ = new VulkanContext(); - if (vulkan_->InitError().size()) { - *error_message = vulkan_->InitError(); - delete vulkan_; - vulkan_ = nullptr; + if (!VulkanLoad()) { + *error_message = "Failed to load Vulkan driver library"; return false; } + vulkan_ = new VulkanContext(); int vulkanFlags = VULKAN_FLAG_PRESENT_MAILBOX; // vulkanFlags |= VULKAN_FLAG_VALIDATE; VulkanContext::CreateInfo info{}; diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index f566a7faff..e96c1e6343 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -432,9 +432,7 @@ public: JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr) : UI::InertView(layoutParams), xAxis_(xAxis), xDir_(xDir), - yAxis_(yAxis), yDir_(yDir), - curX_(0.0f), curY_(0.0f), - maxCount_(500) {} + yAxis_(yAxis), yDir_(yDir) {} void Draw(UIContext &dc) override; void Update() override; void Axis(const AxisInput &input) override { @@ -448,8 +446,6 @@ public: private: struct Location { - Location() : x(0.0f), y(0.0f) {} - Location(float xx, float yy) : x(xx), y(yy) {} float x; float y; }; @@ -459,40 +455,44 @@ private: int yAxis_; int yDir_; - float curX_; - float curY_; + float curX_ = 0.0f; + float curY_ = 0.0f; std::deque locations_; - int maxCount_; + int maxCount_ = 500; }; void JoystickHistoryView::Draw(UIContext &dc) { if (xAxis_ > -1 && yAxis_ > -1) { const AtlasImage &image = dc.Draw()->GetAtlas()->images[I_CROSS]; float minRadius = std::min(bounds_.w, bounds_.h) * 0.5f - image.w; - + dc.Begin(); int a = maxCount_ - (int)locations_.size(); for (auto iter = locations_.begin(); iter != locations_.end(); ++iter) { float x = bounds_.centerX() + minRadius * iter->x; float y = bounds_.centerY() - minRadius * iter->y; float alpha = (float)a / maxCount_; - if (alpha < 0.0f) alpha = 0.0f; + if (alpha < 0.0f) { + alpha = 0.0f; + } dc.Draw()->DrawImage(I_CROSS, x, y, 0.8f, colorAlpha(0xFFFFFF, alpha), ALIGN_CENTER); a++; } - dc.BeginNoTex(); - dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2, minRadius * 2, 0x80FFFFFF); dc.Flush(); - dc.Begin(); + dc.BeginNoTex(); + dc.Draw()->RectOutline(bounds_.centerX() - minRadius, bounds_.centerY() - minRadius, minRadius * 2.0f, minRadius * 2.0f, 0x80FFFFFF); + dc.Flush(); } else { dc.DrawText("N/A", bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER); } } void JoystickHistoryView::Update() { - locations_.push_back(Location(curX_, curY_)); - if ((int)locations_.size() > maxCount_) { - locations_.pop_front(); + if (xAxis_ > -1 && yAxis_ > -1) { + locations_.push_back(Location{ curX_, curY_ }); + if ((int)locations_.size() > maxCount_) { + locations_.pop_front(); + } } } @@ -521,12 +521,11 @@ bool AnalogTestScreen::axis(const AxisInput &axis) { // This is mainly to catch axis events that would otherwise get translated // into arrow keys, since seeing keyboard arrow key events appear when using // a controller would be confusing for the user. - char buf[512]; - if (IgnoreAxisForMapping(axis.axisId)) return false; if (axis.value > g_Config.fAxisBindThreshold || axis.value < -g_Config.fAxisBindThreshold) { + char buf[512]; snprintf(buf, sizeof(buf), "Axis: %d (value %1.3f) Device ID: %d", axis.axisId, axis.value, axis.deviceId); // Null-check just in case they weren't created yet. diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 0c8d63705e..b733028670 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -438,6 +438,9 @@ void SystemInfoScreen::CreateViews() { deviceSpecs->Add(new ItemHeader(si->T("System Information"))); deviceSpecs->Add(new InfoItem(si->T("System Name", "Name"), System_GetProperty(SYSPROP_NAME))); +#if PPSSPP_PLATFORM(ANDROID) + deviceSpecs->Add(new InfoItem(si->T("System Version"), StringFromInt(System_GetPropertyInt(SYSPROP_SYSTEMVERSION)))); +#endif deviceSpecs->Add(new InfoItem(si->T("Lang/Region"), System_GetProperty(SYSPROP_LANGREGION))); std::string board = System_GetProperty(SYSPROP_BOARDNAME); if (!board.empty()) diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp index 59ca85f76e..09f9f16a08 100644 --- a/Windows/GPU/WindowsVulkanContext.cpp +++ b/Windows/GPU/WindowsVulkanContext.cpp @@ -89,14 +89,14 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m g_LogOptions.msgBoxOnError = false; Version gitVer(PPSSPP_GIT_VERSION); - g_Vulkan = new VulkanContext(); - if (g_Vulkan->InitError().size()) { - *error_message = g_Vulkan->InitError(); - delete g_Vulkan; - g_Vulkan = nullptr; + + if (!VulkanLoad()) { + *error_message = "Failed to load Vulkan driver library"; return false; } - // int vulkanFlags = VULKAN_FLAG_PRESENT_FIFO_RELAXED; + + g_Vulkan = new VulkanContext(); + VulkanContext::CreateInfo info{}; info.app_name = "PPSSPP"; info.app_ver = gitVer.ToInteger(); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 017034b2b9..76c90d7cd7 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -258,7 +258,7 @@ namespace MainWindow } } - void RelaseMouseWheel() { + void ReleaseMouseWheel() { // For simplicity release both wheel events KeyInput key; key.deviceId = DEVICE_ID_MOUSE; @@ -856,7 +856,8 @@ namespace MainWindow return 0; // Hack: need to release wheel event with a delay for games to register it was "pressed down". case TIMER_WHEELRELEASE: - RelaseMouseWheel(); + ReleaseMouseWheel(); + KillTimer(hWnd, TIMER_WHEELRELEASE); return 0; } break; diff --git a/android/jni/AndroidVulkanContext.cpp b/android/jni/AndroidVulkanContext.cpp index f20247145c..5060d4de77 100644 --- a/android/jni/AndroidVulkanContext.cpp +++ b/android/jni/AndroidVulkanContext.cpp @@ -92,9 +92,16 @@ bool AndroidVulkanContext::InitAPI() { ILOG("Creating Vulkan context"); Version gitVer(PPSSPP_GIT_VERSION); + if (!VulkanLoad()) { + ELOG("Failed to load Vulkan driver library"); + return false; + } + if (!g_Vulkan) { + // TODO: Assert if g_Vulkan already exists here? g_Vulkan = new VulkanContext(); } + VulkanContext::CreateInfo info{}; info.app_name = "PPSSPP"; info.app_ver = gitVer.ToInteger(); @@ -102,7 +109,6 @@ bool AndroidVulkanContext::InitAPI() { VkResult res = g_Vulkan->CreateInstance(info); if (res != VK_SUCCESS) { ELOG("Failed to create vulkan context: %s", g_Vulkan->InitError().c_str()); - System_SendMessage("toast", "No Vulkan compatible device found. Using OpenGL instead."); VulkanSetAvailable(false); delete g_Vulkan; g_Vulkan = nullptr; diff --git a/cmake/Toolchains/ios.cmake b/cmake/Toolchains/ios.cmake index 718e270561..5cbc2644ab 100644 --- a/cmake/Toolchains/ios.cmake +++ b/cmake/Toolchains/ios.cmake @@ -72,14 +72,14 @@ else() set(IOS_ARCH "i386;x86_64") endif() -set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE string "Build architecture for iOS") +set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE STRING "Build architecture for iOS") set(CMAKE_ASM_FLAGS "" CACHE STRING "" FORCE) foreach(arch ${IOS_ARCH}) set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}" CACHE STRING "" FORCE) endforeach() # Set the find root to the iOS developer roots and to user defined paths -set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root") +set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE STRING "iOS find search path root") # default to searching for frameworks first set(CMAKE_FIND_FRAMEWORK FIRST) diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index a0f384f149..960f224180 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -805,7 +805,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit) VkDescriptorPoolCreateInfo dp{ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; dp.flags = 0; // Don't want to mess around with individually freeing these, let's go dynamic each frame. - dp.maxSets = 200; // 200 textures per frame should be enough for the UI... + dp.maxSets = 4096; // 200 textures per frame was not enough for the UI. dp.pPoolSizes = dpTypes; dp.poolSizeCount = ARRAY_SIZE(dpTypes); diff --git a/libretro/LibretroVulkanContext.cpp b/libretro/LibretroVulkanContext.cpp index 69679f16bc..ed5615b500 100644 --- a/libretro/LibretroVulkanContext.cpp +++ b/libretro/LibretroVulkanContext.cpp @@ -30,14 +30,20 @@ void LibretroVulkanContext::SwapBuffers() { static bool create_device(retro_vulkan_context *context, VkInstance instance, VkPhysicalDevice gpu, VkSurfaceKHR surface, PFN_vkGetInstanceProcAddr get_instance_proc_addr, const char **required_device_extensions, unsigned num_required_device_extensions, const char **required_device_layers, unsigned num_required_device_layers, const VkPhysicalDeviceFeatures *required_features) { init_glslang(); - vk = new VulkanContext; - if (!vk->InitError().empty()) { - ERROR_LOG(G3D, "%s", vk->InitError().c_str()); + if (!VulkanLoad()) { + // TODO: In the context of RetroArch, someone has already loaded the functions - + // we shouldn't need to load them again. On the other hand, it can't really hurt, we're gonna + // get the same pointers. + ERROR_LOG(G3D, "RetroArch called the Vulkan entry point without Vulkan available???"); return false; } + vk = new VulkanContext(); + vk_libretro_init(instance, gpu, surface, get_instance_proc_addr, required_device_extensions, num_required_device_extensions, required_device_layers, num_required_device_layers, required_features); + // TODO: Here we'll inject the instance and all of the stuff into the VulkanContext. + vk->CreateInstance({}); int physical_device = 0; diff --git a/libretro/Makefile.common b/libretro/Makefile.common index cf2d07681c..0d331ced8d 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -381,6 +381,7 @@ SOURCES_CXX += $(NATIVEDIR)/math/dataconv.cpp \ $(COREDIR)/HLE/sceHttp.cpp \ $(COREDIR)/HLE/sceImpose.cpp \ $(COREDIR)/HLE/sceIo.cpp \ + $(COREDIR)/HLE/sceUsbMic.cpp \ $(COREDIR)/HLE/sceJpeg.cpp \ $(COREDIR)/HLE/sceKernel.cpp \ $(COREDIR)/HLE/sceKernelAlarm.cpp \