|
|
5f5628 |
From e8f7568016249822bb95c87447ded6abb724c13b Mon Sep 17 00:00:00 2001
|
|
|
5f5628 |
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
5f5628 |
Date: Thu, 1 Apr 2021 08:46:52 +0200
|
|
|
5f5628 |
Subject: [PATCH xserver 12/27] xwayland/eglstream: Add more error checking
|
|
|
5f5628 |
MIME-Version: 1.0
|
|
|
5f5628 |
Content-Type: text/plain; charset=UTF-8
|
|
|
5f5628 |
Content-Transfer-Encoding: 8bit
|
|
|
5f5628 |
|
|
|
5f5628 |
eglCreateStreamKHR() can fail and return EGL_NO_STREAM_KHR, in which
|
|
|
5f5628 |
case there is no point in trying to create a buffer from it.
|
|
|
5f5628 |
|
|
|
5f5628 |
Similarly, eglCreateStreamProducerSurfaceKHR() also fail and return
|
|
|
5f5628 |
EGL_NO_SURFACE, which in turn will be used in eglMakeCurrent() as
|
|
|
5f5628 |
draw/read surface, and therefore would mean no draw/read buffer.
|
|
|
5f5628 |
|
|
|
5f5628 |
In those cases, log the error, and bail out early. That won't solve the
|
|
|
5f5628 |
issue but will help with investigating the root cause of issues with
|
|
|
5f5628 |
EGLStream backend.
|
|
|
5f5628 |
|
|
|
5f5628 |
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
5f5628 |
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
|
|
|
5f5628 |
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
|
|
|
5f5628 |
(cherry picked from commit cc596bcfb273eeab82ac3d59867668af8bad2abf)
|
|
|
5f5628 |
---
|
|
|
5f5628 |
hw/xwayland/xwayland-glamor-eglstream.c | 93 +++++++++++++++++++++++++
|
|
|
5f5628 |
1 file changed, 93 insertions(+)
|
|
|
5f5628 |
|
|
|
5f5628 |
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
|
|
|
5f5628 |
index 9abb7b779..77b24a4b4 100644
|
|
|
5f5628 |
--- a/hw/xwayland/xwayland-glamor-eglstream.c
|
|
|
5f5628 |
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
|
|
|
5f5628 |
@@ -387,6 +387,84 @@ xwl_eglstream_set_window_pixmap(WindowPtr window, PixmapPtr pixmap)
|
|
|
5f5628 |
xwl_screen->screen->SetWindowPixmap = xwl_eglstream_set_window_pixmap;
|
|
|
5f5628 |
}
|
|
|
5f5628 |
|
|
|
5f5628 |
+static const char *
|
|
|
5f5628 |
+xwl_eglstream_get_error_str(EGLint error)
|
|
|
5f5628 |
+{
|
|
|
5f5628 |
+ switch (error) {
|
|
|
5f5628 |
+ case EGL_BAD_PARAMETER:
|
|
|
5f5628 |
+ return "EGL_BAD_PARAMETER";
|
|
|
5f5628 |
+ case EGL_BAD_ATTRIBUTE:
|
|
|
5f5628 |
+ return "EGL_BAD_ATTRIBUTE";
|
|
|
5f5628 |
+ case EGL_BAD_MATCH:
|
|
|
5f5628 |
+ return "EGL_BAD_MATCH";
|
|
|
5f5628 |
+ case EGL_BAD_ACCESS:
|
|
|
5f5628 |
+ return "EGL_BAD_ACCESS";
|
|
|
5f5628 |
+ case EGL_BAD_STATE_KHR:
|
|
|
5f5628 |
+ return "EGL_BAD_STATE_KHR";
|
|
|
5f5628 |
+ case EGL_BAD_STREAM_KHR:
|
|
|
5f5628 |
+ return "EGL_BAD_STREAM_KHR";
|
|
|
5f5628 |
+ case EGL_BAD_DISPLAY:
|
|
|
5f5628 |
+ return "EGL_BAD_DISPLAY";
|
|
|
5f5628 |
+ case EGL_NOT_INITIALIZED:
|
|
|
5f5628 |
+ return "EGL_NOT_INITIALIZED";
|
|
|
5f5628 |
+ default:
|
|
|
5f5628 |
+ return "Unknown error";
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
+}
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+static const char *
|
|
|
5f5628 |
+xwl_eglstream_get_stream_state_str(EGLint state)
|
|
|
5f5628 |
+{
|
|
|
5f5628 |
+ switch (state) {
|
|
|
5f5628 |
+ case EGL_STREAM_STATE_CREATED_KHR:
|
|
|
5f5628 |
+ return "EGL_STREAM_STATE_CREATED_KHR";
|
|
|
5f5628 |
+ case EGL_STREAM_STATE_CONNECTING_KHR:
|
|
|
5f5628 |
+ return "EGL_STREAM_STATE_CONNECTING_KHR";
|
|
|
5f5628 |
+ case EGL_STREAM_STATE_EMPTY_KHR:
|
|
|
5f5628 |
+ return "EGL_STREAM_STATE_EMPTY_KHR";
|
|
|
5f5628 |
+ case EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR:
|
|
|
5f5628 |
+ return "EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR";
|
|
|
5f5628 |
+ case EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR:
|
|
|
5f5628 |
+ return "EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR";
|
|
|
5f5628 |
+ case EGL_STREAM_STATE_DISCONNECTED_KHR:
|
|
|
5f5628 |
+ return "EGL_STREAM_STATE_DISCONNECTED_KHR";
|
|
|
5f5628 |
+ default:
|
|
|
5f5628 |
+ return "Unknown state";
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
+}
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+static EGLint
|
|
|
5f5628 |
+xwl_eglstream_get_state(EGLDisplay egl_display, EGLStreamKHR egl_stream)
|
|
|
5f5628 |
+{
|
|
|
5f5628 |
+ EGLint state;
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+ eglQueryStreamKHR(egl_display, egl_stream, EGL_STREAM_STATE_KHR, &state);
|
|
|
5f5628 |
+ if (!eglQueryStreamKHR(egl_display, egl_stream,
|
|
|
5f5628 |
+ EGL_STREAM_STATE_KHR, &state)) {
|
|
|
5f5628 |
+ EGLint state_error = eglGetError();
|
|
|
5f5628 |
+ ErrorF("eglstream: Failed to query state - error 0x%X: %s\n",
|
|
|
5f5628 |
+ state_error, xwl_eglstream_get_error_str(state_error));
|
|
|
5f5628 |
+ return EGL_FALSE;
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+ return state;
|
|
|
5f5628 |
+}
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+static void
|
|
|
5f5628 |
+xwl_eglstream_print_error(EGLDisplay egl_display,
|
|
|
5f5628 |
+ EGLStreamKHR egl_stream, EGLint error)
|
|
|
5f5628 |
+{
|
|
|
5f5628 |
+ ErrorF("eglstream: error 0x%X: %s\n", error,
|
|
|
5f5628 |
+ xwl_eglstream_get_error_str(error));
|
|
|
5f5628 |
+
|
|
|
5f5628 |
+ if (error == EGL_BAD_STATE_KHR) {
|
|
|
5f5628 |
+ EGLint state = xwl_eglstream_get_state(egl_display, egl_stream);
|
|
|
5f5628 |
+ ErrorF("eglstream: stream state 0x%X: %s\n", state,
|
|
|
5f5628 |
+ xwl_eglstream_get_stream_state_str(state));
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
+}
|
|
|
5f5628 |
+
|
|
|
5f5628 |
/* Because we run asynchronously with our wayland compositor, it's possible
|
|
|
5f5628 |
* that an X client event could cause us to begin creating a stream for a
|
|
|
5f5628 |
* pixmap/window combo before the stream for the pixmap this window
|
|
|
5f5628 |
@@ -466,6 +544,13 @@ xwl_eglstream_consumer_ready_callback(void *data,
|
|
|
5f5628 |
EGL_NONE
|
|
|
5f5628 |
});
|
|
|
5f5628 |
|
|
|
5f5628 |
+ if (xwl_pixmap->surface == EGL_NO_SURFACE) {
|
|
|
5f5628 |
+ ErrorF("eglstream: Failed to create EGLSurface for pixmap\n");
|
|
|
5f5628 |
+ xwl_eglstream_print_error(xwl_screen->egl_display,
|
|
|
5f5628 |
+ xwl_pixmap->stream, eglGetError());
|
|
|
5f5628 |
+ goto out;
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
+
|
|
|
5f5628 |
DebugF("eglstream: win %d completes eglstream for pixmap %p, congrats!\n",
|
|
|
5f5628 |
pending->window->drawable.id, pending->pixmap);
|
|
|
5f5628 |
|
|
|
5f5628 |
@@ -543,8 +628,16 @@ xwl_eglstream_create_pixmap_and_stream(struct xwl_screen *xwl_screen,
|
|
|
5f5628 |
xwl_pixmap->xwl_screen = xwl_screen;
|
|
|
5f5628 |
xwl_pixmap->surface = EGL_NO_SURFACE;
|
|
|
5f5628 |
xwl_pixmap->stream = eglCreateStreamKHR(xwl_screen->egl_display, NULL);
|
|
|
5f5628 |
+ if (xwl_pixmap->stream == EGL_NO_STREAM_KHR) {
|
|
|
5f5628 |
+ ErrorF("eglstream: Couldn't create EGL stream.\n");
|
|
|
5f5628 |
+ goto fail;
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
stream_fd = eglGetStreamFileDescriptorKHR(xwl_screen->egl_display,
|
|
|
5f5628 |
xwl_pixmap->stream);
|
|
|
5f5628 |
+ if (stream_fd == EGL_NO_FILE_DESCRIPTOR_KHR) {
|
|
|
5f5628 |
+ ErrorF("eglstream: Couldn't get EGL stream file descriptor.\n");
|
|
|
5f5628 |
+ goto fail;
|
|
|
5f5628 |
+ }
|
|
|
5f5628 |
|
|
|
5f5628 |
wl_array_init(&stream_attribs);
|
|
|
5f5628 |
xwl_pixmap->buffer =
|
|
|
5f5628 |
--
|
|
|
5f5628 |
2.31.1
|
|
|
5f5628 |
|