Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 17 | #include <log/log.h> |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 18 | #include <ui/Rect.h> |
| 19 | #include <ui/Region.h> |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 20 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 21 | #include "GLES20RenderEngine.h" |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 22 | #include "GLExtensions.h" |
Chia-I Wu | 401ef83 | 2017-12-01 10:52:22 -0800 | [diff] [blame] | 23 | #include "Image.h" |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 24 | #include "Mesh.h" |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 25 | #include "RenderEngine.h" |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 26 | |
Fabien Sanglard | c93afd5 | 2017-03-13 13:02:42 -0700 | [diff] [blame] | 27 | #include <SurfaceFlinger.h> |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 28 | #include <vector> |
Fabien Sanglard | c93afd5 | 2017-03-13 13:02:42 -0700 | [diff] [blame] | 29 | |
Jorim Jaggi | 5b15ef6 | 2018-01-17 18:31:39 +0100 | [diff] [blame] | 30 | #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> |
| 31 | #include <configstore/Utils.h> |
Lloyd Pique | 63f9dbf | 2018-06-21 13:13:07 -0700 | [diff] [blame] | 32 | #include <private/gui/SyncFeatures.h> |
Jorim Jaggi | 5b15ef6 | 2018-01-17 18:31:39 +0100 | [diff] [blame] | 33 | |
| 34 | using namespace android::hardware::configstore; |
| 35 | using namespace android::hardware::configstore::V1_0; |
| 36 | |
Jiyong Park | 00b15b8 | 2017-08-10 20:30:56 +0900 | [diff] [blame] | 37 | extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 38 | |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 39 | // --------------------------------------------------------------------------- |
| 40 | namespace android { |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 41 | namespace RE { |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 42 | // --------------------------------------------------------------------------- |
| 43 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 44 | RenderEngine::~RenderEngine() = default; |
| 45 | |
| 46 | namespace impl { |
| 47 | |
Chia-I Wu | d4d9c6f | 2017-11-09 16:55:31 -0800 | [diff] [blame] | 48 | std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featureFlags) { |
| 49 | // initialize EGL for the default display |
| 50 | EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 51 | if (!eglInitialize(display, nullptr, nullptr)) { |
Chia-I Wu | d4d9c6f | 2017-11-09 16:55:31 -0800 | [diff] [blame] | 52 | LOG_ALWAYS_FATAL("failed to initialize EGL"); |
| 53 | } |
| 54 | |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 55 | GLExtensions& extensions = GLExtensions::getInstance(); |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 56 | extensions.initWithEGLStrings(eglQueryStringImplementationANDROID(display, EGL_VERSION), |
| 57 | eglQueryStringImplementationANDROID(display, EGL_EXTENSIONS)); |
| 58 | |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 59 | // The code assumes that ES2 or later is available if this extension is |
| 60 | // supported. |
| 61 | EGLConfig config = EGL_NO_CONFIG; |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 62 | if (!extensions.hasNoConfigContext()) { |
Steven Thomas | d7f49c5 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 63 | config = chooseEglConfig(display, hwcFormat, /*logConfig*/ true); |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | EGLint renderableType = 0; |
| 67 | if (config == EGL_NO_CONFIG) { |
| 68 | renderableType = EGL_OPENGL_ES2_BIT; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 69 | } else if (!eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType)) { |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 70 | LOG_ALWAYS_FATAL("can't query EGLConfig RENDERABLE_TYPE"); |
| 71 | } |
| 72 | EGLint contextClientVersion = 0; |
Mathias Agopian | 2185f8b | 2013-09-18 16:20:26 -0700 | [diff] [blame] | 73 | if (renderableType & EGL_OPENGL_ES2_BIT) { |
| 74 | contextClientVersion = 2; |
| 75 | } else if (renderableType & EGL_OPENGL_ES_BIT) { |
| 76 | contextClientVersion = 1; |
| 77 | } else { |
| 78 | LOG_ALWAYS_FATAL("no supported EGL_RENDERABLE_TYPEs"); |
| 79 | } |
| 80 | |
Fabien Sanglard | c93afd5 | 2017-03-13 13:02:42 -0700 | [diff] [blame] | 81 | std::vector<EGLint> contextAttributes; |
| 82 | contextAttributes.reserve(6); |
| 83 | contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION); |
| 84 | contextAttributes.push_back(contextClientVersion); |
Jorim Jaggi | 5b15ef6 | 2018-01-17 18:31:39 +0100 | [diff] [blame] | 85 | bool useContextPriority = overrideUseContextPriorityFromConfig(extensions.hasContextPriority()); |
| 86 | if (useContextPriority) { |
Fabien Sanglard | c93afd5 | 2017-03-13 13:02:42 -0700 | [diff] [blame] | 87 | contextAttributes.push_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); |
| 88 | contextAttributes.push_back(EGL_CONTEXT_PRIORITY_HIGH_IMG); |
| 89 | } |
Fabien Sanglard | c93afd5 | 2017-03-13 13:02:42 -0700 | [diff] [blame] | 90 | contextAttributes.push_back(EGL_NONE); |
| 91 | |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 92 | EGLContext ctxt = eglCreateContext(display, config, nullptr, contextAttributes.data()); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 93 | |
| 94 | // if can't create a GL context, we can only abort. |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 95 | LOG_ALWAYS_FATAL_IF(ctxt == EGL_NO_CONTEXT, "EGLContext creation failed"); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 96 | |
| 97 | // now figure out what version of GL did we actually get |
| 98 | // NOTE: a dummy surface is not needed if KHR_create_context is supported |
| 99 | |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 100 | EGLConfig dummyConfig = config; |
| 101 | if (dummyConfig == EGL_NO_CONFIG) { |
Steven Thomas | d7f49c5 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 102 | dummyConfig = chooseEglConfig(display, hwcFormat, /*logConfig*/ true); |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 103 | } |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 104 | EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_NONE}; |
Jesse Hall | 19e8729 | 2013-12-23 21:02:15 -0800 | [diff] [blame] | 105 | EGLSurface dummy = eglCreatePbufferSurface(display, dummyConfig, attribs); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 106 | LOG_ALWAYS_FATAL_IF(dummy == EGL_NO_SURFACE, "can't create dummy pbuffer"); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 107 | EGLBoolean success = eglMakeCurrent(display, dummy, dummy, ctxt); |
| 108 | LOG_ALWAYS_FATAL_IF(!success, "can't make dummy pbuffer current"); |
| 109 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 110 | extensions.initWithGLStrings(glGetString(GL_VENDOR), glGetString(GL_RENDERER), |
| 111 | glGetString(GL_VERSION), glGetString(GL_EXTENSIONS)); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 112 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 113 | GlesVersion version = parseGlesVersion(extensions.getVersion()); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 114 | |
| 115 | // initialize the renderer while GL is current |
| 116 | |
Chia-I Wu | b2c7624 | 2017-11-09 17:17:07 -0800 | [diff] [blame] | 117 | std::unique_ptr<RenderEngine> engine; |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 118 | switch (version) { |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 119 | case GLES_VERSION_1_0: |
| 120 | case GLES_VERSION_1_1: |
| 121 | LOG_ALWAYS_FATAL("SurfaceFlinger requires OpenGL ES 2.0 minimum to run."); |
| 122 | break; |
| 123 | case GLES_VERSION_2_0: |
| 124 | case GLES_VERSION_3_0: |
| 125 | engine = std::make_unique<GLES20RenderEngine>(featureFlags); |
| 126 | break; |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 127 | } |
Chia-I Wu | 2b6386e | 2017-11-09 13:03:17 -0800 | [diff] [blame] | 128 | engine->setEGLHandles(display, config, ctxt); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 129 | |
| 130 | ALOGI("OpenGL ES informations:"); |
| 131 | ALOGI("vendor : %s", extensions.getVendor()); |
| 132 | ALOGI("renderer : %s", extensions.getRenderer()); |
| 133 | ALOGI("version : %s", extensions.getVersion()); |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 134 | ALOGI("extensions: %s", extensions.getExtensions()); |
Michael Lentine | 9ae79d8 | 2014-07-30 16:42:12 -0700 | [diff] [blame] | 135 | ALOGI("GL_MAX_TEXTURE_SIZE = %zu", engine->getMaxTextureSize()); |
| 136 | ALOGI("GL_MAX_VIEWPORT_DIMS = %zu", engine->getMaxViewportDims()); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 137 | |
| 138 | eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
| 139 | eglDestroySurface(display, dummy); |
| 140 | |
| 141 | return engine; |
| 142 | } |
| 143 | |
Jorim Jaggi | 5b15ef6 | 2018-01-17 18:31:39 +0100 | [diff] [blame] | 144 | bool RenderEngine::overrideUseContextPriorityFromConfig(bool useContextPriority) { |
| 145 | OptionalBool ret; |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 146 | ISurfaceFlingerConfigs::getService()->useContextPriority([&ret](OptionalBool b) { ret = b; }); |
Jorim Jaggi | 5b15ef6 | 2018-01-17 18:31:39 +0100 | [diff] [blame] | 147 | if (ret.specified) { |
| 148 | return ret.value; |
| 149 | } else { |
| 150 | return useContextPriority; |
| 151 | } |
| 152 | } |
| 153 | |
Chia-I Wu | 93e14df | 2018-06-04 10:10:17 -0700 | [diff] [blame] | 154 | RenderEngine::RenderEngine(uint32_t featureFlags) |
| 155 | : mEGLDisplay(EGL_NO_DISPLAY), |
| 156 | mEGLConfig(nullptr), |
| 157 | mEGLContext(EGL_NO_CONTEXT), |
| 158 | mFeatureFlags(featureFlags) {} |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 159 | |
| 160 | RenderEngine::~RenderEngine() { |
Chia-I Wu | b01450b | 2017-11-09 16:55:31 -0800 | [diff] [blame] | 161 | eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
| 162 | eglTerminate(mEGLDisplay); |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Chia-I Wu | 2b6386e | 2017-11-09 13:03:17 -0800 | [diff] [blame] | 165 | void RenderEngine::setEGLHandles(EGLDisplay display, EGLConfig config, EGLContext ctxt) { |
| 166 | mEGLDisplay = display; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 167 | mEGLConfig = config; |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 168 | mEGLContext = ctxt; |
| 169 | } |
| 170 | |
Chia-I Wu | 2b6386e | 2017-11-09 13:03:17 -0800 | [diff] [blame] | 171 | EGLDisplay RenderEngine::getEGLDisplay() const { |
| 172 | return mEGLDisplay; |
| 173 | } |
| 174 | |
| 175 | EGLConfig RenderEngine::getEGLConfig() const { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 176 | return mEGLConfig; |
| 177 | } |
| 178 | |
Lloyd Pique | 63f9dbf | 2018-06-21 13:13:07 -0700 | [diff] [blame] | 179 | bool RenderEngine::useNativeFenceSync() const { |
| 180 | return SyncFeatures::getInstance().useNativeFenceSync(); |
| 181 | } |
| 182 | |
| 183 | bool RenderEngine::useWaitSync() const { |
| 184 | return SyncFeatures::getInstance().useWaitSync(); |
| 185 | } |
| 186 | |
Chia-I Wu | 9f2db77 | 2017-11-30 21:06:50 -0800 | [diff] [blame] | 187 | bool RenderEngine::isCurrent() const { |
| 188 | return mEGLDisplay == eglGetCurrentDisplay() && mEGLContext == eglGetCurrentContext(); |
| 189 | } |
| 190 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 191 | std::unique_ptr<RE::Surface> RenderEngine::createSurface() { |
| 192 | return std::make_unique<Surface>(*this); |
| 193 | } |
| 194 | |
| 195 | std::unique_ptr<RE::Image> RenderEngine::createImage() { |
| 196 | return std::make_unique<Image>(*this); |
| 197 | } |
| 198 | |
| 199 | bool RenderEngine::setCurrentSurface(const android::RE::Surface& surface) { |
| 200 | // Note: RE::Surface is an abstract interface. This implementation only ever |
| 201 | // creates RE::impl::Surface's, so it is safe to just cast to the actual |
| 202 | // type. |
| 203 | return setCurrentSurface(static_cast<const android::RE::impl::Surface&>(surface)); |
| 204 | } |
| 205 | |
| 206 | bool RenderEngine::setCurrentSurface(const android::RE::impl::Surface& surface) { |
Chia-I Wu | f846a35 | 2017-11-10 09:22:52 -0800 | [diff] [blame] | 207 | bool success = true; |
| 208 | EGLSurface eglSurface = surface.getEGLSurface(); |
| 209 | if (eglSurface != eglGetCurrentSurface(EGL_DRAW)) { |
| 210 | success = eglMakeCurrent(mEGLDisplay, eglSurface, eglSurface, mEGLContext) == EGL_TRUE; |
| 211 | if (success && surface.getAsync()) { |
| 212 | eglSwapInterval(mEGLDisplay, 0); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return success; |
Chia-I Wu | 7f40290 | 2017-11-09 12:51:10 -0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | void RenderEngine::resetCurrentSurface() { |
| 220 | eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
| 221 | } |
| 222 | |
Chia-I Wu | 767fcf7 | 2017-11-30 22:07:38 -0800 | [diff] [blame] | 223 | base::unique_fd RenderEngine::flush() { |
| 224 | if (!GLExtensions::getInstance().hasNativeFenceSync()) { |
| 225 | return base::unique_fd(); |
| 226 | } |
| 227 | |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 228 | EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, nullptr); |
Chia-I Wu | 767fcf7 | 2017-11-30 22:07:38 -0800 | [diff] [blame] | 229 | if (sync == EGL_NO_SYNC_KHR) { |
| 230 | ALOGW("failed to create EGL native fence sync: %#x", eglGetError()); |
| 231 | return base::unique_fd(); |
| 232 | } |
| 233 | |
| 234 | // native fence fd will not be populated until flush() is done. |
| 235 | glFlush(); |
| 236 | |
| 237 | // get the fence fd |
| 238 | base::unique_fd fenceFd(eglDupNativeFenceFDANDROID(mEGLDisplay, sync)); |
| 239 | eglDestroySyncKHR(mEGLDisplay, sync); |
| 240 | if (fenceFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) { |
| 241 | ALOGW("failed to dup EGL native fence sync: %#x", eglGetError()); |
| 242 | } |
| 243 | |
| 244 | return fenceFd; |
| 245 | } |
| 246 | |
| 247 | bool RenderEngine::finish() { |
| 248 | if (!GLExtensions::getInstance().hasFenceSync()) { |
| 249 | ALOGW("no synchronization support"); |
| 250 | return false; |
| 251 | } |
| 252 | |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 253 | EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, nullptr); |
Chia-I Wu | 767fcf7 | 2017-11-30 22:07:38 -0800 | [diff] [blame] | 254 | if (sync == EGL_NO_SYNC_KHR) { |
| 255 | ALOGW("failed to create EGL fence sync: %#x", eglGetError()); |
| 256 | return false; |
| 257 | } |
| 258 | |
| 259 | EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, |
| 260 | 2000000000 /*2 sec*/); |
| 261 | EGLint error = eglGetError(); |
| 262 | eglDestroySyncKHR(mEGLDisplay, sync); |
| 263 | if (result != EGL_CONDITION_SATISFIED_KHR) { |
| 264 | if (result == EGL_TIMEOUT_EXPIRED_KHR) { |
| 265 | ALOGW("fence wait timed out"); |
| 266 | } else { |
| 267 | ALOGW("error waiting on EGL fence: %#x", error); |
| 268 | } |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | return true; |
| 273 | } |
| 274 | |
| 275 | bool RenderEngine::waitFence(base::unique_fd fenceFd) { |
| 276 | if (!GLExtensions::getInstance().hasNativeFenceSync() || |
| 277 | !GLExtensions::getInstance().hasWaitSync()) { |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fenceFd, EGL_NONE}; |
| 282 | EGLSyncKHR sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs); |
| 283 | if (sync == EGL_NO_SYNC_KHR) { |
| 284 | ALOGE("failed to create EGL native fence sync: %#x", eglGetError()); |
| 285 | return false; |
| 286 | } |
| 287 | |
| 288 | // fenceFd is now owned by EGLSync |
| 289 | (void)fenceFd.release(); |
| 290 | |
| 291 | // XXX: The spec draft is inconsistent as to whether this should return an |
| 292 | // EGLint or void. Ignore the return value for now, as it's not strictly |
| 293 | // needed. |
| 294 | eglWaitSyncKHR(mEGLDisplay, sync, 0); |
| 295 | EGLint error = eglGetError(); |
| 296 | eglDestroySyncKHR(mEGLDisplay, sync); |
| 297 | if (error != EGL_SUCCESS) { |
| 298 | ALOGE("failed to wait for EGL native fence sync: %#x", error); |
| 299 | return false; |
| 300 | } |
| 301 | |
| 302 | return true; |
| 303 | } |
| 304 | |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 305 | void RenderEngine::checkErrors() const { |
| 306 | do { |
| 307 | // there could be more than one error flag |
| 308 | GLenum error = glGetError(); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 309 | if (error == GL_NO_ERROR) break; |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 310 | ALOGE("GL error 0x%04x", int(error)); |
| 311 | } while (true); |
| 312 | } |
| 313 | |
| 314 | RenderEngine::GlesVersion RenderEngine::parseGlesVersion(const char* str) { |
| 315 | int major, minor; |
| 316 | if (sscanf(str, "OpenGL ES-CM %d.%d", &major, &minor) != 2) { |
| 317 | if (sscanf(str, "OpenGL ES %d.%d", &major, &minor) != 2) { |
| 318 | ALOGW("Unable to parse GL_VERSION string: \"%s\"", str); |
| 319 | return GLES_VERSION_1_0; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | if (major == 1 && minor == 0) return GLES_VERSION_1_0; |
| 324 | if (major == 1 && minor >= 1) return GLES_VERSION_1_1; |
| 325 | if (major == 2 && minor >= 0) return GLES_VERSION_2_0; |
| 326 | if (major == 3 && minor >= 0) return GLES_VERSION_3_0; |
| 327 | |
| 328 | ALOGW("Unrecognized OpenGL ES version: %d.%d", major, minor); |
| 329 | return GLES_VERSION_1_0; |
| 330 | } |
| 331 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 332 | void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height, float red, |
| 333 | float green, float blue, float alpha) { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 334 | size_t c; |
| 335 | Rect const* r = region.getArray(&c); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 336 | Mesh mesh(Mesh::TRIANGLES, c * 6, 2); |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 337 | Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>()); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 338 | for (size_t i = 0; i < c; i++, r++) { |
| 339 | position[i * 6 + 0].x = r->left; |
| 340 | position[i * 6 + 0].y = height - r->top; |
| 341 | position[i * 6 + 1].x = r->left; |
| 342 | position[i * 6 + 1].y = height - r->bottom; |
| 343 | position[i * 6 + 2].x = r->right; |
| 344 | position[i * 6 + 2].y = height - r->bottom; |
| 345 | position[i * 6 + 3].x = r->left; |
| 346 | position[i * 6 + 3].y = height - r->top; |
| 347 | position[i * 6 + 4].x = r->right; |
| 348 | position[i * 6 + 4].y = height - r->bottom; |
| 349 | position[i * 6 + 5].x = r->right; |
| 350 | position[i * 6 + 5].y = height - r->top; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 351 | } |
Mathias Agopian | 19733a3 | 2013-08-28 18:13:56 -0700 | [diff] [blame] | 352 | setupFillWithColor(red, green, blue, alpha); |
| 353 | drawMesh(mesh); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | void RenderEngine::clearWithColor(float red, float green, float blue, float alpha) { |
| 357 | glClearColor(red, green, blue, alpha); |
| 358 | glClear(GL_COLOR_BUFFER_BIT); |
| 359 | } |
| 360 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 361 | void RenderEngine::setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 362 | glScissor(left, bottom, right, top); |
| 363 | glEnable(GL_SCISSOR_TEST); |
| 364 | } |
| 365 | |
| 366 | void RenderEngine::disableScissor() { |
| 367 | glDisable(GL_SCISSOR_TEST); |
| 368 | } |
| 369 | |
| 370 | void RenderEngine::genTextures(size_t count, uint32_t* names) { |
| 371 | glGenTextures(count, names); |
| 372 | } |
| 373 | |
| 374 | void RenderEngine::deleteTextures(size_t count, uint32_t const* names) { |
| 375 | glDeleteTextures(count, names); |
| 376 | } |
| 377 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 378 | void RenderEngine::bindExternalTextureImage(uint32_t texName, const android::RE::Image& image) { |
| 379 | // Note: RE::Image is an abstract interface. This implementation only ever |
| 380 | // creates RE::impl::Image's, so it is safe to just cast to the actual type. |
| 381 | return bindExternalTextureImage(texName, static_cast<const android::RE::impl::Image&>(image)); |
| 382 | } |
| 383 | |
| 384 | void RenderEngine::bindExternalTextureImage(uint32_t texName, |
| 385 | const android::RE::impl::Image& image) { |
Chia-I Wu | 401ef83 | 2017-12-01 10:52:22 -0800 | [diff] [blame] | 386 | const GLenum target = GL_TEXTURE_EXTERNAL_OES; |
| 387 | |
| 388 | glBindTexture(target, texName); |
| 389 | if (image.getEGLImage() != EGL_NO_IMAGE_KHR) { |
| 390 | glEGLImageTargetTexture2DOES(target, static_cast<GLeglImageOES>(image.getEGLImage())); |
| 391 | } |
| 392 | } |
| 393 | |
Mathias Agopian | d555684 | 2013-09-19 17:08:37 -0700 | [diff] [blame] | 394 | void RenderEngine::readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels) { |
| 395 | glReadPixels(l, b, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 396 | } |
| 397 | |
Mathias Agopian | 458197d | 2013-08-15 14:56:51 -0700 | [diff] [blame] | 398 | void RenderEngine::dump(String8& result) { |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 399 | const GLExtensions& extensions = GLExtensions::getInstance(); |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 400 | |
| 401 | result.appendFormat("EGL implementation : %s\n", extensions.getEGLVersion()); |
| 402 | result.appendFormat("%s\n", extensions.getEGLExtensions()); |
| 403 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 404 | result.appendFormat("GLES: %s, %s, %s\n", extensions.getVendor(), extensions.getRenderer(), |
| 405 | extensions.getVersion()); |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 406 | result.appendFormat("%s\n", extensions.getExtensions()); |
Mathias Agopian | 458197d | 2013-08-15 14:56:51 -0700 | [diff] [blame] | 407 | } |
| 408 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 409 | // --------------------------------------------------------------------------- |
| 410 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 411 | void RenderEngine::bindNativeBufferAsFrameBuffer(ANativeWindowBuffer* buffer, |
| 412 | RE::BindNativeBufferAsFramebuffer* bindHelper) { |
| 413 | bindHelper->mImage = eglCreateImageKHR(mEGLDisplay, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, |
| 414 | buffer, nullptr); |
| 415 | if (bindHelper->mImage == EGL_NO_IMAGE_KHR) { |
| 416 | bindHelper->mStatus = NO_MEMORY; |
Chia-I Wu | eadbaa6 | 2017-11-09 11:26:15 -0800 | [diff] [blame] | 417 | return; |
| 418 | } |
| 419 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 420 | uint32_t glStatus; |
| 421 | bindImageAsFramebuffer(bindHelper->mImage, &bindHelper->mTexName, &bindHelper->mFbName, |
| 422 | &glStatus); |
Mathias Agopian | 458197d | 2013-08-15 14:56:51 -0700 | [diff] [blame] | 423 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 424 | ALOGE_IF(glStatus != GL_FRAMEBUFFER_COMPLETE_OES, "glCheckFramebufferStatusOES error %d", |
| 425 | glStatus); |
| 426 | |
| 427 | bindHelper->mStatus = glStatus == GL_FRAMEBUFFER_COMPLETE_OES ? NO_ERROR : BAD_VALUE; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 430 | void RenderEngine::unbindNativeBufferAsFrameBuffer(RE::BindNativeBufferAsFramebuffer* bindHelper) { |
| 431 | if (bindHelper->mImage == EGL_NO_IMAGE_KHR) { |
Chia-I Wu | eadbaa6 | 2017-11-09 11:26:15 -0800 | [diff] [blame] | 432 | return; |
| 433 | } |
| 434 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 435 | // back to main framebuffer |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 436 | unbindFramebuffer(bindHelper->mTexName, bindHelper->mFbName); |
| 437 | eglDestroyImageKHR(mEGLDisplay, bindHelper->mImage); |
Dan Stoza | a277ccb | 2018-05-31 15:28:00 -0700 | [diff] [blame] | 438 | |
| 439 | // Workaround for b/77935566 to force the EGL driver to release the |
| 440 | // screenshot buffer |
| 441 | setScissor(0, 0, 0, 0); |
| 442 | clearWithColor(0.0, 0.0, 0.0, 0.0); |
| 443 | disableScissor(); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 446 | // --------------------------------------------------------------------------- |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 447 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 448 | static status_t selectConfigForAttribute(EGLDisplay dpy, EGLint const* attrs, EGLint attribute, |
| 449 | EGLint wanted, EGLConfig* outConfig) { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 450 | EGLint numConfigs = -1, n = 0; |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 451 | eglGetConfigs(dpy, nullptr, 0, &numConfigs); |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 452 | EGLConfig* const configs = new EGLConfig[numConfigs]; |
| 453 | eglChooseConfig(dpy, attrs, configs, numConfigs, &n); |
| 454 | |
| 455 | if (n) { |
| 456 | if (attribute != EGL_NONE) { |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 457 | for (int i = 0; i < n; i++) { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 458 | EGLint value = 0; |
| 459 | eglGetConfigAttrib(dpy, configs[i], attribute, &value); |
| 460 | if (wanted == value) { |
| 461 | *outConfig = configs[i]; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 462 | delete[] configs; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 463 | return NO_ERROR; |
| 464 | } |
| 465 | } |
| 466 | } else { |
| 467 | // just pick the first one |
| 468 | *outConfig = configs[0]; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 469 | delete[] configs; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 470 | return NO_ERROR; |
| 471 | } |
| 472 | } |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 473 | delete[] configs; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 474 | return NAME_NOT_FOUND; |
| 475 | } |
| 476 | |
| 477 | class EGLAttributeVector { |
| 478 | struct Attribute; |
| 479 | class Adder; |
| 480 | friend class Adder; |
| 481 | KeyedVector<Attribute, EGLint> mList; |
| 482 | struct Attribute { |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 483 | Attribute() : v(0){}; |
| 484 | explicit Attribute(EGLint v) : v(v) {} |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 485 | EGLint v; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 486 | bool operator<(const Attribute& other) const { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 487 | // this places EGL_NONE at the end |
| 488 | EGLint lhs(v); |
| 489 | EGLint rhs(other.v); |
| 490 | if (lhs == EGL_NONE) lhs = 0x7FFFFFFF; |
| 491 | if (rhs == EGL_NONE) rhs = 0x7FFFFFFF; |
| 492 | return lhs < rhs; |
| 493 | } |
| 494 | }; |
| 495 | class Adder { |
| 496 | friend class EGLAttributeVector; |
| 497 | EGLAttributeVector& v; |
| 498 | EGLint attribute; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 499 | Adder(EGLAttributeVector& v, EGLint attribute) : v(v), attribute(attribute) {} |
| 500 | |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 501 | public: |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 502 | void operator=(EGLint value) { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 503 | if (attribute != EGL_NONE) { |
Chih-Hung Hsieh | c406791 | 2016-05-03 14:03:27 -0700 | [diff] [blame] | 504 | v.mList.add(Attribute(attribute), value); |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 505 | } |
| 506 | } |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 507 | operator EGLint() const { return v.mList[attribute]; } |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 508 | }; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 509 | |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 510 | public: |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 511 | EGLAttributeVector() { mList.add(Attribute(EGL_NONE), EGL_NONE); } |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 512 | void remove(EGLint attribute) { |
| 513 | if (attribute != EGL_NONE) { |
Chih-Hung Hsieh | c406791 | 2016-05-03 14:03:27 -0700 | [diff] [blame] | 514 | mList.removeItem(Attribute(attribute)); |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 515 | } |
| 516 | } |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 517 | Adder operator[](EGLint attribute) { return Adder(*this, attribute); } |
| 518 | EGLint operator[](EGLint attribute) const { return mList[attribute]; } |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 519 | // cast-operator to (EGLint const*) |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 520 | operator EGLint const*() const { return &mList.keyAt(0).v; } |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 521 | }; |
| 522 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 523 | static status_t selectEGLConfig(EGLDisplay display, EGLint format, EGLint renderableType, |
| 524 | EGLConfig* config) { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 525 | // select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if |
| 526 | // it is to be used with WIFI displays |
| 527 | status_t err; |
| 528 | EGLint wantedAttribute; |
| 529 | EGLint wantedAttributeValue; |
| 530 | |
| 531 | EGLAttributeVector attribs; |
| 532 | if (renderableType) { |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 533 | attribs[EGL_RENDERABLE_TYPE] = renderableType; |
| 534 | attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE; |
| 535 | attribs[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 536 | attribs[EGL_FRAMEBUFFER_TARGET_ANDROID] = EGL_TRUE; |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 537 | attribs[EGL_RED_SIZE] = 8; |
| 538 | attribs[EGL_GREEN_SIZE] = 8; |
| 539 | attribs[EGL_BLUE_SIZE] = 8; |
| 540 | attribs[EGL_ALPHA_SIZE] = 8; |
| 541 | wantedAttribute = EGL_NONE; |
| 542 | wantedAttributeValue = EGL_NONE; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 543 | } else { |
| 544 | // if no renderable type specified, fallback to a simplified query |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 545 | wantedAttribute = EGL_NATIVE_VISUAL_ID; |
| 546 | wantedAttributeValue = format; |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 547 | } |
| 548 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 549 | err = selectConfigForAttribute(display, attribs, wantedAttribute, wantedAttributeValue, config); |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 550 | if (err == NO_ERROR) { |
| 551 | EGLint caveat; |
| 552 | if (eglGetConfigAttrib(display, *config, EGL_CONFIG_CAVEAT, &caveat)) |
| 553 | ALOGW_IF(caveat == EGL_SLOW_CONFIG, "EGL_SLOW_CONFIG selected!"); |
| 554 | } |
| 555 | |
| 556 | return err; |
| 557 | } |
| 558 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 559 | EGLConfig RenderEngine::chooseEglConfig(EGLDisplay display, int format, bool logConfig) { |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 560 | status_t err; |
| 561 | EGLConfig config; |
| 562 | |
| 563 | // First try to get an ES2 config |
| 564 | err = selectEGLConfig(display, format, EGL_OPENGL_ES2_BIT, &config); |
| 565 | if (err != NO_ERROR) { |
| 566 | // If ES2 fails, try ES1 |
| 567 | err = selectEGLConfig(display, format, EGL_OPENGL_ES_BIT, &config); |
| 568 | if (err != NO_ERROR) { |
| 569 | // still didn't work, probably because we're on the emulator... |
| 570 | // try a simplified query |
| 571 | ALOGW("no suitable EGLConfig found, trying a simpler query"); |
| 572 | err = selectEGLConfig(display, format, 0, &config); |
| 573 | if (err != NO_ERROR) { |
| 574 | // this EGL is too lame for android |
| 575 | LOG_ALWAYS_FATAL("no suitable EGLConfig found, giving up"); |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | |
Steven Thomas | d7f49c5 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 580 | if (logConfig) { |
| 581 | // print some debugging info |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 582 | EGLint r, g, b, a; |
| 583 | eglGetConfigAttrib(display, config, EGL_RED_SIZE, &r); |
Steven Thomas | d7f49c5 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 584 | eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &g); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 585 | eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &b); |
Steven Thomas | d7f49c5 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 586 | eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &a); |
| 587 | ALOGI("EGL information:"); |
| 588 | ALOGI("vendor : %s", eglQueryString(display, EGL_VENDOR)); |
| 589 | ALOGI("version : %s", eglQueryString(display, EGL_VERSION)); |
| 590 | ALOGI("extensions: %s", eglQueryString(display, EGL_EXTENSIONS)); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 591 | ALOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS) ?: "Not Supported"); |
Steven Thomas | d7f49c5 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 592 | ALOGI("EGLSurface: %d-%d-%d-%d, config=%p", r, g, b, a, config); |
| 593 | } |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 594 | |
| 595 | return config; |
| 596 | } |
| 597 | |
Dan Stoza | 4e63777 | 2016-07-28 13:31:51 -0700 | [diff] [blame] | 598 | void RenderEngine::primeCache() const { |
Peiyong Lin | 13effd1 | 2018-07-24 17:01:47 -0700 | [diff] [blame^] | 599 | ProgramCache::getInstance().primeCache(mFeatureFlags & USE_COLOR_MANAGEMENT); |
Dan Stoza | 4e63777 | 2016-07-28 13:31:51 -0700 | [diff] [blame] | 600 | } |
| 601 | |
Jesse Hall | 05f8c70 | 2013-12-23 20:44:38 -0800 | [diff] [blame] | 602 | // --------------------------------------------------------------------------- |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 603 | |
| 604 | } // namespace impl |
| 605 | } // namespace RE |
| 606 | } // namespace android |