vsg-dev / VulkanSceneGraph

Vulkan & C++17 based Scene Graph Project
http://www.vulkanscenegraph.org
MIT License
1.28k stars 206 forks source link

Screen orientation on Android #1242

Open Duron27 opened 2 months ago

Duron27 commented 2 months ago

There seems to be an issue with android screen orientation.

In swapchain.cpp changing This line to createInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; allows the screen to rotate but seems to solve it but cause performance issues.

I'm stuck on 1.0.9 at the moment, sorry if this is fixed in a later release.

robertosfield commented 2 months ago

There hasn't been anyone else reporting this issue and no fixes have submitted for this so it's very unlikely that any of the VSG-1.1.x developer releases or VSG master will have addressed the issue.

I don't have any Android experience myself so can't provide insights in how we might address the problem - I rely on those who have Android setup and expertise to help support the platform, as it's still a niche platform for the VSG community it does unfortunately mean there aren't many engineers that help shake down the platform, so I you can investigate and resolve the issue it would be much appreciated.

If you come across discussions online about the problem and fixes for it let me know - a link to online docs/discussions or just explanations would help myself and other gain insight to what might need to be done.

Duron27 commented 2 months ago

There's a vulkan dev helping me with this issue so maybe we will figure it out. Has anyone tried changing the screen orientation? I'm not sure it's android specific.

robertosfield commented 1 month ago

I don't recall any discussions about changing screen orientation. So far the VSG user base has been mainly desktop based.

If you can provide any information/insights that you've come across then I can considering this w.r.t any general changes to the core VSG that might be required. Presently there is a WindowResizeHandler that updates projection matrices and any affected graphics piplines when the window size is resized, perhaps this can be generalized to handle the case of orientation changes as well as there may be an overlap if what changes need to be applied.

There may also be an need to extend the vsg::Window base class to handle the case of window orientation changes as the code right now assumes a consistent orientation.

Duron27 commented 1 month ago

Im going to see if this will work in the swapchain.cpp file vulkan-prerotation

robertosfield commented 1 month ago

Thanks for the link. I think Option 3 would be the best. If we can get an orientation message from the OS/Windowing system rather than recreate the viewport we could just rotate the camera - perhaps rotation of the projection matrix.