OSDN Git Service

RenderEngine: support non-RGBA_8888 format
authorChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 28 Jul 2017 11:44:57 +0000 (19:44 +0800)
committerMauro Rossi <issor.oruam@gmail.com>
Mon, 24 Jul 2023 16:03:23 +0000 (18:03 +0200)
Some of our GPUs (e.g., radeon) don't support RGBA_8888 well.
To workaround it, just get the EGL config by a simpler query.

This patch should be reverted once all of our GPUs support
RGBA_8888.

libs/renderengine/gl/GLESRenderEngine.cpp

index 467f848..26c0fb7 100644 (file)
@@ -327,7 +327,7 @@ std::unique_ptr<GLESRenderEngine> GLESRenderEngine::create(const RenderEngineCre
             break;
     }
 
-    ALOGI("OpenGL ES informations:");
+    ALOGI("OpenGL ES informations: format=0x%x", args.pixelFormat);
     ALOGI("vendor    : %s", extensions.getVendor());
     ALOGI("renderer  : %s", extensions.getRenderer());
     ALOGI("version   : %s", extensions.getVersion());
@@ -342,8 +342,14 @@ EGLConfig GLESRenderEngine::chooseEglConfig(EGLDisplay display, int format, bool
     EGLConfig config;
 
     // First try to get an ES3 config
-    err = selectEGLConfig(display, format, EGL_OPENGL_ES3_BIT, &config);
-    if (err != NO_ERROR) {
+    // Only try to get an ES3/ES2 config if format is RGBA_8888
+    if (format != HAL_PIXEL_FORMAT_RGBA_8888) {
+        ALOGI("Trying a simpler query for non-RGBA_8888");
+        err = selectEGLConfig(display, format, 0, &config);
+        if (err != NO_ERROR) {
+            LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up");
+        }
+    } else if ((err = selectEGLConfig(display, format, EGL_OPENGL_ES3_BIT, &config)) != NO_ERROR) {
         // If ES3 fails, try to get an ES2 config
         err = selectEGLConfig(display, format, EGL_OPENGL_ES2_BIT, &config);
         if (err != NO_ERROR) {
@@ -365,7 +371,7 @@ EGLConfig GLESRenderEngine::chooseEglConfig(EGLDisplay display, int format, bool
         eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &g);
         eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &b);
         eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a);
-        ALOGI("EGL information:");
+        ALOGI("EGL information: format=0x%x", format);
         ALOGI("vendor    : %s", eglQueryString(display, EGL_VENDOR));
         ALOGI("version   : %s", eglQueryString(display, EGL_VERSION));
         ALOGI("extensions: %s", eglQueryString(display, EGL_EXTENSIONS));