Commit 393c44f1 by Geoff Lang Committed by Commit Bot

EGL: Trim requested config parameters to EGL.

ANGLE requests a config with several uneccessary parameters. I suspect these parameters are causing issues in the wild where eglChooseConfig fails. Try requesting ES3 then fall back to ES2 configs. Skip config caveats, floating point configs and multisample configs, we provided the default parameters. The resulting config is very similiar to the one Chrome requests in gl_surface_egl.cc Bug: chromium:1173161 Change-Id: Ifa78ff8081e3d86e823036981e1e2b5f8f751fed Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2665888 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarPeng Huang <penghuang@chromium.org>
parent 6bfb64ae
...@@ -501,12 +501,12 @@ egl::ConfigSet DisplayEGL::generateConfigs() ...@@ -501,12 +501,12 @@ egl::ConfigSet DisplayEGL::generateConfigs()
{ {
ERR() << "RGBA(" << config.redSize << "," << config.greenSize << "," ERR() << "RGBA(" << config.redSize << "," << config.greenSize << ","
<< config.blueSize << "," << config.alphaSize << ") not handled"; << config.blueSize << "," << config.alphaSize << ") not handled";
UNREACHABLE(); continue;
} }
} }
else else
{ {
UNREACHABLE(); continue;
} }
if (config.depthSize == 0 && config.stencilSize == 0) if (config.depthSize == 0 && config.stencilSize == 0)
...@@ -531,7 +531,7 @@ egl::ConfigSet DisplayEGL::generateConfigs() ...@@ -531,7 +531,7 @@ egl::ConfigSet DisplayEGL::generateConfigs()
} }
else else
{ {
UNREACHABLE(); continue;
} }
config.matchNativePixmap = EGL_NONE; config.matchNativePixmap = EGL_NONE;
......
...@@ -65,61 +65,48 @@ egl::Error DisplayAndroid::initialize(egl::Display *display) ...@@ -65,61 +65,48 @@ egl::Error DisplayAndroid::initialize(egl::Display *display)
gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion); gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion);
ASSERT(eglVersion >= gl::Version(1, 4)); ASSERT(eglVersion >= gl::Version(1, 4));
std::vector<EGLint> renderableTypes;
static_assert(EGL_OPENGL_ES3_BIT == EGL_OPENGL_ES3_BIT_KHR, "Extension define must match core"); static_assert(EGL_OPENGL_ES3_BIT == EGL_OPENGL_ES3_BIT_KHR, "Extension define must match core");
EGLint esBit = (eglVersion >= gl::Version(1, 5) || mEGL->hasExtension("EGL_KHR_create_context")) if (eglVersion >= gl::Version(1, 5) || mEGL->hasExtension("EGL_KHR_create_context"))
? EGL_OPENGL_ES3_BIT
: EGL_OPENGL_ES2_BIT;
// clang-format off
std::vector<EGLint> configAttribListBase =
{ {
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER, renderableTypes.push_back(EGL_OPENGL_ES3_BIT);
}
renderableTypes.push_back(EGL_OPENGL_ES2_BIT);
egl::AttributeMap baseConfigAttribs;
baseConfigAttribs.insert(EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
// Android doesn't support pixmaps // Android doesn't support pixmaps
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, baseConfigAttribs.insert(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT);
EGL_CONFIG_CAVEAT, EGL_NONE,
EGL_CONFORMANT, esBit,
EGL_RENDERABLE_TYPE, esBit,
};
// clang-format on
if (mEGL->hasExtension("EGL_EXT_pixel_format_float")) egl::AttributeMap configAttribsWithFormat(baseConfigAttribs);
{ // Choose RGBA8888
// Don't request floating point configs configAttribsWithFormat.insert(EGL_RED_SIZE, 8);
configAttribListBase.push_back(EGL_COLOR_COMPONENT_TYPE_EXT); configAttribsWithFormat.insert(EGL_GREEN_SIZE, 8);
configAttribListBase.push_back(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT); configAttribsWithFormat.insert(EGL_BLUE_SIZE, 8);
} configAttribsWithFormat.insert(EGL_ALPHA_SIZE, 8);
std::vector<EGLint> configAttribListWithFormat = configAttribListBase; // Choose D24S8
// EGL1.5 spec Section 2.2 says that depth, multisample and stencil buffer depths // EGL1.5 spec Section 2.2 says that depth, multisample and stencil buffer depths
// must match for contexts to be compatible. // must match for contexts to be compatible.
// Choose RGBA8888 configAttribsWithFormat.insert(EGL_DEPTH_SIZE, 24);
configAttribListWithFormat.push_back(EGL_RED_SIZE); configAttribsWithFormat.insert(EGL_STENCIL_SIZE, 8);
configAttribListWithFormat.push_back(8);
configAttribListWithFormat.push_back(EGL_GREEN_SIZE); EGLConfig configWithFormat = EGL_NO_CONFIG_KHR;
configAttribListWithFormat.push_back(8); for (EGLint renderableType : renderableTypes)
configAttribListWithFormat.push_back(EGL_BLUE_SIZE); {
configAttribListWithFormat.push_back(8); baseConfigAttribs.insert(EGL_RENDERABLE_TYPE, renderableType);
configAttribListWithFormat.push_back(EGL_ALPHA_SIZE); configAttribsWithFormat.insert(EGL_RENDERABLE_TYPE, renderableType);
configAttribListWithFormat.push_back(8);
// Choose DEPTH24_STENCIL8 std::vector<EGLint> attribVector = configAttribsWithFormat.toIntVector();
configAttribListWithFormat.push_back(EGL_DEPTH_SIZE);
configAttribListWithFormat.push_back(24); EGLint numConfig = 0;
configAttribListWithFormat.push_back(EGL_STENCIL_SIZE); if (mEGL->chooseConfig(attribVector.data(), &configWithFormat, 1, &numConfig) == EGL_TRUE)
configAttribListWithFormat.push_back(8); {
// Choose no multisampling break;
configAttribListWithFormat.push_back(EGL_SAMPLE_BUFFERS); }
configAttribListWithFormat.push_back(0); }
// Complete the attrib lists if (configWithFormat == EGL_NO_CONFIG_KHR)
configAttribListBase.push_back(EGL_NONE);
configAttribListWithFormat.push_back(EGL_NONE);
EGLint numConfig;
EGLConfig configWithFormat;
EGLBoolean success =
mEGL->chooseConfig(configAttribListWithFormat.data(), &configWithFormat, 1, &numConfig);
if (success == EGL_FALSE)
{ {
return egl::EglNotInitialized() return egl::EglNotInitialized()
<< "eglChooseConfig failed with " << egl::Error(mEGL->getError()); << "eglChooseConfig failed with " << egl::Error(mEGL->getError());
...@@ -143,12 +130,12 @@ egl::Error DisplayAndroid::initialize(egl::Display *display) ...@@ -143,12 +130,12 @@ egl::Error DisplayAndroid::initialize(egl::Display *display)
// Create mMockPbuffer with a normal config, but create a no_config mContext, if possible // Create mMockPbuffer with a normal config, but create a no_config mContext, if possible
if (mEGL->hasExtension("EGL_KHR_no_config_context")) if (mEGL->hasExtension("EGL_KHR_no_config_context"))
{ {
mConfigAttribList = configAttribListBase; mConfigAttribList = baseConfigAttribs.toIntVector();
mConfig = EGL_NO_CONFIG_KHR; mConfig = EGL_NO_CONFIG_KHR;
} }
else else
{ {
mConfigAttribList = configAttribListWithFormat; mConfigAttribList = configAttribsWithFormat.toIntVector();
mConfig = configWithFormat; mConfig = configWithFormat;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment