diff options
Diffstat (limited to 'src/glx')
-rw-r--r-- | src/glx/dri2.c | 15 | ||||
-rw-r--r-- | src/glx/dri2_glx.c | 13 | ||||
-rw-r--r-- | src/glx/drisw_glx.c | 110 | ||||
-rw-r--r-- | src/glx/glxcmds.c | 3 |
4 files changed, 104 insertions, 37 deletions
diff --git a/src/glx/dri2.c b/src/glx/dri2.c index 5de55cdbf29..9ca9b3eb065 100644 --- a/src/glx/dri2.c +++ b/src/glx/dri2.c @@ -62,6 +62,8 @@ static Bool DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire); static Status DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire); +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code); static /* const */ XExtensionHooks dri2ExtensionHooks = { NULL, /* create_gc */ @@ -73,7 +75,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = { DRI2CloseDisplay, /* close_display */ DRI2WireToEvent, /* wire_to_event */ DRI2EventToWire, /* event_to_wire */ - NULL, /* error */ + DRI2Error, /* error */ NULL, /* error_string */ }; @@ -160,6 +162,17 @@ DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire) return Success; } +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code) +{ + if (err->majorCode == codes->major_opcode && + err->errorCode == BadDrawable && + err->minorCode == X_DRI2CopyRegion) + return True; + + return False; +} + Bool DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) { diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 5b0f335db6a..14788b89bea 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -202,6 +202,8 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, return &pdraw->base; } +#ifdef X_DRI2GetMSC + static int dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, int64_t *ust, int64_t *msc, int64_t *sbc) @@ -209,6 +211,11 @@ dri2DrawableGetMSC(__GLXscreenConfigs *psc, __GLXDRIdrawable *pdraw, return DRI2GetMSC(psc->dpy, pdraw->xDrawable, ust, msc, sbc); } +#endif + + +#ifdef X_DRI2WaitMSC + static int dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc) @@ -225,6 +232,8 @@ dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, sbc); } +#endif /* X_DRI2WaitMSC */ + static void dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height) { @@ -448,6 +457,8 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, return pdraw->buffers; } +#ifdef X_DRI2SwapInterval + static void dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval) { @@ -465,6 +476,8 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw) return priv->swap_interval; } +#endif /* X_DRI2SwapInterval */ + static const __DRIdri2LoaderExtension dri2LoaderExtension = { {__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION}, dri2GetBuffers, diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 1b94a56fd13..786faff81c1 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -53,13 +53,8 @@ struct __GLXDRIdrawablePrivateRec XVisualInfo *visinfo; XImage *ximage; - int bpp; }; -/** - * swrast loader functions - */ - static Bool XCreateDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable, int visualid) @@ -79,20 +74,21 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues); XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues); - /* create XImage */ + /* visual */ visTemp.screen = DefaultScreen(dpy); visTemp.visualid = visualid; visMask = (VisualScreenMask | VisualIDMask); pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals); - pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ - 0); /* bytes_per_line */ - - /* get the true number of bits per pixel */ - pdp->bpp = pdp->ximage->bits_per_pixel; + /* create XImage */ + pdp->ximage = XCreateImage(dpy, + pdp->visinfo->visual, + pdp->visinfo->depth, + ZPixmap, 0, /* format, offset */ + NULL, /* data */ + 0, 0, /* width, height */ + 32, /* bitmap_pad */ + 0); /* bytes_per_line */ return True; } @@ -107,9 +103,14 @@ XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable) XFreeGC(dpy, pdp->swapgc); } +/** + * swrast loader functions + */ + static void swrastGetDrawableInfo(__DRIdrawable * draw, - int *x, int *y, int *w, int *h, void *loaderPrivate) + int *x, int *y, int *w, int *h, + void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -118,26 +119,42 @@ swrastGetDrawableInfo(__DRIdrawable * draw, Window root; Status stat; - unsigned int bw, depth; + unsigned uw, uh, bw, depth; drawable = pdraw->xDrawable; stat = XGetGeometry(dpy, drawable, &root, - x, y, (unsigned int *) w, (unsigned int *) h, - &bw, &depth); + x, y, &uw, &uh, &bw, &depth); + *w = uw; + *h = uh; } +/** + * Align renderbuffer pitch. + * + * This should be chosen by the driver and the loader (libGL, xserver/glx) + * should use the driver provided pitch. + * + * It seems that the xorg loader (that is the xserver loading swrast_dri for + * indirect rendering, not client-side libGL) requires that the pitch is + * exactly the image width padded to 32 bits. XXX + * + * The above restriction can probably be overcome by using ScratchPixmap and + * CopyArea in the xserver, similar to ShmPutImage, and setting the width of + * the scratch pixmap to 'pitch / cpp'. + */ static inline int -bytes_per_line(int w, int bpp, unsigned mul) +bytes_per_line(unsigned pitch_bits, unsigned mul) { unsigned mask = mul - 1; - return ((w * bpp + mask) & ~mask) / 8; + return ((pitch_bits + mask) & ~mask) / 8; } static void swrastPutImage(__DRIdrawable * draw, int op, - int x, int y, int w, int h, char *data, void *loaderPrivate) + int x, int y, int w, int h, + char *data, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -163,7 +180,7 @@ swrastPutImage(__DRIdrawable * draw, int op, ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); @@ -171,24 +188,25 @@ swrastPutImage(__DRIdrawable * draw, int op, } static void -swrastGetImage(__DRIdrawable * draw, - int x, int y, int w, int h, char *data, void *loaderPrivate) +swrastGetImage(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, void *loaderPrivate) { - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base); - Display *dpy = pdraw->psc->dpy; - Drawable drawable; + __GLXDRIdrawablePrivate *prp = loaderPrivate; + __GLXDRIdrawable *pread = &(prp->base); + Display *dpy = pread->psc->dpy; + Drawable readable; XImage *ximage; - drawable = pdraw->xDrawable; + readable = pread->xDrawable; - ximage = pdp->ximage; + ximage = prp->ximage; ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); - XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); + XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); ximage->data = NULL; } @@ -334,10 +352,17 @@ driCreateDrawable(__GLXscreenConfigs * psc, return pdraw; } -static void -driSwapBuffers(__GLXDRIdrawable * pdraw) +static int64_t +driSwapBuffers(__GLXDRIdrawable * pdraw, + int64_t target_msc, int64_t divisor, int64_t remainder) { + (void) target_msc; + (void) divisor; + (void) remainder; + (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); + + return 0; } static void @@ -350,6 +375,20 @@ driDestroyScreen(__GLXscreenConfigs * psc) dlclose(psc->driver); } +static void * +driOpenSwrast(void) +{ + void *driver = NULL; + + if (driver == NULL) + driver = driOpenDriver("swrast"); + + if (driver == NULL) + driver = driOpenDriver("swrastg"); + + return driver; +} + static __GLXDRIscreen * driCreateScreen(__GLXscreenConfigs * psc, int screen, __GLXdisplayPrivate * priv) @@ -357,14 +396,13 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen, __GLXDRIscreen *psp; const __DRIconfig **driver_configs; const __DRIextension **extensions; - const char *driverName = "swrast"; int i; psp = Xcalloc(1, sizeof *psp); if (psp == NULL) return NULL; - psc->driver = driOpenDriver(driverName); + psc->driver = driOpenSwrast(); if (psc->driver == NULL) goto handle_error; diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 49cbce72f8a..ea267f3dd8a 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -2507,6 +2507,9 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable, if (divisor > 0 && remainder >= divisor) return -1; + if (target_msc == 0 && divisor == 0 && remainder == 0) + remainder = 1; + #ifdef __DRI_SWAP_BUFFER_COUNTER if (psc->counters != NULL) return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, |