From 9a108a46d462c1ca2e87387de9f6c92b26e48b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 1 Dec 2022 10:17:31 +0100 Subject: [PATCH] Disable the PowerVR swapchain hack after driver version 1.386.1368. See #15773 --- Common/GPU/Vulkan/VulkanContext.cpp | 20 +++++++++++++++----- UI/DisplayLayoutScreen.cpp | 23 ++++++++++++++--------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index 389eb6dbbe..19ecb40588 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -1136,11 +1136,21 @@ bool VulkanContext::InitSwapchain() { INFO_LOG(G3D, "Transform supported: %s current: %s chosen: %s", supportedTransforms.c_str(), currentTransform.c_str(), preTransformStr.c_str()); if (physicalDeviceProperties_[physical_device_].properties.vendorID == VULKAN_VENDOR_IMGTEC) { - INFO_LOG(G3D, "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; + u32 driverVersion = physicalDeviceProperties_[physical_device_].properties.driverVersion; + // Cutoff the hack at driver version 1.386.1368 (0x00582558, see issue #15773). + if (driverVersion < 0x00582558) { + INFO_LOG(G3D, "Applying PowerVR hack (rounding off the width!) driverVersion=%08x", driverVersion); + // 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; + + // TODO: Also modify display_xres/display_yres appropriately for scissors to match. + // This will get a bit messy. Ideally we should remove that logic from app-android.cpp + // and move it here, but the OpenGL code still needs it. + } else { + INFO_LOG(G3D, "PowerVR driver version new enough (%08x), not applying swapchain width hack", driverVersion); + } } VkSwapchainCreateInfoKHR swap_chain_info{ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index ed741ec6c9..18d52d8360 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -63,15 +63,14 @@ public: bool Touch(const TouchInput &touch) { int mode = mode_ ? mode_->GetSelection() : 0; - const Bounds &screenBounds = bounds_; if ((touch.flags & TOUCH_MOVE) != 0 && dragging_) { float relativeTouchX = touch.x - startX_; float relativeTouchY = touch.y - startY_; switch (mode) { case MODE_MOVE: - g_Config.fDisplayOffsetX = clamp_value(startDisplayOffsetX_ + relativeTouchX / screenBounds.w, 0.0f, 1.0f); - g_Config.fDisplayOffsetY = clamp_value(startDisplayOffsetY_ + relativeTouchY / screenBounds.h, 0.0f, 1.0f); + g_Config.fDisplayOffsetX = clamp_value(startDisplayOffsetX_ + relativeTouchX / bounds_.w, 0.0f, 1.0f); + g_Config.fDisplayOffsetY = clamp_value(startDisplayOffsetY_ + relativeTouchY / bounds_.h, 0.0f, 1.0f); break; case MODE_RESIZE: { @@ -84,12 +83,18 @@ public: } if ((touch.flags & TOUCH_DOWN) != 0 && !dragging_) { - dragging_ = true; - startX_ = touch.x; - startY_ = touch.y; - startDisplayOffsetX_ = g_Config.fDisplayOffsetX; - startDisplayOffsetY_ = g_Config.fDisplayOffsetY; - startScale_ = g_Config.fDisplayScale; + // Check that we're in the central 80% of the screen. + // If outside, it may be a drag from displaying the back button on phones + // where you have to drag from the side, etc. + if (touch.x >= bounds_.w * 0.1f && touch.x <= bounds_.w * 0.9f && + touch.y >= bounds_.h * 0.1f && touch.y <= bounds_.h * 0.9f) { + dragging_ = true; + startX_ = touch.x; + startY_ = touch.y; + startDisplayOffsetX_ = g_Config.fDisplayOffsetX; + startDisplayOffsetY_ = g_Config.fDisplayOffsetY; + startScale_ = g_Config.fDisplayScale; + } } if ((touch.flags & TOUCH_UP) != 0 && dragging_) {