diff mbox

ui/egl: Reduce required libraries to build with EGL support

Message ID 87lhaso56w.fsf@mail.parknet.co.jp
State New
Headers show

Commit Message

OGAWA Hirofumi Oct. 24, 2015, 11:51 a.m. UTC
To support EGL (sdl2-gl, gtk-egl, egl-helpers, etc.), we don't need to
install "gl" or "glesv" packages. (Those are used only for milkymist-tmu2).

So, this move check from opengl to egl.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 configure            |   34 ++++++++++++++++++++++++++++++++--
 include/ui/console.h |    6 +++---
 include/ui/gtk.h     |    4 ++--
 ui/Makefile.objs     |   20 ++++++++++----------
 ui/gtk.c             |    8 ++++----
 ui/sdl2.c            |    8 ++++----
 vl.c                 |    4 ++--
 7 files changed, 57 insertions(+), 27 deletions(-)

Comments

Gerd Hoffmann Oct. 26, 2015, 10:16 a.m. UTC | #1
On Sa, 2015-10-24 at 20:51 +0900, OGAWA Hirofumi wrote:
> To support EGL (sdl2-gl, gtk-egl, egl-helpers, etc.), we don't need to
> install "gl" or "glesv" packages. (Those are used only for milkymist-tmu2).

They are needed and used.  Maybe it works if you don't explicitly link
them because epoxy brings them in indirectly then.

cheers,
  Gerd
OGAWA Hirofumi Oct. 26, 2015, 10:39 a.m. UTC | #2
Gerd Hoffmann <kraxel@redhat.com> writes:

> On Sa, 2015-10-24 at 20:51 +0900, OGAWA Hirofumi wrote:
>> To support EGL (sdl2-gl, gtk-egl, egl-helpers, etc.), we don't need to
>> install "gl" or "glesv" packages. (Those are used only for milkymist-tmu2).
>
> They are needed and used.  Maybe it works if you don't explicitly link
> them because epoxy brings them in indirectly then.

Hm, I meant, we don't need to explicitly install those development
packages. I.e. epoxy handling those dynamically.

With epoxy, it removes dependency of development stuff (e.g. headers,
(no versioned) *.so), so no need check those by pkg-config? IOW, need
runtime stuff only.

Thanks.
Gerd Hoffmann Oct. 26, 2015, 12:16 p.m. UTC | #3
On Mo, 2015-10-26 at 19:39 +0900, OGAWA Hirofumi wrote:
> Gerd Hoffmann <kraxel@redhat.com> writes:
> 
> > On Sa, 2015-10-24 at 20:51 +0900, OGAWA Hirofumi wrote:
> >> To support EGL (sdl2-gl, gtk-egl, egl-helpers, etc.), we don't need to
> >> install "gl" or "glesv" packages. (Those are used only for milkymist-tmu2).
> >
> > They are needed and used.  Maybe it works if you don't explicitly link
> > them because epoxy brings them in indirectly then.
> 
> Hm, I meant, we don't need to explicitly install those development
> packages. I.e. epoxy handling those dynamically.

Ah, I see.  Can we just move over tmu2 to use epoxy too, then drop the
deps handled by epoxy?  So we don't need a new CONFIG_EGL option ...

Ideally tmu2 should also be moved from talking to glx directly to use
the (egl-based) qemu opengl interfaces.  That'll be a bit more work
though as tmu2 needs be ported to the modern opengl desktop interfaces
then ...

cheers,
  Gerd
OGAWA Hirofumi Oct. 26, 2015, 5:44 p.m. UTC | #4
Gerd Hoffmann <kraxel@redhat.com> writes:

> On Mo, 2015-10-26 at 19:39 +0900, OGAWA Hirofumi wrote:
>> Gerd Hoffmann <kraxel@redhat.com> writes:
>> 
>> > On Sa, 2015-10-24 at 20:51 +0900, OGAWA Hirofumi wrote:
>> >> To support EGL (sdl2-gl, gtk-egl, egl-helpers, etc.), we don't need to
>> >> install "gl" or "glesv" packages. (Those are used only for milkymist-tmu2).
>> >
>> > They are needed and used.  Maybe it works if you don't explicitly link
>> > them because epoxy brings them in indirectly then.
>> 
>> Hm, I meant, we don't need to explicitly install those development
>> packages. I.e. epoxy handling those dynamically.
>
> Ah, I see.  Can we just move over tmu2 to use epoxy too, then drop the
> deps handled by epoxy?  So we don't need a new CONFIG_EGL option ...

Sounds good.

> Ideally tmu2 should also be moved from talking to glx directly to use
> the (egl-based) qemu opengl interfaces.  That'll be a bit more work
> though as tmu2 needs be ported to the modern opengl desktop interfaces
> then ...

Sure. But it was hard to do for right now, so will send just epoxy stuff.

Thanks.
diff mbox

Patch

diff -puN configure~separate-egl configure
--- qemu2/configure~separate-egl	2015-10-24 20:45:57.526328468 +0900
+++ qemu2-hirofumi/configure	2015-10-24 20:45:57.546328445 +0900
@@ -306,6 +306,7 @@  smartcard=""
 libusb=""
 usb_redir=""
 opengl=""
+egl=""
 zlib="yes"
 lzo=""
 snappy=""
@@ -1031,6 +1032,10 @@  for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
+  --disable-egl) egl="no"
+  ;;
+  --enable-egl) egl="yes"
+  ;;
   --disable-rbd) rbd="no"
   ;;
   --enable-rbd) rbd="yes"
@@ -3209,7 +3214,7 @@  fi
 libs_softmmu="$libs_softmmu $fdt_libs"
 
 ##########################################
-# opengl probe (for sdl2, milkymist-tmu2)
+# opengl probe (for milkymist-tmu2)
 
 # GLX probe, used by milkymist-tmu2
 # this is temporary, code will be switched to egl mid-term.
@@ -3226,7 +3231,7 @@  else
 fi
 
 if test "$opengl" != "no" ; then
-  opengl_pkgs="gl glesv2 epoxy egl"
+  opengl_pkgs="gl glesv2"
   if $pkg_config $opengl_pkgs x11 && test "$have_glx" = "yes"; then
     opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
     opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
@@ -3241,6 +3246,24 @@  if test "$opengl" != "no" ; then
   fi
 fi
 
+##########################################
+# egl probe (for sdl2/gtk egl)
+
+if test "$egl" != "no" ; then
+  egl_pkgs="epoxy egl"
+  if $pkg_config $egl_pkgs; then
+    egl_cflags="$($pkg_config --cflags $egl_pkgs)"
+    egl_libs="$($pkg_config --libs $egl_pkgs)"
+    egl=yes
+  else
+    if test "$egl" = "yes" ; then
+      feature_not_found "egl" "Please install egl (mesa) devel pkgs: $egl_pkgs"
+    fi
+    egl_cflags=""
+    egl_libs=""
+    egl=no
+  fi
+fi
 
 ##########################################
 # archipelago probe
@@ -4639,6 +4662,7 @@  echo "smartcard support $smartcard"
 echo "libusb            $libusb"
 echo "usb net redir     $usb_redir"
 echo "OpenGL support    $opengl"
+echo "EGL support       $egl"
 echo "libiscsi support  $libiscsi"
 echo "libnfs support    $libnfs"
 echo "build guest agent $guest_agent"
@@ -5030,6 +5054,12 @@  if test "$opengl" = "yes" ; then
   echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
 fi
 
+if test "$egl" = "yes" ; then
+  echo "CONFIG_EGL=y" >> $config_host_mak
+  echo "EGL_CFLAGS=$egl_cflags" >> $config_host_mak
+  echo "EGL_LIBS=$egl_libs" >> $config_host_mak
+fi
+
 if test "$lzo" = "yes" ; then
   echo "CONFIG_LZO=y" >> $config_host_mak
 fi
diff -puN include/ui/console.h~separate-egl include/ui/console.h
--- qemu2/include/ui/console.h~separate-egl	2015-10-24 20:45:57.526328468 +0900
+++ qemu2-hirofumi/include/ui/console.h	2015-10-24 20:45:57.546328445 +0900
@@ -9,7 +9,7 @@ 
 #include "qapi-types.h"
 #include "qapi/error.h"
 
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
 # include <epoxy/gl.h>
 #endif
 
@@ -121,7 +121,7 @@  struct DisplaySurface {
     pixman_format_code_t format;
     pixman_image_t *image;
     uint8_t flags;
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
     GLenum glformat;
     GLenum gltype;
     GLuint texture;
@@ -335,7 +335,7 @@  DisplaySurface *qemu_console_surface(Qem
 
 /* console-gl.c */
 typedef struct ConsoleGLState ConsoleGLState;
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
 ConsoleGLState *console_gl_init_context(void);
 void console_gl_fini_context(ConsoleGLState *gls);
 bool console_gl_check_format(DisplayChangeListener *dcl,
diff -puN include/ui/gtk.h~separate-egl include/ui/gtk.h
--- qemu2/include/ui/gtk.h~separate-egl	2015-10-24 20:45:57.530328464 +0900
+++ qemu2-hirofumi/include/ui/gtk.h	2015-10-24 20:45:57.546328445 +0900
@@ -18,7 +18,7 @@ 
 #include <X11/XKBlib.h>
 #endif
 
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
 #include "ui/egl-helpers.h"
 #endif
 
@@ -41,7 +41,7 @@  typedef struct VirtualGfxConsole {
     cairo_surface_t *surface;
     double scale_x;
     double scale_y;
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
     ConsoleGLState *gls;
     EGLContext ectx;
     EGLSurface esurface;
diff -puN ui/Makefile.objs~separate-egl ui/Makefile.objs
--- qemu2/ui/Makefile.objs~separate-egl	2015-10-24 20:45:57.534328459 +0900
+++ qemu2-hirofumi/ui/Makefile.objs	2015-10-24 20:45:57.546328445 +0900
@@ -21,13 +21,13 @@  sdl.mo-objs := sdl.o sdl_zoom.o
 endif
 ifeq ($(CONFIG_SDLABI),2.0)
 sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o
-ifeq ($(CONFIG_OPENGL),y)
+ifeq ($(CONFIG_EGL),y)
 sdl.mo-objs += sdl2-gl.o
 endif
 endif
 sdl.mo-cflags := $(SDL_CFLAGS)
 
-ifeq ($(CONFIG_OPENGL),y)
+ifeq ($(CONFIG_EGL),y)
 common-obj-y += shader.o
 common-obj-y += console-gl.o
 common-obj-y += egl-helpers.o
@@ -35,12 +35,12 @@  common-obj-$(CONFIG_GTK) += gtk-egl.o
 endif
 
 gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
-gtk-egl.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS) $(OPENGL_CFLAGS)
-shader.o-cflags += $(OPENGL_CFLAGS)
-console-gl.o-cflags += $(OPENGL_CFLAGS)
-egl-helpers.o-cflags += $(OPENGL_CFLAGS)
+gtk-egl.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS) $(EGL_CFLAGS)
+shader.o-cflags += $(EGL_CFLAGS)
+console-gl.o-cflags += $(EGL_CFLAGS)
+egl-helpers.o-cflags += $(EGL_CFLAGS)
 
-gtk-egl.o-libs += $(OPENGL_LIBS)
-shader.o-libs += $(OPENGL_LIBS)
-console-gl.o-libs += $(OPENGL_LIBS)
-egl-helpers.o-libs += $(OPENGL_LIBS)
+gtk-egl.o-libs += $(EGL_LIBS)
+shader.o-libs += $(EGL_LIBS)
+console-gl.o-libs += $(EGL_LIBS)
+egl-helpers.o-libs += $(EGL_LIBS)
diff -puN ui/gtk.c~separate-egl ui/gtk.c
--- qemu2/ui/gtk.c~separate-egl	2015-10-24 20:45:57.534328459 +0900
+++ qemu2-hirofumi/ui/gtk.c	2015-10-24 20:45:57.546328445 +0900
@@ -603,7 +603,7 @@  static const DisplayChangeListenerOps dc
 };
 
 
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
 
 /** DisplayState Callbacks (opengl version) **/
 
@@ -675,7 +675,7 @@  static gboolean gd_draw_event(GtkWidget
     int ww, wh;
     int fbw, fbh;
 
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
     if (vc->gfx.gls) {
         gd_egl_draw(vc);
         return TRUE;
@@ -1754,7 +1754,7 @@  static GSList *gd_vc_gfx_init(GtkDisplay
     gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
                              vc->tab_item, gtk_label_new(vc->label));
 
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
     if (display_opengl) {
         /*
          * gtk_widget_set_double_buffered() was deprecated in 3.14.
@@ -2058,7 +2058,7 @@  void early_gtk_display_init(int opengl)
     case 0:  /* off */
         break;
     case 1: /* on */
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
         gtk_egl_init();
 #endif
         break;
diff -puN ui/sdl2.c~separate-egl ui/sdl2.c
--- qemu2/ui/sdl2.c~separate-egl	2015-10-24 20:45:57.538328455 +0900
+++ qemu2-hirofumi/ui/sdl2.c	2015-10-24 20:45:57.546328445 +0900
@@ -118,7 +118,7 @@  void sdl2_window_resize(struct sdl2_cons
 static void sdl2_redraw(struct sdl2_console *scon)
 {
     if (scon->opengl) {
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
         sdl2_gl_redraw(scon);
 #endif
     } else {
@@ -691,7 +691,7 @@  static const DisplayChangeListenerOps dc
     .dpy_cursor_define    = sdl_mouse_define,
 };
 
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
 static const DisplayChangeListenerOps dcl_gl_ops = {
     .dpy_name                = "sdl2-gl",
     .dpy_gfx_update          = sdl2_gl_update,
@@ -710,7 +710,7 @@  void sdl_display_early_init(int opengl)
     case 0:  /* off */
         break;
     case 1: /* on */
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
         display_opengl = 1;
 #endif
         break;
@@ -766,7 +766,7 @@  void sdl_display_init(DisplayState *ds,
             sdl2_console[i].hidden = true;
         }
         sdl2_console[i].idx = i;
-#ifdef CONFIG_OPENGL
+#ifdef CONFIG_EGL
         sdl2_console[i].opengl = display_opengl;
         sdl2_console[i].dcl.ops = display_opengl ? &dcl_gl_ops : &dcl_2d_ops;
 #else
diff -puN vl.c~separate-egl vl.c
--- qemu2/vl.c~separate-egl	2015-10-24 20:45:57.538328455 +0900
+++ qemu2-hirofumi/vl.c	2015-10-24 20:45:57.550328440 +0900
@@ -4221,10 +4221,10 @@  int main(int argc, char **argv, char **e
     }
 #endif
     if (request_opengl == 1 && display_opengl == 0) {
-#if defined(CONFIG_OPENGL)
+#if defined(CONFIG_EGL)
         fprintf(stderr, "OpenGL is not supported by the display.\n");
 #else
-        fprintf(stderr, "QEMU was built without opengl support.\n");
+        fprintf(stderr, "QEMU was built without egl support.\n");
 #endif
         exit(1);
     }