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, ...@@ -922,26 +922,48 @@ egl::Error DisplayGbm::makeCurrent(egl::Surface *drawSurface,
return DisplayGL::makeCurrent(drawSurface, readSurface, context); 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 DisplayGbm::generateConfigs()
{ {
egl::ConfigSet configs; // clang-format off
std::vector<EGLint> configAttribs8888 =
egl::Config config; {
config.bufferSize = 32; EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
config.redSize = 8; EGL_SURFACE_TYPE, EGL_DONT_CARE,
config.greenSize = 8; EGL_CONFIG_CAVEAT, EGL_NONE,
config.blueSize = 8; EGL_CONFORMANT, EGL_DONT_CARE,
config.alphaSize = 8; EGL_RENDERABLE_TYPE, EGL_DONT_CARE,
config.depthSize = 24; EGL_RED_SIZE, 8,
config.stencilSize = 8; EGL_GREEN_SIZE, 8,
config.bindToTextureRGBA = EGL_TRUE; EGL_BLUE_SIZE, 8,
config.renderableType = EGL_OPENGL_ES2_BIT; EGL_ALPHA_SIZE, 8,
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; EGL_BUFFER_SIZE, 32,
config.renderTargetFormat = GL_RGBA8; EGL_DEPTH_SIZE, 24,
config.depthStencilFormat = GL_DEPTH24_STENCIL8; EGL_NONE
};
configs.add(config); // clang-format on
return configs;
if (!validateEglConfig(configAttribs8888.data()))
{
ERR() << "No suitable EGL configs found.";
return egl::ConfigSet();
}
mConfigAttribList = configAttribs8888;
return DisplayEGL::generateConfigs();
} }
bool DisplayGbm::isValidNativeWindow(EGLNativeWindowType window) const bool DisplayGbm::isValidNativeWindow(EGLNativeWindowType window) const
......
...@@ -148,6 +148,7 @@ class DisplayGbm final : public DisplayEGL ...@@ -148,6 +148,7 @@ class DisplayGbm final : public DisplayEGL
unsigned int tv_usec, unsigned int tv_usec,
void *data); void *data);
void pageFlipHandler(unsigned int sequence, uint64_t tv); void pageFlipHandler(unsigned int sequence, uint64_t tv);
bool validateEglConfig(const EGLint *configAttribs);
gbm_device *mGBM; gbm_device *mGBM;
drmModeConnectorPtr mConnector; drmModeConnectorPtr mConnector;
......
...@@ -180,6 +180,8 @@ class EGLSurfaceTest : public ANGLETest ...@@ -180,6 +180,8 @@ class EGLSurfaceTest : public ANGLETest
EGL_DONT_CARE, EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS, EGL_SAMPLE_BUFFERS,
0, 0,
EGL_SURFACE_TYPE,
EGL_DONT_CARE,
EGL_NONE}; EGL_NONE};
EGLint configCount; EGLint configCount;
...@@ -427,6 +429,7 @@ TEST_P(EGLSurfaceTest, ResizeWindow) ...@@ -427,6 +429,7 @@ TEST_P(EGLSurfaceTest, ResizeWindow)
initializeDisplay(); initializeDisplay();
initializeSurfaceWithDefaultConfig(); initializeSurfaceWithDefaultConfig();
initializeContext(); initializeContext();
ANGLE_SKIP_TEST_IF(!mWindowSurface);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext); eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
eglSwapBuffers(mDisplay, mWindowSurface); eglSwapBuffers(mDisplay, mWindowSurface);
...@@ -477,6 +480,7 @@ TEST_P(EGLSurfaceTest, ResizeWindowWithDraw) ...@@ -477,6 +480,7 @@ TEST_P(EGLSurfaceTest, ResizeWindowWithDraw)
initializeDisplay(); initializeDisplay();
initializeSurfaceWithDefaultConfig(); initializeSurfaceWithDefaultConfig();
initializeContext(); initializeContext();
ANGLE_SKIP_TEST_IF(!mWindowSurface);
int size = 64; int size = 64;
EGLint height = 0; EGLint height = 0;
...@@ -566,6 +570,7 @@ TEST_P(EGLSurfaceTest, ResetNativeWindow) ...@@ -566,6 +570,7 @@ TEST_P(EGLSurfaceTest, ResetNativeWindow)
initializeSurfaceWithDefaultConfig(); initializeSurfaceWithDefaultConfig();
initializeContext(); initializeContext();
ANGLE_SKIP_TEST_IF(!mWindowSurface);
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext); 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