WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] xenfb shared buffer

To: Gerd Hoffmann <kraxel@xxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH] xenfb shared buffer
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Wed, 04 Mar 2009 12:10:46 +0000
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Delivery-date: Wed, 04 Mar 2009 04:11:47 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49AE329B.9060400@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <49AD7114.2080002@xxxxxxxxxxxxx> <49AE329B.9060400@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (X11/20080505)
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.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>