From 3f6bc8b703e972c0a16cd775f2ad3a54beaa0ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 24 Aug 2011 21:18:08 -0400 Subject: [PATCH] dri: Remove dri1 common code --- src/mesa/drivers/dri/Makefile.defines | 1 - src/mesa/drivers/dri/common/dri_util.c | 563 +-------------------------- src/mesa/drivers/dri/common/dri_util.h | 285 +-------------- src/mesa/drivers/dri/common/vblank.c | 434 --------------------- src/mesa/drivers/dri/common/vblank.h | 71 ---- src/mesa/drivers/dri/intel/intel_context.c | 15 - src/mesa/drivers/dri/intel/intel_screen.c | 1 - src/mesa/drivers/dri/radeon/radeon_common.c | 26 -- src/mesa/drivers/dri/radeon/radeon_screen.c | 62 +--- 9 files changed, 17 insertions(+), 1441 deletions(-) delete mode 100644 src/mesa/drivers/dri/common/vblank.c delete mode 100644 src/mesa/drivers/dri/common/vblank.h diff --git a/src/mesa/drivers/dri/Makefile.defines b/src/mesa/drivers/dri/Makefile.defines index 19b6de8..ab75a65 100644 --- a/src/mesa/drivers/dri/Makefile.defines +++ b/src/mesa/drivers/dri/Makefile.defines @@ -2,7 +2,6 @@ COMMON_GALLIUM_SOURCES = \ ../common/utils.c \ - ../common/vblank.c \ ../common/dri_util.c \ ../common/xmlconfig.c diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 82638fa..5650bc0 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -50,27 +50,6 @@ typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t static void dri_get_drawable(__DRIdrawable *pdp); static void dri_put_drawable(__DRIdrawable *pdp); -/** - * This is just a token extension used to signal that the driver - * supports setting a read drawable. - */ -const __DRIextension driReadDrawableExtension = { - __DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION -}; - -GLint -driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 ) -{ - if (rect2.x1 > rect1.x1) rect1.x1 = rect2.x1; - if (rect2.x2 < rect1.x2) rect1.x2 = rect2.x2; - if (rect2.y1 > rect1.y1) rect1.y1 = rect2.y1; - if (rect2.y2 < rect1.y2) rect1.y2 = rect2.y2; - - if (rect1.x1 > rect1.x2 || rect1.y1 > rect1.y2) return 0; - - return (rect1.x2 - rect1.x1) * (rect1.y2 - rect1.y1); -} - /*****************************************************************/ /** \name Context (un)binding functions */ /*****************************************************************/ @@ -174,293 +153,10 @@ static int driBindContext(__DRIcontext *pcp, dri_get_drawable(prp); } - /* - ** Now that we have a context associated with this drawable, we can - ** initialize the drawable information if has not been done before. - */ - - if (!psp->dri2.enabled) { - if (pdp && !pdp->pStamp) { - DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - __driUtilUpdateDrawableInfo(pdp); - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - } - if (prp && pdp != prp && !prp->pStamp) { - DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - __driUtilUpdateDrawableInfo(prp); - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - } - } - /* Call device-specific MakeCurrent */ return (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp); } -/*@}*/ - - -/*****************************************************************/ -/** \name Drawable handling functions */ -/*****************************************************************/ -/*@{*/ - -/** - * Update private drawable information. - * - * \param pdp pointer to the private drawable information to update. - * - * This function basically updates the __DRIdrawable struct's - * cliprect information by calling \c __DRIinterfaceMethods::getDrawableInfo. - * This is usually called by the DRI_VALIDATE_DRAWABLE_INFO macro which - * compares the __DRIdrwablePrivate pStamp and lastStamp values. If - * the values are different that means we have to update the clipping - * info. - */ -void -__driUtilUpdateDrawableInfo(__DRIdrawable *pdp) -{ - __DRIscreen *psp = pdp->driScreenPriv; - __DRIcontext *pcp = pdp->driContextPriv; - - if (!pcp - || ((pdp != pcp->driDrawablePriv) && (pdp != pcp->driReadablePriv))) { - /* ERROR!!! - * ...but we must ignore it. There can be many contexts bound to a - * drawable. - */ - } - - if (pdp->pClipRects) { - free(pdp->pClipRects); - pdp->pClipRects = NULL; - } - - if (pdp->pBackClipRects) { - free(pdp->pBackClipRects); - pdp->pBackClipRects = NULL; - } - - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - - if (! (*psp->getDrawableInfo->getDrawableInfo)(pdp, - &pdp->index, &pdp->lastStamp, - &pdp->x, &pdp->y, &pdp->w, &pdp->h, - &pdp->numClipRects, &pdp->pClipRects, - &pdp->backX, - &pdp->backY, - &pdp->numBackClipRects, - &pdp->pBackClipRects, - pdp->loaderPrivate)) { - /* Error -- eg the window may have been destroyed. Keep going - * with no cliprects. - */ - pdp->pStamp = &pdp->lastStamp; /* prevent endless loop */ - pdp->numClipRects = 0; - pdp->pClipRects = NULL; - pdp->numBackClipRects = 0; - pdp->pBackClipRects = NULL; - } - else - pdp->pStamp = &(psp->pSAREA->drawableTable[pdp->index].stamp); - - DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); -} - -/*@}*/ - -/*****************************************************************/ -/** \name GLX callbacks */ -/*****************************************************************/ -/*@{*/ - -static void driReportDamage(__DRIdrawable *pdp, - struct drm_clip_rect *pClipRects, int numClipRects) -{ - __DRIscreen *psp = pdp->driScreenPriv; - - /* Check that we actually have the new damage report method */ - if (psp->damage) { - /* Report the damage. Currently, all our drivers draw - * directly to the front buffer, so we report the damage there - * rather than to the backing storein (if any). - */ - (*psp->damage->reportDamage)(pdp, - pdp->x, pdp->y, - pClipRects, numClipRects, - GL_TRUE, pdp->loaderPrivate); - } -} - - -/** - * Swap buffers. - * - * \param drawablePrivate opaque pointer to the per-drawable private info. - * - * \internal - * This function calls __DRIdrawable::swapBuffers. - * - * Is called directly from glXSwapBuffers(). - */ -static void driSwapBuffers(__DRIdrawable *dPriv) -{ - __DRIscreen *psp = dPriv->driScreenPriv; - drm_clip_rect_t *rects; - int i; - - psp->DriverAPI.SwapBuffers(dPriv); - - if (!dPriv->numClipRects) - return; - - rects = malloc(sizeof(*rects) * dPriv->numClipRects); - - if (!rects) - return; - - for (i = 0; i < dPriv->numClipRects; i++) { - rects[i].x1 = dPriv->pClipRects[i].x1 - dPriv->x; - rects[i].y1 = dPriv->pClipRects[i].y1 - dPriv->y; - rects[i].x2 = dPriv->pClipRects[i].x2 - dPriv->x; - rects[i].y2 = dPriv->pClipRects[i].y2 - dPriv->y; - } - - driReportDamage(dPriv, rects, dPriv->numClipRects); - free(rects); -} - -static int driDrawableGetMSC( __DRIscreen *sPriv, __DRIdrawable *dPriv, - int64_t *msc ) -{ - return sPriv->DriverAPI.GetDrawableMSC(sPriv, dPriv, msc); -} - - -static int driWaitForMSC(__DRIdrawable *dPriv, int64_t target_msc, - int64_t divisor, int64_t remainder, - int64_t * msc, int64_t * sbc) -{ - __DRIswapInfo sInfo; - int status; - - status = dPriv->driScreenPriv->DriverAPI.WaitForMSC( dPriv, target_msc, - divisor, remainder, - msc ); - - /* GetSwapInfo() may not be provided by the driver if GLX_SGI_video_sync - * is supported but GLX_OML_sync_control is not. Therefore, don't return - * an error value if GetSwapInfo() is not implemented. - */ - if ( status == 0 - && dPriv->driScreenPriv->DriverAPI.GetSwapInfo ) { - status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo ); - *sbc = sInfo.swap_count; - } - - return status; -} - - -const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = { - { __DRI_MEDIA_STREAM_COUNTER, __DRI_MEDIA_STREAM_COUNTER_VERSION }, - driWaitForMSC, - driDrawableGetMSC, -}; - - -static void driCopySubBuffer(__DRIdrawable *dPriv, - int x, int y, int w, int h) -{ - drm_clip_rect_t rect; - - rect.x1 = x; - rect.y1 = dPriv->h - y - h; - rect.x2 = x + w; - rect.y2 = rect.y1 + h; - driReportDamage(dPriv, &rect, 1); - - dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h); -} - -const __DRIcopySubBufferExtension driCopySubBufferExtension = { - { __DRI_COPY_SUB_BUFFER, __DRI_COPY_SUB_BUFFER_VERSION }, - driCopySubBuffer -}; - -static void driSetSwapInterval(__DRIdrawable *dPriv, unsigned int interval) -{ - dPriv->swap_interval = interval; -} - -static unsigned int driGetSwapInterval(__DRIdrawable *dPriv) -{ - return dPriv->swap_interval; -} - -const __DRIswapControlExtension driSwapControlExtension = { - { __DRI_SWAP_CONTROL, __DRI_SWAP_CONTROL_VERSION }, - driSetSwapInterval, - driGetSwapInterval -}; - - -/** - * This is called via __DRIscreenRec's createNewDrawable pointer. - */ -static __DRIdrawable * -driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, - drm_drawable_t hwDrawable, int renderType, - const int *attrs, void *data) -{ - __DRIdrawable *pdp; - - /* Since pbuffers are not yet supported, no drawable attributes are - * supported either. - */ - (void) attrs; - - pdp = malloc(sizeof *pdp); - if (!pdp) { - return NULL; - } - - pdp->driContextPriv = NULL; - pdp->loaderPrivate = data; - pdp->hHWDrawable = hwDrawable; - pdp->refcount = 1; - pdp->pStamp = NULL; - pdp->lastStamp = 0; - pdp->index = 0; - pdp->x = 0; - pdp->y = 0; - pdp->w = 0; - pdp->h = 0; - pdp->numClipRects = 0; - pdp->numBackClipRects = 0; - pdp->pClipRects = NULL; - pdp->pBackClipRects = NULL; - pdp->vblSeq = 0; - pdp->vblFlags = 0; - - pdp->driScreenPriv = psp; - - if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes, 0)) { - free(pdp); - return NULL; - } - - pdp->msc_base = 0; - - /* This special default value is replaced with the configured - * default value when the drawable is first bound to a direct - * rendering context. - */ - pdp->swap_interval = (unsigned)-1; - - return pdp; -} - - static __DRIdrawable * dri2CreateNewDrawable(__DRIscreen *screen, const __DRIconfig *config, @@ -468,12 +164,20 @@ dri2CreateNewDrawable(__DRIscreen *screen, { __DRIdrawable *pdraw; - pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, loaderPrivate); + pdraw = malloc(sizeof *pdraw); if (!pdraw) - return NULL; + return NULL; + + pdraw->driContextPriv = NULL; + pdraw->loaderPrivate = loaderPrivate; + pdraw->refcount = 1; + + pdraw->driScreenPriv = screen; - pdraw->pClipRects = &pdraw->dri2.clipRect; - pdraw->pBackClipRects = &pdraw->dri2.clipRect; + if (!(*screen->DriverAPI.CreateBuffer)(screen, pdraw, &config->modes, 0)) { + free(pdraw); + return NULL; + } pdraw->pStamp = &pdraw->dri2.stamp; *pdraw->pStamp = pdraw->lastStamp + 1; @@ -548,14 +252,6 @@ static void dri_put_drawable(__DRIdrawable *pdp) psp = pdp->driScreenPriv; (*psp->DriverAPI.DestroyBuffer)(pdp); - if (pdp->pClipRects && pdp->pClipRects != &pdp->dri2.clipRect) { - free(pdp->pClipRects); - pdp->pClipRects = NULL; - } - if (pdp->pBackClipRects && pdp->pClipRects != &pdp->dri2.clipRect) { - free(pdp->pBackClipRects); - pdp->pBackClipRects = NULL; - } free(pdp); } } @@ -591,53 +287,6 @@ driDestroyContext(__DRIcontext *pcp) } -/** - * Create the per-drawable private driver information. - * - * \param render_type Type of rendering target. \c GLX_RGBA is the only - * type likely to ever be supported for direct-rendering. - * \param shared Context with which to share textures, etc. or NULL - * - * \returns An opaque pointer to the per-context private information on - * success, or \c NULL on failure. - * - * \internal - * This function allocates and fills a __DRIcontextRec structure. It - * performs some device independent initialization and passes all the - * relevent information to __DriverAPIRec::CreateContext to create the - * context. - * - */ -static __DRIcontext * -driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, - int render_type, __DRIcontext *shared, - drm_context_t hwContext, void *data) -{ - __DRIcontext *pcp; - void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; - - pcp = malloc(sizeof *pcp); - if (!pcp) - return NULL; - - pcp->driScreenPriv = psp; - pcp->driDrawablePriv = NULL; - pcp->loaderPrivate = data; - - pcp->dri2.draw_stamp = 0; - pcp->dri2.read_stamp = 0; - - pcp->hHWContext = hwContext; - - if ( !(*psp->DriverAPI.CreateContext)(API_OPENGL, - &config->modes, pcp, shareCtx) ) { - free(pcp); - return NULL; - } - - return pcp; -} - static unsigned int dri2GetAPIMask(__DRIscreen *screen) { @@ -731,14 +380,8 @@ static void driDestroyScreen(__DRIscreen *psp) if (psp->DriverAPI.DestroyScreen) (*psp->DriverAPI.DestroyScreen)(psp); - if (!psp->dri2.enabled) { - (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); - (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize); - (void)drmCloseOnce(psp->fd); - } else { - driDestroyOptionCache(&psp->optionCache); - driDestroyOptionInfo(&psp->optionInfo); - } + driDestroyOptionCache(&psp->optionCache); + driDestroyOptionInfo(&psp->optionInfo); free(psp); } @@ -751,12 +394,6 @@ setupLoaderExtensions(__DRIscreen *psp, int i; for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_GET_DRAWABLE_INFO) == 0) - psp->getDrawableInfo = (__DRIgetDrawableInfoExtension *) extensions[i]; - if (strcmp(extensions[i]->name, __DRI_DAMAGE) == 0) - psp->damage = (__DRIdamageExtension *) extensions[i]; - if (strcmp(extensions[i]->name, __DRI_SYSTEM_TIME) == 0) - psp->systemTime = (__DRIsystemTimeExtension *) extensions[i]; if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0) psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i]; if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0) @@ -767,95 +404,6 @@ setupLoaderExtensions(__DRIscreen *psp, } /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c struct gl_config that the driver can support for windows or - * pbuffers. - * - * For legacy DRI. - * - * \param scrn Index of the screen - * \param ddx_version Version of the 2D DDX. This may not be meaningful for - * all drivers. - * \param dri_version Version of the "server-side" DRI. - * \param drm_version Version of the kernel DRM. - * \param frame_buffer Data describing the location and layout of the - * framebuffer. - * \param pSAREA Pointer to the SAREA. - * \param fd Device handle for the DRM. - * \param extensions ?? - * \param driver_modes Returns modes suppoted by the driver - * \param loaderPrivate ?? - * - * \note There is no need to check the minimum API version in this - * function. Since the name of this function is versioned, it is - * impossible for a loader that is too old to even load this driver. - */ -static __DRIscreen * -driCreateNewScreen(int scrn, - const __DRIversion *ddx_version, - const __DRIversion *dri_version, - const __DRIversion *drm_version, - const __DRIframebuffer *frame_buffer, - drmAddress pSAREA, int fd, - const __DRIextension **extensions, - const __DRIconfig ***driver_modes, - void *loaderPrivate) -{ - static const __DRIextension *emptyExtensionList[] = { NULL }; - __DRIscreen *psp; - - if (driDriverAPI.InitScreen == NULL) - return NULL; - - psp = calloc(1, sizeof *psp); - if (!psp) - return NULL; - - setupLoaderExtensions(psp, extensions); - - /* - ** NOT_DONE: This is used by the X server to detect when the client - ** has died while holding the drawable lock. The client sets the - ** drawable lock to this value. - */ - psp->drawLockID = 1; - - psp->drm_version = *drm_version; - psp->ddx_version = *ddx_version; - psp->dri_version = *dri_version; - - psp->pSAREA = pSAREA; - psp->lock = (drmLock *) &psp->pSAREA->lock; - - psp->pFB = frame_buffer->base; - psp->fbSize = frame_buffer->size; - psp->fbStride = frame_buffer->stride; - psp->fbWidth = frame_buffer->width; - psp->fbHeight = frame_buffer->height; - psp->devPrivSize = frame_buffer->dev_priv_size; - psp->pDevPriv = frame_buffer->dev_priv; - psp->fbBPP = psp->fbStride * 8 / frame_buffer->width; - - psp->extensions = emptyExtensionList; - psp->fd = fd; - psp->myNum = scrn; - psp->dri2.enabled = GL_FALSE; - - psp->DriverAPI = driDriverAPI; - psp->api_mask = (1 << __DRI_API_OPENGL); - - *driver_modes = driDriverAPI.InitScreen(psp); - if (*driver_modes == NULL) { - free(psp); - return NULL; - } - - return psp; -} - -/** * DRI2 */ static __DRIscreen * @@ -865,7 +413,6 @@ dri2CreateNewScreen(int scrn, int fd, { static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; - drmVersionPtr version; if (driDriverAPI.InitScreen2 == NULL) return NULL; @@ -876,18 +423,9 @@ dri2CreateNewScreen(int scrn, int fd, setupLoaderExtensions(psp, extensions); - version = drmGetVersion(fd); - if (version) { - psp->drm_version.major = version->version_major; - psp->drm_version.minor = version->version_minor; - psp->drm_version.patch = version->version_patchlevel; - drmFreeVersion(version); - } - psp->extensions = emptyExtensionList; psp->fd = fd; psp->myNum = scrn; - psp->dri2.enabled = GL_TRUE; psp->DriverAPI = driDriverAPI; psp->api_mask = (1 << __DRI_API_OPENGL); @@ -923,7 +461,7 @@ const __DRIcoreExtension driCoreExtension = { driIndexConfigAttrib, NULL, driDestroyDrawable, - driSwapBuffers, + NULL, NULL, driCopyContext, driDestroyContext, @@ -931,14 +469,6 @@ const __DRIcoreExtension driCoreExtension = { driUnbindContext }; -/** Legacy DRI interface */ -const __DRIlegacyExtension driLegacyExtension = { - { __DRI_LEGACY, __DRI_LEGACY_VERSION }, - driCreateNewScreen, - driCreateNewDrawable, - driCreateNewContext, -}; - /** DRI2 interface */ const __DRIdri2Extension driDRI2Extension = { { __DRI_DRI2, __DRI_DRI2_VERSION }, @@ -958,69 +488,6 @@ const __DRI2configQueryExtension dri2ConfigQueryExtension = { dri2ConfigQueryf, }; -/** - * Calculate amount of swap interval used between GLX buffer swaps. - * - * The usage value, on the range [0,max], is the fraction of total swap - * interval time used between GLX buffer swaps is calculated. - * - * \f$p = t_d / (i * t_r)\f$ - * - * Where \f$t_d\f$ is the time since the last GLX buffer swap, \f$i\f$ is the - * swap interval (as set by \c glXSwapIntervalSGI), and \f$t_r\f$ time - * required for a single vertical refresh period (as returned by \c - * glXGetMscRateOML). - * - * See the documentation for the GLX_MESA_swap_frame_usage extension for more - * details. - * - * \param dPriv Pointer to the private drawable structure. - * \return If less than a single swap interval time period was required - * between GLX buffer swaps, a number greater than 0 and less than - * 1.0 is returned. If exactly one swap interval time period is - * required, 1.0 is returned, and if more than one is required then - * a number greater than 1.0 will be returned. - * - * \sa glXSwapIntervalSGI glXGetMscRateOML - * - * \todo Instead of caching the \c glXGetMscRateOML function pointer, would it - * be possible to cache the sync rate? - */ -float -driCalculateSwapUsage( __DRIdrawable *dPriv, int64_t last_swap_ust, - int64_t current_ust ) -{ - int32_t n; - int32_t d; - int interval; - float usage = 1.0; - __DRIscreen *psp = dPriv->driScreenPriv; - - if ( (*psp->systemTime->getMSCRate)(dPriv, &n, &d, dPriv->loaderPrivate) ) { - interval = (dPriv->swap_interval != 0) ? dPriv->swap_interval : 1; - - - /* We want to calculate - * (current_UST - last_swap_UST) / (interval * us_per_refresh). We get - * current_UST by calling __glXGetUST. last_swap_UST is stored in - * dPriv->swap_ust. interval has already been calculated. - * - * The only tricky part is us_per_refresh. us_per_refresh is - * 1000000 / MSC_rate. We know the MSC_rate is n / d. We can flip it - * around and say us_per_refresh = 1000000 * d / n. Since this goes in - * the denominator of the final calculation, we calculate - * (interval * 1000000 * d) and move n into the numerator. - */ - - usage = (current_ust - last_swap_ust); - usage *= n; - usage /= (interval * d); - usage /= 1000000.0; - } - - return usage; -} - void dri2InvalidateDrawable(__DRIdrawable *drawable) { diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 3d3d5c9..79320bb 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -49,7 +49,6 @@ #include #include -#include #include #include "xmlconfig.h" #include "main/glheader.h" @@ -58,75 +57,14 @@ #define GLX_BAD_CONTEXT 5 -typedef struct __DRIswapInfoRec __DRIswapInfo; - /** * Extensions. */ -extern const __DRIlegacyExtension driLegacyExtension; extern const __DRIcoreExtension driCoreExtension; extern const __DRIdri2Extension driDRI2Extension; -extern const __DRIextension driReadDrawableExtension; -extern const __DRIcopySubBufferExtension driCopySubBufferExtension; -extern const __DRIswapControlExtension driSwapControlExtension; -extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension; extern const __DRI2configQueryExtension dri2ConfigQueryExtension; /** - * Used by DRI_VALIDATE_DRAWABLE_INFO - */ -#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(pDrawPriv) \ - do { \ - if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \ - __driUtilUpdateDrawableInfo(pDrawPriv); \ - } \ - } while (0) - - -/** - * Utility macro to validate the drawable information. - * - * See __DRIdrawable::pStamp and __DRIdrawable::lastStamp. - */ -#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp) \ -do { \ - while (*(pdp->pStamp) != pdp->lastStamp) { \ - register unsigned int hwContext = psp->pSAREA->lock.lock & \ - ~(DRM_LOCK_HELD | DRM_LOCK_CONT); \ - DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, hwContext); \ - \ - DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ - DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \ - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ - \ - DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, hwContext); \ - } \ -} while (0) - -/** - * Same as above, but for two drawables simultaneously. - * - */ - -#define DRI_VALIDATE_TWO_DRAWABLES_INFO(psp, pdp, prp) \ -do { \ - while (*((pdp)->pStamp) != (pdp)->lastStamp || \ - *((prp)->pStamp) != (prp)->lastStamp) { \ - register unsigned int hwContext = (psp)->pSAREA->lock.lock & \ - ~(DRM_LOCK_HELD | DRM_LOCK_CONT); \ - DRM_UNLOCK((psp)->fd, &(psp)->pSAREA->lock, hwContext); \ - \ - DRM_SPINLOCK(&(psp)->pSAREA->drawable_lock, (psp)->drawLockID); \ - DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \ - DRI_VALIDATE_DRAWABLE_INFO_ONCE(prp); \ - DRM_SPINUNLOCK(&(psp)->pSAREA->drawable_lock, (psp)->drawLockID); \ - \ - DRM_LIGHT_LOCK((psp)->fd, &(psp)->pSAREA->lock, hwContext); \ - } \ -} while (0) - - -/** * Driver callback functions. * * Each DRI driver must have one of these structures with all the pointers set @@ -137,8 +75,6 @@ do { \ * this structure. */ struct __DriverAPIRec { - const __DRIconfig **(*InitScreen) (__DRIscreen * priv); - /** * Screen destruction callback */ @@ -171,11 +107,6 @@ struct __DriverAPIRec { void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); /** - * Buffer swapping callback - */ - void (*SwapBuffers)(__DRIdrawable *driDrawPriv); - - /** * Context activation callback */ GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, @@ -187,40 +118,6 @@ struct __DriverAPIRec { */ GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); - /** - * Retrieves statistics about buffer swap operations. Required if - * GLX_OML_sync_control or GLX_MESA_swap_frame_usage is supported. - */ - int (*GetSwapInfo)( __DRIdrawable *dPriv, __DRIswapInfo * sInfo ); - - - /** - * These are required if GLX_OML_sync_control is supported. - */ - /*@{*/ - int (*WaitForMSC)( __DRIdrawable *priv, int64_t target_msc, - int64_t divisor, int64_t remainder, - int64_t * msc ); - int (*WaitForSBC)( __DRIdrawable *priv, int64_t target_sbc, - int64_t * msc, int64_t * sbc ); - - int64_t (*SwapBuffersMSC)( __DRIdrawable *priv, int64_t target_msc, - int64_t divisor, int64_t remainder ); - /*@}*/ - void (*CopySubBuffer)(__DRIdrawable *driDrawPriv, - int x, int y, int w, int h); - - /** - * New version of GetMSC so we can pass drawable data to the low - * level DRM driver (e.g. pipe info). Required if - * GLX_SGI_video_sync or GLX_OML_sync_control is supported. - */ - int (*GetDrawableMSC) ( __DRIscreen * priv, - __DRIdrawable *drawablePrivate, - int64_t *count); - - - /* DRI2 Entry point */ const __DRIconfig **(*InitScreen2) (__DRIscreen * priv); @@ -234,47 +131,11 @@ struct __DriverAPIRec { extern const struct __DriverAPIRec driDriverAPI; -struct __DRIswapInfoRec { - /** - * Number of swapBuffers operations that have been *completed*. - */ - uint64_t swap_count; - - /** - * Unadjusted system time of the last buffer swap. This is the time - * when the swap completed, not the time when swapBuffers was called. - */ - int64_t swap_ust; - - /** - * Number of swap operations that occurred after the swap deadline. That - * is if a swap happens more than swap_interval frames after the previous - * swap, it has missed its deadline. If swap_interval is 0, then the - * swap deadline is 1 frame after the previous swap. - */ - uint64_t swap_missed_count; - - /** - * Amount of time used by the last swap that missed its deadline. This - * is calculated as (__glXGetUST() - swap_ust) / (swap_interval * - * time_for_single_vrefresh)). If the actual value of swap_interval is - * 0, then 1 is used instead. If swap_missed_count is non-zero, this - * should be greater-than 1.0. - */ - float swap_missed_usage; -}; - - /** * Per-drawable private DRI driver information. */ struct __DRIdrawableRec { /** - * Kernel drawable handle - */ - drm_drawable_t hHWDrawable; - - /** * Driver's private drawable information. * * This structure is opaque. @@ -297,10 +158,7 @@ struct __DRIdrawableRec { */ int refcount; - /** - * Index of this drawable information in the SAREA. - */ - unsigned int index; + int w, h; /** * Pointer to the "drawable has changed ID" stamp in the SAREA (or @@ -318,59 +176,6 @@ struct __DRIdrawableRec { unsigned int lastStamp; /** - * \name Drawable - * - * Drawable information used in software fallbacks. - */ - /*@{*/ - int x; - int y; - int w; - int h; - int numClipRects; - drm_clip_rect_t *pClipRects; - /*@}*/ - - /** - * \name Back and depthbuffer - * - * Information about the back and depthbuffer where different from above. - */ - /*@{*/ - int backX; - int backY; - int backClipRectType; - int numBackClipRects; - drm_clip_rect_t *pBackClipRects; - /*@}*/ - - /** - * \name Vertical blank tracking information - * Used for waiting on vertical blank events. - */ - /*@{*/ - unsigned int vblSeq; - unsigned int vblFlags; - /*@}*/ - - /** - * \name Monotonic MSC tracking - * - * Low level driver is responsible for updating msc_base and - * vblSeq values so that higher level code can calculate - * a new msc value or msc target for a WaitMSC call. The new value - * will be: - * msc = msc_base + get_vblank_count() - vblank_base; - * - * And for waiting on a value, core code will use: - * actual_target = target_msc - msc_base + vblank_base; - */ - /*@{*/ - int64_t vblank_base; - int64_t msc_base; - /*@}*/ - - /** * Pointer to context to which this drawable is currently bound. */ __DRIcontext *driContextPriv; @@ -380,15 +185,8 @@ struct __DRIdrawableRec { */ __DRIscreen *driScreenPriv; - /** - * Controls swap interval as used by GLX_SGI_swap_control and - * GLX_MESA_swap_control. - */ - unsigned int swap_interval; - struct { unsigned int stamp; - drm_clip_rect_t clipRect; } dri2; }; @@ -397,11 +195,6 @@ struct __DRIdrawableRec { */ struct __DRIcontextRec { /** - * Kernel context handle used to access the device lock. - */ - drm_context_t hHWContext; - - /** * Device driver's private context data. This structure is opaque. */ void *driverPrivate; @@ -447,28 +240,6 @@ struct __DRIscreenRec { struct __DriverAPIRec DriverAPI; const __DRIextension **extensions; - /** - * DDX / 2D driver version information. - */ - __DRIversion ddx_version; - - /** - * DRI X extension version information. - */ - __DRIversion dri_version; - - /** - * DRM (kernel module) version information. - */ - __DRIversion drm_version; - - /** - * ID used when the client sets the drawable lock. - * - * The X server uses this value to detect if the client has died while - * holding the drawable lock. - */ - int drawLockID; /** * File descriptor returned when the kernel device driver is opened. @@ -481,39 +252,6 @@ struct __DRIscreenRec { int fd; /** - * SAREA pointer - * - * Used to access: - * - the device lock - * - the device-independent per-drawable and per-context(?) information - */ - drm_sarea_t *pSAREA; - - /** - * \name Direct frame buffer access information - * Used for software fallbacks. - */ - /*@{*/ - unsigned char *pFB; - int fbSize; - int fbOrigin; - int fbStride; - int fbWidth; - int fbHeight; - int fbBPP; - /*@}*/ - - /** - * \name Device-dependent private information (stored in the SAREA). - * - * This data is accessed by the client driver only. - */ - /*@{*/ - void *pDevPriv; - int devPrivSize; - /*@}*/ - - /** * Device-dependent private information (not stored in the SAREA). * * This pointer is never touched by the DRI layer. @@ -524,23 +262,12 @@ struct __DRIscreenRec { void *private; #endif - /* Extensions provided by the loader. */ - const __DRIgetDrawableInfoExtension *getDrawableInfo; - const __DRIsystemTimeExtension *systemTime; - const __DRIdamageExtension *damage; - struct { - /* Flag to indicate that this is a DRI2 screen. Many of the above - * fields will not be valid or initializaed in that case. */ - int enabled; __DRIdri2LoaderExtension *loader; __DRIimageLookupExtension *image; __DRIuseInvalidateExtension *useInvalidate; } dri2; - /* The lock actually in use, old sarea or DRI2 */ - drmLock *lock; - driOptionCache optionInfo; driOptionCache optionCache; unsigned int api_mask; @@ -548,16 +275,6 @@ struct __DRIscreenRec { }; extern void -__driUtilUpdateDrawableInfo(__DRIdrawable *pdp); - -extern float -driCalculateSwapUsage( __DRIdrawable *dPriv, - int64_t last_swap_ust, int64_t current_ust ); - -extern GLint -driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 ); - -extern void dri2InvalidateDrawable(__DRIdrawable *drawable); #endif /* _DRI_UTIL_H_ */ diff --git a/src/mesa/drivers/dri/common/vblank.c b/src/mesa/drivers/dri/common/vblank.c deleted file mode 100644 index cb98dd0..0000000 --- a/src/mesa/drivers/dri/common/vblank.c +++ /dev/null @@ -1,434 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * (c) Copyright IBM Corporation 2002 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Ian Romanick - */ - -#include "main/glheader.h" -#include "xf86drm.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/dd.h" -#include "vblank.h" -#include "xmlpool.h" - -static unsigned int msc_to_vblank(__DRIdrawable * dPriv, int64_t msc) -{ - return (unsigned int)(msc - dPriv->msc_base + dPriv->vblank_base); -} - -static int64_t vblank_to_msc(__DRIdrawable * dPriv, unsigned int vblank) -{ - return (int64_t)(vblank - dPriv->vblank_base + dPriv->msc_base); -} - - -/****************************************************************************/ -/** - * Get the current MSC refresh counter. - * - * Stores the 64-bit count of vertical refreshes since some (arbitrary) - * point in time in \c count. Unless the value wraps around, which it - * may, it will never decrease for a given drawable. - * - * \warning This function is called from \c glXGetVideoSyncSGI, which expects - * a \c count of type \c unsigned (32-bit), and \c glXGetSyncValuesOML, which - * expects a \c count of type \c int64_t (signed 64-bit). The kernel ioctl - * currently always returns a \c sequence of type \c unsigned. - * - * \param priv Pointer to the DRI screen private struct. - * \param dPriv Pointer to the DRI drawable private struct - * \param count Storage to hold MSC counter. - * \return Zero is returned on success. A negative errno value - * is returned on failure. - */ -int driDrawableGetMSC32( __DRIscreen * priv, - __DRIdrawable * dPriv, - int64_t * count) -{ - drmVBlank vbl; - int ret; - - /* Don't wait for anything. Just get the current refresh count. */ - - vbl.request.type = DRM_VBLANK_RELATIVE; - vbl.request.sequence = 0; - if ( dPriv && dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) - vbl.request.type |= DRM_VBLANK_SECONDARY; - - ret = drmWaitVBlank( priv->fd, &vbl ); - - if (dPriv) { - *count = vblank_to_msc(dPriv, vbl.reply.sequence); - } else { - /* Old driver (no knowledge of drawable MSC callback) */ - *count = vbl.reply.sequence; - } - - return ret; -} - -/****************************************************************************/ -/** - * Wait for a specified refresh count. This implements most of the - * functionality of \c glXWaitForMscOML from the GLX_OML_sync_control spec. - * Waits for the \c target_msc refresh. If that has already passed, it - * waits until \f$(MSC \bmod divisor)\f$ is equal to \c remainder. If - * \c target_msc is 0, use the behavior of glXWaitVideoSyncSGI(), which - * omits the initial check against a target MSC value. - * - * This function is actually something of a hack. The problem is that, at - * the time of this writing, none of the existing DRM modules support an - * ioctl that returns a 64-bit count (at least not on 32-bit platforms). - * However, this function exists to support a GLX function that requires - * the use of 64-bit counts. As such, there is a little bit of ugly - * hackery at the end of this function to make the 32-bit count act like - * a 64-bit count. There are still some cases where this will break, but - * I believe it catches the most common cases. - * - * The real solution is to provide an ioctl that uses a 64-bit count. - * - * \param dpy Pointer to the \c Display. - * \param priv Pointer to the DRI drawable private. - * \param target_msc Desired refresh count to wait for. A value of 0 - * means to use the glXWaitVideoSyncSGI() behavior. - * \param divisor MSC divisor if \c target_msc is already reached. - * \param remainder Desired MSC remainder if \c target_msc is already - * reached. - * \param msc Buffer to hold MSC when done waiting. - * - * \return Zero on success or \c GLX_BAD_CONTEXT on failure. - */ - -int driWaitForMSC32( __DRIdrawable *priv, - int64_t target_msc, int64_t divisor, int64_t remainder, - int64_t * msc ) -{ - drmVBlank vbl; - - - if ( divisor != 0 ) { - int64_t next = target_msc; - int64_t r; - int dont_wait = (target_msc == 0); - - do { - /* dont_wait means we're using the glXWaitVideoSyncSGI() behavior. - * The first time around, just get the current count and proceed - * to the test for (MSC % divisor) == remainder. - */ - vbl.request.type = dont_wait ? DRM_VBLANK_RELATIVE : - DRM_VBLANK_ABSOLUTE; - vbl.request.sequence = next ? msc_to_vblank(priv, next) : 0; - if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) - vbl.request.type |= DRM_VBLANK_SECONDARY; - - if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) { - /* FIXME: This doesn't seem like the right thing to return here. - */ - return GLX_BAD_CONTEXT; - } - - *msc = vblank_to_msc(priv, vbl.reply.sequence); - - if (!dont_wait && *msc == next) - break; - dont_wait = 0; - - /* Assuming the wait-done test fails, the next refresh to wait for - * will be one that satisfies (MSC % divisor) == remainder. The - * value (MSC - (MSC % divisor) + remainder) is the refresh value - * closest to the current value that would satisfy the equation. - * If this refresh has already happened, we add divisor to obtain - * the next refresh after the current one that will satisfy it. - */ - r = ((uint64_t)*msc % divisor); - next = (*msc - r + remainder); - if (next <= *msc) - next += divisor; - - } while (r != remainder); - } - else { - /* If the \c divisor is zero, just wait until the MSC is greater - * than or equal to \c target_msc. - */ - - vbl.request.type = DRM_VBLANK_ABSOLUTE; - vbl.request.sequence = target_msc ? msc_to_vblank(priv, target_msc) : 0; - - if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) - vbl.request.type |= DRM_VBLANK_SECONDARY; - - if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) { - /* FIXME: This doesn't seem like the right thing to return here. - */ - return GLX_BAD_CONTEXT; - } - } - - *msc = vblank_to_msc(priv, vbl.reply.sequence); - - if ( *msc < target_msc ) { - *msc += 0x0000000100000000LL; - } - - return 0; -} - - -/****************************************************************************/ -/** - * Gets a set of default vertical-blank-wait flags based on the internal GLX - * API version and several configuration options. - */ - -GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache ) -{ - GLuint flags = VBLANK_FLAG_INTERVAL; - int vblank_mode; - - - if ( driCheckOption( optionCache, "vblank_mode", DRI_ENUM ) ) - vblank_mode = driQueryOptioni( optionCache, "vblank_mode" ); - else - vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; - - switch (vblank_mode) { - case DRI_CONF_VBLANK_NEVER: - flags = 0; - break; - case DRI_CONF_VBLANK_DEF_INTERVAL_0: - break; - case DRI_CONF_VBLANK_DEF_INTERVAL_1: - flags |= VBLANK_FLAG_THROTTLE; - break; - case DRI_CONF_VBLANK_ALWAYS_SYNC: - flags |= VBLANK_FLAG_SYNC; - break; - } - - return flags; -} - - -/****************************************************************************/ -/** - * Wrapper to call \c drmWaitVBlank. The main purpose of this function is to - * wrap the error message logging. The error message should only be logged - * the first time the \c drmWaitVBlank fails. If \c drmWaitVBlank is - * successful, \c vbl_seq will be set the sequence value in the reply. - * - * \param vbl Pointer to drmVBlank packet describing how to wait. - * \param vbl_seq Location to store the current refresh counter. - * \param fd File descriptor use to call into the DRM. - * \return Zero on success or -1 on failure. - */ - -static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd ) -{ - int ret; - - - ret = drmWaitVBlank( fd, vbl ); - if ( ret != 0 ) { - static GLboolean first_time = GL_TRUE; - - if ( first_time ) { - fprintf(stderr, - "%s: drmWaitVBlank returned %d, IRQs don't seem to be" - " working correctly.\nTry adjusting the vblank_mode" - " configuration parameter.\n", __FUNCTION__, ret); - first_time = GL_FALSE; - } - - return -1; - } - - *vbl_seq = vbl->reply.sequence; - return 0; -} - - -/****************************************************************************/ -/** - * Returns the default swap interval of the given drawable. - */ - -static unsigned -driGetDefaultVBlankInterval( const __DRIdrawable *priv ) -{ - if ( (priv->vblFlags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) { - return 1; - } - else { - return 0; - } -} - - -/****************************************************************************/ -/** - * Sets the default swap interval when the drawable is first bound to a - * direct rendering context. - */ - -void driDrawableInitVBlank( __DRIdrawable *priv ) -{ - if ( priv->swap_interval == (unsigned)-1 && - !( priv->vblFlags & VBLANK_FLAG_NO_IRQ ) ) { - /* Get current vertical blank sequence */ - drmVBlank vbl; - - vbl.request.type = DRM_VBLANK_RELATIVE; - if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) - vbl.request.type |= DRM_VBLANK_SECONDARY; - vbl.request.sequence = 0; - do_wait( &vbl, &priv->vblSeq, priv->driScreenPriv->fd ); - priv->vblank_base = priv->vblSeq; - - priv->swap_interval = driGetDefaultVBlankInterval( priv ); - } -} - - -/****************************************************************************/ -/** - * Returns the current swap interval of the given drawable. - */ - -unsigned -driGetVBlankInterval( const __DRIdrawable *priv ) -{ - if ( (priv->vblFlags & VBLANK_FLAG_INTERVAL) != 0 ) { - /* this must have been initialized when the drawable was first bound - * to a direct rendering context. */ - assert ( priv->swap_interval != (unsigned)-1 ); - - return priv->swap_interval; - } - else - return driGetDefaultVBlankInterval( priv ); -} - - -/****************************************************************************/ -/** - * Returns the current vertical blank sequence number of the given drawable. - */ - -void -driGetCurrentVBlank( __DRIdrawable *priv ) -{ - drmVBlank vbl; - - vbl.request.type = DRM_VBLANK_RELATIVE; - if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) { - vbl.request.type |= DRM_VBLANK_SECONDARY; - } - vbl.request.sequence = 0; - - (void) do_wait( &vbl, &priv->vblSeq, priv->driScreenPriv->fd ); -} - - -/****************************************************************************/ -/** - * Waits for the vertical blank for use with glXSwapBuffers. - * - * \param missed_deadline Set to \c GL_TRUE if the MSC after waiting is later - * than the "target" based on \c priv->vblFlags. The idea is - * that if \c missed_deadline is set, then the application is - * not achieving its desired framerate. - * \return Zero on success, -1 on error. - */ - -int -driWaitForVBlank( __DRIdrawable *priv, GLboolean * missed_deadline ) -{ - drmVBlank vbl; - unsigned original_seq; - unsigned deadline; - unsigned interval; - unsigned diff; - - *missed_deadline = GL_FALSE; - if ( (priv->vblFlags & (VBLANK_FLAG_INTERVAL | - VBLANK_FLAG_THROTTLE | - VBLANK_FLAG_SYNC)) == 0 || - (priv->vblFlags & VBLANK_FLAG_NO_IRQ) != 0 ) { - return 0; - } - - - /* VBLANK_FLAG_SYNC means to wait for at least one vertical blank. If - * that flag is not set, do a fake wait for zero vertical blanking - * periods so that we can get the current MSC. - * - * VBLANK_FLAG_INTERVAL and VBLANK_FLAG_THROTTLE mean to wait for at - * least one vertical blank since the last wait. Since do_wait modifies - * priv->vblSeq, we have to save the original value of priv->vblSeq for the - * VBLANK_FLAG_INTERVAL / VBLANK_FLAG_THROTTLE calculation later. - */ - - original_seq = priv->vblSeq; - interval = driGetVBlankInterval(priv); - deadline = original_seq + interval; - - vbl.request.type = DRM_VBLANK_RELATIVE; - if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) { - vbl.request.type |= DRM_VBLANK_SECONDARY; - } - vbl.request.sequence = ((priv->vblFlags & VBLANK_FLAG_SYNC) != 0) ? 1 : 0; - - if ( do_wait( & vbl, &priv->vblSeq, priv->driScreenPriv->fd ) != 0 ) { - return -1; - } - - diff = priv->vblSeq - deadline; - - /* No need to wait again if we've already reached the target */ - if (diff <= (1 << 23)) { - *missed_deadline = (priv->vblFlags & VBLANK_FLAG_SYNC) ? (diff > 0) : - GL_TRUE; - return 0; - } - - /* Wait until the target vertical blank. */ - vbl.request.type = DRM_VBLANK_ABSOLUTE; - if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) { - vbl.request.type |= DRM_VBLANK_SECONDARY; - } - vbl.request.sequence = deadline; - - if ( do_wait( & vbl, &priv->vblSeq, priv->driScreenPriv->fd ) != 0 ) { - return -1; - } - - diff = priv->vblSeq - deadline; - *missed_deadline = diff > 0 && diff <= (1 << 23); - - return 0; -} diff --git a/src/mesa/drivers/dri/common/vblank.h b/src/mesa/drivers/dri/common/vblank.h deleted file mode 100644 index 067fb5e..0000000 --- a/src/mesa/drivers/dri/common/vblank.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- mode: c; c-basic-offset: 3 -*- */ -/* - * (c) Copyright IBM Corporation 2002 - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Ian Romanick - */ - -#ifndef DRI_VBLANK_H -#define DRI_VBLANK_H - -#include "main/context.h" -#include "dri_util.h" -#include "xmlconfig.h" - -#define VBLANK_FLAG_INTERVAL (1U << 0) /* Respect the swap_interval setting - */ -#define VBLANK_FLAG_THROTTLE (1U << 1) /* Wait 1 refresh since last call. - */ -#define VBLANK_FLAG_SYNC (1U << 2) /* Sync to the next refresh. - */ -#define VBLANK_FLAG_NO_IRQ (1U << 7) /* DRM has no IRQ to wait on. - */ -#define VBLANK_FLAG_SECONDARY (1U << 8) /* Wait for secondary vblank. - */ - -extern int driGetMSC32( __DRIscreen * priv, int64_t * count ); -extern int driDrawableGetMSC32( __DRIscreen * priv, - __DRIdrawable * drawablePrivate, - int64_t * count); -extern int driWaitForMSC32( __DRIdrawable *priv, - int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc ); -extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache ); -extern void driDrawableInitVBlank ( __DRIdrawable *priv ); -extern unsigned driGetVBlankInterval( const __DRIdrawable *priv ); -extern void driGetCurrentVBlank( __DRIdrawable *priv ); -extern int driWaitForVBlank( __DRIdrawable *priv, - GLboolean * missed_deadline ); - -#undef usleep -#include /* for usleep() */ -#include /* for sched_yield() */ - -#define DO_USLEEP(nr) \ - do { \ - if (0) fprintf(stderr, "%s: usleep for %u\n", __FUNCTION__, nr ); \ - if (1) usleep( nr ); \ - sched_yield(); \ - } while( 0 ) - -#endif /* DRI_VBLANK_H */ diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 14342ef..43f3fdb 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -311,21 +311,6 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) if (buffers == NULL) return; - drawable->x = 0; - drawable->y = 0; - drawable->backX = 0; - drawable->backY = 0; - drawable->numClipRects = 1; - drawable->pClipRects[0].x1 = 0; - drawable->pClipRects[0].y1 = 0; - drawable->pClipRects[0].x2 = drawable->w; - drawable->pClipRects[0].y2 = drawable->h; - drawable->numBackClipRects = 1; - drawable->pBackClipRects[0].x1 = 0; - drawable->pBackClipRects[0].y1 = 0; - drawable->pBackClipRects[0].x2 = drawable->w; - drawable->pBackClipRects[0].y2 = drawable->h; - for (i = 0; i < count; i++) { switch (buffers[i].attachment) { case __DRI_BUFFER_FRONT_LEFT: diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index bd8d574..8ca69be 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -316,7 +316,6 @@ static struct __DRIimageExtensionRec intelImageExtension = { }; static const __DRIextension *intelScreenExtensions[] = { - &driReadDrawableExtension, &intelTexBufferExtension.base, &intelFlushExtension.base, &intelImageExtension.base, diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c index e7a6623..7a3265a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.c +++ b/src/mesa/drivers/dri/radeon/radeon_common.c @@ -611,32 +611,6 @@ void radeonSwapBuffers(__DRIdrawable * dPriv) } } -void radeonCopySubBuffer(__DRIdrawable * dPriv, - int x, int y, int w, int h ) -{ - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - radeonContextPtr radeon; - struct gl_context *ctx; - - radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = radeon->glCtx; - - if (ctx->Visual.doubleBufferMode) { - drm_clip_rect_t rect; - rect.x1 = x + dPriv->x; - rect.y1 = (dPriv->h - y - h) + dPriv->y; - rect.x2 = rect.x1 + w; - rect.y2 = rect.y1 + h; - _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */ - radeonCopyBuffer(dPriv, &rect); - } - } else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "%s: drawable has no context!", - __FUNCTION__); - } -} - /** * Check if we're about to draw into the front color buffer. * If so, set the intel->front_buffer_dirty field to true. diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 583a644..3f8f706 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -1551,9 +1551,6 @@ radeonCreateScreen( __DRIscreen *sPriv ) } i = 0; - screen->extensions[i++] = &driCopySubBufferExtension.base; - screen->extensions[i++] = &driReadDrawableExtension; - if ( screen->irq != 0 ) { screen->extensions[i++] = &driSwapControlExtension.base; screen->extensions[i++] = &driMediaStreamCounterExtension.base; @@ -2027,55 +2024,6 @@ radeonDestroyBuffer(__DRIdrawable *driDrawPriv) } -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the struct gl_config supported by this driver - */ -static const __DRIconfig ** -radeonInitScreen(__DRIscreen *psp) -{ -#if defined(RADEON_R100) - static const char *driver_name = "Radeon"; - static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 6, 0 }; -#elif defined(RADEON_R200) - static const char *driver_name = "R200"; - static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 6, 0 }; -#elif defined(RADEON_R300) - static const char *driver_name = "R300"; - static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 24, 0 }; -#elif defined(RADEON_R600) - static const char *driver_name = "R600"; - static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 }; - static const __DRIversion dri_expected = { 4, 0, 0 }; - static const __DRIversion drm_expected = { 1, 24, 0 }; -#endif - RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv; - - if ( ! driCheckDriDdxDrmVersions3( driver_name, - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) { - return NULL; - } - - if (!radeonInitDriver(psp)) - return NULL; - - /* for now fill in all modes */ - return radeonFillInModes( psp, - dri_priv->bpp, - (dri_priv->bpp == 16) ? 16 : 24, - (dri_priv->bpp == 16) ? 0 : 8, 1); -} #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) /** @@ -2176,7 +2124,7 @@ getSwapInfo( __DRIdrawable *dPriv, __DRIswapInfo * sInfo ) } const struct __DriverAPIRec driDriverAPI = { - .InitScreen = radeonInitScreen, + .InitScreen = NULL, .DestroyScreen = radeonDestroyScreen, #if defined(RADEON_R200) .CreateContext = r200CreateContext, @@ -2193,15 +2141,8 @@ const struct __DriverAPIRec driDriverAPI = { #endif .CreateBuffer = radeonCreateBuffer, .DestroyBuffer = radeonDestroyBuffer, - .SwapBuffers = radeonSwapBuffers, .MakeCurrent = radeonMakeCurrent, .UnbindContext = radeonUnbindContext, - .GetSwapInfo = getSwapInfo, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL, - .CopySubBuffer = radeonCopySubBuffer, /* DRI2 */ .InitScreen2 = radeonInitScreen2, }; @@ -2209,7 +2150,6 @@ const struct __DriverAPIRec driDriverAPI = { /* This is the table of extensions that the loader will dlsym() for. */ PUBLIC const __DRIextension *__driDriverExtensions[] = { &driCoreExtension.base, - &driLegacyExtension.base, &driDRI2Extension.base, NULL }; -- 1.7.4.1