aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@gmail.com>2021-02-23 15:03:07 +0900
committerGerd Hoffmann <kraxel@redhat.com>2021-03-04 09:35:30 +0100
commitbc6a3565c89243f0aaa24bac6dc37fb52b16d5c5 (patch)
treec67c6b57bd5832fbf17c70bc2fae1d9c91d54b91 /ui
parentd9c32b8f7f5f05511d77a1ec1d1d35bf7bff2961 (diff)
configure: Improve OpenGL dependency detections
This has the following visible changes: - GBM is required only for OpenGL dma-buf. - X11 is explicitly required by gtk-egl. - EGL is now mandatory for the OpenGL displays. The last one needs some detailed description. Before this change, EGL was tested only for OpenGL dma-buf with the check of EGL_MESA_image_dma_buf_export. However, all of the OpenGL displays depend on EGL and EGL_MESA_image_dma_buf_export is always defined by epoxy's EGL interface. Therefore, it makes more sense to always check the presence of EGL and say the OpenGL displays are available along with OpenGL dma-buf if it is present. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> Message-Id: <20210223060307.87736-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/egl-helpers.c8
-rw-r--r--ui/gtk-egl.c6
-rw-r--r--ui/gtk-gl-area.c2
-rw-r--r--ui/gtk.c14
-rw-r--r--ui/meson.build8
5 files changed, 29 insertions, 9 deletions
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 73fe61f878..6d0cb2b5cb 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -140,7 +140,7 @@ void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
/* ---------------------------------------------------------------------- */
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
int qemu_egl_rn_fd;
struct gbm_device *qemu_egl_rn_gbm_dev;
@@ -287,7 +287,7 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf)
dmabuf->texture = 0;
}
-#endif /* CONFIG_OPENGL_DMABUF */
+#endif /* CONFIG_GBM */
/* ---------------------------------------------------------------------- */
@@ -315,6 +315,8 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win)
/* ---------------------------------------------------------------------- */
+#if defined(CONFIG_X11) || defined(CONFIG_GBM)
+
/*
* Taken from glamor_egl.h from the Xorg xserver, which is MIT licensed
*
@@ -441,6 +443,8 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)
#endif
}
+#endif
+
bool qemu_egl_has_dmabuf(void)
{
if (qemu_egl_display == EGL_NO_DISPLAY) {
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 588e7b1bb1..2a2e6d3a17 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -208,7 +208,7 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
egl_dmabuf_import_texture(dmabuf);
if (!dmabuf->texture) {
return;
@@ -224,7 +224,7 @@ void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf, bool have_hot,
uint32_t hot_x, uint32_t hot_y)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
if (dmabuf) {
@@ -252,7 +252,7 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl,
void gd_egl_release_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
egl_dmabuf_release_texture(dmabuf);
#endif
}
diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 4e8ee88b9b..dd5783fec7 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -219,7 +219,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
-#ifdef CONFIG_OPENGL_DMABUF
+#ifdef CONFIG_GBM
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
diff --git a/ui/gtk.c b/ui/gtk.c
index bad716f136..c32ee34edc 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -657,6 +657,8 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = {
.dpy_has_dmabuf = gd_has_dmabuf,
};
+#ifdef CONFIG_X11
+
static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_name = "gtk-egl",
.dpy_gfx_update = gd_egl_update,
@@ -679,6 +681,8 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_has_dmabuf = gd_has_dmabuf,
};
+#endif
+
#endif /* CONFIG_OPENGL */
/** QEMU Events **/
@@ -797,8 +801,12 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
/* invoke render callback please */
return FALSE;
} else {
+#ifdef CONFIG_X11
gd_egl_draw(vc);
return TRUE;
+#else
+ abort();
+#endif
}
}
#endif
@@ -2031,6 +2039,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
G_CALLBACK(gl_area_realize), vc);
vc->gfx.dcl.ops = &dcl_gl_area_ops;
} else {
+#ifdef CONFIG_X11
vc->gfx.drawing_area = gtk_drawing_area_new();
/*
* gtk_widget_set_double_buffered() was deprecated in 3.14.
@@ -2044,6 +2053,9 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
#pragma GCC diagnostic pop
vc->gfx.dcl.ops = &dcl_egl_ops;
vc->gfx.has_dmabuf = qemu_egl_has_dmabuf();
+#else
+ abort();
+#endif
}
} else
#endif
@@ -2354,8 +2366,10 @@ static void early_gtk_display_init(DisplayOptions *opts)
} else
#endif
{
+#ifdef CONFIG_X11
DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_ON;
gtk_egl_init(mode);
+#endif
}
#endif
}
diff --git a/ui/meson.build b/ui/meson.build
index 156b600a99..e8d3ff41b9 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -45,14 +45,15 @@ endif
if config_host.has_key('CONFIG_OPENGL')
opengl_ss = ss.source_set()
+ opengl_ss.add(gbm)
opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
ui_modules += {'opengl' : opengl_ss}
endif
-if config_host.has_key('CONFIG_OPENGL_DMABUF')
+if config_host.has_key('CONFIG_OPENGL') and gbm.found()
egl_headless_ss = ss.source_set()
- egl_headless_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL_DMABUF'],
+ egl_headless_ss.add(when: [opengl, gbm, pixman, 'CONFIG_OPENGL'],
if_true: files('egl-headless.c'))
ui_modules += {'egl-headless' : egl_headless_ss}
endif
@@ -63,7 +64,8 @@ if gtk.found()
gtk_ss = ss.source_set()
gtk_ss.add(gtk, vte, pixman, files('gtk.c'))
gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
- gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c', 'gtk-gl-area.c'))
+ gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-gl-area.c'))
+ gtk_ss.add(when: [x11, opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c'))
ui_modules += {'gtk' : gtk_ss}
endif