![rotate android device emulator mac android studio rotate android device emulator mac android studio](https://i.stack.imgur.com/Xvu9o.png)
#ROTATE ANDROID DEVICE EMULATOR MAC ANDROID STUDIO HOW TO#
In this post we will describe in detail how to implement pre-rotation and handle device rotation in your Vulkan application. Knowing how to set the surface transform flag is important for every Vulkan application, since applications tend to either support multiple orientations, or support a single orientation where its render surface is in a different orientation to what the device considers its identity orientation For example a landscape-only application on a portrait-identity phone, or a portrait-only application on a landscape-identity tablet. The primary mechanism with which this works is by telling the Android OS that we are handling the surface rotation by specifying in the orientation during swapchain creation through the passed in surface transform flags, which stops the Android Compositor from doing the rotation itself. To ensure surface rotations are handled properly with as little overhead as possible (as seen in the case above) we recommend implementing method 3 - this is known as pre-rotation. Handling orientation properly stops GPU preemption by SurfaceFlinger almost entirely, as well as sees the GPU frequency drop 40% as the boosted frequency used by the Android Compositor is no longer needed. On Pixel 4XL, we have seen on shipping titles that SurfaceFlinger (the higher-priority task that drives the Android Compositor) both regularly preempts the application’s work causing 1-3ms hits to frametimes, as well as puts increased pressure on the GPU’s vertex/texture memory as the Compositor has to read the frame to do its composition work. If your application is CPU bound, this becomes a huge power issue due to the increased GPU usage by the Android Compositor which usually is running at a boosted frequency as well and if your application is GPU bound, then it becomes a potentially large performance issue on top of that as the Android Compositor will preempt your application's GPU work causing your application to drop its frame rate. Even if there is a DPU to take care of this for us, there will still likely be a measurable performance penalty to pay.
![rotate android device emulator mac android studio rotate android device emulator mac android studio](https://www.tutorialspoint.com/android/images/android_p.jpg)
There currently isn't a way for an application to know whether surface rotation handled outside of the application will be free. The application itself can handle the surface rotation by rendering a rotated image onto a render surface that matches the current orientation of the display.The Android OS can handle surface rotation by adding a compositor pass that will have a performance cost depending on how the compositor has to deal with rotating the output image.The device has a Display Processing Unit (DPU) that can efficiently handle surface rotation in hardware to match the device orientation (requires a device that supports this).Currently, there are 3 ways that Android can handle reconciling the render surface of the device with the orientation of the device : One of these things is device orientation and its relationship to render surface orientation.
![rotate android device emulator mac android studio rotate android device emulator mac android studio](https://www.lifewire.com/thmb/Cg2MvoIfbiNcl2GBXmS9bfSOmFo=/1518x861/filters:no_upscale():max_bytes(150000):strip_icc()/001_top-android-emulators-3426914-fdc98af221d74634b5926b346a48b6f5.jpg)
![rotate android device emulator mac android studio rotate android device emulator mac android studio](https://www.informatique-mania.com/wp-content/uploads/2021/04/movil-y-recuadro-de-ajustes.jpg)
With that power though comes some new responsibilities developers are expected to explicitly implement things that in OpenGL were handled by the driver. Vulkan provides developers with the power to specify much more information to devices about rendering state compared to OpenGL.