Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f359cb6

Browse files
qjia7Commit Bot
authored andcommitted
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 <[email protected]> Reviewed-by: Geoff Lang <[email protected]>
1 parent 074bc23 commit f359cb6

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

src/libANGLE/renderer/gl/egl/gbm/DisplayGbm.cpp

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -922,26 +922,48 @@ egl::Error DisplayGbm::makeCurrent(egl::Surface *drawSurface,
922922
return DisplayGL::makeCurrent(drawSurface, readSurface, context);
923923
}
924924

925+
bool DisplayGbm::validateEglConfig(const EGLint *configAttribs)
926+
{
927+
EGLint numConfigs;
928+
if (!mEGL->chooseConfig(configAttribs, NULL, 0, &numConfigs))
929+
{
930+
ERR() << "eglChooseConfig failed with error " << egl::Error(mEGL->getError());
931+
return false;
932+
}
933+
if (numConfigs == 0)
934+
{
935+
return false;
936+
}
937+
return true;
938+
}
939+
925940
egl::ConfigSet DisplayGbm::generateConfigs()
926941
{
927-
egl::ConfigSet configs;
928-
929-
egl::Config config;
930-
config.bufferSize = 32;
931-
config.redSize = 8;
932-
config.greenSize = 8;
933-
config.blueSize = 8;
934-
config.alphaSize = 8;
935-
config.depthSize = 24;
936-
config.stencilSize = 8;
937-
config.bindToTextureRGBA = EGL_TRUE;
938-
config.renderableType = EGL_OPENGL_ES2_BIT;
939-
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
940-
config.renderTargetFormat = GL_RGBA8;
941-
config.depthStencilFormat = GL_DEPTH24_STENCIL8;
942-
943-
configs.add(config);
944-
return configs;
942+
// clang-format off
943+
std::vector<EGLint> configAttribs8888 =
944+
{
945+
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
946+
EGL_SURFACE_TYPE, EGL_DONT_CARE,
947+
EGL_CONFIG_CAVEAT, EGL_NONE,
948+
EGL_CONFORMANT, EGL_DONT_CARE,
949+
EGL_RENDERABLE_TYPE, EGL_DONT_CARE,
950+
EGL_RED_SIZE, 8,
951+
EGL_GREEN_SIZE, 8,
952+
EGL_BLUE_SIZE, 8,
953+
EGL_ALPHA_SIZE, 8,
954+
EGL_BUFFER_SIZE, 32,
955+
EGL_DEPTH_SIZE, 24,
956+
EGL_NONE
957+
};
958+
// clang-format on
959+
960+
if (!validateEglConfig(configAttribs8888.data()))
961+
{
962+
ERR() << "No suitable EGL configs found.";
963+
return egl::ConfigSet();
964+
}
965+
mConfigAttribList = configAttribs8888;
966+
return DisplayEGL::generateConfigs();
945967
}
946968

947969
bool DisplayGbm::isValidNativeWindow(EGLNativeWindowType window) const

src/libANGLE/renderer/gl/egl/gbm/DisplayGbm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class DisplayGbm final : public DisplayEGL
148148
unsigned int tv_usec,
149149
void *data);
150150
void pageFlipHandler(unsigned int sequence, uint64_t tv);
151+
bool validateEglConfig(const EGLint *configAttribs);
151152

152153
gbm_device *mGBM;
153154
drmModeConnectorPtr mConnector;

src/tests/egl_tests/EGLSurfaceTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ class EGLSurfaceTest : public ANGLETest
180180
EGL_DONT_CARE,
181181
EGL_SAMPLE_BUFFERS,
182182
0,
183+
EGL_SURFACE_TYPE,
184+
EGL_DONT_CARE,
183185
EGL_NONE};
184186

185187
EGLint configCount;
@@ -427,6 +429,7 @@ TEST_P(EGLSurfaceTest, ResizeWindow)
427429
initializeDisplay();
428430
initializeSurfaceWithDefaultConfig();
429431
initializeContext();
432+
ANGLE_SKIP_TEST_IF(!mWindowSurface);
430433

431434
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
432435
eglSwapBuffers(mDisplay, mWindowSurface);
@@ -477,6 +480,7 @@ TEST_P(EGLSurfaceTest, ResizeWindowWithDraw)
477480
initializeDisplay();
478481
initializeSurfaceWithDefaultConfig();
479482
initializeContext();
483+
ANGLE_SKIP_TEST_IF(!mWindowSurface);
480484

481485
int size = 64;
482486
EGLint height = 0;
@@ -566,6 +570,7 @@ TEST_P(EGLSurfaceTest, ResetNativeWindow)
566570

567571
initializeSurfaceWithDefaultConfig();
568572
initializeContext();
573+
ANGLE_SKIP_TEST_IF(!mWindowSurface);
569574

570575
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
571576

0 commit comments

Comments
 (0)