mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-15 18:18:07 +02:00
compositor: Stop using EGL_KHR_surfaceless_gles2
The remaining use case was making our context current before we had any output surfaces. We can do that now using a dummy surface, so let's stop relying on surfaceless.
This commit is contained in:
parent
cbcd04794c
commit
b5ef591fac
3 changed files with 52 additions and 25 deletions
|
|
@ -60,6 +60,9 @@ struct drm_compositor {
|
|||
uint32_t connector_allocator;
|
||||
struct tty *tty;
|
||||
|
||||
struct gbm_surface *dummy_surface;
|
||||
EGLSurface dummy_egl_surface;
|
||||
|
||||
struct wl_list sprite_list;
|
||||
int sprites_are_broken;
|
||||
|
||||
|
|
@ -770,7 +773,7 @@ static int
|
|||
init_egl(struct drm_compositor *ec, struct udev_device *device)
|
||||
{
|
||||
EGLint major, minor, n;
|
||||
const char *extensions, *filename, *sysnum;
|
||||
const char *filename, *sysnum;
|
||||
int fd;
|
||||
static const EGLint context_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
|
|
@ -817,12 +820,6 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
|
|||
return -1;
|
||||
}
|
||||
|
||||
extensions = eglQueryString(ec->base.display, EGL_EXTENSIONS);
|
||||
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
|
||||
fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
|
||||
fprintf(stderr, "failed to bind api EGL_OPENGL_ES_API\n");
|
||||
return -1;
|
||||
|
|
@ -841,8 +838,24 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(ec->base.display, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, ec->base.context)) {
|
||||
ec->dummy_surface = gbm_surface_create(ec->gbm, 10, 10,
|
||||
GBM_FORMAT_XRGB8888,
|
||||
GBM_BO_USE_RENDERING);
|
||||
if (!ec->dummy_surface) {
|
||||
fprintf(stderr, "failed to create dummy gbm surface\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ec->dummy_egl_surface =
|
||||
eglCreateWindowSurface(ec->base.display, ec->base.config,
|
||||
ec->dummy_surface, NULL);
|
||||
if (ec->dummy_egl_surface == EGL_NO_SURFACE) {
|
||||
fprintf(stderr, "failed to create egl surface\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(ec->base.display, ec->dummy_egl_surface,
|
||||
ec->dummy_egl_surface, ec->base.context)) {
|
||||
fprintf(stderr, "failed to make context current\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@
|
|||
struct wayland_compositor {
|
||||
struct weston_compositor base;
|
||||
|
||||
struct wl_egl_pixmap *dummy_pixmap;
|
||||
EGLSurface dummy_egl_surface;;
|
||||
|
||||
struct {
|
||||
struct wl_display *display;
|
||||
struct wl_compositor *compositor;
|
||||
|
|
@ -260,7 +263,6 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
|
|||
{
|
||||
EGLint major, minor;
|
||||
EGLint n;
|
||||
const char *extensions;
|
||||
EGLint config_attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RED_SIZE, 1,
|
||||
|
|
@ -286,12 +288,6 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
|
|||
return -1;
|
||||
}
|
||||
|
||||
extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
|
||||
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
|
||||
fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
|
||||
fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
|
||||
return -1;
|
||||
|
|
@ -309,8 +305,17 @@ wayland_compositor_init_egl(struct wayland_compositor *c)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(c->base.display, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, c->base.context)) {
|
||||
c->dummy_pixmap = wl_egl_pixmap_create(10, 10, 0);
|
||||
if (!c->dummy_pixmap) {
|
||||
fprintf(stderr, "failure to create dummy_pixmap\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
c->dummy_egl_surface =
|
||||
eglCreatePixmapSurface(c->base.display, c->base.config,
|
||||
c->dummy_pixmap, NULL);
|
||||
if (!eglMakeCurrent(c->base.display, c->dummy_egl_surface,
|
||||
c->dummy_egl_surface, c->base.context)) {
|
||||
fprintf(stderr, "failed to make context current\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@
|
|||
struct x11_compositor {
|
||||
struct weston_compositor base;
|
||||
|
||||
EGLSurface dummy_pbuffer;
|
||||
|
||||
Display *dpy;
|
||||
xcb_connection_t *conn;
|
||||
xcb_screen_t *screen;
|
||||
|
|
@ -117,7 +119,6 @@ x11_compositor_init_egl(struct x11_compositor *c)
|
|||
{
|
||||
EGLint major, minor;
|
||||
EGLint n;
|
||||
const char *extensions;
|
||||
EGLint config_attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RED_SIZE, 1,
|
||||
|
|
@ -131,6 +132,12 @@ x11_compositor_init_egl(struct x11_compositor *c)
|
|||
EGL_NONE
|
||||
};
|
||||
|
||||
static const EGLint pbuffer_attribs[] = {
|
||||
EGL_WIDTH, 10,
|
||||
EGL_HEIGHT, 10,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
c->base.display = eglGetDisplay(c->dpy);
|
||||
if (c->base.display == NULL) {
|
||||
fprintf(stderr, "failed to create display\n");
|
||||
|
|
@ -142,12 +149,6 @@ x11_compositor_init_egl(struct x11_compositor *c)
|
|||
return -1;
|
||||
}
|
||||
|
||||
extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
|
||||
if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
|
||||
fprintf(stderr, "EGL_KHR_surfaceless_gles2 not available\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
|
||||
fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n");
|
||||
return -1;
|
||||
|
|
@ -165,6 +166,14 @@ x11_compositor_init_egl(struct x11_compositor *c)
|
|||
return -1;
|
||||
}
|
||||
|
||||
c->dummy_pbuffer = eglCreatePbufferSurface(c->base.display,
|
||||
c->base.config,
|
||||
pbuffer_attribs);
|
||||
if (c->base.context == NULL) {
|
||||
fprintf(stderr, "failed to create dummy pbuffer\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(c->base.display, EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE, c->base.context)) {
|
||||
fprintf(stderr, "failed to make context current\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue