[Mesa-dev] [PATCH 4/4] drisw/glx: use XShm if possible
Chris Wilson
chris at chris-wilson.co.uk
Wed Jun 10 09:17:59 PDT 2015
On Wed, Jun 10, 2015 at 06:08:57PM +0200, Marc-André Lureau wrote:
> static void
> -swrastPutImage2(__DRIdrawable * draw, int op,
> +swrastXPutImage(__DRIdrawable * draw, int op,
> int x, int y, int w, int h, int stride,
> - char *data, void *loaderPrivate)
> + int shmid, char *data, void *loaderPrivate)
> {
> struct drisw_drawable *pdp = loaderPrivate;
> __GLXDRIdrawable *pdraw = &(pdp->base);
> @@ -144,6 +211,11 @@ swrastPutImage2(__DRIdrawable * draw, int op,
> XImage *ximage;
> GC gc;
>
> + if (!pdp->ximage || shmid != pdp->shminfo.shmid) {
> + if (!XCreateDrawable(pdp, shmid, dpy))
> + return;
> + }
> +
> switch (op) {
> case __DRI_SWRAST_IMAGE_OP_DRAW:
> gc = pdp->gc;
> @@ -156,24 +228,51 @@ swrastPutImage2(__DRIdrawable * draw, int op,
> }
>
> drawable = pdraw->xDrawable;
> -
> ximage = pdp->ximage;
> - ximage->data = data;
> - ximage->width = w;
> - ximage->height = h;
> ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32);
> + ximage->data = data;
>
> - XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
> -
> + if (pdp->shminfo.shmid >= 0) {
> + ximage->width = ximage->bytes_per_line / ((ximage->bits_per_pixel + 7)/ 8);
> + ximage->height = h;
> + XShmPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h, False);
I did not find how you serialised the XServer reading from the SHM
following the call to XShmPutImage (which you may want to flush?) with
subsequent rendering into the image.
Another trick you may like to investigate is using the X server to do
format conversions and tune the swrast for a small number of local
formats (i.e. rgb16, argb32). This of course requires using XRender
after the PutImage - and at that point keeping it as a ShmPixmap is
hugely beneficial to UMA drivers.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the mesa-dev
mailing list