sdl2: add opengl rendering support
cover sdl2: add opengl rendering support
Hi,
Next round of the opengl rendering support patches.
Changes from RfC:
* new patch #2, adding helper functions to render display surfaces as opengl texture.
* sdl2 opengl code just carries the sdl2-specific bits and calls the opengl console helpers added by patch #2.
* Addressing most (but not yet all) review comments from Max.
* opengl support is runtime-switchable via '-display sdl,gl={on,off}'. Defaults to off atm.
please review,
Gerd
Gerd Hoffmann (4):
configure: opengl overhaul
console: add opengl rendering helper functions
sdl2: add support for display rendering using opengl.
sdl2: move SDL_* includes to sdl2.h
configure | 39 ++++++------ default-configs/lm32-softmmu.mak | 2 +- hw/display/Makefile.objs | 2 +- hw/lm32/milkymist-hw.h | 4 +- include/sysemu/sysemu.h | 1 + include/ui/console.h | 24 ++++++++ include/ui/sdl2.h | 17 ++++++ ui/Makefile.objs | 9 +++ ui/console-gl.c | 127 +++++++++++++++++++++++++++++++++++++++ ui/sdl.c | 11 ++++ ui/sdl2-2d.c | 13 ++-- ui/sdl2-gl.c | 107 +++++++++++++++++++++++++++++++++ ui/sdl2-input.c | 6 -- ui/sdl2.c | 73 ++++++++++++++++++---- vl.c | 12 ++++ 15 files changed, 396 insertions(+), 51 deletions(-) create mode 100644 ui/console-gl.c create mode 100644 ui/sdl2-gl.c
Signature · 1 line
1.8.3.1
PATCH 1/4 configure: opengl overhaul
Rename config option from "glx" to "opengl", glx will not be the only option for opengl in near future. Also switch over to pkg-config for opengl support detection.
--- configure | 39 +++++++++++++++++---------------------- default-configs/lm32-softmmu.mak | 2 +- hw/display/Makefile.objs | 2 +- hw/lm32/milkymist-hw.h | 4 ++-- include/sysemu/sysemu.h | 1 + vl.c | 1 + 6 files changed, 23 insertions(+), 26 deletions(-)
configure +17 -22
@@ -309,7 +309,7 @@ rbd="" smartcard_nss="" libusb="" usb_redir="" -glx="" +opengl="" zlib="yes" lzo="" snappy=""
@@ -1026,9 +1026,9 @@ for opt do ;; --enable-vhost-scsi) vhost_scsi="yes" ;; - --disable-glx) glx="no" + --disable-opengl) opengl="no" ;; - --enable-glx) glx="yes" + --enable-opengl) opengl="yes" ;; --disable-rbd) rbd="no" ;;
@@ -3056,23 +3056,18 @@ fi libs_softmmu="$libs_softmmu $fdt_libs" ########################################## -# GLX probe, used by milkymist-tmu2 -if test "$glx" != "no" ; then - glx_libs="-lGL -lX11" - cat > $TMPC << EOF -#include <X11/Xlib.h> -#include <GL/gl.h> -#include <GL/glx.h> -int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; } -EOF - if compile_prog "" "-lGL -lX11" ; then - glx=yes +# opengl probe, used by milkymist-tmu2 +if test "$opengl" != "no" ; then + opengl_pkgs="gl" + if $pkg_config $opengl_pkgs; then + opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11" + opengl=yes else - if test "$glx" = "yes" ; then - feature_not_found "glx" "Install GL devel (e.g. MESA)" + if test "$opengl" = "yes" ; then + feature_not_found "opengl" "Install GL devel (e.g. MESA)" fi - glx_libs= - glx=no + opengl_libs="" + opengl=no fi fi
@@ -4320,7 +4315,7 @@ echo "xfsctl support $xfs" echo "nss used $smartcard_nss" echo "libusb $libusb" echo "usb net redir $usb_redir" -echo "GLX support $glx" +echo "OpenGL support $opengl" echo "libiscsi support $libiscsi" echo "libnfs support $libnfs" echo "build guest agent $guest_agent"
@@ -4682,9 +4677,9 @@ if test "$usb_redir" = "yes" ; then echo "CONFIG_USB_REDIR=y" >> $config_host_mak fi -if test "$glx" = "yes" ; then - echo "CONFIG_GLX=y" >> $config_host_mak - echo "GLX_LIBS=$glx_libs" >> $config_host_mak +if test "$opengl" = "yes" ; then + echo "CONFIG_OPENGL=y" >> $config_host_mak + echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak fi if test "$lzo" = "yes" ; then
default-configs/lm32-softmmu.mak +1 -1
@@ -2,7 +2,7 @@ CONFIG_LM32=y CONFIG_MILKYMIST=y -CONFIG_MILKYMIST_TMU2=$(CONFIG_GLX) +CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) CONFIG_FRAMEBUFFER=y CONFIG_PTIMER=y CONFIG_PFLASH_CFI01=y
hw/display/Makefile.objs +1 -1
@@ -20,7 +20,7 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o ifeq ($(CONFIG_MILKYMIST_TMU2),y) common-obj-y += milkymist-tmu2.o -libs_softmmu += $(GLX_LIBS) +libs_softmmu += $(OPENGL_LIBS) endif obj-$(CONFIG_OMAP) += omap_dss.o
hw/lm32/milkymist-hw.h +2 -2
@@ -86,7 +86,7 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,return dev; } -#ifdef CONFIG_GLX +#ifdef CONFIG_OPENGL #include <X11/Xlib.h> #include <GL/glx.h> static const int glx_fbconfig_attr[] = {
@@ -100,7 +100,7 @@ static const int glx_fbconfig_attr[] = {static inline DeviceState *milkymist_tmu2_create (hwaddr base,qemu_irq irq) { -#ifdef CONFIG_GLX +#ifdef CONFIG_OPENGL DeviceState *dev;Display *d;GLXFBConfig *configs;
include/sysemu/sysemu.h +1 -0
@@ -117,6 +117,7 @@ extern int graphic_width;extern int graphic_height;extern int graphic_depth;extern DisplayType display_type; +extern int display_opengl;extern const char *keyboard_layout;extern int win2k_install_hack;extern int alt_grab;
vl.c +1 -0
@@ -129,6 +129,7 @@ static int data_dir_idx;const char *bios_name =NULL ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;DisplayType display_type =DT_DEFAULT ; +int display_opengl;static int display_remote;const char * keyboard_layout =NULL ;ram_addr_t ram_size;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 1/4] configure: opengl overhaul
Quoted 5 lines · Gerd Hoffmann
Rename config option from "glx" to "opengl", glx will not be the only option for opengl in near future. Also switch over to pkg-config for opengl support detection.
Signed-off-by Gerd Hoffmann <[email protected]>
Gerd, since you're working in this area, can you pick up
http://article.gmane.org/gmane.comp.emulators.qemu/313402 as well? I had queued it for my next pull request, but it conflicts with your stuff.
Paolo
Quoted 163 lines
--- configure | 39 +++++++++++++++++---------------------- default-configs/lm32-softmmu.mak | 2 +- hw/display/Makefile.objs | 2 +- hw/lm32/milkymist-hw.h | 4 ++-- include/sysemu/sysemu.h | 1 + vl.c | 1 + 6 files changed, 23 insertions(+), 26 deletions(-)configure +17
-22@@ -309,7 +309,7 @@ rbd="" smartcard_nss="" libusb="" usb_redir="" -glx="" +opengl="" zlib="yes" lzo="" snappy=""@@ -1026,9 +1026,9 @@ for opt do ;; --enable-vhost-scsi) vhost_scsi="yes" ;; - --disable-glx) glx="no" + --disable-opengl) opengl="no" ;; - --enable-glx) glx="yes" + --enable-opengl) opengl="yes" ;; --disable-rbd) rbd="no" ;;@@ -3056,23 +3056,18 @@ fi libs_softmmu="$libs_softmmu $fdt_libs" ########################################## -# GLX probe, used by milkymist-tmu2 -if test "$glx" != "no" ; then - glx_libs="-lGL -lX11" - cat > $TMPC << EOF -#include <X11/Xlib.h> -#include <GL/gl.h> -#include <GL/glx.h> -int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; } -EOF - if compile_prog "" "-lGL -lX11" ; then - glx=yes +# opengl probe, used by milkymist-tmu2 +if test "$opengl" != "no" ; then + opengl_pkgs="gl" + if $pkg_config $opengl_pkgs; then + opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11" + opengl=yes else - if test "$glx" = "yes" ; then - feature_not_found "glx" "Install GL devel (e.g. MESA)" + if test "$opengl" = "yes" ; then + feature_not_found "opengl" "Install GL devel (e.g. MESA)" fi - glx_libs= - glx=no + opengl_libs="" + opengl=no fi fi@@ -4320,7 +4315,7 @@ echo "xfsctl support $xfs" echo "nss used $smartcard_nss" echo "libusb $libusb" echo "usb net redir $usb_redir" -echo "GLX support $glx" +echo "OpenGL support $opengl" echo "libiscsi support $libiscsi" echo "libnfs support $libnfs" echo "build guest agent $guest_agent"@@ -4682,9 +4677,9 @@ if test "$usb_redir" = "yes" ; then echo "CONFIG_USB_REDIR=y" >> $config_host_mak fi -if test "$glx" = "yes" ; then - echo "CONFIG_GLX=y" >> $config_host_mak - echo "GLX_LIBS=$glx_libs" >> $config_host_mak +if test "$opengl" = "yes" ; then + echo "CONFIG_OPENGL=y" >> $config_host_mak + echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak fi if test "$lzo" = "yes" ; thendefault-configs/lm32-softmmu.mak +1
-1@@ -2,7 +2,7 @@ CONFIG_LM32=y CONFIG_MILKYMIST=y -CONFIG_MILKYMIST_TMU2=$(CONFIG_GLX) +CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) CONFIG_FRAMEBUFFER=y CONFIG_PTIMER=y CONFIG_PFLASH_CFI01=yhw/display/Makefile.objs +1
-1@@ -20,7 +20,7 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o ifeq ($(CONFIG_MILKYMIST_TMU2),y) common-obj-y += milkymist-tmu2.o -libs_softmmu += $(GLX_LIBS) +libs_softmmu += $(OPENGL_LIBS) endif obj-$(CONFIG_OMAP) += omap_dss.ohw/lm32/milkymist-hw.h +2
-2@@ -86,7 +86,7 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,return dev; } -#ifdef CONFIG_GLX +#ifdef CONFIG_OPENGL #include <X11/Xlib.h> #include <GL/glx.h> static const int glx_fbconfig_attr[] = {@@ -100,7 +100,7 @@ static const int glx_fbconfig_attr[] = {static inline DeviceState *milkymist_tmu2_create (hwaddr base,qemu_irq irq) { -#ifdef CONFIG_GLX +#ifdef CONFIG_OPENGL DeviceState *dev;Display *d;GLXFBConfig *configs;include/sysemu/sysemu.h +1
-0@@ -117,6 +117,7 @@ extern int graphic_width;extern int graphic_height;extern int graphic_depth;extern DisplayType display_type; +extern int display_opengl;extern const char *keyboard_layout;extern int win2k_install_hack;extern int alt_grab;vl.c +1
-0@@ -129,6 +129,7 @@ static int data_dir_idx;const char *bios_name =NULL ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;DisplayType display_type =DT_DEFAULT ; +int display_opengl;static int display_remote;const char * keyboard_layout =NULL ;ram_addr_t ram_size;
Re: [Qemu-devel] [PATCH 1/4] configure: opengl overhaul
Quoted 11 lines · Paolo Bonzini
Quoted 5 lines · Gerd Hoffmann
Rename config option from "glx" to "opengl", glx will not be the only option for opengl in near future. Also switch over to pkg-config for opengl support detection.
Signed-off-by Gerd Hoffmann <[email protected]>Gerd, since you're working in this area, can you pick up
http://article.gmane.org/gmane.comp.emulators.qemu/313402 as well? I had queued it for my next pull request, but it conflicts with your stuff.
Yep, the gl bits conflict, I'll pick it up and handle the conflicts.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/4] configure: opengl overhaul
In reply to Gerd HoffmannQuoted 45 lines · Gerd Hoffmann
Rename config option from "glx" to "opengl", glx will not be the only option for opengl in near future. Also switch over to pkg-config for opengl support detection.
Signed-off-by Gerd Hoffmann <[email protected]>--- configure | 39 +++++++++++++++++---------------------- default-configs/lm32-softmmu.mak | 2 +- hw/display/Makefile.objs | 2 +- hw/lm32/milkymist-hw.h | 4 ++-- include/sysemu/sysemu.h | 1 + vl.c | 1 + 6 files changed, 23 insertions(+), 26 deletions(-)configure +3
-5@@ -309,7 +309,7 @@ rbd="" smartcard_nss="" libusb="" usb_redir="" -glx="" +opengl="" zlib="yes" lzo="" snappy=""@@ -1026,9 +1026,9 @@ for opt do ;; --enable-vhost-scsi) vhost_scsi="yes" ;; - --disable-glx) glx="no" + --disable-opengl) opengl="no" ;; - --enable-glx) glx="yes" + --enable-opengl) opengl="yes" ;; --disable-rbd) rbd="no" ;;@@ -3056,23 +3056,18 @@ fi libs_softmmu="$libs_softmmu $fdt_libs" ########################################## -# GLX probe, used by milkymist-tmu2 -if test "$glx" != "no" ; then
configure fi · line 3059
Quoted 10 lines
configure +1
-9- glx_libs="-lGL -lX11" - cat > $TMPC << EOF -#include <X11/Xlib.h> -#include <GL/gl.h> -#include <GL/glx.h> -int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; } -EOF - if compile_prog "" "-lGL -lX11" ; then - glx=yes +# opengl probe, used by milkymist-tmu2
Maybe remove this part of the comment about milkymist?
configure fi · line 3064
Quoted 5 lines
configure +5
-0+if test "$opengl" != "no" ; then + opengl_pkgs="gl" + if $pkg_config $opengl_pkgs; then + opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11" + opengl=yes
pkg-config gl might be successful even without X11 available. In this case, $opengl will be set to 'yes', but linking will probably fail.
Maybe we should keep GLX separated from OpenGL; for SDL we don't need X11, but for milkymist-tmu2 we apparently do.
Max
Quoted 107 lines
configure +8
-8else - if test "$glx" = "yes" ; then - feature_not_found "glx" "Install GL devel (e.g. MESA)" + if test "$opengl" = "yes" ; then + feature_not_found "opengl" "Install GL devel (e.g. MESA)" fi - glx_libs= - glx=no + opengl_libs="" + opengl=no fi fi@@ -4320,7 +4315,7 @@ echo "xfsctl support $xfs" echo "nss used $smartcard_nss" echo "libusb $libusb" echo "usb net redir $usb_redir" -echo "GLX support $glx" +echo "OpenGL support $opengl" echo "libiscsi support $libiscsi" echo "libnfs support $libnfs" echo "build guest agent $guest_agent"@@ -4682,9 +4677,9 @@ if test "$usb_redir" = "yes" ; then echo "CONFIG_USB_REDIR=y" >> $config_host_mak fi -if test "$glx" = "yes" ; then - echo "CONFIG_GLX=y" >> $config_host_mak - echo "GLX_LIBS=$glx_libs" >> $config_host_mak +if test "$opengl" = "yes" ; then + echo "CONFIG_OPENGL=y" >> $config_host_mak + echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak fi if test "$lzo" = "yes" ; thendefault-configs/lm32-softmmu.mak +1
-1@@ -2,7 +2,7 @@ CONFIG_LM32=y CONFIG_MILKYMIST=y -CONFIG_MILKYMIST_TMU2=$(CONFIG_GLX) +CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL) CONFIG_FRAMEBUFFER=y CONFIG_PTIMER=y CONFIG_PFLASH_CFI01=yhw/display/Makefile.objs +1
-1@@ -20,7 +20,7 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o ifeq ($(CONFIG_MILKYMIST_TMU2),y) common-obj-y += milkymist-tmu2.o -libs_softmmu += $(GLX_LIBS) +libs_softmmu += $(OPENGL_LIBS) endif obj-$(CONFIG_OMAP) += omap_dss.ohw/lm32/milkymist-hw.h +2
-2@@ -86,7 +86,7 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,return dev; } -#ifdef CONFIG_GLX +#ifdef CONFIG_OPENGL #include <X11/Xlib.h> #include <GL/glx.h> static const int glx_fbconfig_attr[] = {@@ -100,7 +100,7 @@ static const int glx_fbconfig_attr[] = {static inline DeviceState *milkymist_tmu2_create (hwaddr base,qemu_irq irq) { -#ifdef CONFIG_GLX +#ifdef CONFIG_OPENGL DeviceState *dev;Display *d;GLXFBConfig *configs;include/sysemu/sysemu.h +1
-0@@ -117,6 +117,7 @@ extern int graphic_width;extern int graphic_height;extern int graphic_depth;extern DisplayType display_type; +extern int display_opengl;extern const char *keyboard_layout;extern int win2k_install_hack;extern int alt_grab;vl.c +1
-0@@ -129,6 +129,7 @@ static int data_dir_idx;const char *bios_name =NULL ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;DisplayType display_type =DT_DEFAULT ; +int display_opengl;static int display_remote;const char * keyboard_layout =NULL ;ram_addr_t ram_size;
Re: [Qemu-devel] [PATCH 1/4] configure: opengl overhaul
Hi,
Quoted 3 lines
Quoted 1 line
+# opengl probe, used by milkymist-tmu2
Maybe remove this part of the comment about milkymist?
Will do.
Quoted 8 lines
configure fi · line 3064
Quoted 5 lines
configure +5
-0+if test "$opengl" != "no" ; then + opengl_pkgs="gl" + if $pkg_config $opengl_pkgs; then + opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11" + opengl=yes
pkg-config glmight be successful even without X11 available. In this case, $opengl will be set to 'yes', but linking will probably fail.
Indeed.
Quoted 2 lines
Maybe we should keep GLX separated from OpenGL; for SDL we don't need X11, but for milkymist-tmu2 we apparently do.
That should be only temporary. There will be infrastructure for device emulations to ask the UI for a opengl context. Once this is in place we should be able to switch over milkymist-tmu2 to that so it doesn't has to initialize opengl on its own.
cheers,
Gerd
PATCH 2/4 console: add opengl rendering helper functions
In reply to Gerd Hoffmann--- include/ui/console.h | 23 ++++++++++ ui/Makefile.objs | 5 ++ ui/console-gl.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 ui/console-gl.c
include/ui/console.h +23 -0
@@ -9,6 +9,11 @@#include "qapi-types.h" #include "qapi/error.h" +#ifdef CONFIG_OPENGL +#include <GL/gl.h> +#include <GL/glext.h> +#endif +/* keyboard/mouse support */ #define MOUSE_EVENT_LBUTTON 0x01
@@ -118,6 +123,11 @@ struct DisplaySurface {pixman_format_code_t format;pixman_image_t *image;uint8_t flags; +#ifdef CONFIG_OPENGL +GLenum glformat; +GLenum gltype; +GLuint texture; +#endif }; typedef struct QemuUIInfo {
@@ -320,6 +330,19 @@ void qemu_console_copy(QemuConsole *con, int src_x, int src_y,DisplaySurface *qemu_console_surface (QemuConsole *con);DisplayState *qemu_console_displaystate (QemuConsole *console); +#ifdef CONFIG_OPENGL +/* console-gl.c */ +bool console_gl_check_format (DisplayChangeListener *dcl, +pixman_format_code_t format); +void surface_gl_create_texture (DisplaySurface *surface); +void surface_gl_update_texture (DisplaySurface *surface, +int x,int y,int w,int h); +void surface_gl_render_texture (DisplaySurface *surface); +void surface_gl_destroy_texture (DisplaySurface *surface); +void surface_gl_setup_viewport (DisplaySurface *surface, +int ww,int wh); +#endif +/* sdl.c */ void sdl_display_init (DisplayState *ds,int full_screen,int no_frame);
ui/Makefile.objs +5 -0
@@ -24,4 +24,9 @@ sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o endif sdl.mo-cflags := $(SDL_CFLAGS) +ifeq ($(CONFIG_OPENGL),y) +common-obj-y += console-gl.o +libs_softmmu += $(OPENGL_LIBS) +endif + gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)
ui/console-gl.c new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 2/4] console: add opengl rendering helper functions
Quoted 5 lines · Gerd Hoffmann
+/*
+ * QEMU graphical console -- opengl helper bits
+ *
+ * Copyright (c) 2004 Fabrice Bellard
+ *
Copyright Red Hat / Author you?
Paolo
Re: [Qemu-devel] [PATCH 2/4] console: add opengl rendering helper functions
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Gerd Hoffmann
+/*
+ * QEMU graphical console -- opengl helper bits
+ *
+ * Copyright (c) 2004 Fabrice Bellard
+ *Copyright Red Hat / Author you?
Ahem, yes. Just carelessly moved over the comment from console.c, which doesn't make much sense given this is all new code ...
cheers,
Gerd
Re: [Qemu-devel] [PATCH 2/4] console: add opengl rendering helper functions
In reply to Gerd HoffmannQuoted 104 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/console.h | 23 ++++++++++ ui/Makefile.objs | 5 ++ ui/console-gl.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+)create mode 100644
ui/console-gl.cinclude/ui/console.h +23
-0@@ -9,6 +9,11 @@#include "qapi-types.h" #include "qapi/error.h" +#ifdef CONFIG_OPENGL +#include <GL/gl.h> +#include <GL/glext.h> +#endif +/* keyboard/mouse support */ #define MOUSE_EVENT_LBUTTON 0x01@@ -118,6 +123,11 @@ struct DisplaySurface {pixman_format_code_t format;pixman_image_t *image;uint8_t flags; +#ifdef CONFIG_OPENGL +GLenum glformat; +GLenum gltype; +GLuint texture; +#endif }; typedef struct QemuUIInfo {@@ -320,6 +330,19 @@ void qemu_console_copy(QemuConsole *con, int src_x, int src_y,DisplaySurface *qemu_console_surface (QemuConsole *con);DisplayState *qemu_console_displaystate (QemuConsole *console); +#ifdef CONFIG_OPENGL +/* console-gl.c */ +bool console_gl_check_format (DisplayChangeListener *dcl, +pixman_format_code_t format); +void surface_gl_create_texture (DisplaySurface *surface); +void surface_gl_update_texture (DisplaySurface *surface, +int x,int y,int w,int h); +void surface_gl_render_texture (DisplaySurface *surface); +void surface_gl_destroy_texture (DisplaySurface *surface); +void surface_gl_setup_viewport (DisplaySurface *surface, +int ww,int wh); +#endif +/* sdl.c */ void sdl_display_init (DisplayState *ds,int full_screen,int no_frame);ui/Makefile.objs +5
-0@@ -24,4 +24,9 @@ sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o endif sdl.mo-cflags := $(SDL_CFLAGS) +ifeq ($(CONFIG_OPENGL),y) +common-obj-y += console-gl.o +libs_softmmu += $(OPENGL_LIBS) +endif + gtk.o-cflags := $(GTK_CFLAGS) $(VTE_CFLAGS)ui/console-gl.c new file +28
-0@@ -0,0 +1,127 @@ +/* +* QEMU graphical console -- opengl helper bits +* +* Copyright (c) 2004 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#include "qemu-common.h" +#include "ui/console.h" + +bool console_gl_check_format (DisplayChangeListener *dcl, +pixman_format_code_t format)
ui/console-gl.c line 38
Quoted 10 lines
ui/console-gl.c new file +10
-0+{ +switch (format) { +case PIXMAN_x8r8g8b8: +case PIXMAN_a8r8g8b8: +case PIXMAN_r5g6b5: +return true; +default : +return false; + } +}
What is this function supposed to be used for?
ui/console-gl.c line 45
Quoted 7 lines
ui/console-gl.c new file +7
-0+ +void surface_gl_create_texture (DisplaySurface *surface) +{ +switch (surface->format) { +case PIXMAN_x8r8g8b8: +case PIXMAN_a8r8g8b8: + surface->glformat =GL_BGRA ;
Why does the format code seem to imply ARGB order but you're using the exact opposite? I could imagine something like endianness being the reason, but you're using RGB below where the format code says exactly that.
Quoted 4 lines
ui/console-gl.c new file +4
-0+ surface->gltype =GL_UNSIGNED_BYTE ; +break ; +case PIXMAN_r5g6b5: + surface->glformat =GL_RGB ;
ui/console-gl.c line 59
Quoted 10 lines
ui/console-gl.c new file +10
-0+ surface->gltype =GL_UNSIGNED_SHORT_5_6_5 ; +break ; +default : +g_assert_not_reached (); + } + +glGenTextures (1 , &surface->texture); +glEnable (GL_TEXTURE_2D ); +glBindTexture (GL_TEXTURE_2D , surface->texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
Discarding the alpha channel is intentional, I suppose?
ui/console-gl.c line 63
Quoted 4 lines
ui/console-gl.c new file +4
-0+surface_width (surface), +surface_height (surface), +0 , surface->glformat, surface->gltype, + surface_data(surface));
Is surface_stride(surface) specified to be surface_width(surface) * bytes_per_pixel (I don't know pixman so I don't know)? If it isn't then this may not work.
Quoted 10 lines
ui/console-gl.c new file +10
-0+ +glTexParameteri (GL_TEXTURE_2D ,GL_TEXTURE_MAG_FILTER ,GL_LINEAR ); +glTexParameteri (GL_TEXTURE_2D ,GL_TEXTURE_MIN_FILTER ,GL_LINEAR ); +} + +void surface_gl_update_texture (DisplaySurface *surface, +int x,int y,int w,int h) +{ +uint8_t *data = (void *)surface_data (surface); +
ui/console-gl.c line 83
Quoted 10 lines
ui/console-gl.c new file +10
-0+glTexSubImage2D (GL_TEXTURE_2D ,0 , +0 , y, +surface_width (surface), h, + surface->glformat, surface->gltype, + data +surface_stride (surface) * y); +} + +void surface_gl_render_texture (DisplaySurface *surface) +{ +glClearColor (0.0 ,0.0 ,0.0 ,0 );
I still find this strange (the RGB values are doubles, the alpha channel is an integer; and actually all parameters are expected to be floats), but I can live with it.
ui/console-gl.c line 90
Quoted 7 lines
ui/console-gl.c new file +7
-0+glClear (GL_COLOR_BUFFER_BIT ); + +glBegin (GL_QUADS ); +glTexCoord2i (0 ,1 );glVertex3i (-1 ,-1 ,0 ); +glTexCoord2i (0 ,0 );glVertex3i (-1 ,1 ,0 ); +glTexCoord2i (1 ,0 );glVertex3i (1 ,1 ,0 ); +glTexCoord2i (1 ,1 );glVertex3i (1 ,-1 ,0 );
I don't know whether I've said it before, but you can use glVertex2i() here.
Quoted 27 lines
ui/console-gl.c new file +27
-0+glEnd (); +} + +void surface_gl_destroy_texture (DisplaySurface *surface) +{ +if (!surface || !surface->texture) { +return ; + } +glDeleteTextures (1 , &surface->texture); + surface->texture =0 ; +} + +void surface_gl_setup_viewport (DisplaySurface *surface, +int ww,int wh) +{ +int gw, gh, stripe; +float sw, sh; + + gw =surface_width (surface); + gh =surface_height (surface); + + sw = (float )ww/gw; + sh = (float )wh/gh; +if (sw < sh) { + stripe = wh - wh*sw/sh; +glViewport (0 , stripe /2 , ww, wh - stripe); + }else {
ui/console-gl.c line 127
Quoted 10 lines
ui/console-gl.c new file +10
-0+ stripe = ww - ww*sh/sw; +glViewport (stripe /2 ,0 , ww - stripe, wh); + } + +glMatrixMode (GL_PROJECTION ); +glLoadIdentity (); + +glMatrixMode (GL_MODELVIEW ); +glLoadIdentity (); +}
Looks fine to me in general.
Max
Re: [Qemu-devel] [PATCH 2/4] console: add opengl rendering helper functions
Hi,
Quoted 6 lines
Quoted 6 lines
ui/console-gl.c new file +6
-0+bool console_gl_check_format (DisplayChangeListener *dcl, +pixman_format_code_t format) +{ +switch (format) { +case PIXMAN_x8r8g8b8: +case PIXMAN_a8r8g8b8:
Quoted 8 lines
ui/console-gl.c line 38
Quoted 6 lines
ui/console-gl.c new file +6
-0+case PIXMAN_r5g6b5: +return true; +default : +return false; + } +}What is this function supposed to be used for?
Inflight change, there is a patch series on the list adding a check_format callback to DisplayChangeListenerOps, for format negotiation.
Quoted 11 lines
ui/console-gl.c line 45
Quoted 7 lines
ui/console-gl.c new file +7
-0+ +void surface_gl_create_texture (DisplaySurface *surface) +{ +switch (surface->format) { +case PIXMAN_x8r8g8b8: +case PIXMAN_a8r8g8b8: + surface->glformat =GL_BGRA ;Why does the format code seem to imply ARGB order but you're using the exact opposite? I could imagine something like endianness being the reason, but you're using RGB below where the format code says exactly that.
endianness indeed. pixman formats are native endian, so this actually is bgra ordering in memory. While looking at it: I guess GL_BGRA is fixed byte ordering? So this probably needs fixing to work correctly on bigendian machines ...
Quoted 1 line
Discarding the alpha channel is intentional, I suppose?
Yes.
Quoted 8 lines
ui/console-gl.c line 63
Quoted 5 lines
ui/console-gl.c new file +4
-0+surface_width (surface), +surface_height (surface), +0 , surface->glformat, surface->gltype, + surface_data(surface));Is
surface_stride(surface)specified to besurface_width(surface)*bytes_per_pixel(I don't know pixman so I don't know)?
Usually this is the case, but there can be exceptions. Hmm, can I explicitly pass the stride?
thanks,
Gerd
Re: [Qemu-devel] [PATCH 2/4] console: add opengl rendering helper functions
Quoted 15 lines · Gerd Hoffmann
Hi,Quoted 5 lines
Quoted 5 lines
ui/console-gl.c new file +5
-0+bool console_gl_check_format (DisplayChangeListener *dcl, +pixman_format_code_t format) +{ +switch (format) { +case PIXMAN_x8r8g8b8:Quoted 8 lines
ui/console-gl.c line 38
Quoted 7 lines
ui/console-gl.c new file +7
-0+case PIXMAN_a8r8g8b8: +case PIXMAN_r5g6b5: +return true; +default : +return false; + } +}What is this function supposed to be used for?
Quoted 3 lines
Inflight change, there is a patch series on the list adding a
check_formatcallback to DisplayChangeListenerOps, for format negotiation.
OK.
Quoted 10 lines
Quoted 10 lines
ui/console-gl.c line 45
Quoted 7 lines
ui/console-gl.c new file +7
-0+ +void surface_gl_create_texture (DisplaySurface *surface) +{ +switch (surface->format) { +case PIXMAN_x8r8g8b8: +case PIXMAN_a8r8g8b8: + surface->glformat =GL_BGRA ;Why does the format code seem to imply ARGB order but you're using the exact opposite? I could imagine something like endianness being the reason, but you're using RGB below where the format code says exactly that.
Quoted 3 lines
endianness indeed. pixman formats are native endian, so this actually is bgra ordering in memory. While looking at it: I guess
GL_BGRAis fixed byte ordering?
Yes, I think so.
Quoted 2 lines
So this probably needs fixing to work correctly on bigendian machines ...
Probably, right.
Quoted 11 lines
Quoted 1 line
Discarding the alpha channel is intentional, I suppose?
Yes.
Quoted 6 lines
ui/console-gl.c line 63
Quoted 4 lines
ui/console-gl.c new file +4
-0+surface_width (surface), +surface_height (surface), +0 , surface->glformat, surface->gltype, + surface_data(surface));Is
surface_stride(surface)specified to besurface_width(surface)*bytes_per_pixel(I don't know pixman so I don't know)?Usually this is the case, but there can be exceptions. Hmm, can I explicitly pass the stride?
The internet™ tells me about glPixelStorei(GL_UNPACK_ROW_LENGTH, $pixels_per_row) and glPixelStorei(GL_UNPACK_ALIGNMENT, $row_alignment_in_bytes) (which need to be called before using glTexImage2D() or glTexSubImage2D()). You may want to use it for surface_gl_update_texture(), too (if that isn't too much work).
Max
PATCH 3/4 sdl2: add support for display rendering using opengl.
In reply to Gerd HoffmannAdd new sdl2-gl.c file, with display
rendering functions using opengl.
--- include/ui/console.h | 1 + include/ui/sdl2.h | 10 +++++ ui/Makefile.objs | 4 ++ ui/sdl.c | 11 +++++ ui/sdl2-2d.c | 7 ++++ ui/sdl2-gl.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 67 ++++++++++++++++++++++++++---- vl.c | 11 +++++ 8 files changed, 218 insertions(+), 7 deletions(-) create mode 100644 ui/sdl2-gl.c
include/ui/console.h +1 -0
@@ -344,6 +344,7 @@ void surface_gl_setup_viewport(DisplaySurface *surface,#endif /* sdl.c */ +void sdl_display_early_init (int opengl);void sdl_display_init (DisplayState *ds,int full_screen,int no_frame);/* cocoa.m */
include/ui/sdl2.h +10 -0
@@ -11,6 +11,9 @@ struct sdl2_console {int last_vm_running;/* per console for caption reasons */ int x, y;int hidden; +int opengl; +int updates; +SDL_GLContext winctx; };void sdl2_window_create (struct sdl2_console *scon);
@@ -29,4 +32,11 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,void sdl2_2d_refresh (DisplayChangeListener *dcl);void sdl2_2d_redraw (struct sdl2_console *scon); +void sdl2_gl_update (DisplayChangeListener *dcl, +int x,int y,int w,int h); +void sdl2_gl_switch (DisplayChangeListener *dcl, +DisplaySurface *new_surface); +void sdl2_gl_refresh (DisplayChangeListener *dcl); +void sdl2_gl_redraw (struct sdl2_console *scon); +#endif /* SDL2_H */
ui/Makefile.objs +4 -0
@@ -21,6 +21,10 @@ sdl.mo-objs := sdl.o sdl_zoom.o endif ifeq ($(CONFIG_SDLABI),2.0) sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o +ifeq ($(CONFIG_OPENGL),y) +sdl.mo-objs += sdl2-gl.o +libs_softmmu += $(OPENGL_LIBS) +endif endif sdl.mo-cflags := $(SDL_CFLAGS)
ui/sdl.c +11 -0
@@ -873,6 +873,17 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = sdl_mouse_define, }; +void sdl_display_early_init (int opengl) +{ +if (opengl ==1 /* on */ ) { +fprintf (stderr, +"SDL1 display code has no opengl support.\n" +"Please recompile qemu with SDL2, using\n" +"./configure --enable-sdl --with-sdlabi=2.0\n" ); +exit (1 ); + } +} +void sdl_display_init (DisplayState *ds,int full_screen,int no_frame) {int flags;
ui/sdl2-2d.c +7 -0
@@ -42,6 +42,8 @@ void sdl2_2d_update(DisplayChangeListener *dcl,DisplaySurface *surf =qemu_console_surface (dcl->con);SDL_Rect rect; +assert (!scon->opengl); +if (!surf) {return ; }
@@ -67,6 +69,8 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,DisplaySurface *old_surface = scon->surface;int format =0 ; +assert (!scon->opengl); + scon->surface = new_surface;if (scon->texture) {
@@ -107,12 +111,15 @@ void sdl2_2d_refresh(DisplayChangeListener *dcl) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); +assert (!scon->opengl);graphic_hw_update (dcl->con);sdl2_poll_events (scon); }void sdl2_2d_redraw (struct sdl2_console *scon) { +assert (!scon->opengl); +if (!scon->surface) {return ; }
ui/sdl2-gl.c new file +114 -0
114 lines not on this page · raw message
ui/sdl2.c +60 -7
120 lines not on this page · raw message
vl.c +11 -0
@@ -1939,6 +1939,7 @@ static DisplayType select_display(const char *p) {const char *opts;DisplayType display =DT_DEFAULT ; +int opengl =-1 ;if (strstart (p,"sdl" , &opts)) {#ifdef CONFIG_SDL
@@ -1982,6 +1983,15 @@ static DisplayType select_display(const char *p) }else { goto invalid_sdl_args; } + }else if (strstart (opts,",gl=" , &nextopt)) { + opts = nextopt; +if (strstart (opts,"on" , &nextopt)) { + opengl =1 ; + }else if (strstart (opts,"off" , &nextopt)) { + opengl =0 ; + }else { + goto invalid_sdl_args; + } }else { invalid_sdl_args:fprintf (stderr,"Invalid SDL option string: %s\n" , p);
@@ -1989,6 +1999,7 @@ static DisplayType select_display(const char *p) } opts = nextopt; } +sdl_display_early_init (opengl);#else fprintf (stderr,"SDL support is disabled\n" );exit (1 );
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 3/4] sdl2: add support for display rendering using opengl.
Quoted 135 lines · Gerd Hoffmann
Add new
sdl2-gl.cfile, with display
rendering functions using opengl.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/console.h | 1 + include/ui/sdl2.h | 10 +++++ ui/Makefile.objs | 4 ++ ui/sdl.c | 11 +++++ ui/sdl2-2d.c | 7 ++++ ui/sdl2-gl.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 67 ++++++++++++++++++++++++++---- vl.c | 11 +++++ 8 files changed, 218 insertions(+), 7 deletions(-)create mode 100644
ui/sdl2-gl.cinclude/ui/console.h +1
-0@@ -344,6 +344,7 @@ void surface_gl_setup_viewport(DisplaySurface *surface,#endif /* sdl.c */ +void sdl_display_early_init (int opengl);void sdl_display_init (DisplayState *ds,int full_screen,int no_frame);/* cocoa.m */ include/ui/sdl2.h +10
-0@@ -11,6 +11,9 @@ struct sdl2_console {int last_vm_running;/* per console for caption reasons */ int x, y;int hidden; +int opengl; +int updates; +SDL_GLContext winctx; };void sdl2_window_create (struct sdl2_console *scon);@@ -29,4 +32,11 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,void sdl2_2d_refresh (DisplayChangeListener *dcl);void sdl2_2d_redraw (struct sdl2_console *scon); +void sdl2_gl_update (DisplayChangeListener *dcl, +int x,int y,int w,int h); +void sdl2_gl_switch (DisplayChangeListener *dcl, +DisplaySurface *new_surface); +void sdl2_gl_refresh (DisplayChangeListener *dcl); +void sdl2_gl_redraw (struct sdl2_console *scon); +#endif /* SDL2_H */ ui/Makefile.objs +4
-0@@ -21,6 +21,10 @@ sdl.mo-objs := sdl.o sdl_zoom.o endif ifeq ($(CONFIG_SDLABI),2.0) sdl.mo-objs := sdl2.o sdl2-input.o sdl2-2d.o +ifeq ($(CONFIG_OPENGL),y) +sdl.mo-objs += sdl2-gl.o +libs_softmmu += $(OPENGL_LIBS) +endif endif sdl.mo-cflags := $(SDL_CFLAGS)ui/sdl.c +11
-0@@ -873,6 +873,17 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = sdl_mouse_define, }; +void sdl_display_early_init (int opengl) +{ +if (opengl ==1 /* on */ ) { +fprintf (stderr, +"SDL1 display code has no opengl support.\n" +"Please recompile qemu with SDL2, using\n" +"./configure --enable-sdl --with-sdlabi=2.0\n" ); +exit (1 ); + } +} +void sdl_display_init (DisplayState *ds,int full_screen,int no_frame) {int flags;ui/sdl2-2d.c +7
-0@@ -42,6 +42,8 @@ void sdl2_2d_update(DisplayChangeListener *dcl,DisplaySurface *surf =qemu_console_surface (dcl->con);SDL_Rect rect; +assert (!scon->opengl); +if (!surf) {return ; }@@ -67,6 +69,8 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,DisplaySurface *old_surface = scon->surface;int format =0 ; +assert (!scon->opengl); + scon->surface = new_surface;if (scon->texture) {@@ -107,12 +111,15 @@ void sdl2_2d_refresh(DisplayChangeListener *dcl) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); +assert (!scon->opengl);graphic_hw_update (dcl->con);sdl2_poll_events (scon); }void sdl2_2d_redraw (struct sdl2_console *scon) { +assert (!scon->opengl); +if (!scon->surface) {return ; }ui/sdl2-gl.c new file +0
-0
ui/sdl2-gl.c line 4
Quoted 4 lines
ui/sdl2-gl.c new file +4
-0@@ -0,0 +1,114 @@ +/* +* QEMU SDL display driver +* +* Copyright (c) 2003 Fabrice Bellard
Just as mentioned by Paolo on patch 2, this may be supposed to mention you instead.
Quoted 10 lines
ui/sdl2-gl.c new file +10
-0+* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software.
ui/sdl2-gl.c line 24
Quoted 10 lines
ui/sdl2-gl.c new file +10
-0+* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */
And this line seems wrong.
Quoted 39 lines
ui/sdl2-gl.c new file +39
-0+ +/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ +#undef WIN32_LEAN_AND_MEAN + +#include <SDL.h> +#include <SDL_syswm.h> +#include <SDL_opengl.h> + +#include "qemu-common.h" +#include "ui/console.h" +#include "ui/input.h" +#include "ui/sdl2.h" +#include "sysemu/sysemu.h" + +static void sdl2_gl_render_surface (struct sdl2_console *scon) +{ +int ww, wh; + +SDL_GL_MakeCurrent (scon->real_window, scon->winctx); + +SDL_GetWindowSize (scon->real_window, &ww, &wh); +surface_gl_setup_viewport (scon->surface, ww, wh); + +surface_gl_render_texture (scon->surface); +SDL_GL_SwapWindow (scon->real_window); +} + +void sdl2_gl_update (DisplayChangeListener *dcl, +int x,int y,int w,int h) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); + +assert (scon->opengl); + +SDL_GL_MakeCurrent (scon->real_window, scon->winctx); +surface_gl_update_texture (scon->surface, x, y, w, h); + scon->updates++; +} +
ui/sdl2-gl.c line 73
Quoted 10 lines
ui/sdl2-gl.c new file +10
-0+void sdl2_gl_switch (DisplayChangeListener *dcl, +DisplaySurface *new_surface) +{ + struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); +DisplaySurface *old_surface = scon->surface; + +assert (scon->opengl); + +SDL_GL_MakeCurrent (scon->real_window, scon->winctx); +surface_gl_destroy_texture (scon->surface);
Can a surface be in use by multiple DCLs? If so, this would probably need reference counting.
Quoted 4 lines
ui/sdl2-gl.c new file +4
-0+ + scon->surface = new_surface; + +if (!new_surface) {
ui/sdl2-gl.c line 87
Quoted 10 lines
ui/sdl2-gl.c new file +10
-0+sdl2_window_destroy (scon); +return ; + } + +if (!scon->real_window) { +sdl2_window_create (scon); + }else if (old_surface && + ((surface_width (old_surface) !=surface_width (new_surface)) || + (surface_height (old_surface) !=surface_height (new_surface)))) { +sdl2_window_resize (scon);
Hm, now that I think about it... If the window is scaled, this will reset the scaling to 100 %. Fine, why not. However, if the new surface has the same dimensions as the old surface, the window will not be scaled. That would seem strange to me.
Apart from this and the question about surfaces used by multiple DCLs at the same time, the patch looks good to me (the option parsing in select_display() in vl.c looks like nightmare fuel, but it's just in line with its environment).
Max
PATCH 4/4 sdl2: move SDL_* includes to sdl2.h
In reply to Gerd Hoffmann--- include/ui/sdl2.h | 7 +++++++ ui/sdl2-2d.c | 6 ------ ui/sdl2-gl.c | 7 ------- ui/sdl2-input.c | 6 ------ ui/sdl2.c | 6 ------ 5 files changed, 7 insertions(+), 25 deletions(-)
include/ui/sdl2.h +7 -0
@@ -1,6 +1,13 @@ #ifndef SDL2_H #define SDL2_H +/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ +#undef WIN32_LEAN_AND_MEAN + +#include <SDL.h> +#include <SDL_syswm.h> +#include <SDL_opengl.h> + struct sdl2_console { DisplayChangeListener dcl; DisplaySurface *surface;
ui/sdl2-2d.c +0 -6
@@ -23,12 +23,6 @@*/ /* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ -/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ -#undef WIN32_LEAN_AND_MEAN - -#include <SDL.h> -#include <SDL_syswm.h> -#include "qemu-common.h" #include "ui/console.h" #include "ui/input.h"
ui/sdl2-gl.c +0 -7
@@ -23,13 +23,6 @@*/ /* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ -/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ -#undef WIN32_LEAN_AND_MEAN - -#include <SDL.h> -#include <SDL_syswm.h> -#include <SDL_opengl.h> -#include "qemu-common.h" #include "ui/console.h" #include "ui/input.h"
ui/sdl2-input.c +0 -6
@@ -23,12 +23,6 @@*/ /* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ -/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ -#undef WIN32_LEAN_AND_MEAN - -#include <SDL.h> -#include <SDL_syswm.h> -#include "qemu-common.h" #include "ui/console.h" #include "ui/input.h"
ui/sdl2.c +0 -6
@@ -23,12 +23,6 @@*/ /* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ -/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ -#undef WIN32_LEAN_AND_MEAN - -#include <SDL.h> -#include <SDL_syswm.h> -#include "qemu-common.h" #include "ui/console.h" #include "ui/input.h"
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 4/4] sdl2: move SDL_* includes to sdl2.h
Quoted 8 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/sdl2.h | 7 +++++++ ui/sdl2-2d.c | 6 ------ ui/sdl2-gl.c | 7 ------- ui/sdl2-input.c | 6 ------ ui/sdl2.c | 6 ------ 5 files changed, 7 insertions(+), 25 deletions(-)