mirror of https://github.com/xemu-project/xemu.git
egl-helpers: fix display init for x11
When running on gtk we need X11 platform not mesa platform.
Create separate functions for mesa and x11 so we can keep
the egl #ifdef mess local to egl-helpers.c
Fixes: 0ea1523fb6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20170505104101.30589-4-kraxel@redhat.com
This commit is contained in:
parent
9f728c7940
commit
e1913dbb58
|
@ -21,7 +21,8 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc);
|
||||||
|
|
||||||
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win);
|
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win);
|
||||||
|
|
||||||
int qemu_egl_init_dpy(EGLNativeDisplayType dpy);
|
int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy);
|
||||||
|
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy);
|
||||||
EGLContext qemu_egl_init_ctx(void);
|
EGLContext qemu_egl_init_ctx(void);
|
||||||
|
|
||||||
#endif /* EGL_HELPERS_H */
|
#endif /* EGL_HELPERS_H */
|
||||||
|
|
|
@ -93,7 +93,7 @@ int egl_rendernode_init(const char *rendernode)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_egl_init_dpy((EGLNativeDisplayType)qemu_egl_rn_gbm_dev);
|
qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev);
|
||||||
|
|
||||||
if (!epoxy_has_egl_extension(qemu_egl_display,
|
if (!epoxy_has_egl_extension(qemu_egl_display,
|
||||||
"EGL_KHR_surfaceless_context")) {
|
"EGL_KHR_surfaceless_context")) {
|
||||||
|
@ -206,20 +206,19 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win)
|
||||||
* platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
|
* platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
|
||||||
* like mesa will be able to advertise these (even though it can do EGL 1.5).
|
* like mesa will be able to advertise these (even though it can do EGL 1.5).
|
||||||
*/
|
*/
|
||||||
static EGLDisplay qemu_egl_get_display(void *native)
|
static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
|
||||||
|
EGLenum platform)
|
||||||
{
|
{
|
||||||
EGLDisplay dpy = EGL_NO_DISPLAY;
|
EGLDisplay dpy = EGL_NO_DISPLAY;
|
||||||
|
|
||||||
#ifdef EGL_MESA_platform_gbm
|
|
||||||
/* In practise any EGL 1.5 implementation would support the EXT extension */
|
/* In practise any EGL 1.5 implementation would support the EXT extension */
|
||||||
if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
|
if (epoxy_has_egl_extension(NULL, "EGL_EXT_platform_base")) {
|
||||||
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
|
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
|
||||||
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
|
(void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
if (getPlatformDisplayEXT) {
|
if (getPlatformDisplayEXT && platform != 0) {
|
||||||
dpy = getPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, native, NULL);
|
dpy = getPlatformDisplayEXT(platform, native, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dpy == EGL_NO_DISPLAY) {
|
if (dpy == EGL_NO_DISPLAY) {
|
||||||
/* fallback */
|
/* fallback */
|
||||||
|
@ -228,7 +227,8 @@ static EGLDisplay qemu_egl_get_display(void *native)
|
||||||
return dpy;
|
return dpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_egl_init_dpy(EGLNativeDisplayType dpy)
|
static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
|
||||||
|
EGLenum platform)
|
||||||
{
|
{
|
||||||
static const EGLint conf_att_gl[] = {
|
static const EGLint conf_att_gl[] = {
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
|
@ -243,7 +243,7 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy)
|
||||||
EGLBoolean b;
|
EGLBoolean b;
|
||||||
EGLint n;
|
EGLint n;
|
||||||
|
|
||||||
qemu_egl_display = qemu_egl_get_display(dpy);
|
qemu_egl_display = qemu_egl_get_display(dpy, platform);
|
||||||
if (qemu_egl_display == EGL_NO_DISPLAY) {
|
if (qemu_egl_display == EGL_NO_DISPLAY) {
|
||||||
error_report("egl: eglGetDisplay failed");
|
error_report("egl: eglGetDisplay failed");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -270,6 +270,24 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy)
|
||||||
|
{
|
||||||
|
#ifdef EGL_KHR_platform_x11
|
||||||
|
return qemu_egl_init_dpy(dpy, EGL_PLATFORM_X11_KHR);
|
||||||
|
#else
|
||||||
|
return qemu_egl_init_dpy(dpy, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy)
|
||||||
|
{
|
||||||
|
#ifdef EGL_MESA_platform_gbm
|
||||||
|
return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA);
|
||||||
|
#else
|
||||||
|
return qemu_egl_init_dpy(dpy, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
EGLContext qemu_egl_init_ctx(void)
|
EGLContext qemu_egl_init_ctx(void)
|
||||||
{
|
{
|
||||||
static const EGLint ctx_att_gl[] = {
|
static const EGLint ctx_att_gl[] = {
|
||||||
|
|
|
@ -246,7 +246,7 @@ void gtk_egl_init(void)
|
||||||
GdkDisplay *gdk_display = gdk_display_get_default();
|
GdkDisplay *gdk_display = gdk_display_get_default();
|
||||||
Display *x11_display = gdk_x11_display_get_xdisplay(gdk_display);
|
Display *x11_display = gdk_x11_display_get_xdisplay(gdk_display);
|
||||||
|
|
||||||
if (qemu_egl_init_dpy(x11_display) < 0) {
|
if (qemu_egl_init_dpy_x11(x11_display) < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue