Repository navigation
Fix rotated Vulkan output on Android - #119
Conversation
| #ifdef __ANDROID__ | ||
| // Applications render in window coordinates, so let Android rotate the presentation. | ||
| if(swapChainSupport.capabilities.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) | ||
| createInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; |
There was a problem hiding this comment.
should it be just VkSurfaceTransformFlagBitsKHR(0) in all cases?
There was a problem hiding this comment.
0 isn’t valid here; identity is VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR (1). We can remove the Android guard and prefer identity on all platforms, while retaining the supported-transform check and fallback.
There was a problem hiding this comment.
Base on this guide here: https://docs.vulkan.org/samples/latest/samples/performance/surface_rotation/README.html
0 allowed.
Or more exact wording:
Ignore the preTransform field in VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR. This will not match the value returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR and therefore the Android Compositor will rotate the scene before presenting it to the display
Basically, as long as we letting composer do it's job we good.
There was a problem hiding this comment.
Agreed on letting the compositor handle rotation. The linked sample uses VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, not 0. I can remove the Android guard and use that selection across platforms, keeping the supported-transform check.
There was a problem hiding this comment.
I can remove the Android guard and use that selection across platforms, keeping the supported-transform check.
Sounds good: VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR by default, if possible and currentTransform otherwise
There was a problem hiding this comment.
Updated as suggested: prefer VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR when supported, otherwise use currentTransform. Removed the Android guard.
|
Merged, thanks! |
OpenGothic's main menu renders rotated 90 degrees on Android. The swapchain uses
currentTransformeven though the application renders an unrotated frame.Prefer
VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHRwhen supported on any platform, letting the presentation engine handle rotation. Otherwise, usecurrentTransform.Verified upright rendering with OpenGothic on a Galaxy S24.
Related: Try/OpenGothic#1001