Commit f359cb66 by Jiajia Qin Committed by Commit Bot

Reland: Refactor DisplayGbm::generateConfigs

We should explicitly set EGL_SURFACE_TYPE to EGL_DONT_CARE. Otherwise, it's default value is EGL_WINDOW_BIT. However, on some platforms, only EGL_PBUFFER_BIT is supported. In this case, no matching config is found. So mWindowSurface and mPbufferSurface will be nullptr. That's why we see the bot failed. Bug: chromium:1105208 Change-Id: I8ee2487fd24bab86a5ec22fbe7b8ff68081bc15c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2304429 Commit-Queue: Jiajia Qin <jiajia.qin@intel.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 074bc23f
......@@ -922,26 +922,48 @@ egl::Error DisplayGbm::makeCurrent(egl::Surface *drawSurface,
return DisplayGL::makeCurrent(drawSurface, readSurface, context);
}
bool DisplayGbm::validateEglConfig(const EGLint *configAttribs)
{
EGLint numConfigs;
if (!mEGL->chooseConfig(configAttribs, NULL, 0, &numConfigs))
{
ERR() << "eglChooseConfig failed with error " << egl::Error(mEGL->getError());
return false;
}
if (numConfigs == 0)
{
return false;
}
return true;
}
egl::ConfigSet DisplayGbm::generateConfigs()
{
egl::ConfigSet configs;
egl::Config config;
config.bufferSize = 32;
config.redSize = 8;
config.greenSize = 8;
config.blueSize = 8;
config.alphaSize = 8;
config.depthSize = 24;
config.stencilSize = 8;
config.bindToTextureRGBA = EGL_TRUE;
config.renderableType = EGL_OPENGL_ES2_BIT;
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
config.renderTargetFormat = GL_RGBA8;
config.depthStencilFormat = GL_DEPTH24_STENCIL8;
configs.add(config);
return configs;
// clang-format off
std::vector<EGLint> configAttribs8888 =
{
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
EGL_SURFACE_TYPE, EGL_DONT_CARE,
EGL_CONFIG_CAVEAT, EGL_NONE,
EGL_CONFORMANT, EGL_DONT_CARE,
EGL_RENDERABLE_TYPE, EGL_DONT_CARE,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_BUFFER_SIZE, 32,
EGL_DEPTH_SIZE, 24,
EGL_NONE
};
// clang-format on
if (!validateEglConfig(configAttribs8888.data()))
{
ERR() << "No suitable EGL configs found.";
return egl::ConfigSet();
}
mConfigAttribList = configAttribs8888;
return DisplayEGL::generateConfigs();
}
bool DisplayGbm::isValidNativeWindow(EGLNativeWindowType window) const
......
......@@ -148,6 +148,7 @@ class DisplayGbm final : public DisplayEGL
unsigned int tv_usec,
void *data);
void pageFlipHandler(unsigned int sequence, uint64_t tv);
bool validateEglConfig(const EGLint *configAttribs);
gbm_device *mGBM;
drmModeConnectorPtr mConnector;
......
......@@ -180,6 +180,8 @@ class EGLSurfaceTest : public ANGLETest
EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS,
0,
EGL_SURFACE_TYPE,
EGL_DONT_CARE,
EGL_NONE};
EGLint configCount;
......@@ -427,6 +429,7 @@ TEST_P(EGLSurfaceTest, ResizeWindow)
initializeDisplay();
initializeSurfaceWithDefaultConfig();
initializeContext();
ANGLE_SKIP_TEST_IF(!mWindowSurface);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
eglSwapBuffers(mDisplay, mWindowSurface);
......@@ -477,6 +480,7 @@ TEST_P(EGLSurfaceTest, ResizeWindowWithDraw)
initializeDisplay();
initializeSurfaceWithDefaultConfig();
initializeContext();
ANGLE_SKIP_TEST_IF(!mWindowSurface);
int size = 64;
EGLint height = 0;
......@@ -566,6 +570,7 @@ TEST_P(EGLSurfaceTest, ResetNativeWindow)
initializeSurfaceWithDefaultConfig();
initializeContext();
ANGLE_SKIP_TEST_IF(!mWindowSurface);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
......
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