mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-18 06:47:31 -04:00
render/egl: drop EGL_PLATFORM_GBM_KHR
Now that we match other devices for DRM platform devices, we no longer need this to support split render/display systems.
This commit is contained in:
parent
a69a6ae391
commit
c0ffee9715
3 changed files with 13 additions and 74 deletions
|
|
@ -7,7 +7,6 @@ struct wlr_egl {
|
||||||
EGLDisplay display;
|
EGLDisplay display;
|
||||||
EGLContext context;
|
EGLContext context;
|
||||||
EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT
|
EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT
|
||||||
struct gbm_device *gbm_device;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
// Display extensions
|
// Display extensions
|
||||||
|
|
@ -23,7 +22,6 @@ struct wlr_egl {
|
||||||
|
|
||||||
// Client extensions
|
// Client extensions
|
||||||
bool EXT_device_query;
|
bool EXT_device_query;
|
||||||
bool KHR_platform_gbm;
|
|
||||||
bool EXT_platform_device;
|
bool EXT_platform_device;
|
||||||
bool KHR_display_reference;
|
bool KHR_display_reference;
|
||||||
} exts;
|
} exts;
|
||||||
|
|
|
||||||
80
render/egl.c
80
render/egl.c
|
|
@ -5,7 +5,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <gbm.h>
|
|
||||||
#include <wlr/render/egl.h>
|
#include <wlr/render/egl.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include <wlr/util/region.h>
|
#include <wlr/util/region.h>
|
||||||
|
|
@ -219,8 +218,6 @@ static struct wlr_egl *egl_create(void) {
|
||||||
load_egl_proc(&egl->procs.eglGetPlatformDisplayEXT,
|
load_egl_proc(&egl->procs.eglGetPlatformDisplayEXT,
|
||||||
"eglGetPlatformDisplayEXT");
|
"eglGetPlatformDisplayEXT");
|
||||||
|
|
||||||
egl->exts.KHR_platform_gbm = check_egl_ext(client_exts_str,
|
|
||||||
"EGL_KHR_platform_gbm");
|
|
||||||
egl->exts.EXT_platform_device = check_egl_ext(client_exts_str,
|
egl->exts.EXT_platform_device = check_egl_ext(client_exts_str,
|
||||||
"EGL_EXT_platform_device");
|
"EGL_EXT_platform_device");
|
||||||
egl->exts.KHR_display_reference = check_egl_ext(client_exts_str,
|
egl->exts.KHR_display_reference = check_egl_ext(client_exts_str,
|
||||||
|
|
@ -496,28 +493,6 @@ static EGLDeviceEXT get_egl_device_from_drm_fd(struct wlr_egl *egl,
|
||||||
return egl_device;
|
return egl_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int open_render_node(int drm_fd) {
|
|
||||||
char *render_name = drmGetRenderDeviceNameFromFd(drm_fd);
|
|
||||||
if (render_name == NULL) {
|
|
||||||
// This can happen on split render/display platforms, fallback to
|
|
||||||
// primary node
|
|
||||||
render_name = drmGetPrimaryDeviceNameFromFd(drm_fd);
|
|
||||||
if (render_name == NULL) {
|
|
||||||
wlr_log_errno(WLR_ERROR, "drmGetPrimaryDeviceNameFromFd failed");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
wlr_log(WLR_DEBUG, "DRM device '%s' has no render node, "
|
|
||||||
"falling back to primary node", render_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int render_fd = open(render_name, O_RDWR | O_CLOEXEC);
|
|
||||||
if (render_fd < 0) {
|
|
||||||
wlr_log_errno(WLR_ERROR, "Failed to open DRM node '%s'", render_name);
|
|
||||||
}
|
|
||||||
free(render_name);
|
|
||||||
return render_fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd) {
|
struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd) {
|
||||||
struct wlr_egl *egl = egl_create();
|
struct wlr_egl *egl = egl_create();
|
||||||
if (egl == NULL) {
|
if (egl == NULL) {
|
||||||
|
|
@ -525,49 +500,22 @@ struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (egl->exts.EXT_platform_device) {
|
if (!egl->exts.EXT_platform_device) {
|
||||||
/*
|
|
||||||
* Search for the EGL device matching the DRM fd using the
|
|
||||||
* EXT_device_enumeration extension.
|
|
||||||
*/
|
|
||||||
EGLDeviceEXT egl_device = get_egl_device_from_drm_fd(egl, drm_fd);
|
|
||||||
if (egl_device != EGL_NO_DEVICE_EXT) {
|
|
||||||
if (egl_init(egl, EGL_PLATFORM_DEVICE_EXT, egl_device)) {
|
|
||||||
wlr_log(WLR_DEBUG, "Using EGL_PLATFORM_DEVICE_EXT");
|
|
||||||
return egl;
|
|
||||||
}
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
/* Falls back on GBM in case the device was not found */
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_DEBUG, "EXT_platform_device not supported");
|
wlr_log(WLR_DEBUG, "EXT_platform_device not supported");
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (egl->exts.KHR_platform_gbm) {
|
EGLDeviceEXT egl_device = get_egl_device_from_drm_fd(egl, drm_fd);
|
||||||
int gbm_fd = open_render_node(drm_fd);
|
if (egl_device == EGL_NO_DEVICE_EXT) {
|
||||||
if (gbm_fd < 0) {
|
goto error;
|
||||||
wlr_log(WLR_ERROR, "Failed to open DRM render node");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
egl->gbm_device = gbm_create_device(gbm_fd);
|
|
||||||
if (!egl->gbm_device) {
|
|
||||||
close(gbm_fd);
|
|
||||||
wlr_log(WLR_ERROR, "Failed to create GBM device");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (egl_init(egl, EGL_PLATFORM_GBM_KHR, egl->gbm_device)) {
|
|
||||||
wlr_log(WLR_DEBUG, "Using EGL_PLATFORM_GBM_KHR");
|
|
||||||
return egl;
|
|
||||||
}
|
|
||||||
|
|
||||||
gbm_device_destroy(egl->gbm_device);
|
|
||||||
close(gbm_fd);
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_DEBUG, "KHR_platform_gbm not supported");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!egl_init(egl, EGL_PLATFORM_DEVICE_EXT, egl_device)) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return egl;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
wlr_log(WLR_ERROR, "Failed to initialize EGL context");
|
wlr_log(WLR_ERROR, "Failed to initialize EGL context");
|
||||||
free(egl);
|
free(egl);
|
||||||
|
|
@ -623,12 +571,6 @@ void wlr_egl_destroy(struct wlr_egl *egl) {
|
||||||
|
|
||||||
eglReleaseThread();
|
eglReleaseThread();
|
||||||
|
|
||||||
if (egl->gbm_device) {
|
|
||||||
int gbm_fd = gbm_device_get_fd(egl->gbm_device);
|
|
||||||
gbm_device_destroy(egl->gbm_device);
|
|
||||||
close(gbm_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(egl);
|
free(egl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,8 @@ endif
|
||||||
|
|
||||||
if 'gles2' in renderers or 'auto' in renderers
|
if 'gles2' in renderers or 'auto' in renderers
|
||||||
egl = dependency('egl', required: 'gles2' in renderers)
|
egl = dependency('egl', required: 'gles2' in renderers)
|
||||||
gbm = dependency('gbm', required: 'gles2' in renderers)
|
if egl.found()
|
||||||
if egl.found() and gbm.found()
|
wlr_deps += egl
|
||||||
wlr_deps += [egl, gbm]
|
|
||||||
wlr_files += files('egl.c')
|
wlr_files += files('egl.c')
|
||||||
internal_features += { 'egl': true }
|
internal_features += { 'egl': true }
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue