All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xenfb shared buffer
@ 2009-03-03 18:04 Stefano Stabellini
  2009-03-04  7:49 ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2009-03-03 18:04 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Gerd Hoffmann

After the recent DisplayState changes is now possible to share the xenfb
backend buffer with the display frontend (sdl, vnc), avoid a memcpy for
each screen update.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

---

diff -r f73b2e267fa4 hw/xenfb.c
--- a/hw/xenfb.c	Mon Mar 02 16:06:43 2009 +0000
+++ b/hw/xenfb.c	Tue Mar 03 17:53:46 2009 +0000
@@ -595,14 +595,7 @@
 {
     int line;
 
-    /*
-     * TODO: xen's qemu-dm seems to have some patches to
-     *       make the qemu display code avoid unneeded
-     *       work.
-     *        - Port them over.
-     *        - Put ds->shared_buf back into use then.
-     */
-    if (1 /* !xenfb->c.ds->shared_buf */) {
+    if (!is_buffer_shared(xenfb->c.ds->surface)) {
 	if (xenfb->depth == ds_get_bits_per_pixel(xenfb->c.ds)) { /* Perfect match can use fast path */
 	    for (line = y ; line < (y+h) ; line++) {
 		memcpy(ds_get_data(xenfb->c.ds) + (line * ds_get_linesize(xenfb->c.ds)) + (x * ds_get_bytes_per_pixel(xenfb->c.ds)),
@@ -735,10 +728,30 @@
     }
 
     /* resize if needed */
-    if (xenfb->width != ds_get_width(xenfb->c.ds) || xenfb->height != ds_get_height(xenfb->c.ds)) {
+    if (xenfb->width != ds_get_width(xenfb->c.ds) ||
+        xenfb->height != ds_get_height(xenfb->c.ds) ||
+        xenfb->depth != ds_get_bits_per_pixel(xenfb->c.ds) ||
+        xenfb->row_stride != ds_get_linesize(xenfb->c.ds) ||
+        xenfb->pixels + xenfb->offset != ds_get_data(xenfb->c.ds)) {
+        switch (xenfb->depth) {
+        case 16:
+        case 32:
+            /* console.c supported depth -> buffer can be used directly */
+            qemu_free_displaysurface(xenfb->c.ds);
+            xenfb->c.ds->surface = qemu_create_displaysurface_from
+                (xenfb->width, xenfb->height, xenfb->depth,
+                 xenfb->row_stride, xenfb->pixels + xenfb->offset);
+            dpy_resize(xenfb->c.ds);
+            break;
+        default:
+            /* we must convert stuff */
+            qemu_resize_displaysurface(xenfb->c.ds,
+                                       xenfb->width, xenfb->height,
+                                       xenfb->depth, xenfb->row_stride);
+            break;
+        }
         xen_be_printf(&xenfb->c.xendev, 1, "update: resizing: %dx%d\n",
                       xenfb->width, xenfb->height);
-        qemu_console_resize(xenfb->c.ds, xenfb->width, xenfb->height);
         xenfb->up_fullscreen = 1;
     }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xenfb shared buffer
  2009-03-03 18:04 [PATCH] xenfb shared buffer Stefano Stabellini
@ 2009-03-04  7:49 ` Gerd Hoffmann
  2009-03-04 12:10   ` Stefano Stabellini
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2009-03-04  7:49 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel, Ian Jackson

Stefano Stabellini wrote:
> After the recent DisplayState changes is now possible to share the xenfb
> backend buffer with the display frontend (sdl, vnc), avoid a memcpy for
> each screen update.

I have this and a few more updates to make xenfb work smoothly with
displaystate already, look here:

http://git.et.redhat.com/?p=qemu-kraxel.git;a=commitdiff;h=34c58e4e1cc8450e7077a134c013ec805aa940fb

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xenfb shared buffer
  2009-03-04  7:49 ` Gerd Hoffmann
@ 2009-03-04 12:10   ` Stefano Stabellini
  2009-03-04 12:32     ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2009-03-04 12:10 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: xen-devel, Ian Jackson

Gerd Hoffmann wrote:

> Stefano Stabellini wrote:
>> After the recent DisplayState changes is now possible to share the xenfb
>> backend buffer with the display frontend (sdl, vnc), avoid a memcpy for
>> each screen update.
> 
> I have this and a few more updates to make xenfb work smoothly with
> displaystate already, look here:
> 
> http://git.et.redhat.com/?p=qemu-kraxel.git;a=commitdiff;h=34c58e4e1cc8450e7077a134c013ec805aa940fb
> 
> cheers,
>   Gerd
> 
> 



Your patch is correct, I only have a comment:

diff --git a/hw/xenfb.c b/hw/xenfb.c

>@@ -590,62 +593,52 @@ static int xenfb_configure_fb(struct XenFB *xenfb, size_t fb_len_lim,
>-/* This copies data from the guest framebuffer region, into QEMU's copy
>- * NB. QEMU's copy is stored in the pixel format of a) the local X
>- * server (SDL case) or b) the current VNC client pixel format.
>- * When shifting between colour depths we preserve the MSB.
>+/*
>+ * This copies data from the guest framebuffer region, into QEMU's
>+ * displaysurface. qemu uses 16 or 32 bpp.  In case the pv framebuffer
>+ * uses something else we must convert and copy, otherwise we can
>+ * supply the buffer directly and no thing here.
>  */
> static void xenfb_guest_copy(struct XenFB *xenfb, int x, int y, int w, int h)
> {
>-    int line;
>-
>-    /*
>-     * TODO: xen's qemu-dm seems to have some patches to
>-     *       make the qemu display code avoid unneeded
>-     *       work.
>-     *        - Port them over.
>-     *        - Put ds->shared_buf back into use then.
>-     */
>-    if (1 /* !xenfb->c.ds->shared_buf */) {
>-	if (xenfb->depth == xenfb->c.ds->depth) { /* Perfect match can use fast path */
>-	    for (line = y ; line < (y+h) ; line++) {
>-		memcpy(xenfb->c.ds->data + (line * xenfb->c.ds->linesize) + (x * xenfb->c.ds->depth / 8),
>-		       xenfb->pixels + xenfb->offset + (line * xenfb->row_stride) + (x * xenfb->depth / 8),
>-		       w * xenfb->depth / 8);
>-	    }
>-	} else { /* Mismatch requires slow pixel munging */
>-	    /* 8 bit == r:3 g:3 b:2 */
>-	    /* 16 bit == r:5 g:6 b:5 */
>-	    /* 24 bit == r:8 g:8 b:8 */
>-	    /* 32 bit == r:8 g:8 b:8 (padding:8) */
>-	    if (xenfb->depth == 8) {
>-		if (xenfb->c.ds->depth == 16) {
>-		    BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
>-		} else if (xenfb->c.ds->depth == 32) {
>-		    BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
>-		}
>-	    } else if (xenfb->depth == 16) {
>-		if (xenfb->c.ds->depth == 8) {
>-		    BLT(uint16_t, uint8_t,   5, 6, 5,   3, 3, 2);
>-		} else if (xenfb->c.ds->depth == 32) {
>-		    BLT(uint16_t, uint32_t,  5, 6, 5,   8, 8, 8);
>-		}
>-	    } else if (xenfb->depth == 24 || xenfb->depth == 32) {
>-		if (xenfb->c.ds->depth == 8) {
>-		    BLT(uint32_t, uint8_t,   8, 8, 8,   3, 3, 2);
>-		} else if (xenfb->c.ds->depth == 16) {
>-		    BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
>-		} else if (xenfb->c.ds->depth == 32) {
>-		    BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
>-		}
>-	    }
>+    int line, oops = 0;
>+    int bpp = ds_get_bits_per_pixel(xenfb->c.ds);
>+    int linesize = ds_get_linesize(xenfb->c.ds);
>+    uint8_t *data = ds_get_data(xenfb->c.ds);
>+
>+    if (!is_buffer_shared(xenfb->c.ds->surface)) {
>+        switch (xenfb->depth) {
>+        case 8:
>+            if (bpp == 16) {
>+                BLT(uint8_t, uint16_t,   3, 3, 2,   5, 6, 5);
>+            } else if (bpp == 32) {
>+                BLT(uint8_t, uint32_t,   3, 3, 2,   8, 8, 8);
>+            } else {
>+                oops = 1;
>+            }
>+            break;
>+        case 24:
>+            if (bpp == 16) {
>+                BLT(uint32_t, uint16_t,  8, 8, 8,   5, 6, 5);
>+            } else if (bpp == 32) {
>+                BLT(uint32_t, uint32_t,  8, 8, 8,   8, 8, 8);
>+            } else {
>+                oops = 1;
>+            }
>+            break;
>+        default:
>+            oops = 1;
> 	}
>     }
>+    if (oops) /* should not happen */
>+        xen_be_printf(&xenfb->c.xendev, 0, "%s: oops: convert %d -> %d bpp?\n",
>+                      __FUNCTION__, xenfb->depth, bpp);
>+
>     dpy_update(xenfb->c.ds, x, y, w, h);
> }
>



I am OK with these changes but I wouldn't bother removing the 16 and 32
bpp conversion code even if currently it would never be used.
After all is working and well tested code that may be useful in the
future.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xenfb shared buffer
  2009-03-04 12:10   ` Stefano Stabellini
@ 2009-03-04 12:32     ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2009-03-04 12:32 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel, Ian Jackson

Stefano Stabellini wrote:
> I am OK with these changes but I wouldn't bother removing the 16 and 32
> bpp conversion code even if currently it would never be used.
> After all is working and well tested code that may be useful in the
> future.

Well I killed it intentionally.  That way we'll notice for sure if xenfb
doesn't share the buffer although it should.  Restoring the
functionality in case we ever need it again is easy as all the magic is
in the BLT() macro anyway.

cheers
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-04 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03 18:04 [PATCH] xenfb shared buffer Stefano Stabellini
2009-03-04  7:49 ` Gerd Hoffmann
2009-03-04 12:10   ` Stefano Stabellini
2009-03-04 12:32     ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.