Commit e7e072ef by Yuly Novikov Committed by Commit Bot

Use EGL_KHR_no_config_context in Android GLES backend, when available

Create ANGLE's real context with EGL_NO_CONFIG_KHR. This allows ANGLE to advertise EGLConfigs which previously were hidden due to incompatibility with ANGLE's context. Also enable EGLContextCompatibilityTest on ES2_OPENGLES to test this. BUG=angleproject:2468 Change-Id: I6fbbe01b4b93db7df39606980f0f58eb74b11e31 Reviewed-on: https://chromium-review.googlesource.com/1022088Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent aecfa71b
...@@ -56,58 +56,84 @@ egl::Error DisplayAndroid::initialize(egl::Display *display) ...@@ -56,58 +56,84 @@ egl::Error DisplayAndroid::initialize(egl::Display *display)
: EGL_OPENGL_ES2_BIT; : EGL_OPENGL_ES2_BIT;
// clang-format off // clang-format off
mConfigAttribList = std::vector<EGLint> configAttribListBase =
{ {
// Choose RGBA8888
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
// EGL1.5 spec Section 2.2 says that depth, multisample and stencil buffer depths
// must match for contexts to be compatible.
EGL_DEPTH_SIZE, 24,
EGL_STENCIL_SIZE, 8,
EGL_SAMPLE_BUFFERS, 0,
// Android doesn't support pixmaps // Android doesn't support pixmaps
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
EGL_CONFIG_CAVEAT, EGL_NONE, EGL_CONFIG_CAVEAT, EGL_NONE,
EGL_CONFORMANT, esBit, EGL_CONFORMANT, esBit,
EGL_RENDERABLE_TYPE, esBit, EGL_RENDERABLE_TYPE, esBit,
}; };
// clang-format on
if (mEGL->hasExtension("EGL_EXT_pixel_format_float")) if (mEGL->hasExtension("EGL_EXT_pixel_format_float"))
{ {
// Don't request floating point configs // Don't request floating point configs
mConfigAttribList.push_back(EGL_COLOR_COMPONENT_TYPE_EXT); configAttribListBase.push_back(EGL_COLOR_COMPONENT_TYPE_EXT);
mConfigAttribList.push_back(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT); configAttribListBase.push_back(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT);
} }
// Complete the attrib list std::vector<EGLint> configAttribListWithFormat = configAttribListBase;
mConfigAttribList.push_back(EGL_NONE); // EGL1.5 spec Section 2.2 says that depth, multisample and stencil buffer depths
// must match for contexts to be compatible.
// Choose RGBA8888
configAttribListWithFormat.push_back(EGL_RED_SIZE);
configAttribListWithFormat.push_back(8);
configAttribListWithFormat.push_back(EGL_GREEN_SIZE);
configAttribListWithFormat.push_back(8);
configAttribListWithFormat.push_back(EGL_BLUE_SIZE);
configAttribListWithFormat.push_back(8);
configAttribListWithFormat.push_back(EGL_ALPHA_SIZE);
configAttribListWithFormat.push_back(8);
// Choose DEPTH24_STENCIL8
configAttribListWithFormat.push_back(EGL_DEPTH_SIZE);
configAttribListWithFormat.push_back(24);
configAttribListWithFormat.push_back(EGL_STENCIL_SIZE);
configAttribListWithFormat.push_back(8);
// Choose no multisampling
configAttribListWithFormat.push_back(EGL_SAMPLE_BUFFERS);
configAttribListWithFormat.push_back(0);
// Complete the attrib lists
configAttribListBase.push_back(EGL_NONE);
configAttribListWithFormat.push_back(EGL_NONE);
// clang-format on
EGLint numConfig; EGLint numConfig;
EGLConfig configWithFormat;
EGLBoolean success = mEGL->chooseConfig(mConfigAttribList.data(), &mConfig, 1, &numConfig); EGLBoolean success =
mEGL->chooseConfig(configAttribListWithFormat.data(), &configWithFormat, 1, &numConfig);
if (success == EGL_FALSE) if (success == EGL_FALSE)
{ {
return egl::EglNotInitialized() return egl::EglNotInitialized()
<< "eglChooseConfig failed with " << egl::Error(mEGL->getError()); << "eglChooseConfig failed with " << egl::Error(mEGL->getError());
} }
ANGLE_TRY(initializeContext(display->getAttributeMap()));
int dummyPbufferAttribs[] = { int dummyPbufferAttribs[] = {
EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE,
}; };
mDummyPbuffer = mEGL->createPbufferSurface(mConfig, dummyPbufferAttribs); mDummyPbuffer = mEGL->createPbufferSurface(configWithFormat, dummyPbufferAttribs);
if (mDummyPbuffer == EGL_NO_SURFACE) if (mDummyPbuffer == EGL_NO_SURFACE)
{ {
return egl::EglNotInitialized() return egl::EglNotInitialized()
<< "eglCreatePbufferSurface failed with " << egl::Error(mEGL->getError()); << "eglCreatePbufferSurface failed with " << egl::Error(mEGL->getError());
} }
// Create mDummyPbuffer with a normal config, but create a no_config mContext, if possible
if (mEGL->hasExtension("EGL_KHR_no_config_context"))
{
mConfigAttribList = configAttribListBase;
mConfig = EGL_NO_CONFIG_KHR;
}
else
{
mConfigAttribList = configAttribListWithFormat;
mConfig = configWithFormat;
}
ANGLE_TRY(initializeContext(display->getAttributeMap()));
success = mEGL->makeCurrent(mDummyPbuffer, mContext); success = mEGL->makeCurrent(mDummyPbuffer, mContext);
if (success == EGL_FALSE) if (success == EGL_FALSE)
{ {
...@@ -316,8 +342,20 @@ egl::ConfigSet DisplayAndroid::generateConfigs() ...@@ -316,8 +342,20 @@ egl::ConfigSet DisplayAndroid::generateConfigs()
{ {
config.renderTargetFormat = GL_RGB565; config.renderTargetFormat = GL_RGB565;
} }
else if (config.redSize == 5 && config.greenSize == 5 && config.blueSize == 5 &&
config.alphaSize == 1)
{
config.renderTargetFormat = GL_RGB5_A1;
}
else if (config.redSize == 4 && config.greenSize == 4 && config.blueSize == 4 &&
config.alphaSize == 4)
{
config.renderTargetFormat = GL_RGBA4;
}
else else
{ {
ERR() << "RGBA(" << config.redSize << "," << config.greenSize << ","
<< config.blueSize << "," << config.alphaSize << ") not handled";
UNREACHABLE(); UNREACHABLE();
} }
} }
......
...@@ -361,5 +361,9 @@ TEST_P(EGLContextCompatibilityTest, PbufferDifferentConfig) ...@@ -361,5 +361,9 @@ TEST_P(EGLContextCompatibilityTest, PbufferDifferentConfig)
// scales with the square of the number of configs exposed and can time out in some debug builds. // scales with the square of the number of configs exposed and can time out in some debug builds.
// http://anglebug.com/2121 // http://anglebug.com/2121
#if defined(NDEBUG) #if defined(NDEBUG)
ANGLE_INSTANTIATE_TEST(EGLContextCompatibilityTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL()); ANGLE_INSTANTIATE_TEST(EGLContextCompatibilityTest,
ES2_D3D9(),
ES2_D3D11(),
ES2_OPENGL(),
ES2_OPENGLES());
#endif #endif
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