Skip to contentSkip to conversation

opengl rendering in the sdl window

PATCH In review Stefano Stabellini 13 participants 75 messages Aug 29, 2008 – Sep 9, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opengl rendering in the sdl window

This patch comes from xen-unstable and adds opengl support for rendering the guest framebuffer in the SDL window.
SDL is needed anyway to open the window and handle the events. Opengl rendering is optional and can be turned off at both compile time and run time (--disable-opengl).
Some of the benefits of using opengl are:

-faster rendering, less CPU intensive, especially with good graphic cards;

-makes the window resizing possible and hardware accelerated, thus very efficient and smooth;

-allows other optimizations like sharing directly a buffer in vram with the guest (not yet implemented).

Opengl rendering actually is enabled only when the buffer is shared to avoid adding one more copy of the pixel buffer.

This patch depends upon the shared buffer patch and the previous sdl patch.

---

configure +31 -0
index acb4a4a..a794827 100755
@@ -271,6 +271,8 @@ for opt do
   ;;
   --disable-sdl) sdl="no"
   ;;
+  --disable-opengl) opengl="no"
+  ;;
   --fmod-lib=*) fmod_lib="$optarg"
   ;;
   --fmod-inc=*) fmod_inc="$optarg"
@@ -749,6 +751,26 @@ else
 fi # -z $sdl
 
 ##########################################
+# OpenGL test
+
+if test -z "$opengl" && test "$sdl" = "yes"
+then
+cat > $TMPC << EOF
+#include <GL/gl.h>
+#ifndef GL_TEXTURE_RECTANGLE_ARB
+#error "Opengl doesn't support GL_TEXTURE_RECTANGLE_ARB"
+#endif
+int main( void ) { return (int) glGetString(GL_EXTENSIONS); }
+EOF
+if $cc -o $TMPE $TMPC -lGL 2> /dev/null
+then
+opengl="yes"
+else
+opengl="no"
+fi
+fi
+
+##########################################
 # VNC TLS detection
 if test "$vnc_tls" = "yes" ; then
 cat > $TMPC <<EOF
@@ -941,6 +963,7 @@ if test "$sdl" != "no" ; then
     echo "SDL static link   $sdl_static"
 fi
 echo "curses support    $curses"
+echo "OpenGL support    $opengl"
 echo "mingw32 support   $mingw32"
 echo "Audio drivers     $audio_drv_list"
 echo "Extra audio cards $audio_card_list"
@@ -1199,6 +1222,14 @@ if test "$sdl1" = "yes" ; then
     echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
   fi
 fi
+if test $opengl = "yes"
+then
+    echo "#define CONFIG_OPENGL 1" >> $config_h
+    echo "CONFIG_OPENGL=yes" >> $config_mak
+    echo "SDL_CFLAGS+=-I/usr/include/GL" >> $config_mak
+    echo "SDL_LIBS+=-lXext" >> $config_mak
+    echo "SDL_LIBS+=-lGL" >> $config_mak
+fi
 if test "$cocoa" = "yes" ; then
   echo "#define CONFIG_COCOA 1" >> $config_h
   echo "CONFIG_COCOA=yes" >> $config_mak
console.h +1 -1
index 7d252b7..a2004ba 100644
@@ -153,7 +153,7 @@ void qemu_console_resize_shared(QEMUConsole *console, int width, int height,
                                 int depth, int linesize, void *pixels);
 
 /* sdl.c */
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
+void sdl_display_init(DisplayState *ds, int full_screen, int no_frame, int opengl_enable);
 
 /* cocoa.m */
 void cocoa_display_init(DisplayState *ds, int full_screen);
sdl.c +185 -12

280 lines not on this page · raw message

vl.c +18 -1
index 245177a..c661fa9 100644
@@ -201,6 +201,11 @@ int graphic_height = 600;
 int graphic_depth = 15;
 #endif
 int full_screen = 0;
+#ifdef CONFIG_OPENGL
+int opengl_enabled = 1;
+#else
+int opengl_enabled = 0;
+#endif
 int no_frame = 0;
 int no_quit = 0;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
@@ -7681,6 +7686,9 @@ static void help(int exitcode)
            "-no-frame       open SDL window without a frame and window decorations\n"
            "-alt-grab       use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n"
            "-no-quit        disable SDL window close capability\n"
+#ifdef CONFIG_OPENGL
+           "-disable-opengl disable OpenGL rendering, using SDL\n"
+#endif
 #endif
 #ifdef TARGET_I386
            "-no-fd-bootchk  disable boot signature checking for floppy disks\n"
@@ -7881,6 +7889,7 @@ enum {
     QEMU_OPTION_no_frame,
     QEMU_OPTION_alt_grab,
     QEMU_OPTION_no_quit,
+    QEMU_OPTION_disable_opengl,
     QEMU_OPTION_pidfile,
     QEMU_OPTION_no_kqemu,
     QEMU_OPTION_kernel_kqemu,
@@ -7983,6 +7992,9 @@ const QEMUOption qemu_options[] = {
     { "no-frame", 0, QEMU_OPTION_no_frame },
     { "alt-grab", 0, QEMU_OPTION_alt_grab },
     { "no-quit", 0, QEMU_OPTION_no_quit },
+#ifdef CONFIG_OPENGL
+    { "disable-opengl", 0, QEMU_OPTION_disable_opengl },
+#endif
 #endif
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
     { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
@@ -8729,6 +8741,11 @@ int main(int argc, char **argv)
             case QEMU_OPTION_no_quit:
                 no_quit = 1;
                 break;
+#ifdef CONFIG_OPENGL
+            case QEMU_OPTION_disable_opengl:
+                opengl_enabled = 0;
+                break;
+#endif
 #endif
             case QEMU_OPTION_pidfile:
                 pid_file = optarg;
@@ -9104,7 +9121,7 @@ int main(int argc, char **argv)
 #endif
     {
 #if defined(CONFIG_SDL)
-        sdl_display_init(ds, full_screen, no_frame);
+        sdl_display_init(ds, full_screen, no_frame, opengl_enabled);
 #elif defined(CONFIG_COCOA)
         cocoa_display_init(ds, full_screen);
 #else
#2 lore raw
In reply to Stefano Stabellini
Quoted 10 lines · Stefano Stabellini

This patch comes from xen-unstable and adds opengl support for rendering the guest framebuffer in the SDL window.
SDL is needed anyway to open the window and handle the events. Opengl rendering is optional and can be turned off at both compile time and run time (--disable-opengl).
Some of the benefits of using opengl are:

-faster rendering, less CPU intensive, especially with good graphic cards;

Have you measured this or is this just intuition? I've measured it with gtk-vnc and I did not observe any CPU usage decrease in using OpenGL for rendering verses an XShmImage.

Quoted 3 lines

-makes the window resizing possible and hardware accelerated, thus very efficient and smooth;

This is neat, but, I'm unsure if the right way to support OpenGL is through SDL. For instance, there were Cocoa OpenGL patches posted a bit ago that would be largely similar. It may make more sense to have an OpenGL front-end that has conditional code for SDL/Cocoa/X/etc.

Then again, I've been kicking around the idea of doing a GTK front-end. An obvious thing to do here would be a glext based OpenGL version (as we do in gtk-vnc).

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

Regards,

Anthony Liguori

#3 lore raw

Hi,

Quoted 4 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

I really like vnc. Main reason is that the VM and the display are separate, so you can close the window and the VM keeps running. So when creating a nifty user interface I'd put that into a separate process which talks to qemu via monitor and vnc. Or maybe better some shared memory approach for the display.

cheers,
Gerd

#4 lore raw
In reply to Anthony Liguori
Quoted 20 lines · Anthony Liguori
Quoted 10 lines · Stefano Stabellini

This patch comes from xen-unstable and adds opengl support for rendering the guest framebuffer in the SDL window.
SDL is needed anyway to open the window and handle the events. Opengl rendering is optional and can be turned off at both compile time and run time (--disable-opengl).
Some of the benefits of using opengl are:

-faster rendering, less CPU intensive, especially with good graphic cards;

Have you measured this or is this just intuition? I've measured it with gtk-vnc and I did not observe any CPU usage decrease in using OpenGL for rendering verses an XShmImage.

Quoted 3 lines

-makes the window resizing possible and hardware accelerated, thus very efficient and smooth;

Quoted 8 lines

This is neat, but, I'm unsure if the right way to support OpenGL is through SDL. For instance, there were Cocoa OpenGL patches posted a bit ago that would be largely similar. It may make more sense to have an OpenGL front-end that has conditional code for SDL/Cocoa/X/etc.

Then again, I've been kicking around the idea of doing a GTK front-end. An obvious thing to do here would be a glext based OpenGL version (as we do in gtk-vnc).

Actually I'm not so sure this was a good idea in the end. I'm seriously considering re-writing the GTK-VNC stuff to use Cairo, which in turn can use 2-d hardware acceleration primitives - it really doesn't need the full 3-d acceleration stack just for scaling.

Quoted 4 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

As long as that's optional, because in a server deployment scenario like oVirt I don't want to pull in the GTK stack just to run QEMU vms. We currently have a minimal OS image target of < 64 MB in size. Adding GTK and its deps will totally blow that limit.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#5 lore raw

Am 04.09.2008 um 11:42 schrieb Daniel P. Berrange:

Quoted 10 lines · Anthony Liguori
Quoted 4 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

As long as that's optional, because in a server deployment scenario like oVirt I don't want to pull in the GTK stack just to run QEMU vms. We currently have a minimal OS image target of < 64 MB in size. Adding GTK and its deps will totally blow that limit.

All graphical frontends have been optional (--disable-sdl, undocumented --disable-gfx-check).

Andreas

#6 lore raw
Quoted 18 lines · Andreas F?rber

Am 04.09.2008 um 11:42 schrieb Daniel P. Berrange:

Quoted 7 lines · Anthony Liguori
Quoted 5 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a
proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

Quoted 7 lines

As long as that's optional, because in a server deployment scenario like
oVirt I don't want to pull in the GTK stack just to run QEMU vms. We currently
have a minimal OS image target of < 64 MB in size. Adding GTK and its deps
will totally blow that limit.

Quoted 2 lines

All graphical frontends have been optional (--disable-sdl, undocumented --disable-gfx-check).

It gets a little more complicated when you have to ship this still in binary packages though. Users typically expect us to enable all the compile time options which are a available for a particular OS distro, so they'd expect GTK enabled by default if we had that. At the same time many people won't want QEMU to have a dep on GTK. I don't want to end up building multiple binary packages of QEMU, with & without the frontend. It might warrant having a libqemu, and separate graphical frontends, one GTK, one VNC,... That of course raises a question if ABI for libqemu - it could be put in a private lib directory just for the official frontends to use, and declared 'not for public use'.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#7 lore raw

Am 04.09.2008 um 12:20 schrieb Daniel P. Berrange:

Quoted 19 lines · Andreas F?rber
Quoted 18 lines

Am 04.09.2008 um 11:42 schrieb Daniel P. Berrange:

Quoted 14 lines · Anthony Liguori
Quoted 5 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a
proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

As long as that's optional, because in a server deployment scenario like
oVirt I don't want to pull in the GTK stack just to run QEMU vms. We currently
have a minimal OS image target of < 64 MB in size. Adding GTK and its deps
will totally blow that limit.

Quoted 8 lines
Quoted 2 lines

All graphical frontends have been optional (--disable-sdl, undocumented --disable-gfx-check).

It gets a little more complicated when you have to ship this still in binary packages though. Users typically expect us to enable all the compile time options which are a available for a particular OS distro, so they'd expect GTK enabled by default if we had that. At the same time many people won't want QEMU to have a dep on GTK.

True. I've seen headless storage nodes run even without X11 installed, which would probably be just as problematic for SDL.

Debian Etch for instance has a similar issue, it pulls in the whole OOo suite if I install GNOME in a VM for XDMCP. It's always a balancing act, between "standard" Linux desktop and more advanced users.

Anyway, this is still a bikeshed discussion until Anthony provides details of what he's up to. :)

Andreas

#8 lore raw
In reply to Daniel P. Berrange
Quoted 9 lines · Daniel P. Berrange

It gets a little more complicated when you have to ship this still in binary packages though. Users typically expect us to enable all the compile time options which are a available for a particular OS distro,
so they'd expect GTK enabled by default if we had that. At the same time many people won't want QEMU to have a dep on GTK. I don't want to end up building multiple binary packages of QEMU, with & without
the frontend. It might warrant having a libqemu, and separate graphical
frontends, one GTK, one VNC,... That of course raises a question if
ABI for libqemu - it could be put in a private lib directory just for
the official frontends to use, and declared 'not for public use'.

Alternatively, we can have qemu dlopen() the graphical frontends (and maybe even block format drivers, or even emulated devices).

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw
In reply to Daniel P. Berrange
Quoted 7 lines · Daniel P. Berrange

On Wed, Sep 03, 2008 at 10:00:31PM -0500, Anthony Liguori wrote:

Actually I'm not so sure this was a good idea in the end. I'm seriously considering re-writing the GTK-VNC stuff to use Cairo, which in turn can use 2-d hardware acceleration primitives - it really doesn't need the full 3-d acceleration stack just for scaling.

I tried to originally write the GTK-VNC scaling stuff in Cairo. Could not get it to perform well at all. I'd be really interested if you had better luck with it.

Quoted 8 lines
Quoted 2 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

As long as that's optional, because in a server deployment scenario like oVirt I don't want to pull in the GTK stack just to run QEMU vms. We currently have a minimal OS image target of < 64 MB in size. Adding GTK and its deps will totally blow that limit.

Of course.

Regards,

Anthony Liguori

Quoted 2 lines

Daniel

#10 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Daniel P. Berrange

On Wed, Sep 03, 2008 at 10:00:31PM -0500, Anthony Liguori wrote:

Actually I'm not so sure this was a good idea in the end. I'm seriously considering re-writing the GTK-VNC stuff to use Cairo, which in turn can use 2-d hardware acceleration primitives - it really doesn't need the full 3-d acceleration stack just for scaling.

Quoted 3 lines

I tried to originally write the GTK-VNC scaling stuff in Cairo. Could not get it to perform well at all. I'd be really interested if you had better luck with it.

I've just posted patches to the GTK-VNC devel list demonstrating use of Cairo for all rendering. I can't notice any serious drop in performance when enabling scaling with Cairo. If you confirm my tests, it'd be worth evaluating Cairo as an alternative to OpenGL in QEMU too.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#11 lore raw
Quoted 12 lines · Daniel P. Berrange
Quoted 10 lines · Anthony Liguori
Quoted 8 lines · Daniel P. Berrange

On Wed, Sep 03, 2008 at 10:00:31PM -0500, Anthony Liguori wrote:

Actually I'm not so sure this was a good idea in the end. I'm seriously considering re-writing the GTK-VNC stuff to use Cairo, which in turn can use 2-d hardware acceleration primitives - it really doesn't need the full 3-d acceleration stack just for scaling.

Quoted 8 lines
Quoted 2 lines

I tried to originally write the GTK-VNC scaling stuff in Cairo. Could not get it to perform well at all. I'd be really interested if you had better luck with it.

I've just posted patches to the GTK-VNC devel list demonstrating use of Cairo for all rendering. I can't notice any serious drop in performance when enabling scaling with Cairo. If you confirm my tests, it'd be worth evaluating Cairo as an alternative to OpenGL in QEMU too.

Here's the beginning of a GTK front-end in case someone wants to try adapting the Cairo patches to QEMU.

Regards,

Anthony Liguori

Quoted 3 lines

Regards,
Daniel

Makefile +6 -0
index 0472e16..3927c40 100644
@@ -124,6 +124,9 @@ ifdef CONFIG_CURSES
 OBJS+=curses.o
 endif
 OBJS+=vnc.o d3des.o
+ifdef CONFIG_GTK
+OBJS+=gtk.o
+endif
 
 ifdef CONFIG_COCOA
 OBJS+=cocoa.o
@@ -145,6 +148,9 @@ cocoa.o: cocoa.m
 sdl.o: sdl.c keymaps.c sdl_keysym.h
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
 
+gtk.o: gtk.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(GTK_CFLAGS) -c -o $@ $<
+
 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(CONFIG_VNC_TLS_CFLAGS) -c -o $@ $<
 
Makefile.target +4 -0
index 42162c3..572b44b 100644
@@ -515,6 +515,10 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
 LIBS += $(CONFIG_VNC_TLS_LIBS)
 endif
 
+ifdef CONFIG_GTK
+LIBS += $(GTK_LIBS)
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
configure +25 -0
index 0a3b7c9..d0e63fa 100755
@@ -90,6 +90,7 @@ EXESUF=""
 gdbstub="yes"
 slirp="yes"
 vde="yes"
+gtk="yes"
 fmod_lib=""
 fmod_inc=""
 vnc_tls="yes"
@@ -283,6 +284,8 @@ for opt do
   ;;
   --disable-vde) vde="no"
   ;;
+  --disable-gtk) gtk="no"
+  ;;
   --disable-kqemu) kqemu="no"
   ;;
   --disable-brlapi) brlapi="no"
@@ -436,6 +439,7 @@ echo "  --fmod-inc               path to FMOD includes"
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
 echo "  --disable-vde            disable support for vde network"
+echo "  --disable-gtk            disable support for GTK"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -758,6 +762,20 @@ EOF
     fi
 fi
 
+if test "$gtk" = "yes" ; then
+    cat > $TMPC <<EOF
+#include <gtk/gtk.h>
+int main(int argc, char **argv) { gtk_init(&argc, &argv); return 0; }
+EOF
+    gtk_cflags=`pkg-config --cflags gtk+-2.0`
+    gtk_libs=`pkg-config --libs gtk+-2.0`
+    if $cc $ARCH_CFLAGS -o $TMPE $TMPC $gtk_cflags $gtk_libs ; then
+	:
+    else
+	gtk="no"
+    fi
+fi
+
 ##########################################
 # Sound support libraries probe
 
@@ -923,6 +941,7 @@ echo "Documentation     $build_docs"
 echo "uname -r          $uname_release"
 echo "NPTL support      $nptl"
 echo "vde support       $vde"
+echo "gtk support       $gtk"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1097,6 +1116,12 @@ if test "$vde" = "yes" ; then
   echo "#define CONFIG_VDE 1" >> $config_h
   echo "VDE_LIBS=-lvdeplug" >> $config_mak
 fi
+if test "$gtk" = "yes" ; then
+  echo "CONFIG_GTK=yes" >> $config_mak
+  echo "#define CONFIG_GTK 1" >> $config_h
+  echo "GTK_CFLAGS=$gtk_cflags" >> $config_mak
+  echo "GTK_LIBS=$gtk_libs" >> $config_mak
+fi
 for card in $audio_card_list; do
     def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
     echo "$def=yes" >> $config_mak
console.h +5 -0
index e852dd1..92de255 100644
@@ -140,6 +140,11 @@ void qemu_console_resize(QEMUConsole *console, int width, int height);
 /* sdl.c */
 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
 
+/* gtk.c */
+void gtk_display_init(DisplayState *ds, int *argc, char ***argv);
+
+void gtk_display_main_loop(DisplayState *ds, int (*func)(void));
+
 /* cocoa.m */
 void cocoa_display_init(DisplayState *ds, int full_screen);
 
gdk_keysym.h new file +280 -0

280 lines not on this page · raw message

gtk.c new file +356 -0

356 lines not on this page · raw message

hw/ps2.c +9 -0
index 054b92f..daccc93 100644
@@ -284,6 +284,8 @@ static void ps2_mouse_send_packet(PS2MouseState *s)
     unsigned int b;
     int dx1, dy1, dz1;
 
+    printf("sending packet\n");
+
     dx1 = s->mouse_dx;
     dy1 = s->mouse_dy;
     dz1 = s->mouse_dz;
@@ -332,6 +334,8 @@ static void ps2_mouse_event(void *opaque,
 {
     PS2MouseState *s = opaque;
 
+    printf("status - %d\n", (s->mouse_status & MOUSE_STATUS_ENABLED));
+
     /* check if deltas are recorded when disabled */
     if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
         return;
@@ -345,6 +349,9 @@ static void ps2_mouse_event(void *opaque,
 	return;
     s->mouse_buttons = buttons_state;
 
+    printf("remote: %d\n", !(s->mouse_status & MOUSE_STATUS_REMOTE));
+    printf("queue count %d\n", s->common.queue.count);
+
     if (!(s->mouse_status & MOUSE_STATUS_REMOTE) &&
         (s->common.queue.count < (PS2_QUEUE_SIZE - 16))) {
         for(;;) {
@@ -392,6 +399,7 @@ void ps2_write_mouse(void *opaque, int val)
             ps2_queue(&s->common, AUX_ACK);
             break;
         case AUX_SET_STREAM:
+            printf("stream\n");
             s->mouse_status &= ~MOUSE_STATUS_REMOTE;
             ps2_queue(&s->common, AUX_ACK);
             break;
@@ -400,6 +408,7 @@ void ps2_write_mouse(void *opaque, int val)
             ps2_queue(&s->common, AUX_ACK);
             break;
         case AUX_SET_REMOTE:
+            printf("remote\n");
             s->mouse_status |= MOUSE_STATUS_REMOTE;
             ps2_queue(&s->common, AUX_ACK);
             break;
vl.c +7 -1
index 03cd386..0410bff 100644
@@ -9012,7 +9012,9 @@ int main(int argc, char **argv)
     } else
 #endif
     {
-#if defined(CONFIG_SDL)
+#if defined(CONFIG_GTK)
+        gtk_display_init(ds, &argc, &argv);
+#elif defined(CONFIG_SDL)
         sdl_display_init(ds, full_screen, no_frame);
 #elif defined(CONFIG_COCOA)
         cocoa_display_init(ds, full_screen);
@@ -9146,7 +9148,11 @@ int main(int argc, char **argv)
 	close(fd);
     }
 
+#if defined(CONFIG_GTK)
+    gtk_display_main_loop(ds, main_loop);
+#else
     main_loop();
+#endif
     quit_timers();
 
 #if !defined(_WIN32)
#12 lore raw
In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Stefano Stabellini

This patch comes from xen-unstable and adds opengl support for rendering the guest framebuffer in the SDL window.
SDL is needed anyway to open the window and handle the events. Opengl rendering is optional and can be turned off at both compile time and run time (--disable-opengl).
Some of the benefits of using opengl are:

Quoted 7 lines
Quoted 3 lines

-faster rendering, less CPU intensive, especially with good graphic cards;

Have you measured this or is this just intuition? I've measured it with gtk-vnc and I did not observe any CPU usage decrease in using OpenGL for rendering verses an XShmImage.

I wrote that because before my patches all the colour conversions were done in vga_template; after the sdl shared buffer patch the colour conversions are done by SDL that sadly most of the time still implements them using CPU based algorithms.
The opengl code should be able to offload all the colour conversions to the GPU.
So I was referring to SDL vs. OpenGL.

Then there is the video memory versus system memory discussion: the opengl patch loads the guest framebuffer into video memory then does the conversion and blitting video->video that should be accelerated. SDL_CreateRGBSurfaceFrom creates the surface in system memory so the blitting shouldn't be accelerated.
I am saying should and shouldn't because it also depends on the video card drivers and the opengl implementation.

#13 lore raw
Quoted 19 lines · Stefano Stabellini
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Stefano Stabellini

This patch comes from xen-unstable and adds opengl support for rendering the guest framebuffer in the SDL window.
SDL is needed anyway to open the window and handle the events. Opengl rendering is optional and can be turned off at both compile time and run time (--disable-opengl).
Some of the benefits of using opengl are:

Quoted 7 lines
Quoted 3 lines

-faster rendering, less CPU intensive, especially with good graphic cards;

Have you measured this or is this just intuition? I've measured it with gtk-vnc and I did not observe any CPU usage decrease in using OpenGL for rendering verses an XShmImage.

Quoted 7 lines

I wrote that because before my patches all the colour conversions were done in vga_template; after the sdl shared buffer patch the colour conversions are done by SDL that sadly most of the time still implements them using CPU based algorithms.
The opengl code should be able to offload all the colour conversions to the GPU.
So I was referring to SDL vs. OpenGL.

Fwiw, in my experience with Xine and mplayer, drawing video updates to the screen using OpenGL was quite a lot slower than drawing them with XShmImage. That needs colour conversion as video doesn't even use RGB.

Probably OpenGL is faster on some hardware, and slower on some hardware. Don't assume it's always faster.

Quoted 7 lines

Then there is the video memory versus system memory discussion: the opengl patch loads the guest framebuffer into video memory then does the conversion and blitting video->video that should be accelerated. SDL_CreateRGBSurfaceFrom creates the surface in system memory so the blitting shouldn't be accelerated.
I am saying should and shouldn't because it also depends on the video card drivers and the opengl implementation.

Yes it very much depends on the drivers and opengl implementation. It isn't always possible to map the guest framebuffer into video (texture) memory, and also some opengl implementations are not particularly fast at copying textures from CPU memory to texture memory.

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it. I think VMware uses it in full-screen mode.

-- Jamie

#14 lore raw
Quoted 2 lines · Jamie Lokier, le Fri 05 Sep 2008 13:02:15 +0100, a écrit :

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it.

It is being deprecated and probably never works nowadays anyway :)

Samuel

#15 lore raw
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Jamie Lokier, le Fri 05 Sep 2008 13:02:15 +0100, a écrit :

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it.

It is being deprecated and probably never works nowadays anyway :)

That's a shame as the alternatives are all slower on old video cards. Understandable, though.

-- Jamie

#16 lore raw
Quoted 8 lines · Jamie Lokier, le Sun 07 Sep 2008 00:27:23 +0100, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Jamie Lokier, le Fri 05 Sep 2008 13:02:15 +0100, a écrit :

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it.

It is being deprecated and probably never works nowadays anyway :)

That's a shame as the alternatives are all slower on old video cards.

Yes, and because alternatives don't provide so much performance. Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

Samuel

#17 lore raw
Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Jamie Lokier, le Sun 07 Sep 2008 00:27:23 +0100, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 2 lines · Jamie Lokier, le Fri 05 Sep 2008 13:02:15 +0100, a écrit :

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

It is being deprecated and probably never works nowadays anyway :)

That's a shame as the alternatives are all slower on old video cards.

Yes, and because alternatives don't provide so much performance. Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

You really don't want to have the guest writing directly to host video ram. Video ram tends to be high-latency, so you want to write to regular memory, then use a wide block transfer or DMA to copy to video ram.

If you really need zero-copy then you should have the renderer read the data directly out of the guest framebuffer.

Paul

#18 lore raw
Quoted 7 lines · Paul Brook, le Sun 07 Sep 2008 15:36:51 +0100, a écrit :
Quoted 3 lines

Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

You really don't want to have the guest writing directly to host video ram. Video ram tends to be high-latency, so you want to write to regular memory, then use a wide block transfer or DMA to copy to video ram.

How often? Which part(s) of the framebuffer?

Quoted 2 lines

If you really need zero-copy then you should have the renderer read the data directly out of the guest framebuffer.

Same questions.

Samuel

#19 lore raw
Quoted 10 lines · Samuel Thibault
Quoted 7 lines · Paul Brook, le Sun 07 Sep 2008 15:36:51 +0100, a écrit :
Quoted 3 lines

Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

You really don't want to have the guest writing directly to host video ram. Video ram tends to be high-latency, so you want to write to regular memory, then use a wide block transfer or DMA to copy to video ram.

How often?

You probably want to sync the updates to the vertical refresh. Updating more often than that is pointless.

Quoted 1 line

Which part(s) of the framebuffer?

Whichever parts have changed.

Paul

#20 lore raw
Quoted 6 lines · Paul Brook, le Sun 07 Sep 2008 16:03:30 +0100, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 4 lines · Paul Brook, le Sun 07 Sep 2008 15:36:51 +0100, a écrit :
Quoted 3 lines

Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

You really don't want to have the guest writing directly to host video ram. Video ram tends to be high-latency, so you want to write to regular memory, then use a wide block transfer or DMA to copy to video ram.

How often?

You probably want to sync the updates to the vertical refresh. Updating more often than that is pointless.

Sure.

Quoted 3 lines
Quoted 1 line

Which part(s) of the framebuffer?

Whichever parts have changed.

Sure, how do you detect that?
The previous Xen memcmp method was eating 10% cpu for a 30Hz refresh, just for the memcmp. Now it uses the pagetable dirty bits and after some idleness, trapping, but having the guest just write to actual video memory (when it _has_ to be shown on the screen anyway) seems the fastest way.

Samuel

#21 lore raw
Quoted 10 lines
Quoted 3 lines
Quoted 1 line

Which part(s) of the framebuffer?

Whichever parts have changed.

Sure, how do you detect that?
The previous Xen memcmp method was eating 10% cpu for a 30Hz refresh, just for the memcmp. Now it uses the pagetable dirty bits and after some idleness, trapping, but having the guest just write to actual video memory (when it _has_ to be shown on the screen anyway) seems the fastest way.

Page granularity dirtyness is trivial. In fact qemu already does this. I'd be surprised if finer granularity gave any real benefit.

It also depends what testcase you're benchmarking. A few pixels changing every frame is IMHO not a particularly interesting case. The only time this really happens is mouse movement, and there are better ways of fixing that (proper hardware mouse cursors). The interesting cases are guest completely idle, and large screen updates.

Paul

#22 lore raw
Quoted 2 lines · Paul Brook, le Sun 07 Sep 2008 16:35:54 +0100, a écrit :

It also depends what testcase you're benchmarking. A few pixels changing every frame is IMHO not a particularly interesting case.

But we shouldn't spend time on it. For qemu it's trivial to get the dirtyness of course. For Xen/KVM it's far less.

Quoted 1 line

The interesting cases are guest completely idle,

Which needs to be somehow detected.

Quoted 1 line

and large screen updates.

In that case, why blitting from main memory to video memory? Sure video memory is slow. But the guest already does tricky stuff to cope with that...

Samuel

#23 lore raw
Quoted 5 lines
Quoted 1 line

and large screen updates.

In that case, why blitting from main memory to video memory? Sure video memory is slow. But the guest already does tricky stuff to cope with that...

I'd bet that tricky stuff doesn't work inside qemu.

Paul

#24 lore raw
In reply to Samuel Thibault
Quoted 8 lines · Samuel Thibault
Quoted 2 lines · Paul Brook, le Sun 07 Sep 2008 16:35:54 +0100, a écrit :

It also depends what testcase you're benchmarking. A few pixels changing every frame is IMHO not a particularly interesting case.

But we shouldn't spend time on it. For qemu it's trivial to get the dirtyness of course. For Xen/KVM it's far less.

It's actually pretty simple with KVM.

FWIW, I don't see guests consume a tremendous amount of CPU when idle with KVM. Can ya'll post some numbers with OpenGL and QEMU that show reduced CPU consumption? I'm going to try out the patches myself but if you have a test case that is known to benefit, that would be helpful.

Regards,

Anthony Liguori

#25 lore raw
Quoted 9 lines · Anthony Liguori, le Sun 07 Sep 2008 19:08:30 -0500, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 2 lines · Paul Brook, le Sun 07 Sep 2008 16:35:54 +0100, a écrit :

It also depends what testcase you're benchmarking. A few pixels changing every frame is IMHO not a particularly interesting case.

But we shouldn't spend time on it. For qemu it's trivial to get the dirtyness of course. For Xen/KVM it's far less.

It's actually pretty simple with KVM.

Well, you still have to ask the kernel for the dirty pages (qemu_kvm_get_dirty_pages). Much less simple and efficient than just reading from qemu's dirty array.

Quoted 3 lines

FWIW, I don't see guests consume a tremendous amount of CPU when idle with KVM. Can ya'll post some numbers with OpenGL and QEMU that show reduced CPU consumption?

I wasn't arguing for OpenGL, but for DGA (and thus have no numbers since it doesn't work any more).

Samuel

#26 lore raw
In reply to Paul Brook
Quoted 11 lines · Paul Brook
Quoted 10 lines · Samuel Thibault
Quoted 8 lines · Jamie Lokier, le Sun 07 Sep 2008 00:27:23 +0100, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Jamie Lokier, le Fri 05 Sep 2008 13:02:15 +0100, a écrit :

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it.

It is being deprecated and probably never works nowadays anyway :)

That's a shame as the alternatives are all slower on old video cards.

Quoted 8 lines
Quoted 4 lines

Yes, and because alternatives don't provide so much performance. Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

You really don't want to have the guest writing directly to host video ram. Video ram tends to be high-latency, so you want to write to regular memory, then use a wide block transfer or DMA to copy to video ram.

Latency applies mainly when reading.

A good quality guest _expects_ that reading its video RAM will be slow, and only writes to its video RAM, and possible by preparing images off-screen then wide block transfers. :-)

Quoted 2 lines

If you really need zero-copy then you should have the renderer read the data directly out of the guest framebuffer.

That still forces one extra copy compared with XF86DGA. "Renderer reads the data directly out of the guest framebuffer" is the extra copy.

It's negligable on modern 3d cards, but slow on machines or those where fast blitting or 3d isn't supported.

-- Jamie

#27 lore raw
Quoted 17 lines · Jamie Lokier
Quoted 7 lines · Paul Brook
Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Jamie Lokier, le Sun 07 Sep 2008 00:27:23 +0100, a écrit :
Quoted 4 lines · Samuel Thibault
Quoted 2 lines · Jamie Lokier, le Fri 05 Sep 2008 13:02:15 +0100, a écrit :

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it.

It is being deprecated and probably never works nowadays anyway :)

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

That's a shame as the alternatives are all slower on old video cards.

Yes, and because alternatives don't provide so much performance. Ideally, once switched to fullscreen you could just let the guest directly write to the actual video memory (particularly interesting for Xen and KVM).

You really don't want to have the guest writing directly to host video ram. Video ram tends to be high-latency, so you want to write to regular memory, then use a wide block transfer or DMA to copy to video ram.

Quoted 5 lines

Latency applies mainly when reading.

A good quality guest _expects_ that reading its video RAM will be slow, and only writes to its video RAM, and possible by preparing images off-screen then wide block transfers. :-)

That is a really good point.
Usually the safe way to handle the video ram VS main memory problem is to write to main memory then copy the whole buffer to video ram every so often.
But in our case the guest thinks that he is writing to video ram already, so in theory he is already using all precautions needed to handle the latency problem.
It is actually probable that the guest is handling another buffer in his own memory and syncing that one with what he thinks to be the video ram.

#28 lore raw
Quoted 4 lines · Stefano Stabellini
Quoted 3 lines

A good quality guest _expects_ that reading its video RAM will be slow, and only writes to its video RAM, and possible by preparing images off-screen then wide block transfers. :-)

Quoted 9 lines

That is a really good point.
Usually the safe way to handle the video ram VS main memory problem is to write to main memory then copy the whole buffer to video ram every so often.
But in our case the guest thinks that he is writing to video ram already, so in theory he is already using all precautions needed to handle the latency problem.
It is actually probable that the guest is handling another buffer in his own memory and syncing that one with what he thinks to be the video ram.

Yes, especially with any guest in the last 15 years :-), so I would imagine that mapping to video RAM as directly as you can would give the best results (e.g. using an OpenGL memory-mapped texture or X11 MIT-SHM image if they're possible to protect safely). That's also saving power, by the way, even if your machine is plenty fast enough that extra full-screen image copies aren't humanly visible.

That said, numbers talk better than hand-waving.

-- Jamie

#29 lore raw
In reply to Jamie Lokier
Quoted 7 lines · Jamie Lokier

Fwiw, in my experience with Xine and mplayer, drawing video updates to the screen using OpenGL was quite a lot slower than drawing them with XShmImage. That needs colour conversion as video doesn't even use RGB.

Probably OpenGL is faster on some hardware, and slower on some hardware. Don't assume it's always faster.

Yes, good point.

Quoted 4 lines

Yes it very much depends on the drivers and opengl implementation. It isn't always possible to map the guest framebuffer into video (texture) memory, and also some opengl implementations are not particularly fast at copying textures from CPU memory to texture memory.

This is also true.

Quoted 3 lines

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it. I think VMware uses it in full-screen mode.

I went with OpenGL because I wanted the accelerated window resize feature, and because I think it will give us more opportunities for further improvements (for example using PBOs as soon as they are supported by at least one open source graphic card driver).

#30 lore raw
Quoted 9 lines · Stefano Stabellini
Quoted 3 lines · Jamie Lokier

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it. I think VMware uses it in full-screen mode.

I went with OpenGL because I wanted the accelerated window resize feature, and because I think it will give us more opportunities for further improvements (for example using PBOs as soon as they are supported by at least one open source graphic card driver).

The problem with OpenGL is that it has horrible rendering issues if you are also using a compositing window manager like Compiz. You need an X server & driver which supports Redirected Direct Rendering [1]. No distro currently has any official support for this yet. AFAIK, the next Fedora 10 will be the first to support it, and even then only on Intel hardware[2]. ATI is still a fair way off, and NVidia support is nowhere to be seen. For accelerated resize of windows though you shouldn't need 3d - the graphics driver 2-d hardware acceleration support ought to be sufficient I'd imagine

Regards,
Daniel

[1] http://hoegsberg.blogspot.com/2007/08/redirected-direct-rendering.html
[2] http://hoegsberg.blogspot.com/2008/03/i-just-committed-last-bit-of-dri2-work.html

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#31 lore raw
Quoted 6 lines · Daniel P. Berrange

The problem with OpenGL is that it has horrible rendering issues if you are also using a compositing window manager like Compiz. You need an X server & driver which supports Redirected Direct Rendering [1]. No distro currently has any official support for this yet. AFAIK, the next Fedora 10 will be the first to support it, and even then only on Intel hardware[2]. ATI is still a fair way off, and NVidia support is nowhere to be seen.

I don't think this should impact our choice, these are all issues that will be solved sooner or later (hopefully sooner).

Quoted 5 lines

For
accelerated resize of windows though you shouldn't need 3d - the graphics driver 2-d hardware acceleration support ought to be sufficient I'd imagine

SDL doesn't offer this feature, and OpenGL is not just for 3D.

#32 lore raw
Quoted 11 lines · Stefano Stabellini
Quoted 6 lines · Daniel P. Berrange

The problem with OpenGL is that it has horrible rendering issues if you
are also using a compositing window manager like Compiz. You need an X
server & driver which supports Redirected Direct Rendering [1]. No distro currently has any official support for this yet. AFAIK, the next Fedora 10 will be the first to support it, and even then only on Intel hardware[2].
ATI is still a fair way off, and NVidia support is nowhere to be seen.

Quoted 3 lines

I don't think this should impact our choice, these are all issues that will be solved sooner or later (hopefully sooner).

Practically speaking, it's a royal pain. It means it has to be disabled by default. What's most annoying is that Ubuntu enables compiz by default so there are a lot of users that will be affected.

There are a lot of outstanding SDL/VNC patches right now. I'm going to spend time testing/applying them tomorrow. OpenGL support is neat but I'm on the fence about whether it's the right thing to apply it.

I'd like to see if it really makes a difference performance wise to render with OpenGL. I've had good results in the past using software bilinear interpolation to do scaling. If OpenGL doesn't provide a measurable performance advantage, doing it in software may be the right thing to do.

Regards,

Anthony Liguori

Quoted 11 lines
Quoted 6 lines

For
accelerated resize of windows though you shouldn't need 3d - the graphics driver 2-d hardware acceleration support ought to be sufficient I'd imagine

SDL doesn't offer this feature, and OpenGL is not just for 3D.

#33 lore raw
Quoted 6 lines · Anthony Liguori

I'd like to see if it really makes a difference performance wise to render with OpenGL. I've had good results in the past using software bilinear interpolation to do scaling. If OpenGL doesn't provide a measurable performance advantage, doing it in software may be the right thing to do.

I'll do some tests and try to post some results soon.

#34 lore raw
In reply to Anthony Liguori
Quoted 5 lines · Anthony Liguori

I'd like to see if it really makes a difference performance wise to render with OpenGL. I've had good results in the past using software bilinear interpolation to do scaling. If OpenGL doesn't provide a measurable performance advantage, doing it in software may be the right thing to do.

Software interpolation, especially bilinear or other filter, is relatively slow if you're expanding a lot of pixels e.g. 640x384 to 1920x1200. OpenGL will surely beat it.

On the other hand, OpenGL can to be relatively slow (in my experience) if there is no colour conversion and scaling to do and X11-SHM would be a straight 2d blit on the server side.

In principle OpenGL should as fast as the 2d blit or faster on implementations where the image in client app's memory is a memory-mapped texture, but that seems to be still a work in progress on BSD and Linux. DRI2 was dropped this summer because the TTM texture memory manager was ousted in favour of the GEM texture memory manager... and they haven't caught up with each other yet. You need some kind of good shared texture memory to get great speed out of OpenGL displaying a texture which is being constantly updated by the client app.

Imho, if there is an OpenGL backend (overlaid on SDL, Xlib, or whatever), it should be a switch, for the next few years probably defaulting to X11-SHM (or plain X11 when remote), and changing the default to OpenGL in a few years when that's working really well everywhere.

-- Jamie

#35 lore raw
Quoted 25 lines · Jamie Lokier
Quoted 5 lines · Anthony Liguori

I'd like to see if it really makes a difference performance wise to render with OpenGL. I've had good results in the past using software bilinear interpolation to do scaling. If OpenGL doesn't provide a measurable performance advantage, doing it in software may be the right thing to do.

Software interpolation, especially bilinear or other filter, is relatively slow if you're expanding a lot of pixels e.g. 640x384 to 1920x1200. OpenGL will surely beat it.

On the other hand, OpenGL can to be relatively slow (in my experience) if there is no colour conversion and scaling to do and X11-SHM would be a straight 2d blit on the server side.

In principle OpenGL should as fast as the 2d blit or faster on implementations where the image in client app's memory is a memory-mapped texture, but that seems to be still a work in progress on BSD and Linux. DRI2 was dropped this summer because the TTM texture memory manager was ousted in favour of the GEM texture memory manager... and they haven't caught up with each other yet. You need some kind of good shared texture memory to get great speed out of OpenGL displaying a texture which is being constantly updated by the client app.

Quoted 6 lines

Imho, if there is an OpenGL backend (overlaid on SDL, Xlib, or whatever), it should be a switch, for the next few years probably defaulting to X11-SHM (or plain X11 when remote), and changing the default to OpenGL in a few years when that's working really well everywhere.

I agree with you on everything.

#36 lore raw
In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

Practically speaking, it's a royal pain. It means it has to be disabled by default. What's most annoying is that Ubuntu enables compiz by default so there are a lot of users that will be affected.

I'm under the impression that the Compiz problem in stable distros is that OpenGL rendering isn't redirected by the compositor, so it doesn't follow the transformed window in rotating-cube desktops, faded or wobbly windows etc. (Much like Xv for video players sits over everything).

If that's all (not crashes etc.) that might be acceptable.

-- Jamie

#37 lore raw
Quoted 10 lines · Jamie Lokier
Quoted 3 lines · Anthony Liguori

Practically speaking, it's a royal pain. It means it has to be disabled by default. What's most annoying is that Ubuntu enables compiz by default so there are a lot of users that will be affected.

I'm under the impression that the Compiz problem in stable distros is that OpenGL rendering isn't redirected by the compositor, so it doesn't follow the transformed window in rotating-cube desktops, faded or wobbly windows etc. (Much like Xv for video players sits over everything).

The rotating-cube issue is a one annoyance - the bigger problem is that it'll render over the top of other windows, even when it doesn't have input focus, and when you move the window, the area where it used to be doesn't get refreshed. This makes overlapping window management pretty unusable :-(

http://people.redhat.com/berrange/glxgears_compiz.png

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#38 lore raw
Quoted 5 lines · Daniel P. Berrange

The rotating-cube issue is a one annoyance - the bigger problem is that it'll render over the top of other windows, even when it doesn't have input focus, and when you move the window, the area where it used to be doesn't get refreshed. This makes overlapping window management pretty unusable :-(

Oh, that reminds my of the horrible mess we had in the early tv card days, when DMA'img the TV image directly to the visible frame buffer, behind the X-Servers back. Then try to track window clipping changes, update the DMA instructions for the TV card (*after* the X-Server changed the window stacking), then use dirty tricks to force the X-Server refreshing the screen to remove tv image artefacts from the window just raised. Certainly nothing we should try again ...

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

cheers,
Gerd

#39 lore raw
Quoted 5 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Right now VNC works very well except for the overhead of sending the image over a socket :-)

The Gtk-VNC widget (currently used by the Vinagre application) accelerated in that way would work nicely inside a Gtk GUI providing buttons etc. for controlling QEMU.

-- Jamie

#40 lore raw
Quoted 10 lines · Jamie Lokier
Quoted 5 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Or use the monitor, which the gui needs anyway to implement the nice control buttons for the user. Which would it make easier to re-attach the gui to the vm as all you need to know is where the monitor is ...

cheers,
Gerd

#41 lore raw
Quoted 8 lines · Gerd Hoffmann
Quoted 7 lines · Jamie Lokier
Quoted 5 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Quoted 7 lines
Quoted 3 lines

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Or use the monitor, which the gui needs anyway to implement the nice control buttons for the user. Which would it make easier to re-attach the gui to the vm as all you need to know is where the monitor is ...

You want to transmit the image or the image-blit-please protocol over the monitor connection? I think the monitor would need a few improvements before it could do that well.

A nice thing about VNC-SHM would be the GUI could run on a different machine to the emulator (SHM not used then), since it only needs VNC and monitor, which can both be remote.

-- Jamie

#42 lore raw
Quoted 7 lines · Jamie Lokier
Quoted 3 lines · Gerd Hoffmann

Or use the monitor, which the gui needs anyway to implement the nice control buttons for the user. Which would it make easier to re-attach the gui to the vm as all you need to know is where the monitor is ...

You want to transmit the image or the image-blit-please protocol over the monitor connection?

Negotiate a shared memory segment somehow, then send just notifications. Have to think about how to to that in detail, ideally this would be a shared memory segment shared by all three instances involved: the gui process, the qemu process and the X-Server. So qemu can render directly into a XShmImage, although it has no (direct) connection to the X-Server.

Quoted 2 lines

I think the monitor would need a few
improvements before it could do that well.

Sure, we'll need (a) multiple connections at the same time and (b) some "select <eventtype>" command for async notify for that. I think they will come anyway for several other reasons.

Quoted 3 lines

A nice thing about VNC-SHM would be the GUI could run on a different machine to the emulator (SHM not used then), since it only needs VNC and monitor, which can both be remote.

For the remote case it certainly doesn't make sense to reinvent VNC. But you'll probably use some management layer like libvirt anyway then, ssh'ing into the remote machine for starting / stopping VM's isn't very handy.

I'm targeting the local desktop use case. But maybe vnc + shmem-extention works equally well here.

cheers,
Gerd

#43 lore raw
Quoted 12 lines · Gerd Hoffmann
Quoted 9 lines · Jamie Lokier
Quoted 4 lines · Gerd Hoffmann

Or use the monitor, which the gui needs anyway to implement the nice control buttons for the user. Which would it make easier to re-attach the gui to the vm as all you need to know is where the monitor is ...

You want to transmit the image or the image-blit-please protocol over the monitor connection?

Quoted 6 lines

Negotiate a shared memory segment somehow, then send just notifications. Have to think about how to to that in detail, ideally this would be a shared memory segment shared by all three instances involved: the gui process, the qemu process and the X-Server. So qemu can render directly into a XShmImage, although it has no (direct) connection to the X-Server.

This is exactly how my VNC Shm patches worked. The protocol extension is generic but it happens to work very well with an XShmImage.

If someone wants to resurrect these patches, they can find them on gtk-vnc-devel (probably). Otherwise, I'll queue them up for when I have some free time. Now with Dan's cairo patches, the impact to gtk-vnc should be minimal.

Regards,

Anthony Liguori

#44 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann

Negotiate a shared memory segment somehow, then send just notifications. Have to think about how to to that in detail, ideally this would be a shared memory segment shared by all three instances involved: the gui process, the qemu process and the X-Server. So qemu can render directly into a XShmImage, although it has no (direct) connection to the X-Server.

This is exactly how my VNC Shm patches worked. The protocol extension is generic but it happens to work very well with an XShmImage.

Oh, great. Lets dig out and polish the patches then.

cheers,
Gerd

#45 lore raw
In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann
Quoted 3 lines

A nice thing about VNC-SHM would be the GUI could run on a different machine to the emulator (SHM not used then), since it only needs VNC and monitor, which can both be remote.

For the remote case it certainly doesn't make sense to reinvent VNC.

It doesn't make sense to use a completely different protocol in _every way_ for the local case than the remote case, does it?

Quoted 1 line

But you'll probably use some management layer like libvirt anyway then,

Nope.

Quoted 2 lines

ssh'ing into the remote machine for starting / stopping VM's isn't very handy.

I disagree: it's exactly the same as the local case in every respect, except you put the words "ssh host" before the qemu/kvm command you would have run locally.

This holds even for a hypothetical GUI app running locally which wraps a VNC widget and has some QEMU control buttons. It just needs to know the qemu/kvm command it runs starts with "ssh host ...".

If there was a GUI app which runs well locally - why would you want to use something completely different to control a VM which happens to run on another machine? That would be a really annoying and artificial distinction. The same GUI controls are useful in either case.

Quoted 2 lines

I'm targeting the local desktop use case. But maybe vnc + shmem-extention works equally well here.

It's worth a try.

Personally I run a few local kvms and a few remote kvms and I can hardly tell the difference. Either way I run a kvm command, then a VNC client. (I stopped using SDL after accidentally killing VMs by clicking on the close button too many times.)

-- Jamie

#46 lore raw
In reply to Jamie Lokier
Quoted 10 lines · Jamie Lokier
Quoted 5 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Funny you should mention that. Anthony had code todo exactly that against for both QEMU and GTK-VNC a while back. We had it in the GTK-VNC for a short while but removed it due to some race conditions in its impl, and it interracted badly with our OpenGL impl. We could easily revisit this idea if it were thought to be important / useful.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#47 lore raw
Quoted 15 lines · Daniel P. Berrange
Quoted 8 lines · Jamie Lokier
Quoted 6 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Quoted 4 lines

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Quoted 5 lines

Funny you should mention that. Anthony had code todo exactly that against
for both QEMU and GTK-VNC a while back. We had it in the GTK-VNC for a short while but removed it due to some race conditions in its impl, and it interracted badly with our OpenGL impl. We could easily revisit this
idea if it were thought to be important / useful.

The difficulty is deleting the shared memory segment reliably.

Normally, what you want to do is:

shmget()
shmat()
shmctl(IPC_RMID)

...

shmdt()

And the first sequence has to be as reliable and quick as possible because if you exit before the shmctl(), you'll leak the shared memory.

Unfortunately, you have to shmget() in the client and shmat() in the server and client, so that means:

shmget()
shmat()

...

notify server of key
wait for server to confirm shmat()

...

shmctl(IPC_RMID)

..

shmdt()

Which leaves a huge window open where bad things can happen. The client can exit, the client can crash. This is particularly troublesome in a library because it's really not nice to try and register an atexit() handler or something like that from a library.

It would be nice to come up with a solution to this.

Regards,

Anthony Liguori

Quoted 2 lines

Daniel

#48 lore raw

Hi,

Some OS (especially *nix) versions have pretty small size restrictions on shmem. OS X for instance has a restriction of total 4mb for all processes.

I first ran into this limits with an early server/viewer patch submitted to this list using terminal/shmem. (Was it submitted by Anthony? The Idea was dropped in favor of VNC later.)

Then some months ago, after the last cocoa OpenGL patch, I started a new OpenGL version of Q, with qemu as a separate server and Q as a viewer app. The Idea was to have a lean qemu server process running and then attach a viewer/controller to it and have fast/resizable/fullscreen video opposed to the vnc solution. They share the video-buffer with mmap instead of shmem. I've got some notes on the experiment and shmem size limitation on this blogentry http://mike.kronenberg.org/?p=40

For the OpenGL implementation, look at cocoa.m... I think my last patch was never applied... but the OpenGL code should work correctly.

Just some thoughts.

Mike Kronenberg

Quoted 67 lines · Anthony Liguori
Quoted 15 lines · Daniel P. Berrange
Quoted 8 lines · Jamie Lokier
Quoted 6 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Quoted 4 lines

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Quoted 5 lines

Funny you should mention that. Anthony had code todo exactly that against
for both QEMU and GTK-VNC a while back. We had it in the GTK-VNC for a short while but removed it due to some race conditions in its impl, and it interracted badly with our OpenGL impl. We could easily revisit this
idea if it were thought to be important / useful.

The difficulty is deleting the shared memory segment reliably.

Normally, what you want to do is:

shmget()
shmat()
shmctl(IPC_RMID)

...

shmdt()

And the first sequence has to be as reliable and quick as possible because if you exit before the shmctl(), you'll leak the shared memory.

Unfortunately, you have to shmget() in the client and shmat() in the server and client, so that means:

shmget()
shmat()

...

notify server of key
wait for server to confirm shmat()

...

shmctl(IPC_RMID)

..

shmdt()

Which leaves a huge window open where bad things can happen. The client can exit, the client can crash. This is particularly troublesome in a library because it's really not nice to try and register an atexit() handler or something like that from a library.

It would be nice to come up with a solution to this.

Regards,

Anthony Liguori

Quoted 2 lines

Daniel

#49 lore raw
Quoted 5 lines · Mike Kronenberg

Hi,

Some OS (especially *nix) versions have pretty small size restrictions on shmem.
OS X for instance has a restriction of total 4mb for all processes.

I bet that can be configured somewhere.

Linux had that too long ago (2.2.x or so?), and there was a knob to tune that limit.

But even shmem allocation failing shouldn't be a fundamental problem, vnc can just fallback to non-shm mode then.

cheers,
Gerd

#50 lore raw
Quoted 9 lines · Gerd Hoffmann
Quoted 5 lines · Mike Kronenberg

Hi,

Some OS (especially *nix) versions have pretty small size restrictions on shmem.
OS X for instance has a restriction of total 4mb for all processes.

I bet that can be configured somewhere.

Quoted 10 lines

Linux had that too long ago (2.2.x or so?), and there was a knob to tune that limit.

But even shmem allocation failing shouldn't be a fundamental problem, vnc can just fallback to non-shm mode then.

cheers,
Gerd

Tuning is no problem, it just needs root access to change it and a reboot. But i don't like the thought of programs manipulating my system defaults :)

cheers
Mike

#51 lore raw
In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori

The difficulty is deleting the shared memory segment reliably.

Normally, what you want to do is:

shmget()
shmat()
shmctl(IPC_RMID)

Quoted 6 lines

...

shmdt()

And the first sequence has to be as reliable and quick as possible because if you exit before the shmctl(), you'll leak the shared memory.

Yes, it's ugly, but it's the same problem faced by Gtk apps etc. which are writing images - doesn't even SDL have this problem?

The nearest thing to "right" I found in X11-SHM apps is:

- Catch many signals and shmctl(SHM_RMID) in the handler before re-raising the signal to kill the program.
- Try to recognise old, stale shm segments when starting anew and remove them. This can be done by putting a signature into them somewhere which won't be overridden in use.

(There is also some trickiness in ensuring that the connection really is local, and you're not doing a remote connection which just happens to successfully attach to a SHM segment on a different machine with the same id. With SSH X11 forwarding and other ways X11 is proxied, I found the only way to be sure is create a segment, write strong random values to it, ask the X server to read from it and return the pixel values over the normal connection, and verify if they match.)

But that's X11-SHM. For a new protocol, you can do this:

- fd = shm_open()
- shm_unlink()
- pass file descriptor over the connection.

Or even this:

- fd = open("/tmp/XXX")
- unlink()
- pass file descriptor over the connection.

Both ends call mmap().

It's not perfect (there really should be a create-shmem-with-no-name syscall), but the window for leaks is quite small, and it's fine to use in a library.

-- Jamie

#52 lore raw
In reply to Anthony Liguori
Quoted 12 lines · Anthony Liguori

shmget()
shmat()

...

notify server of key
wait for server to confirm shmat()

...

shmctl(IPC_RMID)

Quoted 8 lines

..

shmdt()

Which leaves a huge window open where bad things can happen. The client can exit, the client can crash. This is particularly troublesome in a library because it's really not nice to try and register an atexit() handler or something like that from a library.

Another way to do it, which ought to be quite reliable, is to fork() (and maybe exec) a child helper process which calls shmget() then prints out the ID, for the parent to read, then waits on its input. There is also a pipe from parent to child. If the parent closes the pipe to child or dies, the child kills the shm ID immediately. This catches all kinds of parent crashing and deliberate kills, and you can still close the pipe as soon as the parent confirms everyone is attached to the segment.

What do Gtk and/or Qt and/or Gecko do? They're likely to have thought about it.

-- Jamie

#53 lore raw
Quoted 21 lines · Jamie Lokier
Quoted 10 lines · Anthony Liguori

shmget()
shmat()

...

notify server of key
wait for server to confirm shmat()

...

Quoted 8 lines

shmctl(IPC_RMID)

..

shmdt()

Which leaves a huge window open where bad things can happen. The client can exit, the client can crash. This is particularly troublesome in a library because it's really not nice to try and register an atexit() handler or something like that from a library.

Quoted 9 lines

Another way to do it, which ought to be quite reliable, is to fork() (and maybe exec) a child helper process which calls shmget() then prints out the ID, for the parent to read, then waits on its input. There is also a pipe from parent to child. If the parent closes the pipe to child or dies, the child kills the shm ID immediately. This catches all kinds of parent crashing and deliberate kills, and you can still close the pipe as soon as the parent confirms everyone is attached to the segment.

But you still leak if both processes are killed at once (think killall qemu-system-x86_64). An exec would be a little safer but it's pretty hideous.

Quoted 3 lines

What do Gtk and/or Qt and/or Gecko do? They're likely to have thought about it.

It's not a problem for Gtk because the window of possibly leaking is so short. It creates the shmid, send it to the x server, shmat, then shmctl. The key point is that it interacts with the X server synchronously so not much bad can happen while it's talking to the X server.

It's probably not a huge problem in practice, but I've never liked this. Sys V shared memory is really just crappy.

Regards,

Anthony Liguori

Quoted 2 lines

-- Jamie

#54 lore raw
Quoted 3 lines · Anthony Liguori

But you still leak if both processes are killed at once (think killall qemu-system-x86_64). An exec would be a little safer but it's pretty hideous.

I agree it's not pretty.

Quoted 9 lines
Quoted 4 lines

What do Gtk and/or Qt and/or Gecko do? They're likely to have thought about it.

It's not a problem for Gtk because the window of possibly leaking is so short. It creates the shmid, send it to the x server, shmat, then shmctl. The key point is that it interacts with the X server synchronously so not much bad can happen while it's talking to the X server.

Gtk is a library too. Sure, it's usually used synchronously, but other user threads can terminate the program while Gtk is doing its stuff. Not _that_ different from providing an async VNC client library with an API function "vnc_cleanup - call this if your program terminates and you might not have closed all VNC connections". User program can call atexit() themselves, or g_atexit() if it's a Gtk program. That's reasonably conventional.

Quoted 2 lines

It's probably not a huge problem in practice, but I've never liked this. Sys V shared memory is really just crappy.

Yes, and POSIX shm seems to perpetuate the silliness, though a bit more flexible in what you can put into an ID.

-- Jamie

#55 lore raw
In reply to Daniel P. Berrange
Quoted 12 lines · Daniel P. Berrange
Quoted 10 lines · Jamie Lokier
Quoted 5 lines · Gerd Hoffmann

Beside that I still think it would be a good idea to separate qemu and the gui into two separate processes, so you can close the GUI window and keep the VM running. It also solves the dependency issue for distros as the gtk frontend with all the dependencies can just go into a separate sub-package.

Extending VNC with a "shared memory" extension, similar to Xlib's MIT-SHM extension, and implementing it in QEMU and Gtk-VNC would be a nice way to do this.

Quoted 5 lines

Funny you should mention that. Anthony had code todo exactly that against for both QEMU and GTK-VNC a while back. We had it in the GTK-VNC for a short while but removed it due to some race conditions in its impl, and it interracted badly with our OpenGL impl. We could easily revisit this idea if it were thought to be important / useful.

Just thought I'd mention one other thing - it is not actually clearcut / or guarenteed that XShm + VNC would improve performance in all circumstances. This is because X pixmaps created via XShm apparently cannot live in video memory, and thus it is not so easy to get full performance advantage of hardware acceleration - this could impact scaling for example. The need to perform XSync operations when updating the pixmaps may also negate the benefit of avoiding the socket I/O. It would all depend on the size of the updates vs frequency of them. Still defintely worth a try to see what kind of difference Shm makes in a real world scenario with QEMU.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#56 lore raw
Quoted 5 lines · Daniel P. Berrange

Just thought I'd mention one other thing - it is not actually clearcut / or guarenteed that XShm + VNC would improve performance in all circumstances. This is because X pixmaps created via XShm apparently cannot live in video memory, and thus it is not so easy to get full performance advantage of hardware acceleration - this could impact scaling for example.

I haven't seen any scaling with VNC so far, but it would be nice sometimes.

How does sending the image over the wire then asking the server to scale it using RENDER improve on sending it over XShm then asking the server to xscale the pixel using RENDER? Or is there something else you can do when you don't use XShm?

Quoted 3 lines

The need to
perform XSync operations when updating the pixmaps may also negate the benefit of avoiding the socket I/O.

You don't have to do XSync, if you don't mind a bit of tearing which you're probably going to get anyway, or if you do some fancy locking until you receive XShmCompletionEvent asynchronously and the blit is fast. Or you can double-buffer or triple-buffer with multiple XShm pixmaps; I don't know how that compares with sending the image over the socket. Or you can do both: switch to a new buffer only when the guest writes to video memory before receiving XShmCopmletionEvent, otherwise stay with the old buffer.

-- Jamie

#57 lore raw
Quoted 11 lines · Jamie Lokier
Quoted 6 lines · Daniel P. Berrange

Just thought I'd mention one other thing - it is not actually clearcut / or guarenteed that XShm + VNC would improve performance in all circumstances. This is because X pixmaps created via XShm apparently cannot live in video memory, and thus it is not so easy to get full performance advantage of hardware acceleration - this could impact scaling for example.

I haven't seen any scaling with VNC so far, but it would be nice sometimes.

It's been supported in gtk-vnc for a while now.

Quoted 5 lines

How does sending the image over the wire then asking the server to scale it using RENDER improve on sending it over XShm then asking the server to xscale the pixel using RENDER? Or is there something else you can do when you don't use XShm?

The key point being you can avoid a copy even when using a shared memory extension because you don't necessarily have to back the shared memory with an XShmImage. Even if you have to copy from shared memory to a hardware framebuffer, you avoid copying the data to the kernel socket buffer.

But copying data isn't super expensive assuming you're hitting the cpu cache (which you probably are). So I don't know how much it saves in real life.

Regards,

Anthony Liguori

#58 lore raw
Quoted 3 lines · Anthony Liguori

But copying data isn't super expensive assuming you're hitting the cpu cache (which you probably are). So I don't know how much it saves in real life.

Indeed. Framebuffers are sometimes a bit big to fit in the CPU cache, if the whole picture is being updated. But I see what you mean when there's a partial update.

-- Jamie

#59 lore raw
In reply to Jamie Lokier
Quoted 11 lines · Jamie Lokier
Quoted 2 lines · Anthony Liguori

Practically speaking, it's a royal pain. It means it has to be disabled by default. What's most annoying is that Ubuntu enables compiz by default so there are a lot of users that will be affected.

I'm under the impression that the Compiz problem in stable distros is that OpenGL rendering isn't redirected by the compositor, so it doesn't follow the transformed window in rotating-cube desktops, faded or wobbly windows etc. (Much like Xv for video players sits over everything).

No, the window overlays get all messed up and the screen quickly becomes garbage. Even in the absence of all of the desktop effects.

Regards,

Anthony Liguori

Quoted 6 lines

If that's all (not crashes etc.) that might be acceptable.

-- Jamie

#60 lore raw
In reply to Daniel P. Berrange
Quoted 8 lines · Daniel P. Berrange
Quoted 6 lines · Stefano Stabellini
Quoted 4 lines · Jamie Lokier

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it. I think VMware uses it in full-screen mode.

Quoted 8 lines
Quoted 5 lines

I went with OpenGL because I wanted the accelerated window resize feature, and because I think it will give us more opportunities for further improvements (for example using PBOs as soon as they are supported by at least one open source graphic card driver).

The problem with OpenGL is that it has horrible rendering issues if you are also using a compositing window manager like Compiz.

I would say that this is a compiz problem.

Quoted 2 lines

You need an X
server & driver which supports Redirected Direct Rendering [1]. No distro currently has any official support for this yet.

Or a distro problem.

Quoted 7 lines

AFAIK, the next Fedora 10
will be the first to support it, and even then only on Intel hardware[2]. ATI is still a fair way off, and NVidia support is nowhere to be seen. For accelerated resize of windows though you shouldn't need 3d - the graphics driver 2-d hardware acceleration support ought to be sufficient I'd imagine

I don't see how distros can enable compiz if it breaks opengl applications like this.

Signature · 1 line
error compiling committee.c: too many arguments to function
#61 lore raw
Quoted 15 lines · Avi Kivity
Quoted 14 lines · Daniel P. Berrange
Quoted 11 lines · Stefano Stabellini
Quoted 4 lines · Jamie Lokier

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it. I think VMware uses it in full-screen mode.

I went with OpenGL because I wanted the accelerated window resize feature, and because I think it will give us more opportunities for further improvements (for example using PBOs as soon as they are supported by at least one open source graphic card driver).

Quoted 4 lines
Quoted 2 lines

The problem with OpenGL is that it has horrible rendering issues if you are also using a compositing window manager like Compiz.

I would say that this is a compiz problem.

Not really. Its a limitation of current X server driver architecture which is being addressed by DRI2 / Redirected direct rendering work

Quoted 5 lines
Quoted 3 lines

You need an X
server & driver which supports Redirected Direct Rendering [1]. No distro currently has any official support for this yet.

Or a distro problem.

The distros can't do anything about it, until X driver architecture work is done.

Quoted 9 lines
Quoted 6 lines

AFAIK, the next Fedora 10
will be the first to support it, and even then only on Intel hardware[2]. ATI is still a fair way off, and NVidia support is nowhere to be seen. For accelerated resize of windows though you shouldn't need 3d - the graphics driver 2-d hardware acceleration support ought to be sufficient I'd imagine

I don't see how distros can enable compiz if it breaks opengl applications like this.

This is exactly why Fedora does not yet enable compiz by default. Many users still enable it though.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#62 lore raw
Quoted 10 lines · Daniel P. Berrange
Quoted 5 lines
Quoted 3 lines

The problem with OpenGL is that it has horrible rendering issues if you are also using a compositing window manager like Compiz.

I would say that this is a compiz problem.

Not really. Its a limitation of current X server driver architecture which is being addressed by DRI2 / Redirected direct rendering work

Quoted 7 lines
Quoted 2 lines

Or a distro problem.

The distros can't do anything about it, until X driver architecture work is done.

The distros can avoid shipping compiz until it is resolved one way or another. Are wobbly windows worth breaking applications?

Quoted 3 lines

This is exactly why Fedora does not yet enable compiz by default. Many users still enable it though.

Ah, okay then. The gui should probably say something about voiding the warranty, etc.

Signature · 1 line
error compiling committee.c: too many arguments to function
#63 lore raw

I completely agree with Avi: Opengl has been around since 1992, and now you tell me that it is better not to use it because it breaks Compiz?! To say the least it would be a bad long term engineering decision.

Quoted 15 lines · Avi Kivity
Quoted 4 lines

Daniel P. Berrange wrote:
The distros can't do anything about it, until X driver architecture work is done.

The distros can avoid shipping compiz until it is resolved one way or another. Are wobbly windows worth breaking applications?

Quoted 3 lines

This is exactly why Fedora does not yet enable compiz by default. Many users still enable it though.

Ah, okay then. The gui should probably say something about voiding the warranty, etc.

#64 lore raw
Quoted 3 lines · Stefano Stabellini

I completely agree with Avi: Opengl has been around since 1992, and now you tell me that it is better not to use it because it breaks Compiz?! To say the least it would be a bad long term engineering decision.

It would be a bad decision *if* OpenGL were the only technical solution to the problem. There are a variety of possible solutions with various pluses & minuses. If it is possible to do an implementation which uses hardware acceleration for scaling to get the same level of performance as the OpenGL proposal, it is good sense to evaluate it. Blindly going for OpenGL when it has known problems without evaluating alternatives would be the bad engineering decision.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#65 lore raw
Quoted 5 lines · Daniel P. Berrange
Quoted 3 lines · Stefano Stabellini

I completely agree with Avi: Opengl has been around since 1992, and now you tell me that it is better not to use it because it breaks Compiz?! To say the least it would be a bad long term engineering decision.

Quoted 7 lines

It would be a bad decision *if* OpenGL were the only technical solution to the problem. There are a variety of possible solutions with various pluses & minuses. If it is possible to do an implementation which uses hardware acceleration for scaling to get the same level of performance as the OpenGL proposal, it is good sense to evaluate it. Blindly going for OpenGL when it has known problems without evaluating alternatives would be the bad engineering decision.

You are right that we have a variety of possible solution each one with its own pros and cons.
I think removing SDL(+Opengl) for Gtk and Cairo is not a good idea *but* we could add another Gtk based fronted.
We are already forced to work with multiple frontend because of vnc, so at this point adding another one won't cause any harm.

#66 lore raw
Quoted 16 lines · Stefano Stabellini
Quoted 5 lines · Daniel P. Berrange
Quoted 3 lines · Stefano Stabellini

I completely agree with Avi: Opengl has been around since 1992, and now you tell me that it is better not to use it because it breaks Compiz?! To say the least it would be a bad long term engineering decision.

Quoted 7 lines

It would be a bad decision *if* OpenGL were the only technical solution to the problem. There are a variety of possible solutions with various pluses & minuses. If it is possible to do an implementation which uses hardware acceleration for scaling to get the same level of performance as the OpenGL proposal, it is good sense to evaluate it. Blindly going for OpenGL when it has known problems without evaluating alternatives would be the bad engineering decision.

Quoted 4 lines

You are right that we have a variety of possible solution each one with its own pros and cons.
I think removing SDL(+Opengl) for Gtk and Cairo is not a good idea *but* we could add another Gtk based fronted.

Sorry, I wasn't being entirely clear in my suggestion. Cairo itself is not tied to any toolkit - its dependancy is on libX11 / the RENDER extension. So, use of Cairo is rather tangential to question of GTK vs SDL - you can use Cairo with either of them. That said, it may turn out that SDL does not expose enough of its X11 internals to allow an efficient use of Cairo. It would need some experimentation to determine for sure, because the docs aren't entirely clear on this question.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#67 lore raw
Quoted 34 lines · Stefano Stabellini
Quoted 26 lines
Quoted 9 lines · Daniel P. Berrange
Quoted 6 lines · Stefano Stabellini

I completely agree with Avi: Opengl has been around since 1992, and now
you tell me that it is better not to use it because it breaks Compiz?!
To say the least it would be a bad long term engineering decision.

Quoted 13 lines

It would be a bad decision *if* OpenGL were the only technical solution
to the problem. There are a variety of possible solutions with various
pluses & minuses. If it is possible to do an implementation which uses
hardware acceleration for scaling to get the same level of performance
as the OpenGL proposal, it is good sense to evaluate it. Blindly going
for OpenGL when it has known problems without evaluating alternatives
would be the bad engineering decision.

Quoted 6 lines

You are right that we have a variety of possible solution each one with
its own pros and cons.
I think removing SDL(+Opengl) for Gtk and Cairo is not a good idea *but*
we could add another Gtk based fronted.

Quoted 13 lines

Sorry, I wasn't being entirely clear in my suggestion. Cairo itself is not
tied to any toolkit - its dependancy is on libX11 / the RENDER extension.
So, use of Cairo is rather tangential to question of GTK vs SDL - you can
use Cairo with either of them. That said, it may turn out that SDL does
not expose enough of its X11 internals to allow an efficient use of Cairo.
It would need some experimentation to determine for sure, because the docs
aren't entirely clear on this question.

It would definitely make things much less portable... Cairo itself is quite a beast to port I heard... (not everyone uses X11...)

François.

#68 lore raw
Quoted 14 lines · François Revol
Quoted 5 lines

Sorry, I wasn't being entirely clear in my suggestion. Cairo itself is not
tied to any toolkit - its dependancy is on libX11 / the RENDER extension.
So, use of Cairo is rather tangential to question of GTK vs SDL - you

Quoted 8 lines

can
use Cairo with either of them. That said, it may turn out that SDL does
not expose enough of its X11 internals to allow an efficient use of Cairo.
It would need some experimentation to determine for sure, because the docs
aren't entirely clear on this question.

Quoted 3 lines

It would definitely make things much less portable... Cairo itself is quite a beast to port I heard... (not everyone uses X11...)

Cairo can work with a basic framebuffer, I think, so in principle that should be easy to use on any target, but not accelerated.

Cairo's software renderer is said not to be particularly fast, as those things go, in various places (including on the Cairo list last summer).

Don't Mozilla/Firefox use Cairo these days? Do they use it on Windows?

Regarding SDL and X11, a "raw" Xlib front end (no SDL) would not be much code, if the intent is to do the rendering with something other than SDL, since all it does is create a window and support a few basic events. (It might still not be worth the work, though).

-- Jamie

#69 lore raw
In reply to François Revol
Quoted 4 lines

It would definitely make things much less portable...
Cairo itself is quite a beast to port I heard... (not everyone uses X11...)

It compiles fine on Windows.

Regards,

Anthony Liguori

Quoted 4 lines

François.

#70 lore raw
Quoted 8 lines
Quoted 5 lines

It would definitely make things much less portable... Cairo itself is quite a beast to port I heard... (not everyone uses X11...)

It compiles fine on Windows.

I wasn't thinking about windows.

François.

#71 lore raw
In reply to Stefano Stabellini
Quoted 23 lines · Stefano Stabellini
Quoted 7 lines · Jamie Lokier

Fwiw, in my experience with Xine and mplayer, drawing video updates to the screen using OpenGL was quite a lot slower than drawing them with XShmImage. That needs colour conversion as video doesn't even use RGB.

Probably OpenGL is faster on some hardware, and slower on some hardware. Don't assume it's always faster.

Yes, good point.

Quoted 4 lines

Yes it very much depends on the drivers and opengl implementation. It isn't always possible to map the guest framebuffer into video (texture) memory, and also some opengl implementations are not particularly fast at copying textures from CPU memory to texture memory.

This is also true.

Quoted 8 lines
Quoted 3 lines

Another way to map guest framebuffer to video memory is the XF86DGA extension, which is great when you can use it. I think VMware uses it in full-screen mode.

I went with OpenGL because I wanted the accelerated window resize feature, and because I think it will give us more opportunities for further improvements (for example using PBOs as soon as they are supported by at least one open source graphic card driver).

I have code that uses PBO or PDR or XAMM, for cirrus it was always on par with the standard SDL drawing speed wise, and i expected it to be faster with VMWare SVGA, but back when i was musing with it VMWare SVGA didn't quite work with Linux guests, then it was fixed but i got carried away by different stuff. I can probably brush it up and release if anybody is interested.

Signature · 1 line
mailto:[email protected]
#72 lore raw
In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori

This is neat, but, I'm unsure if the right way to support OpenGL is through SDL. For instance, there were Cocoa OpenGL patches posted a bit ago that would be largely similar. It may make more sense to have an OpenGL front-end that has conditional code for SDL/Cocoa/X/etc.

Then again, I've been kicking around the idea of doing a GTK front-end. An obvious thing to do here would be a glext based OpenGL version (as we do in gtk-vnc).

I don't think GTK support would add much to what qemu already has (aside from more dependencies :).

Quoted 5 lines

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

While decoupling the opengl code from the sdl code seems a good idea, in
practice opengl is only for rendering and the sdl code handles so much
more than that.
Opengl depends heavily on SDL for everything else, so separating the two of them may not be straightforward.

If you really want to go this route, probably the simplest way is to treat opengl as a separate drop in reandering replacement for sdl (or whatever other future frontend).
Opengl would substitute only few critical rendering related functions (sdl_resize_shared, sdl_colourdepth, sdl_update, sdl_setdata).

#73 lore raw
Quoted 8 lines · Stefano Stabellini
Quoted 6 lines · Anthony Liguori

This is neat, but, I'm unsure if the right way to support OpenGL is

through SDL. For instance, there were Cocoa OpenGL patches posted a bit ago that would be largely similar. It may make more sense to have an OpenGL front-end that has conditional code for SDL/Cocoa/X/etc.

Quoted 8 lines
Quoted 3 lines

Then again, I've been kicking around the idea of doing a GTK front-end. An obvious thing to do here would be a glext based OpenGL version (as we do in gtk-vnc).

I don't think GTK support would add much to what qemu already has (aside from more dependencies :).

Well the goal would be to replace the monitor with a menu/toolbar.

Pressing ctrl-alt-2, then typing change ide0-cd0 'path/to/file' without being able to use copy/paste and with funky completion is pretty unfriendly IMHO.

Being able to use a familiar file browser for this sort of thing would go a long way in improving user experience, I think.

Regards,

Anthony Liguori

#74 lore raw
In reply to Anthony Liguori

Am 04.09.2008 um 05:00 schrieb Anthony Liguori:

Quoted 11 lines
Quoted 4 lines · Stefano Stabellini

-makes the window resizing possible and hardware accelerated, thus very
efficient and smooth;

This is neat, but, I'm unsure if the right way to support OpenGL is through SDL. For instance, there were Cocoa OpenGL patches posted a bit ago that would be largely similar. It may make more sense to have an OpenGL front-end that has conditional code for SDL/Cocoa/X/etc.

Then again, I've been kicking around the idea of doing a GTK front-end. An obvious thing to do here would be a glext based OpenGL version (as we do in gtk-vnc).

I think we need to have some discussion about what the long term front-end should be for QEMU. Otherwise, we're going to end up with a proliferation of front-ends. Personally, I'd rather move from SDL to GTK so that we can build a proper user interface.

Anthony, you are aware of the Gtk+ QEMU Launcher?
https://gna.org/projects/qemulaunch/

Haven't used it personally but it's installed on all our Fedora lab machines.

In general I thought fancy ("proper") graphical frontends were left to the famous Management Applications. But I agree it could be useful to rethink the relation of QEMU to such secondary projects. I remember seeing the issue in Q that some parts of QEMU assume readability of stderr (e.g., when assigning more RAM than the default sparc machine allows), which is unhandy for a graphical app launched from the OS X Dock or GNOME menu. Having a clear set of macros/functions that can and should be overwritten by frontends (a separate header file that can be exchanged instead of constantly breaking patches) might help. In general maybe also a solution similar in spirit to Glauber's QEMU Accel tree might be useful. Q has a patch in their tree for instance that hooks into IDE to display disk activity. Food for thought.

Andreas