自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Cuttlefish:GPU 圖形加速
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Cuttlefish 的加速圖形模式會使用主機的實體圖形處理單元 (GPU) 進行轉譯,方法是將訪客轉譯指令傳遞至主機,在主機上執行轉譯指令呼叫,然後將轉譯結果傳回給訪客。
搭載 Android 11 以上版本的 Cuttlefish 裝置會偵測及使用加速圖形。如果主機不支援加速圖形,或是 Android 版本為 Android 10 以下,Cuttlefish 裝置中的訪客端算繪作業 (例如 UI 和影片播放) 就會由 SwiftShader 處理。SwiftShader 是 OpenGL 和 Vulkan API 的軟體實作項目。由於 SwiftShader 是軟體實作,因此可為 Cuttlefish 提供可在任何主機上執行的通用算繪解決方案。
不過,使用 SwiftShader 的效能不如一般裝置。轉譯是平行問題,可進行大量平行處理,因為像素值可獨立計算。圖形處理器 (GPU) 是硬體單元,可透過加速算繪來解決這個問題。
需求條件
加速圖形模式需要主機具備下列條件:
- 支援
GL_KHR_surfaceless_context
擴充功能的 EGL 驅動程式
- 支援 OpenGL ES 的驅動程式
- 支援 Vulkan 的驅動程式
使用加速圖形模式
GfxStream
如要使用 GfxStream 加速圖形模式,請使用 --gpu_mode=gfxstream
標記啟動本機 Cuttlefish 裝置。使用這個模式時,OpenGL 和 Vulkan API 呼叫會直接轉送至主機。
launch_cvd --gpu_mode=gfxstream
Virgl
如要使用 Virgl 加速圖形模式,請使用 --gpu_mode=drm_virgl
標記啟動本機 Cuttlefish 裝置。
launch_cvd --gpu_mode=drm_virgl
使用 Virgl 加速繪圖模式時,OpenGL API 呼叫會轉譯為中介表示法 (請參閱 Gallium3D)。中介表示法會傳送至主機,而主機上的 virglrenderer 程式庫會將中介表示法轉譯回 OpenGL API 呼叫。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Cuttlefish: GPU graphics acceleration\n\nCuttlefish's accelerated graphics mode uses your host machine's physical\ngraphics processing unit (GPU) for rendering by passing guest rendering commands\nto your host machine, running the rendering commands calls on your host machine,\nand passing the rendered results back to the guest.\n\nA Cuttlefish device running in Android 11 or higher\ndetects and uses accelerated graphics. If the host machine doesn't support\naccelerated graphics or the Android version is\nAndroid 10 or lower, guest-side rendering (for example,\nUI and video playback) in your Cuttlefish device is handled by SwiftShader.\nSwiftShader is a software implementation of the OpenGL and Vulkan APIs. Because\nSwiftShader is a software implementation, it provides a universally accessible\nrendering solution for Cuttlefish capable of running on any host machine.\n\nHowever, using SwiftShader isn't as performant as a normal device. Rendering is\na parallel problem that can be massively parallelized, as pixel\nvalues can be computed independently. Graphics processing units (GPUs) are\nhardware units that address this problem by accelerating rendering.\n\nRequirements\n------------\n\nAccelerated graphics mode requires that the host have:\n\n- EGL capable driver supporting the `GL_KHR_surfaceless_context` extension\n- OpenGL ES capable driver\n- Vulkan capable driver\n\nUse accelerated graphics modes\n------------------------------\n\n### GfxStream\n\nTo use the GfxStream accelerated graphics mode, launch your local Cuttlefish\ndevice with the `--gpu_mode=gfxstream` flag. Using this mode, OpenGL and Vulkan\nAPI calls are forwarded directly to the host. \n\n```\nlaunch_cvd --gpu_mode=gfxstream\n```\n\n### Virgl\n\nTo use the Virgl accelerated graphics mode, launch your local Cuttlefish device\nwith the `--gpu_mode=drm_virgl` flag. \n\n```\nlaunch_cvd --gpu_mode=drm_virgl\n```\n\nWhen using the Virgl accelerated graphics mode, OpenGL API calls are translated\ninto an intermediate representation (see\n[Gallium3D](https://www.freedesktop.org/wiki/Software/gallium/)). The\nintermediate representation is communicated to the host and the\n[virglrenderer](https://gitlab.freedesktop.org/virgl/virglrenderer) library on\nthe host translates the intermediate representation back to OpenGL API calls.\n| **Note:** Vulkan isn't supported."]]