Merge pull request #22734 from hrydgard/vulkan-stale-extent-workaround

Android Vulkan: Bring back the stale surface extent workaround
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2026-10-22 21:52:20 +02:00
commit 79cedbc13f
3 files changed
+27

No files matched your search

+15
View File
@@ -1556,6 +1556,21 @@ bool VulkanContext::InitSwapchain(VkPresentModeKHR desiredPresentMode) {
}
}
#if PPSSPP_PLATFORM(ANDROID)
// After an in-place rotation, the surface can report the new transform together with the previous
// orientation's extent. A Redmi 9A (PowerVR, Android 11) keeps doing it after surfaceChanged has given us the
// new size, so the swapchain stays wrong until the next rotation. The latest window size from surfaceChanged
// is current (g_display can lag behind it, until the render thread applies the resize), so if the extent is
// exactly that transposed, it's stale.
const VkExtent2D windowSize = cbGetDrawSize_ ? cbGetDrawSize_() : VkExtent2D{};
if (windowSize.width > 0 && windowSize.height > 0 && windowSize.width != windowSize.height &&
currentExtent.width == windowSize.height && currentExtent.height == windowSize.width) {
WARN_LOG(Log::G3D, "Surface extent %dx%d is the window transposed, probably stale after a rotation. Using %dx%d.",
currentExtent.width, currentExtent.height, windowSize.width, windowSize.height);
std::swap(currentExtent.width, currentExtent.height);
}
#endif
swapChainExtent_.width = clamp(currentExtent.width, surfCapabilities_.minImageExtent.width, surfCapabilities_.maxImageExtent.width);
swapChainExtent_.height = clamp(currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height);