From 1c8bed1fdce8981ce98af5bae8a9f72d09a6b471 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 27 Aug 2019 01:50:39 +0200 Subject: [PATCH 01/18] (Libretro) Buildfix - update Makefile.common --- libretro/Makefile.common | 1 + 1 file changed, 1 insertion(+) 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 \ From a80c8c7c9cb2277e2a34c46b121e3aac7742b80d Mon Sep 17 00:00:00 2001 From: Florin9doi Date: Sat, 31 Aug 2019 12:25:16 +0300 Subject: [PATCH 02/18] [iOS] Resolve Cmake warning --- cmake/Toolchains/ios.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 515bbd28fc17964733ca027537074bd9789a2115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 15:39:33 +0200 Subject: [PATCH 03/18] VulkanMaybeAvailable: Bail earlier in some cases where there's no surface extension. --- Common/Vulkan/VulkanLoader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Common/Vulkan/VulkanLoader.cpp b/Common/Vulkan/VulkanLoader.cpp index 4f4c25feb0..5b0d0eb34c 100644 --- a/Common/Vulkan/VulkanLoader.cpp +++ b/Common/Vulkan/VulkanLoader.cpp @@ -334,7 +334,9 @@ bool VulkanMayBeAvailable() { ELOG("Enumerating VK extensions failed."); goto bail; } - + for (auto &ext: instanceExts) { + ILOG(" %s", ext.extensionName); + } if (platformSurfaceExtension) { for (auto iter : instanceExts) { ILOG("VulkanMaybeAvailable: Instance extension found: %s (%08x)", iter.extensionName, iter.specVersion); @@ -352,6 +354,11 @@ bool VulkanMayBeAvailable() { 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) { From 88612d1d30ce18bb784fad96dd52f797f0570bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 16:10:28 +0200 Subject: [PATCH 04/18] Oops, fix the last commit, it got a little restrictive. --- Common/Vulkan/VulkanLoader.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Common/Vulkan/VulkanLoader.cpp b/Common/Vulkan/VulkanLoader.cpp index 5b0d0eb34c..0d6d4b650c 100644 --- a/Common/Vulkan/VulkanLoader.cpp +++ b/Common/Vulkan/VulkanLoader.cpp @@ -334,22 +334,19 @@ bool VulkanMayBeAvailable() { ELOG("Enumerating VK extensions failed."); goto bail; } - for (auto &ext: instanceExts) { - ILOG(" %s", ext.extensionName); + 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) { - 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; - } - } if (!platformSurfaceExtensionFound || !surfaceExtensionFound) { ELOG("Platform surface extension not found"); goto bail; @@ -360,6 +357,7 @@ bool VulkanMayBeAvailable() { 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"); From 1d46f40634d229664cb7660b2f0927f68f87e7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 16:22:29 +0200 Subject: [PATCH 05/18] SDL/Vulkan: Fix scale problems when maximizing/restoring the window. --- SDL/SDLMain.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 0d001f32ad..a17851588a 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,11 +662,6 @@ 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; From 1d528d6f3bf47035d244b9685965f727d2bbffdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 17:07:35 +0200 Subject: [PATCH 06/18] Linux: Port the proper memory base finding over to MemArenaPosix.cpp. Who knows, might fix some crashes. --- .gitignore | 1 + Common/MemArenaPosix.cpp | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 01c0268ea7..2beadcfc83 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/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, From 5847bf3201f058a7b6b7e76962f64d9ca7a3fc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 18:19:32 +0200 Subject: [PATCH 07/18] Attempt to work around the PowerVR bug again (pretransform undid the old workaround in landscape). See #12276 --- Common/Vulkan/VulkanContext.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index dc87073214..4ab1aa735d 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -933,9 +933,12 @@ bool VulkanContext::InitSwapchain() { swapChainExtent_.height = clamp(surfCapabilities_.currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height); if (physicalDeviceProperties_[physical_device_].properties.vendorID == VULKAN_VENDOR_IMGTEC) { + ILOG("Applying PowerVR hack (rounding off the dimensions!)"); // Swap chain width hack to avoid issue #11743 (PowerVR driver bug). - // TODO: Check if still broken if pretransform is used! + // To keep the size consistent even with pretransform, also round off the height. + // This is fixed in newer PowerVR drivers but I don't know the cutoff. swapChainExtent_.width &= ~31; + swapChainExtent_.height &= ~31; } ILOG("swapChainExtent: %dx%d", swapChainExtent_.width, swapChainExtent_.height); From 7610220b307f75a3e0e137db543d231efffc0bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 22:20:44 +0200 Subject: [PATCH 08/18] Vulkan: Prepare for adding a second init path for VulkanContext. Will eventually be used for libretro. --- Common/Vulkan/VulkanContext.cpp | 19 ++++++------------- SDL/SDLVulkanGraphicsContext.cpp | 8 +++----- Windows/GPU/WindowsVulkanContext.cpp | 12 ++++++------ android/jni/AndroidVulkanContext.cpp | 7 +++++++ libretro/LibretroVulkanContext.cpp | 12 +++++++++--- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 4ab1aa735d..869f776dbc 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"; 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/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/android/jni/AndroidVulkanContext.cpp b/android/jni/AndroidVulkanContext.cpp index f20247145c..44a565d37b 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(); 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; From 63305d5248466eb89ab94f68da0fe9d9fb2538b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 1 Sep 2019 23:00:35 +0200 Subject: [PATCH 09/18] SDL: Add back a couple of lines that should have been copied, not deleted. Thanks [Unknown] --- SDL/SDLMain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index a17851588a..ddf6e5cf20 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -662,7 +662,9 @@ int main(int argc, char *argv[]) { break; case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_SHOWN: - + windowHidden = false; + Core_NotifyWindowHidden(windowHidden); + break; default: break; } From 95367b34c9ef7d13948fa1ebced236df40b3d8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 18:15:01 +0200 Subject: [PATCH 10/18] Vulkan: Even more logging in VulkanMayBeAvailable. --- Common/Vulkan/VulkanLoader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/Vulkan/VulkanLoader.cpp b/Common/Vulkan/VulkanLoader.cpp index 0d6d4b650c..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; @@ -387,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); @@ -407,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. From 3af7229abc684778e4cf3465067b189642eb18c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 18:39:10 +0200 Subject: [PATCH 11/18] Bump up the descriptor pool size for the UI. Should fix #12299. --- ext/native/thin3d/thin3d_vulkan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From 6ae18c27f4e96a5dd46be6d640ae55702e368568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 19:06:29 +0200 Subject: [PATCH 12/18] Vulkan/PowerVR: Make another blind fix attempt for #12296. Can't find my PowerVR device :/ --- Common/Vulkan/VulkanContext.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 869f776dbc..955039de51 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -925,15 +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) { - ILOG("Applying PowerVR hack (rounding off the dimensions!)"); - // Swap chain width hack to avoid issue #11743 (PowerVR driver bug). - // To keep the size consistent even with pretransform, also round off the height. - // This is fixed in newer PowerVR drivers but I don't know the cutoff. - swapChainExtent_.width &= ~31; - swapChainExtent_.height &= ~31; - } - ILOG("swapChainExtent: %dx%d", swapChainExtent_.width, swapChainExtent_.height); // TODO: Find a better way to specify the prioritized present mode while being able @@ -1020,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; From 57c6ab7206aaeda74a0af3fe2ea96edd5d33a247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 20:02:40 +0200 Subject: [PATCH 13/18] Android: Remove the popup message when falling back to OpenGL. Fixes #12284 . --- android/jni/AndroidVulkanContext.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/android/jni/AndroidVulkanContext.cpp b/android/jni/AndroidVulkanContext.cpp index 44a565d37b..5060d4de77 100644 --- a/android/jni/AndroidVulkanContext.cpp +++ b/android/jni/AndroidVulkanContext.cpp @@ -109,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; From e2ecf306facd2c6d1ae4461b5ce2082528fdb434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 21:42:07 +0200 Subject: [PATCH 14/18] Android: Be slightly more aggressive at defaulting to Vulkan (from Android 8.1 / 27) --- Core/Config.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index b83d1bc893..814b9fae6f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -575,9 +575,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 @@ -628,10 +628,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; From e3a40e9cd794500141c43b8e7c2534a4eacef18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Sep 2019 21:42:49 +0200 Subject: [PATCH 15/18] Remove an old special case --- Core/Config.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 814b9fae6f..ecb3a7612e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -507,15 +507,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) @@ -714,7 +705,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), From f57b8b19d27badf153e8dba6c84c579929ea66c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 3 Sep 2019 00:01:37 +0200 Subject: [PATCH 16/18] Windows: Kill the mouse wheel release timer after it's used to prevent spamming keyup events. --- Windows/MainWindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 4dbba48ade..fe66c287c8 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; @@ -816,7 +816,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; From 6ff110d0928d684e72ed1c6fa24f13aa6d193121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 3 Sep 2019 00:02:57 +0200 Subject: [PATCH 17/18] Create a default keymap for the MOQI:I7S gamer phone (with builtin controls) --- Common/KeyMap.cpp | 55 +++++++++++++++++++++++++++++++++++++---------- Common/KeyMap.h | 2 ++ 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Common/KeyMap.cpp b/Common/KeyMap.cpp index 737d547b3c..169d7547c2 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 { @@ -184,6 +185,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}, @@ -384,6 +406,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; @@ -853,20 +878,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 @@ -944,8 +973,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) { @@ -953,7 +986,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 15c239c62a..70b6c4f2ea 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; @@ -141,6 +142,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(); From 90de634d1ed203a7064a15fee7cdabd0c205c0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 3 Sep 2019 00:05:18 +0200 Subject: [PATCH 18/18] Analog test screen: Fix drawing of the X marks --- UI/ControlMappingScreen.cpp | 35 +++++++++++++++++------------------ UI/DevScreens.cpp | 3 +++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index edb3f26e2d..f7985ba69b 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 > AXIS_BIND_THRESHOLD || axis.value < -AXIS_BIND_THRESHOLD) { + 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 d3e1d54f5d..35f9eb312f 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -439,6 +439,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())