Cuttlefish: GPU graphics acceleration

Cuttlefish's accelerated graphics mode uses your host machine's physical graphics processing unit (GPU) for rendering by passing guest rendering commands to your host machine, running the rendering commands calls on your host machine, and passing the rendered results back to the guest.

A Cuttlefish device running in Android 11 or higher detects and uses accelerated graphics. If the host machine doesn't support accelerated graphics or the Android version is Android 10 or lower, guest-side rendering (for example, UI and video playback) in your Cuttlefish device is handled by SwiftShader. SwiftShader is a software implementation of the OpenGL and Vulkan APIs. Because SwiftShader is a software implementation, it provides a universally accessible rendering solution for Cuttlefish capable of running on any host machine.

However, using SwiftShader isn't as performant as a normal device. Rendering is a parallel problem that can be massively parallelized, as pixel values can be computed independently. Graphics processing units (GPUs) are hardware units that address this problem by accelerating rendering.

Requirements

Accelerated graphics mode requires that the host have:

  • EGL capable driver supporting the GL_KHR_surfaceless_context extension
  • OpenGL ES capable driver
  • Vulkan capable driver

Use accelerated graphics modes

GfxStream

To use the GfxStream accelerated graphics mode, launch your local Cuttlefish device with the --gpu_mode=gfxstream flag. Using this mode, OpenGL and Vulkan API calls are forwarded directly to the host.

launch_cvd --gpu_mode=gfxstream

Virgl

To use the Virgl accelerated graphics mode, launch your local Cuttlefish device with the --gpu_mode=drm_virgl flag.

launch_cvd --gpu_mode=drm_virgl

When using the Virgl accelerated graphics mode, OpenGL API calls are translated into an intermediate representation (see Gallium3D). The intermediate representation is communicated to the host and the virglrenderer library on the host translates the intermediate representation back to OpenGL API calls.