From 278d851c7cdde77cd80c3a87617479f5447b156f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 17 Jan 2020 11:50:00 +1100 Subject: [PATCH] [egl] added fallback for platforms not supporting eglGetPlatformDisplay --- VERSION | 2 +- client/renderers/EGL/egl.c | 27 ++++++++++++++++++++++++--- common/include/common/framebuffer.h | 8 ++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 0fca67eb..eb7bd6e7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-96-g17e05c6fd5+1 \ No newline at end of file +B1-97-g406e22a681+1 \ No newline at end of file diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index 607073e3..2bd63f66 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -367,11 +367,26 @@ bool egl_render_startup(void * opaque, SDL_Window * window) return false; } + const char *client_exts = eglQueryString(NULL, EGL_EXTENSIONS); + DEBUG_INFO("Supported extensions: %s", client_exts); + + bool useNative = false; + if (strstr(client_exts, "EGL_KHR_platform_base") != NULL) + useNative = true; + + DEBUG_INFO("use native: %s", useNative ? "true" : "false"); + switch(wminfo.subsystem) { case SDL_SYSWM_X11: { - this->display = eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR, wminfo.info.x11.display, NULL); + if (!useNative) + this->display = eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR, wminfo.info.x11.display, NULL); + else + { + EGLNativeDisplayType native = (EGLNativeDisplayType)wminfo.info.x11.display; + this->display = eglGetDisplay(native); + } this->nativeWind = (EGLNativeWindowType)wminfo.info.x11.window; break; } @@ -381,7 +396,13 @@ bool egl_render_startup(void * opaque, SDL_Window * window) { int width, height; SDL_GetWindowSize(window, &width, &height); - this->display = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, wminfo.info.wl.display, NULL); + if (!useNative) + this->display = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, wminfo.info.wl.display, NULL); + else + { + EGLNativeDisplayType native = (EGLNativeDisplayType)wminfo.info.wl.display; + this->display = eglGetDisplay(native); + } this->nativeWind = (EGLNativeWindowType)wl_egl_window_create(wminfo.info.wl.surface, width, height); break; } @@ -564,4 +585,4 @@ struct LG_Renderer LGR_EGL = .render_startup = egl_render_startup, .render = egl_render, .update_fps = egl_update_fps -}; \ No newline at end of file +}; diff --git a/common/include/common/framebuffer.h b/common/include/common/framebuffer.h index c8614fae..20cd479f 100644 --- a/common/include/common/framebuffer.h +++ b/common/include/common/framebuffer.h @@ -34,6 +34,14 @@ FrameBuffer; typedef bool (*FrameBufferReadFn)(void * opaque, const void * src, size_t size); +/** + * Wait for the framebuffer to fill to the specified size + */ +static inline void framebuffer_wait(const FrameBuffer * frame, size_t size) +{ + while(frame->wp != size) {} +} + /** * Read data from the KVMFRFrame into the dst buffer */