[Mesa-dev] [PATCH 4/4] drisw/glx: use XShm if possible
Adam Jackson
ajax at redhat.com
Wed Jun 10 13:34:20 PDT 2015
On Wed, 2015-06-10 at 18:08 +0200, Marc-André Lureau wrote:
> + if (!xshm_error && shmid >= 0) {
> + pdp->shminfo.shmid = shmid;
> + pdp->ximage = XShmCreateImage(dpy,
> + pdp->visinfo->visual,
> + pdp->visinfo->depth,
> + ZPixmap, /* format */
> + NULL, /* data */
> + &pdp->shminfo, /* shminfo */
> + 0, 0); /* width, height */
> + if (pdp->ximage == NULL) {
> + int (*old_handler)(Display *, XErrorEvent *);
> +
> + /* dispatch pending errors */
> + XSync(dpy, False);
> +
> + old_handler = XSetErrorHandler(handle_xerror);
> + /* This may trigger the X protocol error we're ready to catch: */
> + XShmAttach(dpy, &pdp->shminfo);
> + XSync(dpy, False);
>
Telling the server to attach the image only if creating it failed ain't
gonna work too great:
X Error of failed request: BadShmSeg (invalid shared segment
parameter)
Major opcode of failed request: 130 (MIT-SHM)
Minor opcode of failed request: 3 (X_ShmPutImage)
Segment id in failed request: 0x1a00005
Serial number of failed request: 31
Current serial number in output stream: 32
But with the == changed to !=, this does seem to work! Under
(accelerated) gnome-shell, llvmpipe gears gets around 1280fps at its
default window size and 110 fullscreen, compared to about 1110 and 40
with PutImage, respectively. Nice one.
PutImage's semantics are that when it returns the app owns the image
data again: the image has been either copied into xlib's request buffer
or written to the socket. Not so ShmPutImage, which just enqueues the
request and lets the server pick the data up whenever. So it's
possible, if we dirty the front buffer before xserver finishes the
ShmPutImage, that we'd see an inconsistent screen state for a moment.
So I think this wants an XSync after XShmPutImage (which dings windowed
fps by ~50 but doesn't seem to bother fullscreen at all).
With those two things fixed, the series is:
Reviewed-by: Adam Jackson <ajax at redhat.com>
Any chance you feel like trying the same trick with ShmGetImage and
EXT_texture_from_pixmap?
- ajax
More information about the mesa-dev
mailing list