QEMU and OpenGL.
      3D acceleration landing in UIs and display devices.
       
      Gerd Hoffmann <kraxel@redhat.com>
      KVM Forum 2015, Seattle
    
    
      Outline.
      
        - vga emulation news.
        
- virtio-gpu (2d only).
        
          - multihead & input devices.
        
 
- OpenGL coming to qemu.
        
- virtio-gpu and 3d (virgl).
      
vga: cirrus
      
        - Mimics existing hardware from 90ies which can't match todays needs.
        
- It is not our default display device any more (on x86).
        
- d43f0d6 vga: flip qemu 2.2 pc machine types from cirrus to stdvga
      
vga: stdvga
      
        - New default vga device (x86).
        
- bochs-drm.ko kms driver (linux 3.14).
        
- framebuffer endian register (qemu 2.2, linux 3.19).
        
- framebuffer endian property (qemu 2.3).
        
- page flip support, for wayland (linux 3.19).
        
- configurable video memory (libvirt 1.2.11).
        
          - Handles 4k just fine (unlike cirrus).
        
 
- Not accelerated, but solid baseline.
      
set any video mode using xrandr
      #!/bin/sh
width="$1"; height="$2"
if test "$width" = "" -o "$height" = ""; then
	echo "usage: $0 width height"; exit 1
fi
output=$(xrandr --query | awk '/ connected/ { print $1; exit }')
mode="${width}x${height}"
xrandr --query | grep -q -e " $mode "
if test "$?" != "0"; then
	ml=$(cvt $width $height | grep Modeline | cut -d" " -f3-)
	xrandr --newmode "$mode" $ml
	xrandr --addmode "$output" "$mode"
fi
xrandr --output "$output" --mode "$mode"
    
    
      vga: virtio
      
        - virtio-gpu.ko kms driver (linux 4.2).
        
- virtio-vga and virtio-gpu-pci emulation (qemu 2.4).
        
- vga emulation is compatible to stdvga.
        
- Initial merge, supporting 2d mode only.
        
- Adapts to window size.
        
          - Uses monitor hotplug events, gnome-shell handles it (like on physical hardware).
          
- No virt-specific guest agent needed (unlike spice/qxl).
        
 
- Supports multihead.
        
          - Disabled by default, use max_outputs property to enable.
          
- Some details such as tablet support still to be sorted.
          
- Needs more testing.
        
 
multihead, tablets and input routing
      
        - Plan: act like touchscreens do on phyiscal hardware.
        
- Each monitor gets one window (on the host) and one tablet device.
        
- Host: link windows to tablets using input routing:
 -device virtio-vga,id=$vga
 -device usb-tablet,display=$vga,head={0,1}
	    -vnc $vncargs,display=$vga,head={0,1}
- Guest: link tablets to monitors:
 xinput --map-to-output $id $crtc.
- TODO: figure how to do guest setup automatically.
      
console/ui: Initial OpenGL support (qemu 2.4)
      
        - Fills texture with guest display (DisplaySurface).
        
- Render texture using OpenGL.
        
- Disabled by default, turn on using qemu -display $ui,gl=on.
        
- UIs supported in qemu 2.4: SDL2, gtk (using egl).
      
next steps for OpenGL support (qemu 2.5 ?)
      
        - console/ui: allow display devices use OpenGL
        
          - Add callbacks to ui (DisplayChangeListenerOps).
          
- OpenGL context management.
          
- Define output texture, trigger updates.
        
 
- virtio-gpu: add OpenGL support.
        
          - virtio ops to define resources, create contexts etc.
          
- guest sends gallium command stream.
          
- use virglrenderer library to render into a texture.
        
 
Better OpenGL support for gtk (qemu 2.5 ?)
      
        - gtk 3.16 (released March 2015) adds native OpenGL support.
        
          - GtkGLArea widget.
          
- GdkGLContext (in gdk).
        
 
- Add support for that (and prefer over egl code if available).
        
- Should expand OpenGL support to non-X11 platforms: windows, wayland.
      
Headless OpenGL support
      
        - Don't require access to the display manager (x11, wayland).
        
- Using render nodes, export guest display texture as dma-buf.
        
- proof-of-concept egl ui:
        
          - qemu -name $name -display -egl.
          
- qemu-eglview $name.
          
- long-term plans not yet clear.
        
 
- spice integration.
      
Intel vGPU integration
      
        - Intel is busy integrating vgpu into the i915 kvm driver.
        
- guest display will be exported as dma-buf.
        
- qemu can pass-on the dma-buf handle (headless).
        
- qemu can import the dma-buf as texture (gtk).
      
OpenGL remote display
      
        - To be solved.
        
- Hardware assisted video encoding?
        
          - Patches for that are about to land in gstreamer.
          
- H.264 patent situation not helpful.
        
 
Check it out
      
        - Host: cutting edge mesa (10.6) and libepoxy (1.3.1)
        
          - Required for dma-buf support.
          
- egl ui will be disabled with older versions.
        
 
- Host: Install virglrenderer library.
        
- Host: Build qemu, virgl branch.
        
- Guest: Install mesa driver.
        
- Guest: xorg driver.
          - Not needed any more, xorg uses OpenGL for 2d rendering too (glamor).
        
 
Resources
      
        - Slides
        
        
- git repos
        
        
- copr repos
        
      
      
      /