[[["เข้าใจง่าย","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 UTC"],[],[],null,["# Implement OpenGL ES and EGL\n\n[OpenGL](https://www.opengl.org/) is a cross-platform graphics\nAPI that specifies a standard software\ninterface for 3D graphics processing hardware. [OpenGL ES](https://www.khronos.org/opengles/) is a subset of the\nOpenGL specification for embedded devices.\n\nTo be Android [compatible](/docs/compatibility/overview), devices\nneed to provide drivers for EGL, OpenGL ES 1.x, and OpenGL ES 2.0. Support\nfor OpenGL ES 3.x is optional. Key considerations include:\n\n- Ensuring that the GL driver is robust and conforms to OpenGL ES standards.\n- Allowing an unlimited number of GL contexts. Because Android allows apps in the background and tries to keep GL contexts alive, you shouldn't limit the number of contexts in your driver.\n- Being mindful of the amount of memory allocated for each context, because it's common to have 20--30 active GL contexts at once.\n- Supporting the YV12 image format and other YUV image formats that come from other components in the system, such as media codecs or the camera.\n- Supporting the mandatory extensions `EGL_KHR_wait_sync`, `GL_OES_texture_external`, `EGL_ANDROID_image_native_buffer`, and `EGL_ANDROID_recordable`. Additionally, Hardware Composer v1.1 and higher require the `EGL_ANDROID_framebuffer_target` extension.\n\nIt's highly recommended to also support `EGL_ANDROID_blob_cache`,\n`EGL_KHR_fence_sync`, and\n`EGL_ANDROID_native_fence_sync`.\n\nAndroid 10 implements the [EGL 1.5 interface](https://www.khronos.org/registry/EGL/specs/eglspec.1.5.pdf). For information on new features in\nEGL 1.5, see the [Khronos Releases 1.5 Specification](https://www.khronos.org/news/press/khronos-releases-egl-1.5-specification).\n| **Note:** The OpenGL API exposed to app developers differs from the OpenGL implemented on the device. Apps can't directly access the GL driver layer and must go through the interface provided by the APIs.\n\nDriver loading\n--------------\n\nAndroid expects the GPUs available to the system to be known when the system\nimage is built. The preferred paths for 32-bit and 64-bit OpenGL ES drivers are\n`/vendor/lib/egl` and `/vendor/lib64/egl` respectively.\nThe [loader](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/opengl/libs/EGL/Loader.h) uses two system properties,\n`ro.hardware.egl` and `ro.board.platform`, or the exact\nname to discover and load the system drivers. The OpenGL ES driver must be\nshipped in either one binary or split into three binaries. If the OpenGL ES\ndriver is shipped in one binary, use one of the following names: \n\n```genshi\nlibGLES_${ro.hardware.egl}.so\nlibGLES_${ro.board.platform}.so\nlibGLES.so\n```\n\nIf the OpenGL ES driver is shipped into three binaries, use one of the\nfollowing name sets: \n\n```genshi\nlibEGL_${ro.hardware.egl}.so\nlibGLESv1_CM_${ro.hardware.egl}.so\nlibGLESv2_${ro.hardware.egl}.so\n\nlibEGL_${ro.board.platform}.so\nlibGLESv1_CM_${ro.board.platform}.so\nlibGLESv2_${ro.board.platform}.so\n\nlibEGL.so\nlibGLESv1_CM.so\nlibGLESv2.so\n```\n\nOpenGL ES layers\n----------------\n\nAndroid 10 introduces a layering system for GLES\n2.0+. GLES layers are shared objects available from within apps or provided by\ntools. GLES layers enable debuggable apps to discover and load layers using the\nsame setup mechanisms as\n[Vulkan](https://developer.android.com/ndk/guides/graphics/validation-layer#vl-adb).\n| **Caution:** When layering is enabled, GLES 1.x exclusive functions continue to route to GLES 1.x drivers, but functions shared with GLES 2.0+ are routed to 2.0+ drivers.\n\nGLES LayerLoader, a component within the EGL loader, identifies GLES layers.\nFor each layer the GLES LayerLoader finds, the GLES LayerLoader\ncalls `AndroidGLESLayer_Initialize`, walks libEGL's function lists,\nand calls `AndroidGLESLayer_GetProcAddress` for all known functions.\nIf the layer intercepts a function, it tracks the function's address.\nIf the layer doesn't intercept a function,\n`AndroidGLESLayer_GetProcAddress` returns the same function\naddress it was passed. The LayerLoader then updates the function hook list to\npoint to the layer's entry point.\n\n### Enable layers\n\n| **Note:** Android's security model and policies differ significantly from other platforms. Android only enables those who have root access to load GLES layers from a device's local storage. Without root access, GLES layers can only be loaded for debuggable apps.\n\nYou can enable GLES layers either per app or globally. Per-app settings\npersist across reboots, while global properties are cleared on reboot.\n\nTo enable layers *per app*: \n\n # Enable layers\n adb shell settings put global enable_gpu_debug_layers 1\n\n # Specify target app\n adb shell settings put global gpu_debug_app \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003epackage_name\u003c/span\u003e\u003c/var\u003e\n\n # Specify layer list (from top to bottom)\n adb shell settings put global gpu_debug_layers_gles \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003elayer1\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003elayer2\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-o\"\u003e...\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003elayerN\u003c/span\u003e\u003c/var\u003e\n\n # Specify packages to search for layers\n adb shell settings put global gpu_debug_layer_app \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003epackage1\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003epackage2\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-o\"\u003e...\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003epackageN\u003c/span\u003e\u003c/var\u003e\n\nTo disable layers *per app*: \n\n adb shell settings delete global enable_gpu_debug_layers\n adb shell settings delete global gpu_debug_app\n adb shell settings delete global gpu_debug_layer_app\n\nTo enable layers *globally*: \n\n # Attempts to load layers for all applications, including native executables\n adb shell setprop debug.gles.layers \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003elayer1\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003elayer2\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-o\"\u003e...\u003c/span\u003e\u003c/var\u003e:\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003elayerN\u003c/span\u003e\u003c/var\u003e\n\n### Test layers\n\nGLES layers are backed by Android CTS and are required to pass CTS tests for\n[compatible devices](/docs/compatibility/overview). To identify if layers\nare working on a device, run `$ atest CtsGpuToolsHostTestCases`."]]