From da7ef932b189d2c4142da5bd00846e66eed8e36f Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Mon, 10 Apr 2023 21:28:54 -0700 Subject: [PATCH] Fix EGL enumeration with mesa/nouveau --- .../FeatureLib/pfGLPipeline/plGLEnumerate.cpp | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLEnumerate.cpp b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLEnumerate.cpp index 4a81002de3..0b21f401da 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLEnumerate.cpp +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLEnumerate.cpp @@ -100,12 +100,18 @@ void plEGLEnumerate(std::vector& records) if (!eglBindAPI(EGL_OPENGL_API)) break; - GLint numConfigs = 0; - if (!eglGetConfigs(display, nullptr, 0, &numConfigs) || numConfigs == 0) - break; + /* Set up the config attributes for EGL */ + EGLConfig config; + EGLint config_count; + EGLint config_attrs[] = { + EGL_BUFFER_SIZE, 24, + EGL_DEPTH_SIZE, 24, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_NONE + }; - std::vector configs(numConfigs); - if (!eglGetConfigs(display, configs.data(), configs.size(), &numConfigs)) + if (!eglChooseConfig(display, config_attrs, &config, 1, &config_count) || config_count != 1) break; EGLint ctx_attrs[] = { @@ -114,11 +120,17 @@ void plEGLEnumerate(std::vector& records) EGL_NONE }; - context = eglCreateContext(display, configs[0], EGL_NO_CONTEXT, ctx_attrs); + context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctx_attrs); if (context == EGL_NO_CONTEXT) break; - surface = eglCreatePbufferSurface(display, configs[0], nullptr); + EGLint pbuf_attrs[] = { + EGL_WIDTH, 800, + EGL_HEIGHT, 600, + EGL_NONE + }; + + surface = eglCreatePbufferSurface(display, config, pbuf_attrs); if (surface == EGL_NO_SURFACE) break;