platformsupport: remove initBufferConfigs

Instead, rely on EGL_KHR_no_config_context everywhere except the standalone x11 backend
This commit is contained in:
Xaver Hugl 2023-03-20 16:55:49 +01:00
parent 57c7eccb32
commit 94ac8d235b
9 changed files with 12 additions and 50 deletions

View file

@ -107,10 +107,10 @@ void EglGbmBackend::init()
bool EglGbmBackend::initRenderingContext() bool EglGbmBackend::initRenderingContext()
{ {
return createContext(initBufferConfigs()) && makeCurrent(); return initBufferConfigs() && createContext(EGL_NO_CONFIG_KHR) && makeCurrent();
} }
EGLConfig EglGbmBackend::initBufferConfigs() bool EglGbmBackend::initBufferConfigs()
{ {
const EGLint config_attribs[] = { const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_SURFACE_TYPE,
@ -136,7 +136,7 @@ EGLConfig EglGbmBackend::initBufferConfigs()
sizeof(configs) / sizeof(EGLConfig), sizeof(configs) / sizeof(EGLConfig),
&count)) { &count)) {
qCCritical(KWIN_DRM) << "eglChooseConfig failed:" << getEglErrorString(); qCCritical(KWIN_DRM) << "eglChooseConfig failed:" << getEglErrorString();
return EGL_NO_CONFIG_KHR; return false;
} }
// Loop through all configs, choosing the first one that has suitable format. // Loop through all configs, choosing the first one that has suitable format.
@ -159,7 +159,7 @@ EGLConfig EglGbmBackend::initBufferConfigs()
m_formats[gbmFormat] = format; m_formats[gbmFormat] = format;
} }
if (!m_formats.isEmpty()) { if (!m_formats.isEmpty()) {
return EGL_NO_CONFIG_KHR; return true;
} }
qCCritical(KWIN_DRM, "Choosing EGL config did not return a supported config. There were %u configs", count); qCCritical(KWIN_DRM, "Choosing EGL config did not return a supported config. There were %u configs", count);
@ -174,7 +174,7 @@ EGLConfig EglGbmBackend::initBufferConfigs()
gbm_format_get_name(gbmFormat, &name); gbm_format_get_name(gbmFormat, &name);
qCCritical(KWIN_DRM, "EGL config %d has format %s with %d,%d,%d,%d bits for r,g,b,a", i, name.name, redSize, greenSize, blueSize, alphaSize); qCCritical(KWIN_DRM, "EGL config %d has format %s with %d,%d,%d,%d bits for r,g,b,a", i, name.name, redSize, greenSize, blueSize, alphaSize);
} }
return EGL_NO_CONFIG_KHR; return false;
} }
std::unique_ptr<SurfaceTexture> EglGbmBackend::createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) std::unique_ptr<SurfaceTexture> EglGbmBackend::createSurfaceTextureInternal(SurfacePixmapInternal *pixmap)

View file

@ -82,7 +82,7 @@ public:
private: private:
bool initializeEgl(); bool initializeEgl();
EGLConfig initBufferConfigs() override; bool initBufferConfigs();
bool initRenderingContext(); bool initRenderingContext();
DrmBackend *m_backend; DrmBackend *m_backend;

View file

@ -137,11 +137,7 @@ void VirtualEglBackend::init()
bool VirtualEglBackend::initRenderingContext() bool VirtualEglBackend::initRenderingContext()
{ {
if (!createContext(initBufferConfigs())) { return createContext(EGL_NO_CONFIG_KHR) && makeCurrent();
return false;
}
return makeCurrent();
} }
void VirtualEglBackend::addOutput(Output *output) void VirtualEglBackend::addOutput(Output *output)

View file

@ -382,7 +382,7 @@ void WaylandEglBackend::init()
bool WaylandEglBackend::initRenderingContext() bool WaylandEglBackend::initRenderingContext()
{ {
if (!createContext(initBufferConfigs())) { if (!createContext(EGL_NO_CONFIG_KHR)) {
return false; return false;
} }

View file

@ -199,7 +199,7 @@ bool EglBackend::initRenderingContext()
setEglDisplay(display); setEglDisplay(display);
if (!createContext(initBufferConfigs())) { if (!createContext(chooseBufferConfig())) {
qCCritical(KWIN_CORE) << "Create OpenGL context failed"; qCCritical(KWIN_CORE) << "Create OpenGL context failed";
return false; return false;
} }
@ -256,7 +256,7 @@ EGLSurface EglBackend::createSurface(xcb_window_t window)
return surface; return surface;
} }
EGLConfig EglBackend::initBufferConfigs() EGLConfig EglBackend::chooseBufferConfig()
{ {
const EGLint config_attribs[] = { const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_SURFACE_TYPE,

View file

@ -53,7 +53,7 @@ public:
OutputLayer *primaryLayer(Output *output) override; OutputLayer *primaryLayer(Output *output) override;
protected: protected:
EGLConfig initBufferConfigs() override; EGLConfig chooseBufferConfig();
bool initRenderingContext(); bool initRenderingContext();
private: private:

View file

@ -305,7 +305,7 @@ bool X11WindowedEglBackend::initializeEgl()
bool X11WindowedEglBackend::initRenderingContext() bool X11WindowedEglBackend::initRenderingContext()
{ {
if (!createContext(initBufferConfigs())) { if (!createContext(EGL_NO_CONFIG_KHR)) {
return false; return false;
} }

View file

@ -356,39 +356,6 @@ QHash<uint32_t, QVector<uint64_t>> AbstractEglBackend::supportedFormats() const
return m_supportedFormats; return m_supportedFormats;
} }
EGLConfig AbstractEglBackend::initBufferConfigs()
{
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RED_SIZE,
1,
EGL_GREEN_SIZE,
1,
EGL_BLUE_SIZE,
1,
EGL_ALPHA_SIZE,
0,
EGL_RENDERABLE_TYPE,
isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
EGL_CONFIG_CAVEAT,
EGL_NONE,
EGL_NONE,
};
EGLint count;
EGLConfig configs[1024];
if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) {
qCCritical(KWIN_OPENGL) << "choose config failed";
return EGL_NO_CONFIG_KHR;
}
if (count != 1) {
qCCritical(KWIN_OPENGL) << "choose config did not return a config" << count;
return EGL_NO_CONFIG_KHR;
}
return configs[0];
}
::EGLDisplay AbstractEglBackend::eglDisplay() const ::EGLDisplay AbstractEglBackend::eglDisplay() const
{ {
return m_display->handle(); return m_display->handle();

View file

@ -77,7 +77,6 @@ protected:
bool hasClientExtension(const QByteArray &ext) const; bool hasClientExtension(const QByteArray &ext) const;
bool isOpenGLES() const; bool isOpenGLES() const;
bool createContext(EGLConfig config); bool createContext(EGLConfig config);
virtual EGLConfig initBufferConfigs();
private: private:
bool ensureGlobalShareContext(EGLConfig config); bool ensureGlobalShareContext(EGLConfig config);