From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: xen-devel <xen-devel@lists.xensource.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [PATCH] xenfb shared buffer
Date: Wed, 04 Mar 2009 12:10:46 +0000 [thread overview]
Message-ID: <49AE6FC6.9080307@eu.citrix.com> (raw)
In-Reply-To: <49AE329B.9060400@redhat.com>
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.
next prev parent reply other threads:[~2009-03-04 12:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2009-03-04 12:32 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49AE6FC6.9080307@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=kraxel@redhat.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.