9ae3a8
From 3067d5947bd28c5c05ba8dc7c87b70edc6157a27 Mon Sep 17 00:00:00 2001
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Date: Fri, 20 Oct 2017 11:06:17 +0200
9ae3a8
Subject: [PATCH 2/7] vga: Add mechanism to force the use of a shadow surface
9ae3a8
9ae3a8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Message-id: <20171020110619.2541-10-kraxel@redhat.com>
9ae3a8
Patchwork-id: 77409
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH 09/11] vga: Add mechanism to force the use of a shadow surface
9ae3a8
Bugzilla: 1501295
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9ae3a8
9ae3a8
This prevents surface sharing which will be necessary to
9ae3a8
fix cirrus HW cursor support.
9ae3a8
9ae3a8
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
(cherry picked from commit 5508099397c480f1c3b4f14b0e64593ebe284b26)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/display/vga.c     | 17 +++++++++++++++--
9ae3a8
 hw/display/vga_int.h |  1 +
9ae3a8
 2 files changed, 16 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/display/vga.c b/hw/display/vga.c
9ae3a8
index dda3f5f..a343a0a 100644
9ae3a8
--- a/hw/display/vga.c
9ae3a8
+++ b/hw/display/vga.c
9ae3a8
@@ -1510,6 +1510,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
9ae3a8
     uint8_t *d;
9ae3a8
     uint32_t v, addr1, addr;
9ae3a8
     vga_draw_line_func *vga_draw_line;
9ae3a8
+    bool share_surface;
9ae3a8
 #if defined(TARGET_WORDS_BIGENDIAN)
9ae3a8
     static const bool big_endian_fb = true;
9ae3a8
 #else
9ae3a8
@@ -1558,18 +1559,30 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
9ae3a8
     }
9ae3a8
 
9ae3a8
     depth = s->get_bpp(s);
9ae3a8
+
9ae3a8
+    share_surface = (!s->force_shadow) &&
9ae3a8
+            ( depth == 32 || (depth == 16 && !byteswap) );
9ae3a8
     if (s->line_offset != s->last_line_offset ||
9ae3a8
         disp_width != s->last_width ||
9ae3a8
         height != s->last_height ||
9ae3a8
-        s->last_depth != depth) {
9ae3a8
-        if (depth == 32 || (depth == 16 && !byteswap)) {
9ae3a8
+        s->last_depth != depth ||
9ae3a8
+        share_surface != is_buffer_shared(surface)) {
9ae3a8
+        if (share_surface) {
9ae3a8
             surface = qemu_create_displaysurface_from(disp_width,
9ae3a8
                     height, depth, s->line_offset,
9ae3a8
                     s->vram_ptr + (s->start_addr * 4), byteswap);
9ae3a8
             dpy_gfx_replace_surface(s->con, surface);
9ae3a8
+#ifdef DEBUG_VGA
9ae3a8
+            printf("VGA: Using shared surface for depth=%d swap=%d\n",
9ae3a8
+                   depth, byteswap);
9ae3a8
+#endif
9ae3a8
         } else {
9ae3a8
             qemu_console_resize(s->con, disp_width, height);
9ae3a8
             surface = qemu_console_surface(s->con);
9ae3a8
+#ifdef DEBUG_VGA
9ae3a8
+            printf("VGA: Using shadow surface for depth=%d swap=%d\n",
9ae3a8
+                   depth, byteswap);
9ae3a8
+#endif
9ae3a8
         }
9ae3a8
         s->last_scr_width = disp_width;
9ae3a8
         s->last_scr_height = height;
9ae3a8
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
9ae3a8
index 94add2f..5b9ca87 100644
9ae3a8
--- a/hw/display/vga_int.h
9ae3a8
+++ b/hw/display/vga_int.h
9ae3a8
@@ -149,6 +149,7 @@ typedef struct VGACommonState {
9ae3a8
     uint32_t last_width, last_height; /* in chars or pixels */
9ae3a8
     uint32_t last_scr_width, last_scr_height; /* in pixels */
9ae3a8
     uint32_t last_depth; /* in bits */
9ae3a8
+    bool force_shadow;
9ae3a8
     uint8_t cursor_start, cursor_end;
9ae3a8
     bool cursor_visible_phase;
9ae3a8
     int64_t cursor_blink_time;
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8