Make Pixman an optional dependency
v6 cover Make Pixman an optional dependency
From: Marc-André Lureau <[email protected]>
Hi,
QEMU system emulators can be made to compile and work without Pixman.
Only a few devices and options actually require it (VNC, Gtk, Spice for ex) and will have to be compiled out.
However, most of QEMU graphics-related code is based on pixman_image_t and format. If we want to provide mostly compatible QEMU machines with or without Pixman, all we need to do is to have a small compatibility header with just the bare minimum for those types (see "ui: add pixman-compat.h"). There are a limited number of operations related to geometry that are slightly better implemented in QEMU (without Pixman, see "virtio-gpu: replace PIXMAN for region/rect test").
Without this simple compatibility header approach, QEMU at runtime becomes a very different emulator (without graphics device/board, display etc) and full of "if PIXMAN" conditions in the code. This is a much worse outcome imho, compared to this small header maintainance and compatibility story.
Fixes:
https://gitlab.com/qemu-project/qemu/-/issues/1172
v6:
- add "build-sys: drop needless warning pragmas for old pixman"
- rename pixman-compat.h -> pixman-minimal.h
- add "vl: drop needless -spice checks"
- add "qemu-options: define -vnc only #ifdef CONFIG_VNC"
- add "vl: simplify display_remote logic"
- in "vl: move display early init before default devices", rename the introduced function qemu_setup_display()
- adapt "hw/sm501: allow compiling without PIXMAN" following Zoltan review, using warn_report(), droping Error argument
- various r-b/a-b
v5:
- fixed "vl: move display early init before default devices" patch
v4:
- added "vl: move display early init before default devices" patch
- code style fixes
- a-b from Zoltan
v3:
- improve transient meson condition in first patch (Paolo)
- use muxed console as fallback by default (Paolo)
- make pixman-compat.h closer to original API
- keep "x-pixman" property for sm501 (Zoltan)
Marc-André Lureau (23):
build-sys: add a "pixman" feature
build-sys: drop needless warning pragmas for old pixman
ui: compile out some qemu-pixman functions when !PIXMAN
ui: add pixman-minimal.h
vl: drop needless -spice checks
qemu-options: define -vnc only #ifdef CONFIG_VNC
vl: simplify display_remote logic
vl: move display early init before default devices ui/console: allow to override the default VC
ui/vc: console-vc requires PIXMAN
qmp/hmp: disable screendump if PIXMAN is missing
virtio-gpu: replace PIXMAN for region/rect test ui/console: when PIXMAN is unavailable, don't draw placeholder msg
vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN ui/gl: opengl doesn't require PIXMAN
ui/vnc: VNC requires PIXMAN
ui/spice: SPICE/QXL requires PIXMAN
ui/gtk: -display gtk requires PIXMAN
ui/dbus: do not require PIXMAN
arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN hw/sm501: allow compiling without PIXMAN
hw/display: make ATI_VGA depend on PIXMAN
build-sys: make pixman actually optional
configs/devices/mips64el-softmmu/default.mak | 2 +- meson.build | 25 ++- qapi/ui.json | 3 +- include/ui/console.h | 2 + include/ui/pixman-minimal.h | 195 +++++++++++++++++++ include/ui/qemu-pixman.h | 15 +- include/ui/rect.h | 59 ++++++ hw/display/sm501.c | 46 +++-- hw/display/vhost-user-gpu.c | 2 + hw/display/virtio-gpu.c | 30 ++- system/vl.c | 84 ++++---- ui/console-vc-stubs.c | 33 ++++ ui/console.c | 19 ++ ui/dbus-listener.c | 90 ++++++--- ui/qemu-pixman.c | 6 + ui/ui-hmp-cmds.c | 2 + ui/ui-qmp-cmds.c | 2 + ui/vnc-stubs.c | 12 -- Kconfig.host | 3 + hmp-commands.hx | 2 + hw/arm/Kconfig | 3 +- hw/display/Kconfig | 9 +- hw/display/meson.build | 4 +- meson_options.txt | 2 + qemu-options.hx | 2 + scripts/meson-buildoptions.sh | 3 + ui/meson.build | 22 +-- 27 files changed, 539 insertions(+), 138 deletions(-) create mode 100644 include/ui/pixman-minimal.h create mode 100644 include/ui/rect.h create mode 100644 ui/console-vc-stubs.c
Signature · 1 line
2.41.0
PATCH v6 1/23 build-sys: add a "pixman" feature
From: Marc-André Lureau <[email protected]>
For now, pixman is mandatory, but we set config_host.h and Kconfig. Once compilation is fixed, "pixman" will become actually optional.
--- meson.build | 10 ++++++++-- include/ui/qemu-pixman.h | 2 ++ Kconfig.host | 3 +++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 5 files changed, 18 insertions(+), 2 deletions(-)
meson.build +8 -2
@@ -813,10 +813,14 @@ if 'ust' in get_option('trace_backends') method: 'pkg-config') endif pixman = not_found -if have_system or have_tools - pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8', +if not get_option('pixman').auto() or have_system or have_tools + pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', method: 'pkg-config') endif +if not pixman.found() and (have_system or have_tools) + error('FIXME: pixman is currently required') +endif + zlib = dependency('zlib', required: true) libaio = not_found
@@ -2125,6 +2129,7 @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found()) if seccomp.found() config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc) endif +config_host_data.set('CONFIG_PIXMAN', pixman.found()) config_host_data.set('CONFIG_SNAPPY', snappy.found()) config_host_data.set('CONFIG_SOLARIS', targetos == 'sunos') if get_option('tcg').allowed()
@@ -2844,6 +2849,7 @@ have_ivshmem = config_host_data.get('CONFIG_EVENTFD') host_kconfig = \ (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \ (have_tpm ? ['CONFIG_TPM=y'] : []) + \ + (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \ (spice.found() ? ['CONFIG_SPICE=y'] : []) + \ (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \ (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \
include/ui/qemu-pixman.h +2 -0
@@ -6,11 +6,13 @@#ifndef QEMU_PIXMAN_H #define QEMU_PIXMAN_H +#ifdef CONFIG_PIXMAN /* pixman-0.16.0 headers have a redundant declaration */ #pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wredundant-decls"#include <pixman.h> #pragma GCC diagnostic pop +#endif /* * pixman image formats are defined to be native endian,
Kconfig.host +3 -0
@@ -11,6 +11,9 @@ config OPENGL config X11 bool +config PIXMAN + bool + config SPICE bool
meson_options.txt +2 -0
@@ -224,6 +224,8 @@ option('l2tpv3', type : 'feature', value : 'auto', description: 'l2tpv3 network backend support') option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') +option('pixman', type : 'feature', value : 'auto', + description: 'pixman support') option('slirp', type: 'feature', value: 'auto', description: 'libslirp user mode network backend support') option('vde', type : 'feature', value : 'auto',
scripts/meson-buildoptions.sh +3 -0
@@ -159,6 +159,7 @@ meson_options_help() { printf "%s\n" ' pa PulseAudio sound support' printf "%s\n" ' parallels parallels image format support' printf "%s\n" ' pipewire PipeWire sound support' + printf "%s\n" ' pixman pixman support' printf "%s\n" ' plugins TCG plugins via shared library loading' printf "%s\n" ' png PNG support with libpng' printf "%s\n" ' pvrdma Enable PVRDMA support'
@@ -416,6 +417,8 @@ _meson_option_parse() { --disable-parallels) printf "%s" -Dparallels=disabled ;; --enable-pipewire) printf "%s" -Dpipewire=enabled ;; --disable-pipewire) printf "%s" -Dpipewire=disabled ;; + --enable-pixman) printf "%s" -Dpixman=enabled ;; + --disable-pixman) printf "%s" -Dpixman=disabled ;; --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;; --enable-plugins) printf "%s" -Dplugins=true ;; --disable-plugins) printf "%s" -Dplugins=false ;;
Signature · 1 line
2.41.0
PATCH v6 2/23 build-sys: drop needless warning pragmas for old pixman
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Since commit 236f282c1c7 ("configure: check for pixman-1 version"), QEMU requires >= 0.21.8.
--- include/ui/qemu-pixman.h | 4 ---- 1 file changed, 4 deletions(-)
include/ui/qemu-pixman.h +0 -4
@@ -7,11 +7,7 @@#define QEMU_PIXMAN_H #ifdef CONFIG_PIXMAN -/* pixman-0.16.0 headers have a redundant declaration */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wredundant-decls"#include <pixman.h> -#pragma GCC diagnostic pop#endif /*
Signature · 1 line
2.41.0
Re: [PATCH v6 02/23] build-sys: drop needless warning pragmas for old pixman
Quoted 17 lines · On 25/10/2023 21.07, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Since commit
236f282c1c7("configure: check for pixman-1 version"), QEMU requires >= 0.21.8.Suggested-by Thomas Huth <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- include/ui/qemu-pixman.h | 4 ---- 1 file changed, 4 deletions(-)include/ui/qemu-pixman.h +0
-0@@ -7,11 +7,7 @@#define QEMU_PIXMAN_H
include/ui/qemu-pixman.h line 13
Quoted 10 lines
include/ui/qemu-pixman.h +0
-4#ifdef CONFIG_PIXMAN -/* pixman-0.16.0 headers have a redundant declaration */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wredundant-decls"#include <pixman.h> -#pragma GCC diagnostic pop#endif /*
PATCH v6 3/23 ui: compile out some qemu-pixman functions when !PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Those functions require the PIXMAN library.
--- include/ui/qemu-pixman.h | 7 +++++-- ui/qemu-pixman.c | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
include/ui/qemu-pixman.h +5 -2
@@ -72,17 +72,17 @@ pixman_format_code_t qemu_default_pixman_format(int bpp, bool native_endian);pixman_format_code_t qemu_drm_format_to_pixman (uint32_t drm_format);uint32_t qemu_pixman_to_drm_format (pixman_format_code_t pixman);int qemu_pixman_get_type (int rshift,int gshift,int bshift); -pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf);bool qemu_pixman_check_format (DisplayChangeListener *dcl,pixman_format_code_t format); +#ifdef CONFIG_PIXMAN +pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf);pixman_image_t *qemu_pixman_linebuf_create (pixman_format_code_t format,int width);void qemu_pixman_linebuf_fill (pixman_image_t *linebuf,pixman_image_t *fb,int width,int x,int y);pixman_image_t *qemu_pixman_mirror_create (pixman_format_code_t format,pixman_image_t *image); -void qemu_pixman_image_unref (pixman_image_t *image);pixman_image_t *qemu_pixman_glyph_from_vgafont (int height,const uint8_t *font,unsigned int ch);
@@ -91,6 +91,9 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, pixman_color_t *fgcol, pixman_color_t *bgcol, int x, int y, int cw, int ch); +#endif + +void qemu_pixman_image_unref (pixman_image_t *image);G_DEFINE_AUTOPTR_CLEANUP_FUNC (pixman_image_t, qemu_pixman_image_unref)
ui/qemu-pixman.c +6 -0
@@ -145,6 +145,7 @@ int qemu_pixman_get_type(int rshift, int gshift, int bshift)return type; } +#ifdef CONFIG_PIXMAN pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf) {pixman_format_code_t format;
@@ -158,6 +159,7 @@ pixman_format_code_t qemu_pixman_get_format(PixelFormat *pf) }return format; } +#endif /* * Return true for known-good pixman conversions.
@@ -186,6 +188,7 @@ bool qemu_pixman_check_format(DisplayChangeListener *dcl, } } +#ifdef CONFIG_PIXMAN pixman_image_t *qemu_pixman_linebuf_create (pixman_format_code_t format,int width) {
@@ -211,6 +214,7 @@ pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,NULL , pixman_image_get_stride(image)); } +#endif void qemu_pixman_image_unref (pixman_image_t *image) {
@@ -220,6 +224,7 @@ void qemu_pixman_image_unref(pixman_image_t *image)pixman_image_unref (image); } +#ifdef CONFIG_PIXMAN pixman_image_t *qemu_pixman_glyph_from_vgafont (int height,const uint8_t *font,unsigned int ch) {
@@ -262,3 +267,4 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph,pixman_image_unref (ifg); pixman_image_unref(ibg); } +#endif /* CONFIG_PIXMAN */
Signature · 1 line
2.41.0
PATCH v6 4/23 ui: add pixman-minimal.h
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This is a tiny subset of PIXMAN API that is used pervasively in QEMU codebase to manage images and identify the underlying format.
It doesn't seems worth to wrap this in a QEMU-specific API.
--- include/ui/pixman-minimal.h | 195 ++++++++++++++++++++++++++++++++++++ include/ui/qemu-pixman.h | 2 + 2 files changed, 197 insertions(+) create mode 100644 include/ui/pixman-minimal.h
include/ui/pixman-minimal.h new file +195 -0
@@ -0,0 +1,195 @@ +/* +* SPDX-License-Identifier: MIT +* +* Tiny subset of PIXMAN API commonly used by QEMU. +* +* Copyright 1987, 1988, 1989, 1998 The Open Group +* Copyright 1987, 1988, 1989 Digital Equipment Corporation +* Copyright 1999, 2004, 2008 Keith Packard +* Copyright 2000 SuSE, Inc. +* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc. +* Copyright 2004, 2005, 2007, 2008, 2009, 2010 Red Hat, Inc. +* Copyright 2004 Nicholas Miell +* Copyright 2005 Lars Knoll & Zack Rusin, Trolltech +* Copyright 2005 Trolltech AS +* Copyright 2007 Luca Barbato +* Copyright 2008 Aaron Plattner, NVIDIA Corporation +* Copyright 2008 Rodrigo Kumpera +* Copyright 2008 André Tupinambá +* Copyright 2008 Mozilla Corporation +* Copyright 2008 Frederic Plourde +* Copyright 2009, Oracle and/or its affiliates. All rights reserved. +* Copyright 2009, 2010 Nokia Corporation +* +* 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 (including the next +* paragraph) 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. +*/ + +#ifndef PIXMAN_MINIMAL_H +#define PIXMAN_MINIMAL_H + +#define PIXMAN_TYPE_OTHER 0 +#define PIXMAN_TYPE_ARGB 2 +#define PIXMAN_TYPE_ABGR 3 +#define PIXMAN_TYPE_BGRA 8 +#define PIXMAN_TYPE_RGBA 9 + +#define PIXMAN_FORMAT (bpp, type, a, r, g, b) (((bpp) << 24) | \ + ((type) << 16) | \ + ((a) << 12) | \ + ((r) << 8) | \ + ((g) << 4) | \ + ((b))) + +#define PIXMAN_FORMAT_RESHIFT (val, ofs, num) \ + (((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3)) + +#define PIXMAN_FORMAT_BPP (f) PIXMAN_FORMAT_RESHIFT(f, 24, 8) +#define PIXMAN_FORMAT_TYPE (f) (((f) >> 16) & 0x3f) +#define PIXMAN_FORMAT_A (f) PIXMAN_FORMAT_RESHIFT(f, 12, 4) +#define PIXMAN_FORMAT_R (f) PIXMAN_FORMAT_RESHIFT(f, 8, 4) +#define PIXMAN_FORMAT_G (f) PIXMAN_FORMAT_RESHIFT(f, 4, 4) +#define PIXMAN_FORMAT_B (f) PIXMAN_FORMAT_RESHIFT(f, 0, 4) +#define PIXMAN_FORMAT_DEPTH (f) (PIXMAN_FORMAT_A(f) + \ + PIXMAN_FORMAT_R(f) + \ + PIXMAN_FORMAT_G(f) + \ + PIXMAN_FORMAT_B(f)) + +typedef enum { +/* 32bpp formats */ + PIXMAN_a8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,8 ,8 ,8 ,8 ), + PIXMAN_x8r8g8b8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_a8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,8 ,8 ,8 ,8 ), + PIXMAN_x8b8g8r8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,8 ,8 ,8 ,8 ), + PIXMAN_b8g8r8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_BGRA ,0 ,8 ,8 ,8 ), + PIXMAN_r8g8b8a8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,8 ,8 ,8 ,8 ), + PIXMAN_r8g8b8x8 =PIXMAN_FORMAT (32 ,PIXMAN_TYPE_RGBA ,0 ,8 ,8 ,8 ), +/* 24bpp formats */ + PIXMAN_r8g8b8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ARGB ,0 ,8 ,8 ,8 ), + PIXMAN_b8g8r8 =PIXMAN_FORMAT (24 ,PIXMAN_TYPE_ABGR ,0 ,8 ,8 ,8 ), +/* 16bpp formats */ + PIXMAN_r5g6b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,6 ,5 ), + PIXMAN_a1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,1 ,5 ,5 ,5 ), + PIXMAN_x1r5g5b5 =PIXMAN_FORMAT (16 ,PIXMAN_TYPE_ARGB ,0 ,5 ,5 ,5 ), +}pixman_format_code_t ; + +typedef struct pixman_image pixman_image_t ; + +typedef void (*pixman_image_destroy_func_t )(pixman_image_t *image,void *data); + +struct pixman_image { +int ref_count; +pixman_format_code_t format; +int width; +int height; +int stride; +uint32_t *data; +uint32_t *free_me; +pixman_image_destroy_func_t destroy_func; +void *destroy_data; +}; + +typedef struct pixman_color { +uint16_t red; +uint16_t green; +uint16_t blue; +uint16_t alpha; +}pixman_color_t ; + +static inline pixman_image_t *pixman_image_create_bits (pixman_format_code_t format, +int width, +int height, +uint32_t *bits, +int rowstride_bytes) +{ +pixman_image_t *i =g_new0 (pixman_image_t,1 ); + + i->width = width; + i->height = height; + i->stride = rowstride_bytes ?: width *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (format),8 ); + i->format = format; +if (bits) { + i->data = bits; + }else { + i->free_me = i->data =g_malloc0 (rowstride_bytes * height); + } + i->ref_count =1 ; + +return i; +} + +static inline pixman_image_t *pixman_image_ref (pixman_image_t *i) +{ + i->ref_count++; +return i; +} + +static inline bool pixman_image_unref (pixman_image_t *i) +{ + i->ref_count--; + +if (i->ref_count ==0 ) { +if (i->destroy_func) { + i->destroy_func (i, i->destroy_data); + } +g_free (i->free_me); +g_free (i); + +return true; + } + +return false; +} + +static inline void pixman_image_set_destroy_function (pixman_image_t *i, +pixman_image_destroy_func_t func, +void *data) + +{ + i->destroy_func = func; + i->destroy_data = data; +} + +static inline uint32_t *pixman_image_get_data (pixman_image_t *i) +{ +return i->data; +} + +static inline int pixman_image_get_height (pixman_image_t *i) +{ +return i->height; +} + +static inline int pixman_image_get_width (pixman_image_t *i) +{ +return i->width; +} + +static inline int pixman_image_get_stride (pixman_image_t *i) +{ +return i->stride; +} + +static inline pixman_format_code_t pixman_image_get_format (pixman_image_t *i) +{ +return i->format; +} + +#endif /* PIXMAN_MINIMAL_H */
include/ui/qemu-pixman.h +2 -0
@@ -8,6 +8,8 @@#ifdef CONFIG_PIXMAN #include <pixman.h> +#else +#include "pixman-minimal.h" #endif /*
Signature · 1 line
2.41.0
PATCH v6 5/23 vl: drop needless -spice checks
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Since commit 5324e3e958e ("qemu-options: define -spice only #ifdef CONFIG_SPICE"), it is unnecessary to check at runtime for "-spice" option.
--- system/vl.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
system/vl.c +1 -6
@@ -3475,12 +3475,7 @@ void qemu_init(int argc, char **argv)break ;#ifdef CONFIG_SPICE case QEMU_OPTION_spice: - olist =qemu_find_opts_err ("spice" ,NULL ); -if (!olist) { -error_report ("spice support is disabled" ); -exit (1 ); - } - opts =qemu_opts_parse_noisily (olist, optarg, false); + opts =qemu_opts_parse_noisily (qemu_find_opts ("spice" ), optarg, false);if (!opts) {exit (1 ); }
Signature · 1 line
2.41.0
Re: [PATCH v6 05/23] vl: drop needless -spice checks
Quoted 19 lines · On 25/10/2023 21.07, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Since commit
5324e3e958e("qemu-options: define -spice only #ifdefCONFIG_SPICE"), it is unnecessary to check at runtime for "-spice" option.Signed-off-by Marc-André Lureau <[email protected]>--- system/vl.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)system/vl.c +0
-0@@ -3475,12 +3475,7 @@ void qemu_init(int argc, char **argv)break ;#ifdef CONFIG_SPICE case QEMU_OPTION_spice:
system/vl.c void qemu_init(int argc, char **argv) · line 3481
Quoted 10 lines
system/vl.c +1
-6- olist =qemu_find_opts_err ("spice" ,NULL ); -if (!olist) { -error_report ("spice support is disabled" ); -exit (1 ); - } - opts =qemu_opts_parse_noisily (olist, optarg, false); + opts =qemu_opts_parse_noisily (qemu_find_opts ("spice" ), optarg, false);if (!opts) {exit (1 ); }
PATCH v6 6/23 qemu-options: define -vnc only #ifdef CONFIG_VNC
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- system/vl.c | 13 +++++++++---- ui/vnc-stubs.c | 12 ------------ qemu-options.hx | 2 ++ 3 files changed, 11 insertions(+), 16 deletions(-)
system/vl.c +9 -4
@@ -1095,13 +1095,14 @@ DisplayOptions *qmp_query_display_options(Error **errp)static void parse_display (const char *p) { -const char *opts; -if (is_help_option (p)) {qemu_display_help ();exit (0 ); } +#ifdef CONFIG_VNC +const char *opts; +if (strstart (p,"vnc" , &opts)) {/* * vnc isn't a (local) DisplayType but a protocol for remote
@@ -1113,9 +1114,11 @@ static void parse_display(const char *p)error_report ("VNC requires a display argument vnc=<display>" ); exit(1); } - }else { -parse_display_qapi (p); +return ; } +#endif + +parse_display_qapi (p); }static inline bool nonempty_str (const char *str)
@@ -3344,9 +3347,11 @@ void qemu_init(int argc, char **argv)machine_parse_property_opt (qemu_find_opts ("smp-opts" ),"smp" , optarg);break ; +#ifdef CONFIG_VNC case QEMU_OPTION_vnc:vnc_parse (optarg);break ; +#endif case QEMU_OPTION_no_acpi:warn_report ("-no-acpi is deprecated, use '-machine acpi=off' instead" );qdict_put_str (machine_opts_dict,"acpi" ,"off" );
ui/vnc-stubs.c +0 -12
@@ -10,15 +10,3 @@ int vnc_display_pw_expire(const char *id, time_t expires) {return -ENODEV ; }; -void vnc_parse (const char *str) -{ -if (strcmp (str,"none" ) ==0 ) { -return ; - } -error_setg (&error_fatal,"VNC support is disabled" ); -} -int vnc_init_func (void *opaque,QemuOpts *opts,Error **errp) -{ -error_setg (errp,"VNC support is disabled" ); -return -1 ; -}
qemu-options.hx +2 -0
@@ -2424,8 +2424,10 @@ SRST OBP. ERST +#ifdef CONFIG_VNC DEF("vnc", HAS_ARG, QEMU_OPTION_vnc , "-vnc <display> shorthand for -display vnc=<display>\n", QEMU_ARCH_ALL) +#endif SRST ``-vnc display[,option[,option[,...]]]`` Normally, if QEMU is compiled with graphical window support, it
Signature · 1 line
2.41.0
Re: [PATCH v6 06/23] qemu-options: define -vnc only #ifdef CONFIG_VNC
Quoted 8 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- system/vl.c | 13 +++++++++---- ui/vnc-stubs.c | 12 ------------ qemu-options.hx | 2 ++ 3 files changed, 11 insertions(+), 16 deletions(-)
PATCH v6 7/23 vl: simplify display_remote logic
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Bump the display_remote variable when the -vnc option is parsed, just like -spice.
--- system/vl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
system/vl.c +1 -5
@@ -1401,11 +1401,6 @@ static void qemu_create_default_devices(void)#endif } -#if defined(CONFIG_VNC ) -if (!QTAILQ_EMPTY (&(qemu_find_opts ("vnc" )->head))) { - display_remote++; - } -#endif if (dpy.type ==DISPLAY_TYPE_DEFAULT && !display_remote) {if (!qemu_display_find_default (&dpy)) { dpy.type =DISPLAY_TYPE_NONE ;
@@ -3350,6 +3345,7 @@ void qemu_init(int argc, char **argv)#ifdef CONFIG_VNC case QEMU_OPTION_vnc:vnc_parse (optarg); + display_remote++;break ;#endif case QEMU_OPTION_no_acpi:
Signature · 1 line
2.41.0
Re: [PATCH v6 07/23] vl: simplify display_remote logic
Quoted 27 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Bump the
display_remotevariable when the -vnc option is parsed, just like -spice.Signed-off-by Marc-André Lureau <[email protected]>--- system/vl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)system/vl.c +0
-5@@ -1401,11 +1401,6 @@ static void qemu_create_default_devices(void)#endif } -#if defined(CONFIG_VNC ) -if (!QTAILQ_EMPTY (&(qemu_find_opts ("vnc" )->head))) { - display_remote++; - } -#endif if (dpy.type ==DISPLAY_TYPE_DEFAULT && !display_remote) {if (!qemu_display_find_default (&dpy)) { dpy.type =DISPLAY_TYPE_NONE ;
system/vl.c void qemu_init(int argc, char **argv) · line 3351
Quoted 7 lines
system/vl.c +1
-0@@ -3350,6 +3345,7 @@ void qemu_init(int argc, char **argv)#ifdef CONFIG_VNC case QEMU_OPTION_vnc:vnc_parse (optarg); + display_remote++;break ;#endif case QEMU_OPTION_no_acpi:
PATCH v6 8/23 vl: move display early init before default devices
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The next commit needs to have the display registered itself before creating the default VCs.
--- system/vl.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
system/vl.c +18 -13
@@ -1352,6 +1352,23 @@ static void qemu_disable_default_devices(void) } } +static void qemu_setup_display (void ) +{ +if (dpy.type ==DISPLAY_TYPE_DEFAULT && !display_remote) { +if (!qemu_display_find_default (&dpy)) { + dpy.type =DISPLAY_TYPE_NONE ; +#if defined(CONFIG_VNC ) +vnc_parse ("localhost:0,to=99,id=default" ); +#endif + } + } +if (dpy.type ==DISPLAY_TYPE_DEFAULT ) { + dpy.type =DISPLAY_TYPE_NONE ; + } + +qemu_display_early_init (&dpy); +} +static void qemu_create_default_devices (void ) {MachineClass *machine_class =MACHINE_GET_CLASS (current_machine);
@@ -1401,18 +1418,6 @@ static void qemu_create_default_devices(void)#endif } -if (dpy.type ==DISPLAY_TYPE_DEFAULT && !display_remote) { -if (!qemu_display_find_default (&dpy)) { - dpy.type =DISPLAY_TYPE_NONE ; -#if defined(CONFIG_VNC ) -vnc_parse ("localhost:0,to=99,id=default" ); -#endif - } - } -if (dpy.type ==DISPLAY_TYPE_DEFAULT ) { - dpy.type =DISPLAY_TYPE_NONE ; - } -/* If no default VGA is requested, the default is "none". */ if (default_vga) { vga_model =get_default_vga_model (machine_class);
@@ -1937,7 +1942,6 @@ static void qemu_create_early_backends(void) "ignoring option"); } -qemu_display_early_init (&dpy);qemu_console_early_init ();if (dpy.has_gl && dpy.gl !=DISPLAYGL_MODE_OFF && display_opengl ==0 ) {
@@ -3666,6 +3670,7 @@ void qemu_init(int argc, char **argv)suspend_mux_open ();qemu_disable_default_devices (); +qemu_setup_display ();qemu_create_default_devices ();qemu_create_early_backends ();
Signature · 1 line
2.41.0
Re: [PATCH v6 08/23] vl: move display early init before default devices
Quoted 9 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The next commit needs to have the display registered itself before creating the default VCs.
Signed-off-by Marc-André Lureau <[email protected]>--- system/vl.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
PATCH v6 9/23 ui/console: allow to override the default VC
In reply to [email protected]From: Marc-André Lureau <[email protected]>
If a display is backed by a specialized VC, allow to override the default "vc:80Cx24C". For that, set the dpy.type just before creating the default serial/parallel/monitor.
As suggested by Paolo, if the display doesn't implement a VC (get_vc() returns NULL), use a fallback that will use a muxed console on stdio.
This changes the behaviour of "qemu -display none", to create a muxed serial/monitor by default.
--- include/ui/console.h | 2 ++ system/vl.c | 27 +++++++++++++++++---------- ui/console.c | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-)
include/ui/console.h +2 -0
@@ -462,12 +462,14 @@ struct QemuDisplay {DisplayType type;void (*early_init)(DisplayOptions *opts);void (*init)(DisplayState *ds,DisplayOptions *opts); +const char *vc; };void qemu_display_register (QemuDisplay *ui);bool qemu_display_find_default (DisplayOptions *opts);void qemu_display_early_init (DisplayOptions *opts);void qemu_display_init (DisplayState *ds,DisplayOptions *opts); +const char *qemu_display_get_vc (DisplayOptions *opts);void qemu_display_help (void );/* vnc.c */
system/vl.c +17 -10
@@ -1372,6 +1372,7 @@ static void qemu_setup_display(void)static void qemu_create_default_devices (void ) {MachineClass *machine_class =MACHINE_GET_CLASS (current_machine); +const char *vc =qemu_display_get_vc (&dpy);if (is_daemonized ()) {/* According to documentation and historically, -nographic redirects
@@ -1390,24 +1391,30 @@ static void qemu_create_default_devices(void) } } -if (nographic) { -if (default_parallel) +if (nographic || (!vc && !is_daemonized () &&isatty (STDOUT_FILENO ))) { +if (default_parallel) {add_device_config (DEV_PARALLEL ,"null" ); + }if (default_serial && default_monitor) {add_device_config (DEV_SERIAL ,"mon:stdio" ); }else { -if (default_serial) +if (default_serial) {add_device_config (DEV_SERIAL ,"stdio" ); -if (default_monitor) + } +if (default_monitor) {monitor_parse ("stdio" ,"readline" , false); + } } }else { -if (default_serial) -add_device_config (DEV_SERIAL ,"vc:80Cx24C" ); -if (default_parallel) -add_device_config (DEV_PARALLEL ,"vc:80Cx24C" ); -if (default_monitor) -monitor_parse ("vc:80Cx24C" ,"readline" , false); +if (default_serial) { +add_device_config (DEV_SERIAL , vc ?:"null" ); + } +if (default_parallel) { +add_device_config (DEV_PARALLEL , vc ?:"null" ); + } +if (default_monitor && vc) { +monitor_parse (vc,"readline" , false); + } }if (default_net) {
ui/console.c +14 -0
@@ -1675,6 +1675,20 @@ void qemu_display_init(DisplayState *ds, DisplayOptions *opts) dpys[opts->type]->init (ds, opts); } +const char *qemu_display_get_vc (DisplayOptions *opts) +{ +assert (opts->type <DISPLAY_TYPE__MAX ); +if (opts->type ==DISPLAY_TYPE_NONE ) { +return NULL ; + } +assert (dpys[opts->type] !=NULL ); +if (dpys[opts->type]->vc) { +return dpys[opts->type]->vc; + }else { +return "vc:80Cx24C" ; + } +} +void qemu_display_help (void ) {int idx;
Signature · 1 line
2.41.0
Re: [PATCH v6 09/23] ui/console: allow to override the default VC
Quoted 6 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
If a display is backed by a specialized VC, allow to override the default "vc:80Cx24C". For that, set the dpy.type just before creating the default serial/parallel/monitor.
Quoted 8 lines
As suggested by Paolo, if the display doesn't implement a VC (
get_vc()returns NULL), use a fallback that will use a muxed console on stdio.This changes the behaviour of "qemu -display none", to create a muxed serial/monitor by default.
Signed-off-by Marc-André Lureau <[email protected]>---
Re: [PATCH v6 09/23] ui/console: allow to override the default VC
In reply to [email protected]Quoted 9 lines · On Wed, Oct 25, 2023 at 11:08:03PM +0400, [email protected] wrote:
If a display is backed by a specialized VC, allow to override the default "vc:80Cx24C". For that, set the dpy.type just before creating the default serial/parallel/monitor.
As suggested by Paolo, if the display doesn't implement a VC (
get_vc()returns NULL), use a fallback that will use a muxed console on stdio.This changes the behaviour of "qemu -display none", to create a muxed serial/monitor by default.
Have you verified that this doesn't break libvirt? We use '-display none' for every single VM we run.
Signature · 1 line
Andrea Bolognani / Red Hat / Virtualization
Re: [PATCH v6 09/23] ui/console: allow to override the default VC
Quoted 5 lines · Andrea Bolognani
Quoted 4 lines · On Wed, Oct 25, 2023 at 11:08:03PM +0400, [email protected] wrote:
If a display is backed by a specialized VC, allow to override the default "vc:80Cx24C". For that, set the dpy.type just before creating the default serial/parallel/monitor.
Quoted 8 lines
Quoted 5 lines
As suggested by Paolo, if the display doesn't implement a VC (
get_vc()returns NULL), use a fallback that will use a muxed console on stdio.This changes the behaviour of "qemu -display none", to create a muxed serial/monitor by default.
Have you verified that this doesn't break libvirt? We use '-display none' for every single VM we run.
IIUC we're ok as this logic appears to be skipped when -nodefaults is set.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v6 10/23 ui/vc: console-vc requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Add stubs for the fallback paths.
get_vc() now returns NULL by default if !PIXMAN.
--- ui/console-vc-stubs.c | 33 +++++++++++++++++++++++++++++++++ ui/console.c | 3 +++ ui/meson.build | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 ui/console-vc-stubs.c
ui/console-vc-stubs.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* QEMU VC stubs +*/ +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "chardev/char.h" +#include "ui/console-priv.h" + +void qemu_text_console_select (QemuTextConsole *c) +{ +} + +const char * +qemu_text_console_get_label (QemuTextConsole *c) +{ +return NULL ; +} + +void qemu_text_console_update_cursor (void ) +{ +} + +void qemu_text_console_handle_keysym (QemuTextConsole *s,int keysym) +{ +} + +void qemu_console_early_init (void ) +{ +}
ui/console.c +3 -0
@@ -1685,8 +1685,11 @@ const char *qemu_display_get_vc(DisplayOptions *opts)if (dpys[opts->type]->vc) {return dpys[opts->type]->vc; }else { +#ifdef CONFIG_PIXMAN return "vc:80Cx24C" ; +#endif } +return NULL ; }void qemu_display_help (void )
ui/meson.build +1 -1
@@ -6,7 +6,6 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', - 'console-vc.c', 'cursor.c', 'input-keymap.c', 'input-legacy.c',
@@ -19,6 +18,7 @@ system_ss.add(files( 'ui-qmp-cmds.c', 'util.c', )) +system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) endif
Signature · 1 line
2.41.0
PATCH v6 11/23 qmp/hmp: disable screendump if PIXMAN is missing
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The command requires color conversion and line-by-line feeding. We could have a simple fallback for simple formats though.
--- qapi/ui.json | 3 ++- ui/ui-hmp-cmds.c | 2 ++ ui/ui-qmp-cmds.c | 2 ++ hmp-commands.hx | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-)
qapi/ui.json +2 -1
@@ -200,7 +200,8 @@ { 'command': 'screendump', 'data': {'filename': 'str', '*device': 'str', '*head': 'int', '*format': 'ImageFormat'}, - 'coroutine': true } + 'coroutine': true, + 'if': 'CONFIG_PIXMAN' } ## # == Spice
ui/ui-hmp-cmds.c +2 -0
@@ -437,6 +437,7 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) } } +#ifdef CONFIG_PIXMAN void coroutine_fnhmp_screendump (Monitor *mon,const QDict *qdict) {
@@ -458,6 +459,7 @@ hmp_screendump(Monitor *mon, const QDict *qdict) end: hmp_handle_error(mon, err); } +#endif void hmp_client_migrate_info (Monitor *mon,const QDict *qdict) {
ui/ui-qmp-cmds.c +2 -0
@@ -212,6 +212,7 @@ void qmp_client_migrate_info(const char *protocol, const char *hostname,error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"protocol" ,"'spice'" ); } +#ifdef CONFIG_PIXMAN #ifdef CONFIG_PNG /** * png_save: Take a screenshot as PNG
@@ -391,3 +392,4 @@ qmp_screendump(const char *filename, const char *device, } } } +#endif /* CONFIG_PIXMAN */
hmp-commands.hx +2 -0
@@ -252,6 +252,7 @@ SRST ERST +#ifdef CONFIG_PIXMAN { .name = "screendump", .args_type = "filename:F,format:-fs,device:s?,head:i?",
@@ -267,6 +268,7 @@ SRST ``screendump`` *filename* Save screen into PPM image *filename*. ERST +#endif { .name = "logfile",
Signature · 1 line
2.41.0
PATCH v6 12/23 virtio-gpu: replace PIXMAN for region/rect test
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Use a simpler implementation for rectangle geometry & intersect, drop the need for (more complex) PIXMAN functions.
--- include/ui/rect.h | 59 +++++++++++++++++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 30 ++++++++------------- 2 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 include/ui/rect.h
include/ui/rect.h new file +59 -0
@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_RECT_H +#define QEMU_RECT_H + +#include <stdint.h> +#include <stdbool.h> + +typedef struct QemuRect { +int16_t x; +int16_t y; +uint16_t width; +uint16_t height; +}QemuRect ; + +static inline void qemu_rect_init (QemuRect *rect, +int16_t x,int16_t y, +uint16_t width,uint16_t height) +{ + rect->x = x; + rect->y = x; + rect->width = width; + rect->height = height; +} + +static inline void qemu_rect_translate (QemuRect *rect, +int16_t dx,int16_t dy) +{ + rect->x += dx; + rect->y += dy; +} + +static inline bool qemu_rect_intersect (const QemuRect *a,const QemuRect *b, +QemuRect *res) +{ +int16_t x1, x2, y1, y2; + + x1 =MAX (a->x, b->x); + y1 =MAX (a->y, b->y); + x2 =MIN (a->x + a->width, b->x + b->width); + y2 =MIN (a->y + a->height, b->y + b->height); + +if (x1 >= x2 || y1 >= y2) { +if (res) { +qemu_rect_init (res,0 ,0 ,0 ,0 ); + } + +return false; + } + +if (res) { +qemu_rect_init (res, x1, y1, x2 - x1, y2 - y1); + } + +return true; +} + +#endif
hw/display/virtio-gpu.c +11 -19
@@ -16,6 +16,7 @@#include "qemu/iov.h" #include "sysemu/cpus.h" #include "ui/console.h" +#include "ui/rect.h" #include "trace.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h"
@@ -503,7 +504,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,struct virtio_gpu_simple_resource *res;struct virtio_gpu_resource_flush rf;struct virtio_gpu_scanout *scanout; -pixman_region16_t flush_region; +QemuRect flush_rect;bool within_bounds = false;bool update_submitted = false;int i;
@@ -565,34 +566,25 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,return ; } -pixman_region_init_rect (&flush_region, - rf.r.x, rf.r.y, rf.r.width, rf.r.height); +qemu_rect_init (&flush_rect, rf.r.x, rf.r.y, rf.r.width, rf.r.height);for (i =0 ; i < g->parent_obj.conf.max_outputs; i++) { -pixman_region16_t region, finalregion; -pixman_box16_t *extents; +QemuRect rect;if (!(res->scanout_bitmask & (1 << i))) {continue ; } scanout = &g->parent_obj.scanout[i]; -pixman_region_init (&finalregion); -pixman_region_init_rect (®ion, scanout->x, scanout->y, - scanout->width, scanout->height); +qemu_rect_init (&rect, scanout->x, scanout->y, + scanout->width, scanout->height); -pixman_region_intersect (&finalregion, &flush_region, ®ion); -pixman_region_translate (&finalregion, -scanout->x, -scanout->y); - extents =pixman_region_extents (&finalregion);/* work out the area we need to update for each console */ -dpy_gfx_update (g->parent_obj.scanout[i].con, - extents->x1, extents->y1, - extents->x2 - extents->x1, - extents->y2 - extents->y1); - -pixman_region_fini (®ion); -pixman_region_fini (&finalregion); +if (qemu_rect_intersect (&flush_rect, &rect, &rect)) { +qemu_rect_translate (&rect, -scanout->x, -scanout->y); +dpy_gfx_update (g->parent_obj.scanout[i].con, + rect.x, rect.y, rect.width, rect.height); + } } -pixman_region_fini (&flush_region); }static void virtio_unref_resource (pixman_image_t *image,void *data)
Signature · 1 line
2.41.0
Re: [PATCH v6 12/23] virtio-gpu: replace PIXMAN for region/rect test
Quoted 68 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Use a simpler implementation for rectangle geometry & intersect, drop the need for (more complex) PIXMAN functions.
Signed-off-by Marc-André Lureau <[email protected]>---
include/ui/rect.h| 59 +++++++++++++++++++++++++++++++++++++++++hw/display/virtio-gpu.c| 30 ++++++++-------------2 files changed, 70 insertions(+), 19 deletions(-)create mode 100644
include/ui/rect.hinclude/ui/rect.h new file +49
-0@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_RECT_H +#define QEMU_RECT_H + +#include <stdint.h> +#include <stdbool.h> + +typedef struct QemuRect { +int16_t x; +int16_t y; +uint16_t width; +uint16_t height; +}QemuRect ; + +static inline void qemu_rect_init (QemuRect *rect, +int16_t x,int16_t y, +uint16_t width,uint16_t height) +{ + rect->x = x; + rect->y = x; + rect->width = width; + rect->height = height; +} + +static inline void qemu_rect_translate (QemuRect *rect, +int16_t dx,int16_t dy) +{ + rect->x += dx; + rect->y += dy; +} + +static inline bool qemu_rect_intersect (const QemuRect *a,const QemuRect *b, +QemuRect *res) +{ +int16_t x1, x2, y1, y2; + + x1 =MAX (a->x, b->x); + y1 =MAX (a->y, b->y); + x2 =MIN (a->x + a->width, b->x + b->width); + y2 =MIN (a->y + a->height, b->y + b->height); + +if (x1 >= x2 || y1 >= y2) { +if (res) { +qemu_rect_init (res,0 ,0 ,0 ,0 ); + } + +return false;
include/ui/rect.h line 59
Quoted 10 lines
include/ui/rect.h new file +10
-0+ } + +if (res) { +qemu_rect_init (res, x1, y1, x2 - x1, y2 - y1); + } + +return true; +} + +#endif
Maybe you could move these to pixman-minimal.h as well implementing the missing pixman_region funcs so no need to change the callers? But I don't mind either way.
Regards,
BALATON Zoltan
Quoted 66 lines
hw/display/virtio-gpu.c +11
-19@@ -16,6 +16,7 @@#include "qemu/iov.h" #include "sysemu/cpus.h" #include "ui/console.h" +#include "ui/rect.h" #include "trace.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h" @@ -503,7 +504,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,struct virtio_gpu_simple_resource *res;struct virtio_gpu_resource_flush rf;struct virtio_gpu_scanout *scanout; -pixman_region16_t flush_region; +QemuRect flush_rect;bool within_bounds = false;bool update_submitted = false;int i;@@ -565,34 +566,25 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,return ; } -pixman_region_init_rect (&flush_region, - rf.r.x, rf.r.y, rf.r.width, rf.r.height); +qemu_rect_init (&flush_rect, rf.r.x, rf.r.y, rf.r.width, rf.r.height);for (i =0 ; i < g->parent_obj.conf.max_outputs; i++) { -pixman_region16_t region, finalregion; -pixman_box16_t *extents; +QemuRect rect;if (!(res->scanout_bitmask & (1 << i))) {continue ; } scanout = &g->parent_obj.scanout[i]; -pixman_region_init (&finalregion); -pixman_region_init_rect (®ion, scanout->x, scanout->y, - scanout->width, scanout->height); +qemu_rect_init (&rect, scanout->x, scanout->y, + scanout->width, scanout->height); -pixman_region_intersect (&finalregion, &flush_region, ®ion); -pixman_region_translate (&finalregion, -scanout->x, -scanout->y); - extents =pixman_region_extents (&finalregion);/* work out the area we need to update for each console */ -dpy_gfx_update (g->parent_obj.scanout[i].con, - extents->x1, extents->y1, - extents->x2 - extents->x1, - extents->y2 - extents->y1); - -pixman_region_fini (®ion); -pixman_region_fini (&finalregion); +if (qemu_rect_intersect (&flush_rect, &rect, &rect)) { +qemu_rect_translate (&rect, -scanout->x, -scanout->y); +dpy_gfx_update (g->parent_obj.scanout[i].con, + rect.x, rect.y, rect.width, rect.height); + } } -pixman_region_fini (&flush_region); }static void virtio_unref_resource (pixman_image_t *image,void *data)
Re: [PATCH v6 12/23] virtio-gpu: replace PIXMAN for region/rect test
Hi
Quoted 76 lines · BALATON Zoltan
Quoted 74 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Use a simpler implementation for rectangle geometry & intersect, drop the need for (more complex) PIXMAN functions.
Signed-off-by Marc-André Lureau <[email protected]>---
include/ui/rect.h| 59 +++++++++++++++++++++++++++++++++++++++++hw/display/virtio-gpu.c| 30 ++++++++-------------2 files changed, 70 insertions(+), 19 deletions(-)create mode 100644
include/ui/rect.hinclude/ui/rect.h new file +55
-0@@ -0,0 +1,59 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_RECT_H +#define QEMU_RECT_H + +#include <stdint.h> +#include <stdbool.h> + +typedef struct QemuRect { +int16_t x; +int16_t y; +uint16_t width; +uint16_t height; +}QemuRect ; + +static inline void qemu_rect_init (QemuRect *rect, +int16_t x,int16_t y, +uint16_t width,uint16_t height) +{ + rect->x = x; + rect->y = x; + rect->width = width; + rect->height = height; +} + +static inline void qemu_rect_translate (QemuRect *rect, +int16_t dx,int16_t dy) +{ + rect->x += dx; + rect->y += dy; +} + +static inline bool qemu_rect_intersect (const QemuRect *a,const QemuRect *b, +QemuRect *res) +{ +int16_t x1, x2, y1, y2; + + x1 =MAX (a->x, b->x); + y1 =MAX (a->y, b->y); + x2 =MIN (a->x + a->width, b->x + b->width); + y2 =MIN (a->y + a->height, b->y + b->height); + +if (x1 >= x2 || y1 >= y2) { +if (res) { +qemu_rect_init (res,0 ,0 ,0 ,0 ); + } + +return false; + } + +if (res) { +qemu_rect_init (res, x1, y1, x2 - x1, y2 - y1); + } +
Quoted 9 lines
include/ui/rect.h line 59
Quoted 4 lines
include/ui/rect.h new file +4
-0+ return true; +} + +#endif Maybe you could move these to
pixman-minimal.has well implementing the missingpixman_regionfuncs so no need to change the callers? But I don't mind either way.
The pixman region functions are more complex than what we actually need in QEMU (simple rectangle geometry).
Quoted 69 lines
Regards,
BALATON ZoltanQuoted 66 lines
hw/display/virtio-gpu.c +11
-19@@ -16,6 +16,7 @@#include "qemu/iov.h" #include "sysemu/cpus.h" #include "ui/console.h" +#include "ui/rect.h" #include "trace.h" #include "sysemu/dma.h" #include "sysemu/sysemu.h" @@ -503,7 +504,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,struct virtio_gpu_simple_resource *res;struct virtio_gpu_resource_flush rf;struct virtio_gpu_scanout *scanout; -pixman_region16_t flush_region; +QemuRect flush_rect;bool within_bounds = false;bool update_submitted = false;int i;@@ -565,34 +566,25 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,return ; } -pixman_region_init_rect (&flush_region, - rf.r.x, rf.r.y, rf.r.width, rf.r.height); +qemu_rect_init (&flush_rect, rf.r.x, rf.r.y, rf.r.width, rf.r.height);for (i =0 ; i < g->parent_obj.conf.max_outputs; i++) { -pixman_region16_t region, finalregion; -pixman_box16_t *extents; +QemuRect rect;if (!(res->scanout_bitmask & (1 << i))) {continue ; } scanout = &g->parent_obj.scanout[i]; -pixman_region_init (&finalregion); -pixman_region_init_rect (®ion, scanout->x, scanout->y, - scanout->width, scanout->height); +qemu_rect_init (&rect, scanout->x, scanout->y, + scanout->width, scanout->height); -pixman_region_intersect (&finalregion, &flush_region, ®ion); -pixman_region_translate (&finalregion, -scanout->x, -scanout->y); - extents =pixman_region_extents (&finalregion);/* work out the area we need to update for each console */ -dpy_gfx_update (g->parent_obj.scanout[i].con, - extents->x1, extents->y1, - extents->x2 - extents->x1, - extents->y2 - extents->y1); - -pixman_region_fini (®ion); -pixman_region_fini (&finalregion); +if (qemu_rect_intersect (&flush_rect, &rect, &rect)) { +qemu_rect_translate (&rect, -scanout->x, -scanout->y); +dpy_gfx_update (g->parent_obj.scanout[i].con, + rect.x, rect.y, rect.width, rect.height); + } } -pixman_region_fini (&flush_region); }static void virtio_unref_resource (pixman_image_t *image,void *data)
Signature · 1 line
Marc-André Lureau
PATCH v6 13/23 ui/console: when PIXMAN is unavailable, don't draw placeholder msg
In reply to [email protected]From: Marc-André Lureau <[email protected]>
When we can't draw text, simply show a blank display.
--- ui/console.c | 2 ++ 1 file changed, 2 insertions(+)
ui/console.c +2 -0
@@ -584,6 +584,7 @@ DisplaySurface *qemu_create_placeholder_surface(int w, int h, const char *msg) {DisplaySurface *surface =qemu_create_displaysurface (w, h); +#ifdef CONFIG_PIXMAN pixman_color_t bg =QEMU_PIXMAN_COLOR_BLACK ;pixman_color_t fg =QEMU_PIXMAN_COLOR_GRAY ;pixman_image_t *glyph;
@@ -598,6 +599,7 @@ DisplaySurface *qemu_create_placeholder_surface(int w, int h, x+i, y, FONT_WIDTH, FONT_HEIGHT); qemu_pixman_image_unref(glyph); } +#endif surface->flags |=QEMU_PLACEHOLDER_FLAG ;return surface; }
Signature · 1 line
2.41.0
PATCH v6 14/23 vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
This simply means that 2d drawing updates won't be handled, but 3d should work.
--- hw/display/vhost-user-gpu.c | 2 ++ 1 file changed, 2 insertions(+)
hw/display/vhost-user-gpu.c +2 -0
@@ -307,6 +307,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)dpy_gl_update (con, m->x, m->y, m->width, m->height);break ; } +#ifdef CONFIG_PIXMAN case VHOST_USER_GPU_UPDATE : {VhostUserGpuUpdate *m = &msg->payload.update;
@@ -334,6 +335,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) }break ; } +#endif default :g_warning ("unhandled message %d %d" , msg->request, msg->size); }
Signature · 1 line
2.41.0
Re: [PATCH v6 14/23] vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN
Quoted 4 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This simply means that 2d drawing updates won't be handled, but 3d should work.
Does this silently break guest display when !PIXMAN or I don't understand what this means (I don't know how this device works). If it causes missing display without PIXMAN should this need pixman or print a warning about that?
Regards,
BALATON Zoltan
Quoted 27 lines
Signed-off-by Marc-André Lureau <[email protected]>---
hw/display/vhost-user-gpu.c| 2 ++1 file changed, 2 insertions(+)hw/display/vhost-user-gpu.c +2
-0@@ -307,6 +307,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)dpy_gl_update (con, m->x, m->y, m->width, m->height);break ; } +#ifdef CONFIG_PIXMAN case VHOST_USER_GPU_UPDATE : {VhostUserGpuUpdate *m = &msg->payload.update;@@ -334,6 +335,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) }break ; } +#endif default :g_warning ("unhandled message %d %d" , msg->request, msg->size); }
Re: [PATCH v6 14/23] vhost-user-gpu: skip VHOST_USER_GPU_UPDATE when !PIXMAN
Hi
Quoted 11 lines · BALATON Zoltan
Quoted 4 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
This simply means that 2d drawing updates won't be handled, but 3d should work.
Does this silently break guest display when !PIXMAN or I don't understand what this means (I don't know how this device works). If it causes missing display without PIXMAN should this need pixman or print a warning about that?
The 2D updates will not be displayed. There will be a warning of "unhandled message 8" for each update.
3D updates are still handled, so you could skip the boot phase until the guest 3d driver is loaded, or you could have a vhost-user-gpu backend that only provides 3D updates (aka dmabuf)
Quoted 31 lines
Regards,
BALATON ZoltanQuoted 27 lines
Signed-off-by Marc-André Lureau <[email protected]>---
hw/display/vhost-user-gpu.c| 2 ++1 file changed, 2 insertions(+)hw/display/vhost-user-gpu.c +2
-0@@ -307,6 +307,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)dpy_gl_update (con, m->x, m->y, m->width, m->height);break ; } +#ifdef CONFIG_PIXMAN case VHOST_USER_GPU_UPDATE : {VhostUserGpuUpdate *m = &msg->payload.update;@@ -334,6 +335,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) }break ; } +#endif default :g_warning ("unhandled message %d %d" , msg->request, msg->size); }
Signature · 1 line
Marc-André Lureau
PATCH v6 15/23 ui/gl: opengl doesn't require PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The QEMU fallback covers the requirements. We still need the flags of header inclusion with CONFIG_PIXMAN.
--- ui/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ui/meson.build +2 -2
@@ -60,8 +60,8 @@ endif system_ss.add(opengl) if opengl.found() opengl_ss = ss.source_set() - opengl_ss.add(gbm) - opengl_ss.add(when: [opengl, pixman], + opengl_ss.add(gbm, pixman) + opengl_ss.add(when: [opengl], if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c')) ui_modules += {'opengl' : opengl_ss} endif
Signature · 1 line
2.41.0
Re: [PATCH v6 15/23] ui/gl: opengl doesn't require PIXMAN
Quoted 15 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The QEMU fallback covers the requirements. We still need the flags of header inclusion with
CONFIG_PIXMAN.Signed-off-by Marc-André Lureau <[email protected]>--- ui/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)ui/meson.build +0
-0
ui/meson.build endif · line 63
Quoted 6 lines
ui/meson.build +1
-2@@ -60,8 +60,8 @@ endif system_ss.add(opengl) if opengl.found() opengl_ss = ss.source_set() - opengl_ss.add(gbm) - opengl_ss.add(when: [opengl, pixman], + opengl_ss.add(gbm, pixman)
I don't quite get the above line (sorry, meson ignorant here) ... does "pixman" simply get ignored here if it has not been found?
Thomas
Quoted 4 lines
ui/meson.build +1
-0+ opengl_ss.add(when: [opengl], if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c')) ui_modules += {'opengl' : opengl_ss} endif
Re: [PATCH v6 15/23] ui/gl: opengl doesn't require PIXMAN
Hi
Quoted 12 lines · Thomas Huth
Quoted 10 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The QEMU fallback covers the requirements. We still need the flags of header inclusion with
CONFIG_PIXMAN.Signed-off-by Marc-André Lureau <[email protected]>--- ui/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines
ui/meson.build endif · line 63
Quoted 11 lines
ui/meson.build +1
-2@@ -60,8 +60,8 @@ endif system_ss.add(opengl) if opengl.found() opengl_ss = ss.source_set() - opengl_ss.add(gbm) - opengl_ss.add(when: [opengl, pixman], + opengl_ss.add(gbm, pixman)I don't quite get the above line (sorry, meson ignorant here) ... does "pixman" simply get ignored here if it has not been found?
Yes, when it is 'not_found", it's simply ignored. Essentially, this is making pixman from required to optional to build the opengl source set.
Signature · 1 line
Marc-André Lureau
Thomas Huth
Reviewed-byRe: [PATCH v6 15/23] ui/gl: opengl doesn't require PIXMAN
Quoted 31 lines · Marc-André Lureau
Hi
Quoted 12 lines · Thomas Huth
Quoted 10 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The QEMU fallback covers the requirements. We still need the flags of header inclusion with
CONFIG_PIXMAN.Signed-off-by Marc-André Lureau <[email protected]>--- ui/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 15 lines
ui/meson.build endif · line 63
Quoted 11 lines
ui/meson.build +1
-2@@ -60,8 +60,8 @@ endif system_ss.add(opengl) if opengl.found() opengl_ss = ss.source_set() - opengl_ss.add(gbm) - opengl_ss.add(when: [opengl, pixman], + opengl_ss.add(gbm, pixman)I don't quite get the above line (sorry, meson ignorant here) ... does "pixman" simply get ignored here if it has not been found?
Quoted 3 lines
Yes, when it is '
not_found", it's simply ignored. Essentially, this is making pixman from required to optional to build the opengl source set.
All right, then I think the patch is fine:
But one more cosmetic question:
+ opengl_ss.add(when: [opengl],
if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
Do we still need the "when: [opengl]" part here? ... there is already the "if opengl.found()" earlier in this file, so it looks like this is not necessary anymore now?
Thomas
Re: [PATCH v6 15/23] ui/gl: opengl doesn't require PIXMAN
Hi
Quoted 43 lines · Thomas Huth
Quoted 31 lines · Marc-André Lureau
Hi
Quoted 12 lines · Thomas Huth
Quoted 10 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
The QEMU fallback covers the requirements. We still need the flags of header inclusion with
CONFIG_PIXMAN.Signed-off-by Marc-André Lureau <[email protected]>--- ui/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 15 lines
ui/meson.build endif · line 63
Quoted 11 lines
ui/meson.build +1
-2@@ -60,8 +60,8 @@ endif system_ss.add(opengl) if opengl.found() opengl_ss = ss.source_set() - opengl_ss.add(gbm) - opengl_ss.add(when: [opengl, pixman], + opengl_ss.add(gbm, pixman)I don't quite get the above line (sorry, meson ignorant here) ... does "pixman" simply get ignored here if it has not been found?
Quoted 3 lines
Yes, when it is '
not_found", it's simply ignored. Essentially, this is making pixman from required to optional to build the opengl source set.All right, then I think the patch is fine:
Reviewed-by Thomas Huth <[email protected]>But one more cosmetic question:
Quoted 7 lines
+ opengl_ss.add(when: [opengl],
if_true: files('shader.c', 'console-gl.c','
egl-helpers.c', 'egl-context.c'))Do we still need the "when: [opengl]" part here? ... there is already the "if
opengl.found()" earlier in this file, so it looks like this is not necessary anymore now?
Yes, to get the flags for those units.
Signature · 1 line
Marc-André Lureau
PATCH v6 16/23 ui/vnc: VNC requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- meson.build | 6 +++++- ui/meson.build | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
meson.build +5 -1
@@ -1536,7 +1536,11 @@ endif vnc = not_found jpeg = not_found sasl = not_found -if get_option('vnc').allowed() and have_system +if get_option('vnc') \ + .disable_auto_if(not have_system) \ + .require(pixman.found(), + error_message: 'cannot enable VNC if pixman is not available') \ + .allowed() vnc = declare_dependency() # dummy dependency jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'), method: 'pkg-config')
ui/meson.build +1 -1
@@ -46,7 +46,7 @@ vnc_ss.add(files( )) vnc_ss.add(zlib, jpeg, gnutls) vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c')) -system_ss.add_all(when: vnc, if_true: vnc_ss) +system_ss.add_all(when: [vnc, pixman], if_true: vnc_ss) system_ss.add(when: vnc, if_false: files('vnc-stubs.c')) ui_modules = {}
Signature · 1 line
2.41.0
Re: [PATCH v6 16/23] ui/vnc: VNC requires PIXMAN
Quoted 7 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 6 +++++- ui/meson.build | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
PATCH v6 17/23 ui/spice: SPICE/QXL requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- meson.build | 6 +++++- hw/display/Kconfig | 2 +- ui/meson.build | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-)
meson.build +5 -1
@@ -1015,7 +1015,11 @@ if not get_option('spice_protocol').auto() or have_system method: 'pkg-config') endif spice = not_found -if not get_option('spice').auto() or have_system +if get_option('spice') \ + .disable_auto_if(not have_system) \ + .require(pixman.found(), + error_message: 'cannot enable SPICE if pixman is not available') \ + .allowed() spice = dependency('spice-server', version: '>=0.14.0', required: get_option('spice'), method: 'pkg-config')
hw/display/Kconfig +1 -1
@@ -93,7 +93,7 @@ config VGA config QXL bool - depends on SPICE && PCI + depends on SPICE && PCI && PIXMAN select VGA config VIRTIO_GPU
ui/meson.build +5 -5
@@ -141,12 +141,12 @@ if spice.found() 'spice-display.c' )) ui_modules += {'spice-core' : spice_core_ss} -endif -if spice.found() and gio.found() - spice_ss = ss.source_set() - spice_ss.add(spice, gio, pixman, files('spice-app.c')) - ui_modules += {'spice-app': spice_ss} + if gio.found() + spice_ss = ss.source_set() + spice_ss.add(spice, gio, pixman, files('spice-app.c')) + ui_modules += {'spice-app': spice_ss} + endif endif keymaps = [
Signature · 1 line
2.41.0
PATCH v6 18/23 ui/gtk: -display gtk requires PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
meson.build +5 -1
@@ -1507,7 +1507,11 @@ gtkx11 = not_found vte = not_found have_gtk_clipboard = get_option('gtk_clipboard').enabled() -if not get_option('gtk').auto() or have_system +if get_option('gtk') \ + .disable_auto_if(not have_system) \ + .require(pixman.found(), + error_message: 'cannot enable GTK if pixman is not available') \ + .allowed() gtk = dependency('gtk+-3.0', version: '>=3.22.0', method: 'pkg-config', required: get_option('gtk'))
Signature · 1 line
2.41.0
PATCH v6 19/23 ui/dbus: do not require PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Implement a fallback path for region 2D update.
--- ui/dbus-listener.c | 90 ++++++++++++++++++++++++++++++++-------------- ui/meson.build | 4 +-- 2 files changed, 65 insertions(+), 29 deletions(-)
ui/dbus-listener.c +63 -27
@@ -26,9 +26,6 @@#include "qapi/error.h" #include "sysemu/sysemu.h" #include "dbus.h" -#ifdef CONFIG_OPENGL -#include <pixman.h> -#endif #ifdef G_OS_UNIX #include <gio/gunixfdlist.h> #endif
@@ -41,6 +38,7 @@#include "ui/shader.h" #include "ui/egl-helpers.h" #include "ui/egl-context.h" +#include "ui/qemu-pixman.h" #endif #include "trace.h"
@@ -62,9 +60,11 @@ struct _DBusDisplayListener {QemuDBusDisplay1Listener *proxy; -#ifdef CONFIG_OPENGL +#ifdef CONFIG_PIXMAN /* Keep track of the damage region */ pixman_region32_t gl_damage; +#else +int gl_damage;#endif DisplayChangeListener dcl;
@@ -545,6 +545,7 @@ static void dbus_gl_refresh(DisplayChangeListener *dcl)return ; } +#ifdef CONFIG_PIXMAN int n_rects =pixman_region32_n_rects (&ddl->gl_damage);for (int i =0 ; i < n_rects; i++) {
@@ -555,6 +556,13 @@ static void dbus_gl_refresh(DisplayChangeListener *dcl) box->x2 - box->x1, box->y2 - box->y1); }pixman_region32_clear (&ddl->gl_damage); +#else +if (ddl->gl_damage) { +dbus_call_update_gl (dcl,0 ,0 , +surface_width (ddl->ds),surface_height (ddl->ds)); + ddl->gl_damage =0 ; + } +#endif }#endif /* OPENGL */
@@ -569,20 +577,64 @@ static void dbus_gl_gfx_update(DisplayChangeListener *dcl, {DBusDisplayListener *ddl =container_of (dcl, DBusDisplayListener, dcl); +#ifdef CONFIG_PIXMAN pixman_region32_t rect_region;pixman_region32_init_rect (&rect_region, x, y, w, h);pixman_region32_union (&ddl->gl_damage, &ddl->gl_damage, &rect_region);pixman_region32_fini (&rect_region); +#else + ddl->gl_damage++; +#endif }#endif +static void dbus_gfx_update_sub (DBusDisplayListener *ddl, +int x,int y,int w,int h) +{ +pixman_image_t *img; +size_t stride; +GVariant *v_data; + +/* make a copy, since gvariant only handles linear data */ + stride = w *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (surface_format (ddl->ds)),8 ); + img =pixman_image_create_bits (surface_format (ddl->ds), + w, h,NULL , stride); +#ifdef CONFIG_PIXMAN +pixman_image_composite (PIXMAN_OP_SRC , ddl->ds->image,NULL , img, + x, y,0 ,0 ,0 ,0 , w, h); +#else + { +uint8_t *src = (uint8_t *)pixman_image_get_data (ddl->ds->image); +uint8_t *dst = (uint8_t *)pixman_image_get_data (img); +int bp =PIXMAN_FORMAT_BPP (surface_format (ddl->ds)) /8 ; +int hh; + +for (hh =0 ; hh < h; hh++) { +memcpy (&dst[stride * hh], + &src[surface_stride (ddl->ds) * (hh + y) + x * bp], + stride); + } + } +#endif + v_data =g_variant_new_from_data ( +G_VARIANT_TYPE ("ay" ), +pixman_image_get_data (img), +pixman_image_get_stride (img) * h, + TRUE, + (GDestroyNotify )pixman_image_unref, + img); +qemu_dbus_display1_listener_call_update (ddl->proxy, + x, y, w, h,pixman_image_get_stride (img),pixman_image_get_format (img), + v_data, +G_DBUS_CALL_FLAGS_NONE , +DBUS_DEFAULT_TIMEOUT ,NULL ,NULL ,NULL ); +} +static void dbus_gfx_update (DisplayChangeListener *dcl,int x,int y,int w,int h) {DBusDisplayListener *ddl =container_of (dcl, DBusDisplayListener, dcl); -pixman_image_t *img;GVariant *v_data; -size_t stride;assert (ddl->ds);
@@ -619,25 +671,7 @@ static void dbus_gfx_update(DisplayChangeListener *dcl,return ; } -/* make a copy, since gvariant only handles linear data */ - stride = w *DIV_ROUND_UP (PIXMAN_FORMAT_BPP (surface_format (ddl->ds)),8 ); - img =pixman_image_create_bits (surface_format (ddl->ds), - w, h,NULL , stride); -pixman_image_composite (PIXMAN_OP_SRC , ddl->ds->image,NULL , img, - x, y,0 ,0 ,0 ,0 , w, h); - - v_data =g_variant_new_from_data ( -G_VARIANT_TYPE ("ay" ), -pixman_image_get_data (img), -pixman_image_get_stride (img) * h, - TRUE, - (GDestroyNotify )pixman_image_unref, - img); -qemu_dbus_display1_listener_call_update (ddl->proxy, - x, y, w, h,pixman_image_get_stride (img),pixman_image_get_format (img), - v_data, -G_DBUS_CALL_FLAGS_NONE , -DBUS_DEFAULT_TIMEOUT ,NULL ,NULL ,NULL ); +dbus_gfx_update_sub (ddl, x, y, w, h); }#ifdef CONFIG_OPENGL
@@ -751,8 +785,10 @@ dbus_display_listener_dispose(GObject *object)g_clear_object (&ddl->map_proxy);g_clear_object (&ddl->d3d11_proxy);g_clear_pointer (&ddl->peer_process, CloseHandle); -#ifdef CONFIG_OPENGL +#ifdef CONFIG_PIXMAN pixman_region32_fini (&ddl->gl_damage); +#endif +#ifdef CONFIG_OPENGL egl_fb_destroy (&ddl->fb);#endif #endif
@@ -787,7 +823,7 @@ dbus_display_listener_class_init(DBusDisplayListenerClass *klass)static void dbus_display_listener_init (DBusDisplayListener *ddl) { -#ifdef CONFIG_OPENGL +#ifdef CONFIG_PIXMAN pixman_region32_init (&ddl->gl_damage);#endif }
ui/meson.build +2 -2
@@ -93,7 +93,7 @@ if dbus_display '--generate-c-code', '@BASENAME@']) dbus_display1_lib = static_library('dbus-display1', dbus_display1, dependencies: gio) dbus_display1_dep = declare_dependency(link_with: dbus_display1_lib, include_directories: include_directories('.')) - dbus_ss.add(when: [gio, pixman, dbus_display1_dep], + dbus_ss.add(when: [gio, dbus_display1_dep], if_true: [files( 'dbus-chardev.c', 'dbus-clipboard.c',
@@ -101,7 +101,7 @@ if dbus_display 'dbus-error.c', 'dbus-listener.c', 'dbus.c', - ), opengl, gbm]) + ), opengl, gbm, pixman]) ui_modules += {'dbus' : dbus_ss} endif
Signature · 1 line
2.41.0
PATCH v6 20/23 arm/kconfig: XLNX_ZYNQMP_ARM depends on PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
The Display Port has some strong PIXMAN dependency.
--- hw/arm/Kconfig | 3 ++- hw/display/Kconfig | 5 +++++ hw/display/meson.build | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
hw/arm/Kconfig +2 -1
@@ -451,7 +451,7 @@ config STM32F405_SOC config XLNX_ZYNQMP_ARM bool default y - depends on TCG && AARCH64 + depends on TCG && AARCH64 && PIXMAN select AHCI select ARM_GIC select CADENCE
@@ -463,6 +463,7 @@ config XLNX_ZYNQMP_ARM select XILINX_AXI select XILINX_SPIPS select XLNX_CSU_DMA + select XLNX_DISPLAYPORT select XLNX_ZYNQMP select XLNX_ZDMA select USB_DWC3
hw/display/Kconfig +5 -0
@@ -134,3 +134,8 @@ config MACFB bool select FRAMEBUFFER depends on NUBUS + +config XLNX_DISPLAYPORT + bool + # defaults to "N", enabled by specific boards + depends on PIXMAN
hw/display/meson.build +1 -1
@@ -58,7 +58,7 @@ if config_all_devices.has_key('CONFIG_QXL') endif system_ss.add(when: 'CONFIG_DPCD', if_true: files('dpcd.c')) -system_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx_dp.c')) +system_ss.add(when: 'CONFIG_XLNX_DISPLAYPORT', if_true: files('xlnx_dp.c')) system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c'))
Signature · 1 line
2.41.0
PATCH v6 21/23 hw/sm501: allow compiling without PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
Change the "x-pixman" property default value and use the fallback path when PIXMAN support is disabled.
--- hw/display/sm501.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-)
hw/display/sm501.c +33 -13
@@ -438,6 +438,12 @@#define SM501_HWC_WIDTH 64#define SM501_HWC_HEIGHT 64 +#ifdef CONFIG_PIXMAN +#define DEFAULT_X_PIXMAN 7 +#else +#define DEFAULT_X_PIXMAN 0 +#endif +/* SM501 local memory size taken from "linux/drivers/mfd/sm501.c" */ static const uint32_t sm501_mem_local_size[] = { [0 ] =4 * MiB,
@@ -730,7 +736,6 @@ static void sm501_2d_operation(SM501State *s)switch (cmd) {case 0 :/* BitBlt */ { -static uint32_t tmp_buf[16384 ];unsigned int src_x = (s->twoD_source >>16 ) &0x01FFF ;unsigned int src_y = s->twoD_source &0xFFFF ;uint32_t src_base = s->twoD_source_base &0x03FFFFFF ;
@@ -828,9 +833,11 @@ static void sm501_2d_operation(SM501State *s) de = db + (width + (height -1 ) * dst_pitch) * bypp; overlap = (db < se && sb < de); } +#ifdef CONFIG_PIXMAN if (overlap && (s->use_pixman &BIT (2 ))) {/* pixman can't do reverse blit: copy via temporary */ int tmp_stride =DIV_ROUND_UP (width * bypp,sizeof (uint32_t )); +static uint32_t tmp_buf[16384 ];uint32_t *tmp = tmp_buf;if (tmp_stride *sizeof (uint32_t ) * height >sizeof (tmp_buf)) {
@@ -860,9 +867,12 @@ static void sm501_2d_operation(SM501State *s) dst_pitch * bypp /sizeof (uint32_t ),8 * bypp,8 * bypp, src_x, src_y, dst_x, dst_y, width, height); - }else { + } else +#else + { fallback = true; } +#endif if (fallback) {uint8_t *sp = s->local_mem + src_base;uint8_t *d = s->local_mem + dst_base;
@@ -894,20 +904,23 @@ static void sm501_2d_operation(SM501State *s) color =cpu_to_le16 (color); } +#ifdef CONFIG_PIXMAN if (!(s->use_pixman &BIT (0 )) || (width ==1 && height ==1 ) || !pixman_fill ((uint32_t *)&s->local_mem[dst_base], dst_pitch * bypp /sizeof (uint32_t ),8 * bypp, - dst_x, dst_y, width, height, color)) { -/* fallback when pixman failed or we don't want to call it */ -uint8_t *d = s->local_mem + dst_base; -unsigned int x, y, i; -for (y =0 ; y < height; y++) { - i = (dst_x + (dst_y + y) * dst_pitch) * bypp; -for (x =0 ; x < width; x++, i += bypp) { -stn_he_p (&d[i], bypp, color); + dst_x, dst_y, width, height, color)) +#endif + { +/* fallback when pixman failed or we don't want to call it */ +uint8_t *d = s->local_mem + dst_base; +unsigned int x, y, i; +for (y =0 ; y < height; y++) { + i = (dst_x + (dst_y + y) * dst_pitch) * bypp; +for (x =0 ; x < width; x++, i += bypp) { +stn_he_p (&d[i], bypp, color); + } } } - }break ; }default :
@@ -1878,6 +1891,12 @@ static void sm501_reset(SM501State *s)static void sm501_init (SM501State *s,DeviceState *dev,uint32_t local_mem_bytes) { +#ifndef CONFIG_PIXMAN +if (s->use_pixman !=0 ) { +warn_report ("x-pixman != 0, not effective without PIXMAN" ); + } +#endif + s->local_mem_size_index =get_local_mem_size_index (local_mem_bytes);/* local memory */
@@ -2038,7 +2057,8 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)static Property sm501_sysbus_properties[] = {DEFINE_PROP_UINT32 ("vram-size" , SM501SysBusState, vram_size,0 ), -DEFINE_PROP_UINT8 ("x-pixman" , SM501SysBusState, state.use_pixman,7 ), +/* this a debug option, prefer PROP_UINT over PROP_BIT for simplicity */ +DEFINE_PROP_UINT8 ("x-pixman" , SM501SysBusState, state.use_pixman,DEFAULT_X_PIXMAN ),DEFINE_PROP_END_OF_LIST (), };
@@ -2126,7 +2146,7 @@ static void sm501_realize_pci(PCIDevice *dev, Error **errp)static Property sm501_pci_properties[] = {DEFINE_PROP_UINT32 ("vram-size" , SM501PCIState, vram_size,64 * MiB), -DEFINE_PROP_UINT8 ("x-pixman" , SM501PCIState, state.use_pixman,7 ), +DEFINE_PROP_UINT8 ("x-pixman" , SM501PCIState, state.use_pixman,DEFAULT_X_PIXMAN ),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
2.41.0
Re: [PATCH v6 21/23] hw/sm501: allow compiling without PIXMAN
Quoted 6 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Change the "x-pixman" property default value and use the fallback path when PIXMAN support is disabled.
Signed-off-by Marc-André Lureau <[email protected]>
Quoted 3 lines
---
hw/display/sm501.c| 46 +++++++++++++++++++++++++++++++++-------------1 file changed, 33 insertions(+), 13 deletions(-)
PATCH v6 22/23 hw/display: make ATI_VGA depend on PIXMAN
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- configs/devices/mips64el-softmmu/default.mak | 2 +- hw/display/Kconfig | 2 +- hw/display/meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
configs/devices/mips64el-softmmu/default.mak +1 -1
@@ -3,7 +3,7 @@ include ../mips-softmmu/common.mak CONFIG_FULOONG=y CONFIG_LOONGSON3V=y -CONFIG_ATI_VGA=y +# CONFIG_ATI_VGA=n CONFIG_RTL8139_PCI=y CONFIG_JAZZ=y CONFIG_VT82C686=y
hw/display/Kconfig +1 -1
@@ -125,7 +125,7 @@ config DPCD config ATI_VGA bool default y if PCI_DEVICES - depends on PCI + depends on PCI && PIXMAN select VGA select BITBANG_I2C select DDC
hw/display/meson.build +1 -1
@@ -62,7 +62,7 @@ system_ss.add(when: 'CONFIG_XLNX_DISPLAYPORT', if_true: files('xlnx_dp.c')) system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) -system_ss.add(when: [pixman, 'CONFIG_ATI_VGA'], if_true: files('ati.c', 'ati_2d.c', 'ati_dbg.c')) +system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman]) if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
Signature · 1 line
2.41.0
Re: [PATCH v6 22/23] hw/display: make ATI_VGA depend on PIXMAN
Quoted 18 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>Acked-by BALATON Zoltan <[email protected]>---
configs/devices/mips64el-softmmu/default.mak | 2 +- hw/display/Kconfig | 2 +- hw/display/meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)configs/devices/mips64el-softmmu/default.mak +0
-0@@ -3,7 +3,7 @@include ../mips-softmmu/common.mak
CONFIG_FULOONG=yCONFIG_LOONGSON3V=y
configs/devices/mips64el-softmmu/default.mak line 6
Quoted 2 lines
configs/devices/mips64el-softmmu/default.mak +1
-1-CONFIG_ATI_VGA=y +# CONFIG_ATI_VGA=n
I think I've asked this before but forgot the answer... However fuloong2e has an on board ati-vga so does this (or should it) disable CONFIG_FULOONG when !PIXMAN? Or that machine should omit the on board graphics in this case?
Regards,
BALATON Zoltan
Quoted 30 lines
CONFIG_RTL8139_PCI=yCONFIG_JAZZ=yCONFIG_VT82C686=yhw/display/Kconfig +0
-0@@ -125,7 +125,7 @@ config DPCDconfig
ATI_VGA
bool
default y ifPCI_DEVICEShw/display/Kconfig +1
-1- depends on PCI + depends on PCI && PIXMAN select VGA select BITBANG_I2C select DDChw/display/meson.build +1
-1@@ -62,7 +62,7 @@ system_ss.add(when: 'CONFIG_XLNX_DISPLAYPORT', if_true: files('xlnx_dp.c')) system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) -system_ss.add(when: [pixman, 'CONFIG_ATI_VGA'], if_true: files('ati.c', 'ati_2d.c', 'ati_dbg.c')) +system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman]) if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
Re: [PATCH v6 22/23] hw/display: make ATI_VGA depend on PIXMAN
Hi
Quoted 12 lines · BALATON Zoltan
Quoted 10 lines · On Wed, 25 Oct 2023, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>Acked-by BALATON Zoltan <[email protected]>---
configs/devices/mips64el-softmmu/default.mak | 2 +- hw/display/Kconfig | 2 +- hw/display/meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Quoted 16 lines
configs/devices/mips64el-softmmu/default.mak
Quoted 10 lines
configs/devices/mips64el-softmmu/default.mak +0
-0@@ -3,7 +3,7 @@include ../mips-softmmu/common.mak
CONFIG_FULOONG=yCONFIG_LOONGSON3V=yconfigs/devices/mips64el-softmmu/default.mak +1
-1-CONFIG_ATI_VGA=y +# CONFIG_ATI_VGA=nI think I've asked this before but forgot the answer... However fuloong2e has an on board ati-vga so does this (or should it) disable
CONFIG_FULOONGwhen !PIXMAN? Or that machine should omit the on board graphics in this case?
yes, it is not obvious to spot, because it's a run time error (the "ati-vga" device creation).
I think we should express this like that, but it fails with:
KconfigDataError: cycle found including PCI_BONITO
And I have no idea why. Paolo, any idea?
(quoted diff) +0 -0
b/configs/devices/mips64el-softmmu/default.mak
index 8d85607571..4d80d60511 100644
configs/devices/mips64el-softmmu/default.mak +1 -2
@@ -1,9 +1,8 @@ # Default configuration for mips64el-softmmu include ../mips-softmmu/common.mak -CONFIG_FULOONG=y +#CONFIG_FULOONG=y CONFIG_LOONGSON3V=y -# CONFIG_ATI_VGA=n CONFIG_RTL8139_PCI=y CONFIG_JAZZ=y CONFIG_VT82C686=y
hw/mips/Kconfig +2 -0
@@ -32,7 +32,9 @@ config JAZZ config FULOONG bool + default y if MIPS select PCI_BONITO + depends on ATI_VGA
Quoted 33 lines
Regards,
BALATON ZoltanQuoted 30 lines
CONFIG_RTL8139_PCI=yCONFIG_JAZZ=yCONFIG_VT82C686=yhw/display/Kconfig +0
-0@@ -125,7 +125,7 @@ config DPCDconfig
ATI_VGA
bool
default y ifPCI_DEVICEShw/display/Kconfig +1
-1- depends on PCI + depends on PCI && PIXMAN select VGA select BITBANG_I2C select DDChw/display/meson.build +1
-1@@ -62,7 +62,7 @@ system_ss.add(when: 'CONFIG_XLNX_DISPLAYPORT', if_true: files('xlnx_dp.c')) system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) -system_ss.add(when: [pixman, 'CONFIG_ATI_VGA'], if_true: files('ati.c', 'ati_2d.c', 'ati_dbg.c')) +system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman]) if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
Signature · 1 line
Marc-André Lureau
PATCH v6 23/23 build-sys: make pixman actually optional
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- meson.build | 3 --- 1 file changed, 3 deletions(-)
meson.build +0 -3
@@ -817,9 +817,6 @@ if not get_option('pixman').auto() or have_system or have_tools pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', method: 'pkg-config') endif -if not pixman.found() and (have_system or have_tools) - error('FIXME: pixman is currently required') -endif zlib = dependency('zlib', required: true)
Signature · 1 line
2.41.0
Re: [PATCH v6 23/23] build-sys: make pixman actually optional
Quoted 12 lines · On 25/10/2023 21.08, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 3 --- 1 file changed, 3 deletions(-)meson.build +0
-0
meson.build if not get_option('pixman').auto() or have_system or have_tools · line 822
Quoted 9 lines
meson.build +0
-3@@ -817,9 +817,6 @@ if not get_option('pixman').auto() or have_system or have_tools pixman = dependency('pixman-1', required: get_option('pixman'), version:'>=0.21.8', method: 'pkg-config') endif -if not pixman.found() and (have_system or have_tools) - error('FIXME: pixman is currently required') -endif zlib = dependency('zlib', required: true)