diff options
author | Kristian Høgsberg <krh@redhat.com> | 2008-08-11 16:59:17 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2008-08-29 12:33:28 -0400 |
commit | 5af77d43fe812e127d5d335527fa940ab9d95f38 (patch) | |
tree | 88e6cf7deb768f1cccbf806c7313ce0d1ae469d2 /glx/glxdri2.c | |
parent | 60ad8d5d05485339e89d7f1f9f1ded75de7c7ea1 (diff) |
DRI2: Drop sarea use, implement server side swap buffers.
Diffstat (limited to 'glx/glxdri2.c')
-rw-r--r-- | glx/glxdri2.c | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 7c1f00e79..495de8197 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -69,6 +69,7 @@ struct __GLXDRIscreen { xf86LeaveVTProc *leaveVT; const __DRIcoreExtension *core; + const __DRIdri2Extension *dri2; const __DRIcopySubBufferExtension *copySubBuffer; const __DRIswapControlExtension *swapControl; const __DRItexBufferExtension *texBuffer; @@ -85,6 +86,12 @@ struct __GLXDRIdrawable { __GLXdrawable base; __DRIdrawable *driDrawable; __GLXDRIscreen *screen; + + /* Dimensions as last reported by DRI2GetBuffers. */ + int width; + int height; + __DRIbuffer buffers[5]; + int count; }; static void @@ -107,9 +114,9 @@ static GLboolean __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable) { __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable; - const __DRIcoreExtension *core = private->screen->core; - (*core->swapBuffers)(private->driDrawable); + DRI2SwapBuffers(drawable->pDraw, + 0, 0, private->width, private->height); return TRUE; } @@ -118,26 +125,15 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable) static int __glXDRIdrawableSwapInterval(__GLXdrawable *drawable, int interval) { - __GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable; - const __DRIswapControlExtension *swapControl = private->screen->swapControl; - - if (swapControl) - swapControl->setSwapInterval(private->driDrawable, interval); - return 0; } static void -__glXDRIdrawableCopySubBuffer(__GLXdrawable *basePrivate, +__glXDRIdrawableCopySubBuffer(__GLXdrawable *drawable, int x, int y, int w, int h) { - __GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate; - const __DRIcopySubBufferExtension *copySubBuffer = - private->screen->copySubBuffer; - - if (copySubBuffer) - (*copySubBuffer->copySubBuffer)(private->driDrawable, x, y, w, h); + DRI2SwapBuffers(drawable->pDraw, x, y, w, h); } static void @@ -275,7 +271,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, __GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen; __GLXDRIcontext *context, *shareContext; __GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig; - const __DRIcoreExtension *core = screen->core; __DRIcontext *driShare; shareContext = (__GLXDRIcontext *) baseShareContext; @@ -297,8 +292,9 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, context->base.textureFromPixmap = &__glXDRItextureFromPixmap; context->driContext = - (*core->createNewContext)(screen->driScreen, - config->driConfig, driShare, context); + (*screen->dri2->createNewContext)(screen->driScreen, + config->driConfig, + driShare, context); return &context->base; } @@ -313,8 +309,6 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen, __GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen; __GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig; __GLXDRIdrawable *private; - GLboolean retval; - unsigned int handle, head; private = xalloc(sizeof *private); if (private == NULL) @@ -333,42 +327,54 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen, private->base.swapBuffers = __glXDRIdrawableSwapBuffers; private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; - retval = DRI2CreateDrawable(pDraw, &handle, &head); + if (DRI2CreateDrawable(pDraw)) { + xfree(private); + return NULL; + } private->driDrawable = - (*driScreen->core->createNewDrawable)(driScreen->driScreen, - config->driConfig, - handle, head, private); + (*driScreen->dri2->createNewDrawable)(driScreen->driScreen, + config->driConfig, private); return &private->base; } -static void dri2ReemitDrawableInfo(__DRIdrawable *draw, unsigned int *tail, - void *loaderPrivate) +static __DRIbuffer * +dri2GetBuffers(__DRIdrawable *driDrawable, + int *width, int *height, + unsigned int *attachments, int count, + int *out_count, void *loaderPrivate) { - __GLXDRIdrawable *pdraw = loaderPrivate; + __GLXDRIdrawable *private = loaderPrivate; + DRI2BufferPtr buffers; + int i; - DRI2ReemitDrawableInfo(pdraw->base.pDraw, tail); -} + buffers = DRI2GetBuffers(private->base.pDraw, + width, height, attachments, count, out_count); + if (*out_count > 5) { + *out_count = 0; + return NULL; + } + + private->width = *width; + private->height = *height; + + /* This assumes the DRI2 buffer attachment tokens matches the + * __DRIbuffer tokens. */ + for (i = 0; i < *out_count; i++) { + private->buffers[i].attachment = buffers[i].attachment; + private->buffers[i].name = buffers[i].name; + private->buffers[i].pitch = buffers[i].pitch; + private->buffers[i].cpp = buffers[i].cpp; + private->buffers[i].flags = buffers[i].flags; + } -static void dri2PostDamage(__DRIdrawable *draw, - struct drm_clip_rect *rects, - int numRects, void *loaderPrivate) -{ - __GLXDRIdrawable *drawable = loaderPrivate; - DrawablePtr pDraw = drawable->base.pDraw; - RegionRec region; - - REGION_INIT(pDraw->pScreen, ®ion, (BoxPtr) rects, numRects); - REGION_TRANSLATE(pScreen, ®ion, pDraw->x, pDraw->y); - DamageDamageRegion(pDraw, ®ion); - REGION_UNINIT(pDraw->pScreen, ®ion); + return private->buffers; } -static const __DRIloaderExtension loaderExtension = { - { __DRI_LOADER, __DRI_LOADER_VERSION }, - dri2ReemitDrawableInfo, - dri2PostDamage +static const __DRIdri2LoaderExtension loaderExtension = { + { __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION }, + dri2GetBuffers, }; static const __DRIextension *loader_extensions[] = { @@ -416,18 +422,11 @@ initializeExtensions(__GLXDRIscreen *screen) extensions = screen->core->getExtensions(screen->driScreen); - for (i = 0; extensions[i]; i++) { -#ifdef __DRI_COPY_SUB_BUFFER - if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) { - screen->copySubBuffer = - (const __DRIcopySubBufferExtension *) extensions[i]; - __glXEnableExtension(screen->glx_enable_bits, - "GLX_MESA_copy_sub_buffer"); - - LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n"); - } -#endif + __glXEnableExtension(screen->glx_enable_bits, + "GLX_MESA_copy_sub_buffer"); + LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n"); + for (i = 0; extensions[i]; i++) { #ifdef __DRI_SWAP_CONTROL if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) { screen->swapControl = @@ -461,7 +460,6 @@ __glXDRIscreenProbe(ScreenPtr pScreen) char filename[128]; size_t buffer_size; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - unsigned int sareaHandle; const __DRIextension **extensions; const __DRIconfig **driConfigs; int i; @@ -472,7 +470,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) memset(screen, 0, sizeof *screen); if (!xf86LoaderCheckSymbol("DRI2Connect") || - !DRI2Connect(pScreen, &screen->fd, &driverName, &sareaHandle)) { + !DRI2Connect(pScreen, &screen->fd, &driverName)) { LogMessage(X_INFO, "AIGLX: Screen %d is not DRI2 capable\n", pScreen->myNum); return NULL; @@ -508,24 +506,28 @@ __glXDRIscreenProbe(ScreenPtr pScreen) extensions[i]->version >= __DRI_CORE_VERSION) { screen->core = (const __DRIcoreExtension *) extensions[i]; } + if (strcmp(extensions[i]->name, __DRI_DRI2) == 0 && + extensions[i]->version >= __DRI_DRI2_VERSION) { + screen->dri2 = (const __DRIdri2Extension *) extensions[i]; + } } - if (screen->core == NULL) { + if (screen->core == NULL || screen->dri2 == NULL) { LogMessage(X_ERROR, "AIGLX error: %s exports no DRI extension\n", driverName); goto handle_error; } screen->driScreen = - (*screen->core->createNewScreen)(pScreen->myNum, + (*screen->dri2->createNewScreen)(pScreen->myNum, screen->fd, - sareaHandle, loader_extensions, &driConfigs, screen); if (screen->driScreen == NULL) { - LogMessage(X_ERROR, "AIGLX error: Calling driver entry point failed"); + LogMessage(X_ERROR, + "AIGLX error: Calling driver entry point failed\n"); goto handle_error; } |