From 02f377d5e2dd18537d0807ad63675a0970b5a37d Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 4 Nov 2011 08:57:20 +0100 Subject: xserver pixman mesa git update 4 nov 2011 --- .../src/mesa/drivers/dri/common/Makefile.sources | 5 +- mesalib/src/mesa/drivers/dri/common/dri_util.c | 596 +-------- mesalib/src/mesa/drivers/dri/common/dri_util.h | 285 +---- .../src/mesa/drivers/dri/common/drirenderbuffer.c | 200 --- .../src/mesa/drivers/dri/common/drirenderbuffer.h | 71 -- mesalib/src/mesa/drivers/dri/common/memops.h | 17 - .../src/mesa/drivers/dri/common/spantmp_common.h | 11 +- mesalib/src/mesa/drivers/dri/common/texmem.c | 1341 -------------------- mesalib/src/mesa/drivers/dri/common/texmem.h | 334 ----- mesalib/src/mesa/drivers/dri/common/utils.c | 118 -- mesalib/src/mesa/drivers/dri/common/utils.h | 25 - mesalib/src/mesa/drivers/dri/common/vblank.c | 434 ------- mesalib/src/mesa/drivers/dri/common/vblank.h | 71 -- mesalib/src/mesa/drivers/dri/common/xmlpool/de.po | 141 +- 14 files changed, 137 insertions(+), 3512 deletions(-) delete mode 100644 mesalib/src/mesa/drivers/dri/common/drirenderbuffer.c delete mode 100644 mesalib/src/mesa/drivers/dri/common/drirenderbuffer.h delete mode 100644 mesalib/src/mesa/drivers/dri/common/memops.h delete mode 100644 mesalib/src/mesa/drivers/dri/common/texmem.c delete mode 100644 mesalib/src/mesa/drivers/dri/common/texmem.h delete mode 100644 mesalib/src/mesa/drivers/dri/common/vblank.c delete mode 100644 mesalib/src/mesa/drivers/dri/common/vblank.h (limited to 'mesalib/src/mesa/drivers/dri/common') diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.sources b/mesalib/src/mesa/drivers/dri/common/Makefile.sources index 3432dda45..040b71725 100644 --- a/mesalib/src/mesa/drivers/dri/common/Makefile.sources +++ b/mesalib/src/mesa/drivers/dri/common/Makefile.sources @@ -1,13 +1,10 @@ mesa_dri_common_gallium_SOURCES := \ utils.c \ - vblank.c \ dri_util.c \ xmlconfig.c mesa_dri_common_SOURCES := \ - $(mesa_dri_common_gallium_SOURCES) \ - texmem.c \ - drirenderbuffer.c + $(mesa_dri_common_gallium_SOURCES) # Paths are relative to MESA_TOP. mesa_dri_common_INCLUDES := \ diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index cdd413737..da4e39f9c 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -17,19 +17,11 @@ #include #include -#include -#include #include -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - #include "main/imports.h" -#define None 0 #include "dri_util.h" -#include "drm_sarea.h" #include "utils.h" #include "xmlpool.h" #include "../glsl/glsl_parser_extras.h" @@ -50,27 +42,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,294 +145,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; - (void) renderType; - - 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, @@ -469,15 +156,24 @@ dri2CreateNewDrawable(__DRIscreen *screen, { __DRIdrawable *pdraw; - pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, loaderPrivate); + pdraw = malloc(sizeof *pdraw); if (!pdraw) - return NULL; + return NULL; - pdraw->pClipRects = &pdraw->dri2.clipRect; - pdraw->pBackClipRects = &pdraw->dri2.clipRect; + pdraw->driContextPriv = NULL; + pdraw->loaderPrivate = loaderPrivate; + pdraw->refcount = 1; + pdraw->lastStamp = 0; + pdraw->w = 0; + pdraw->h = 0; + pdraw->driScreenPriv = screen; + + if (!(*screen->DriverAPI.CreateBuffer)(screen, pdraw, &config->modes, 0)) { + free(pdraw); + return NULL; + } - pdraw->pStamp = &pdraw->dri2.stamp; - *pdraw->pStamp = pdraw->lastStamp + 1; + pdraw->dri2.stamp = pdraw->lastStamp + 1; return pdraw; } @@ -549,14 +245,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,58 +279,6 @@ driDestroyContext(__DRIcontext *pcp) } } - -/** - * Create the per-drawable private driver information. - * - * \param render_type Type of rendering target. \c GLX_RGBA_TYPE is the only - * type likely to ever be supported for direct-rendering. - * However, \c GLX_RGBA_FLOAT_TYPE_ARB may eventually be - * supported by some drivers. - * \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; - - (void) render_type; - - 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) { @@ -739,14 +375,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); } @@ -759,12 +389,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) @@ -774,99 +398,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; - - (void) loaderPrivate; - - if (driDriverAPI.InitScreen == NULL) { - __driUtilMessage("driver does not support DRI1"); - 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 */ @@ -899,7 +430,6 @@ dri2CreateNewScreen(int scrn, int fd, psp->extensions = emptyExtensionList; psp->fd = fd; psp->myNum = scrn; - psp->dri2.enabled = GL_TRUE; psp->DriverAPI = driDriverAPI; psp->api_mask = (1 << __DRI_API_OPENGL); @@ -935,7 +465,7 @@ const __DRIcoreExtension driCoreExtension = { driIndexConfigAttrib, NULL, driDestroyDrawable, - driSwapBuffers, + NULL, NULL, driCopyContext, driDestroyContext, @@ -943,14 +473,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 }, @@ -970,73 +492,27 @@ 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) { drawable->dri2.stamp++; } -/*@}*/ +/** + * Check that the gl_framebuffer associated with dPriv is the right size. + * Resize the gl_framebuffer if needed. + * It's expected that the dPriv->driverPrivate member points to a + * gl_framebuffer object. + */ +void +driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate; + if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) { + ctx->Driver.ResizeBuffers(ctx, fb, dPriv->w, dPriv->h); + /* if the driver needs the hw lock for ResizeBuffers, the drawable + might have changed again by now */ + assert(fb->Width == dPriv->w); + assert(fb->Height == dPriv->h); + } +} diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h index 3d3d5c9cd..7a3b0a9b2 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.h +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h @@ -58,74 +58,13 @@ #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. * @@ -137,8 +76,6 @@ do { \ * this structure. */ struct __DriverAPIRec { - const __DRIconfig **(*InitScreen) (__DRIscreen * priv); - /** * Screen destruction callback */ @@ -170,11 +107,6 @@ struct __DriverAPIRec { */ void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); - /** - * Buffer swapping callback - */ - void (*SwapBuffers)(__DRIdrawable *driDrawPriv); - /** * Context activation callback */ @@ -186,40 +118,6 @@ struct __DriverAPIRec { * Context unbinding callback */ 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,46 +132,10 @@ 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. * @@ -297,78 +159,16 @@ struct __DRIdrawableRec { */ int refcount; - /** - * Index of this drawable information in the SAREA. - */ - unsigned int index; - - /** - * Pointer to the "drawable has changed ID" stamp in the SAREA (or - * to dri2.stamp if DRI2 is being used). - */ - unsigned int *pStamp; - /** * Last value of the stamp. * - * If this differs from the value stored at __DRIdrawable::pStamp, + * If this differs from the value stored at __DRIdrawable::dri2.stamp, * then the drawable information has been modified by the X server, and the * drawable information (below) should be retrieved from the X server. */ 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; - /*@}*/ + int w, h; /** * Pointer to context to which this drawable is currently bound. @@ -381,14 +181,10 @@ struct __DRIdrawableRec { __DRIscreen *driScreenPriv; /** - * Controls swap interval as used by GLX_SGI_swap_control and - * GLX_MESA_swap_control. + * Drawable timestamp. Increased when the loader calls invalidate. */ - unsigned int swap_interval; - struct { unsigned int stamp; - drm_clip_rect_t clipRect; } dri2; }; @@ -396,11 +192,6 @@ struct __DRIdrawableRec { * Per-context private driver information. */ 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. */ @@ -447,29 +238,12 @@ 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. * @@ -480,39 +254,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). * @@ -524,23 +265,14 @@ 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 +280,9 @@ 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 ); +dri2InvalidateDrawable(__DRIdrawable *drawable); extern void -dri2InvalidateDrawable(__DRIdrawable *drawable); +driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv); #endif /* _DRI_UTIL_H_ */ diff --git a/mesalib/src/mesa/drivers/dri/common/drirenderbuffer.c b/mesalib/src/mesa/drivers/dri/common/drirenderbuffer.c deleted file mode 100644 index 5e032bd15..000000000 --- a/mesalib/src/mesa/drivers/dri/common/drirenderbuffer.c +++ /dev/null @@ -1,200 +0,0 @@ - -#include "main/mtypes.h" -#include "main/formats.h" -#include "main/renderbuffer.h" -#include "main/imports.h" -#include "drirenderbuffer.h" - - -/** - * This will get called when a window (gl_framebuffer) is resized (probably - * via driUpdateFramebufferSize(), below). - * Just update width, height and internal format fields for now. - * There's usually no memory allocation above because the present - * DRI drivers use statically-allocated full-screen buffers. If that's not - * the case for a DRI driver, a different AllocStorage method should - * be used. - */ -static GLboolean -driRenderbufferStorage(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - rb->Width = width; - rb->Height = height; - rb->InternalFormat = internalFormat; - return GL_TRUE; -} - - -static void -driDeleteRenderbuffer(struct gl_renderbuffer *rb) -{ - /* don't free rb->Data Chances are it's a memory mapped region for - * the dri drivers. - */ - free(rb); -} - - -/** - * Allocate a new driRenderbuffer object. - * Individual drivers are free to implement different versions of - * this function. - * - * At this time, this function can only be used for window-system - * renderbuffers, not user-created RBOs. - * - * \param format Either GL_RGBA, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, - * GL_DEPTH_COMPONENT32, or GL_STENCIL_INDEX8_EXT (for now). - * \param addr address in main memory of the buffer. Probably a memory - * mapped region. - * \param cpp chars or bytes per pixel - * \param offset start of renderbuffer with respect to start of framebuffer - * \param pitch pixels per row - */ -driRenderbuffer * -driNewRenderbuffer(gl_format format, GLvoid *addr, - GLint cpp, GLint offset, GLint pitch, - __DRIdrawable *dPriv) -{ - driRenderbuffer *drb; - - assert(cpp > 0); - assert(pitch > 0); - - drb = calloc(1, sizeof(driRenderbuffer)); - if (drb) { - const GLuint name = 0; - - _mesa_init_renderbuffer(&drb->Base, name); - - /* Make sure we're using a null-valued GetPointer routine */ - assert(drb->Base.GetPointer(NULL, &drb->Base, 0, 0) == NULL); - - switch (format) { - case MESA_FORMAT_ARGB8888: - if (cpp == 2) { - /* override format */ - format = MESA_FORMAT_RGB565; - } - drb->Base.DataType = GL_UNSIGNED_BYTE; - break; - case MESA_FORMAT_Z16: - /* Depth */ - /* we always Get/Put 32-bit Z values */ - drb->Base.DataType = GL_UNSIGNED_INT; - assert(cpp == 2); - break; - case MESA_FORMAT_Z32: - /* Depth */ - /* we always Get/Put 32-bit Z values */ - drb->Base.DataType = GL_UNSIGNED_INT; - assert(cpp == 4); - break; - case MESA_FORMAT_Z24_S8: - drb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - assert(cpp == 4); - break; - case MESA_FORMAT_S8_Z24: - drb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT; - assert(cpp == 4); - break; - case MESA_FORMAT_S8: - /* Stencil */ - drb->Base.DataType = GL_UNSIGNED_BYTE; - break; - default: - _mesa_problem(NULL, "Bad format 0x%x in driNewRenderbuffer", format); - return NULL; - } - - drb->Base.Format = format; - - drb->Base.InternalFormat = - drb->Base._BaseFormat = _mesa_get_format_base_format(format); - - drb->Base.AllocStorage = driRenderbufferStorage; - drb->Base.Delete = driDeleteRenderbuffer; - - drb->Base.Data = addr; - - /* DRI renderbuffer-specific fields: */ - drb->dPriv = dPriv; - drb->offset = offset; - drb->pitch = pitch; - drb->cpp = cpp; - - /* may be changed if page flipping is active: */ - drb->flippedOffset = offset; - drb->flippedPitch = pitch; - drb->flippedData = addr; - } - return drb; -} - - -/** - * Update the front and back renderbuffers' flippedPitch/Offset/Data fields. - * If stereo, flip both the left and right pairs. - * This is used when we do double buffering via page flipping. - * \param fb the framebuffer we're page flipping - * \param flipped if true, set flipped values, else set non-flipped values - */ -void -driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped) -{ - const GLuint count = fb->Visual.stereoMode ? 2 : 1; - GLuint lr; /* left or right */ - - /* we shouldn't really call this function if single-buffered, but - * play it safe. - */ - if (!fb->Visual.doubleBufferMode) - return; - - for (lr = 0; lr < count; lr++) { - GLuint frontBuf = (lr == 0) ? BUFFER_FRONT_LEFT : BUFFER_FRONT_RIGHT; - GLuint backBuf = (lr == 0) ? BUFFER_BACK_LEFT : BUFFER_BACK_RIGHT; - driRenderbuffer *front_drb - = (driRenderbuffer *) fb->Attachment[frontBuf].Renderbuffer; - driRenderbuffer *back_drb - = (driRenderbuffer *) fb->Attachment[backBuf].Renderbuffer; - - if (flipped) { - front_drb->flippedOffset = back_drb->offset; - front_drb->flippedPitch = back_drb->pitch; - front_drb->flippedData = back_drb->Base.Data; - back_drb->flippedOffset = front_drb->offset; - back_drb->flippedPitch = front_drb->pitch; - back_drb->flippedData = front_drb->Base.Data; - } - else { - front_drb->flippedOffset = front_drb->offset; - front_drb->flippedPitch = front_drb->pitch; - front_drb->flippedData = front_drb->Base.Data; - back_drb->flippedOffset = back_drb->offset; - back_drb->flippedPitch = back_drb->pitch; - back_drb->flippedData = back_drb->Base.Data; - } - } -} - - -/** - * Check that the gl_framebuffer associated with dPriv is the right size. - * Resize the gl_framebuffer if needed. - * It's expected that the dPriv->driverPrivate member points to a - * gl_framebuffer object. - */ -void -driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate; - if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) { - ctx->Driver.ResizeBuffers(ctx, fb, dPriv->w, dPriv->h); - /* if the driver needs the hw lock for ResizeBuffers, the drawable - might have changed again by now */ - assert(fb->Width == dPriv->w); - assert(fb->Height == dPriv->h); - } -} diff --git a/mesalib/src/mesa/drivers/dri/common/drirenderbuffer.h b/mesalib/src/mesa/drivers/dri/common/drirenderbuffer.h deleted file mode 100644 index b9065b2dd..000000000 --- a/mesalib/src/mesa/drivers/dri/common/drirenderbuffer.h +++ /dev/null @@ -1,71 +0,0 @@ - -/** - * A driRenderbuffer is dervied from gl_renderbuffer. - * It describes a color buffer (front or back), a depth buffer, or stencil - * buffer etc. - * Specific to DRI drivers are the offset and pitch fields. - */ - - -#ifndef DRIRENDERBUFFER_H -#define DRIRENDERBUFFER_H - -#include "main/mtypes.h" -#include "main/formats.h" -#include "dri_util.h" - - -typedef struct { - struct gl_renderbuffer Base; - - /* Chars or bytes per pixel. If Z and Stencil are stored together this - * will typically be 32 whether this a depth or stencil renderbuffer. - */ - GLint cpp; - - /* Buffer position and pitch (row stride). Recall that for today's DRI - * drivers, we have statically allocated color/depth/stencil buffers. - * So this information describes the whole screen, not just a window. - * To address pixels in a window, we need to know the window's position - * and size with respect to the screen. - */ - GLint offset; /* in bytes */ - GLint pitch; /* in pixels */ - - /* If the driver can do page flipping (full-screen double buffering) - * the current front/back buffers may get swapped. - * If page flipping is disabled, these fields will be identical to - * the offset/pitch/Data above. - * If page flipping is enabled, and this is the front(back) renderbuffer, - * flippedOffset/Pitch/Data will have the back(front) renderbuffer's values. - */ - GLint flippedOffset; - GLint flippedPitch; - GLvoid *flippedData; /* mmap'd address of buffer memory, if used */ - - /* Pointer to corresponding __DRIdrawable. This is used to compute - * the window's position within the framebuffer. - */ - __DRIdrawable *dPriv; - - /* XXX this is for radeon/r200 only. We should really create a new - * r200Renderbuffer class, derived from this class... not a huge deal. - */ - GLboolean depthHasSurface; -} driRenderbuffer; - - -extern driRenderbuffer * -driNewRenderbuffer(gl_format format, GLvoid *addr, - GLint cpp, GLint offset, GLint pitch, - __DRIdrawable *dPriv); - -extern void -driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped); - - -extern void -driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv); - - -#endif /* DRIRENDERBUFFER_H */ diff --git a/mesalib/src/mesa/drivers/dri/common/memops.h b/mesalib/src/mesa/drivers/dri/common/memops.h deleted file mode 100644 index 9cd1d8ec3..000000000 --- a/mesalib/src/mesa/drivers/dri/common/memops.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DRIMEMSETIO_H -#define DRIMEMSETIO_H -/* -* memset an area in I/O space -* We need to be careful about this on some archs -*/ -static INLINE void drimemsetio(void* address, int c, int size) -{ -#if defined(__powerpc__) || defined(__ia64__) - int i; - for(i=0;inumClipRects; \ - while ( _nc-- ) { \ - int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ - int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ - int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ - int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; + int minx = 0; \ + int miny = 0; \ + int maxx = dPriv->w; \ + int maxy = dPriv->h; #endif #ifndef HW_ENDCLIPLOOP #define HW_ENDCLIPLOOP() \ - } \ } while (0) #endif diff --git a/mesalib/src/mesa/drivers/dri/common/texmem.c b/mesalib/src/mesa/drivers/dri/common/texmem.c deleted file mode 100644 index 798ef1ee8..000000000 --- a/mesalib/src/mesa/drivers/dri/common/texmem.c +++ /dev/null @@ -1,1341 +0,0 @@ -/* - * Copyright 2000-2001 VA Linux Systems, Inc. - * (C) Copyright IBM Corporation 2002, 2003 - * 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 - * Keith Whitwell - * Kevin E. Martin - * Gareth Hughes - */ - -/** \file texmem.c - * Implements all of the device-independent texture memory management. - * - * Currently, only a simple LRU texture memory management policy is - * implemented. In the (hopefully very near) future, better policies will be - * implemented. The idea is that the DRI should be able to run in one of two - * modes. In the default mode the DRI will dynamically attempt to discover - * the best texture management policy for the running application. In the - * other mode, the user (via some sort of as yet TBD mechanism) will select - * a texture management policy that is known to work well with the - * application. - */ - -#include "main/imports.h" -#include "main/macros.h" -#include "main/simple_list.h" -#include "texmem.h" - - -static unsigned dummy_swap_counter; - - -/** - * Calculate \f$\log_2\f$ of a value. This is a particularly poor - * implementation of this function. However, since system performance is in - * no way dependent on this function, the slowness of the implementation is - * irrelevent. - * - * \param n Value whose \f$\log_2\f$ is to be calculated - */ - -static GLuint -driLog2( GLuint n ) -{ - GLuint log2; - - for ( log2 = 1 ; n > 1 ; log2++ ) { - n >>= 1; - } - - return log2; -} - - - - -/** - * Determine if a texture is resident in textureable memory. Depending on - * the driver, this may or may not be on-card memory. It could be AGP memory - * or anyother type of memory from which the hardware can directly read - * texels. - * - * This function is intended to be used as the \c IsTextureResident function - * in the device's \c dd_function_table. - * - * \param ctx GL context pointer (currently unused) - * \param texObj Texture object to be tested - */ - -GLboolean -driIsTextureResident( struct gl_context * ctx, - struct gl_texture_object * texObj ) -{ - driTextureObject * t; - - - t = (driTextureObject *) texObj->DriverData; - return( (t != NULL) && (t->memBlock != NULL) ); -} - - - - -/** - * (Re)initialize the global circular LRU list. The last element - * in the array (\a heap->nrRegions) is the sentinal. Keeping it - * at the end of the array allows the other elements of the array - * to be addressed rationally when looking up objects at a particular - * location in texture memory. - * - * \param heap Texture heap to be reset - */ - -static void resetGlobalLRU( driTexHeap * heap ) -{ - drmTextureRegionPtr list = heap->global_regions; - unsigned sz = 1U << heap->logGranularity; - unsigned i; - - for (i = 0 ; (i+1) * sz <= heap->size ; i++) { - list[i].prev = i-1; - list[i].next = i+1; - list[i].age = 0; - } - - i--; - list[0].prev = heap->nrRegions; - list[i].prev = i-1; - list[i].next = heap->nrRegions; - list[heap->nrRegions].prev = i; - list[heap->nrRegions].next = 0; - heap->global_age[0] = 0; -} - -/** - * Print out debugging information about the local texture LRU. - * - * \param heap Texture heap to be printed - * \param callername Name of calling function - */ -static void printLocalLRU( driTexHeap * heap, const char *callername ) -{ - driTextureObject *t; - unsigned sz = 1U << heap->logGranularity; - - fprintf( stderr, "%s in %s:\nLocal LRU, heap %d:\n", - __FUNCTION__, callername, heap->heapId ); - - foreach ( t, &heap->texture_objects ) { - if (!t->memBlock) - continue; - if (!t->tObj) { - fprintf( stderr, "Placeholder (%p) %d at 0x%x sz 0x%x\n", - (void *)t, - t->memBlock->ofs / sz, - t->memBlock->ofs, - t->memBlock->size ); - } else { - fprintf( stderr, "Texture (%p) at 0x%x sz 0x%x\n", - (void *)t, - t->memBlock->ofs, - t->memBlock->size ); - } - } - foreach ( t, heap->swapped_objects ) { - if (!t->tObj) { - fprintf( stderr, "Swapped Placeholder (%p)\n", (void *)t ); - } else { - fprintf( stderr, "Swapped Texture (%p)\n", (void *)t ); - } - } - - fprintf( stderr, "\n" ); -} - -/** - * Print out debugging information about the global texture LRU. - * - * \param heap Texture heap to be printed - * \param callername Name of calling function - */ -static void printGlobalLRU( driTexHeap * heap, const char *callername ) -{ - drmTextureRegionPtr list = heap->global_regions; - unsigned int i, j; - - fprintf( stderr, "%s in %s:\nGlobal LRU, heap %d list %p:\n", - __FUNCTION__, callername, heap->heapId, (void *)list ); - - for ( i = 0, j = heap->nrRegions ; i < heap->nrRegions ; i++ ) { - fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n", - j, list[j].age, list[j].next, list[j].prev, list[j].in_use ); - j = list[j].next; - if ( j == heap->nrRegions ) break; - } - - if ( j != heap->nrRegions ) { - fprintf( stderr, "Loop detected in global LRU\n" ); - for ( i = 0 ; i < heap->nrRegions ; i++ ) { - fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n", - i, list[i].age, list[i].next, list[i].prev, list[i].in_use ); - } - } - - fprintf( stderr, "\n" ); -} - - -/** - * Called by the client whenever it touches a local texture. - * - * \param t Texture object that the client has accessed - */ - -void driUpdateTextureLRU( driTextureObject * t ) -{ - driTexHeap * heap; - drmTextureRegionPtr list; - unsigned shift; - unsigned start; - unsigned end; - unsigned i; - - - heap = t->heap; - if ( heap != NULL ) { - shift = heap->logGranularity; - start = t->memBlock->ofs >> shift; - end = (t->memBlock->ofs + t->memBlock->size - 1) >> shift; - - - heap->local_age = ++heap->global_age[0]; - list = heap->global_regions; - - - /* Update the context's local LRU - */ - - move_to_head( & heap->texture_objects, t ); - - - for (i = start ; i <= end ; i++) { - list[i].age = heap->local_age; - - /* remove_from_list(i) - */ - list[(unsigned)list[i].next].prev = list[i].prev; - list[(unsigned)list[i].prev].next = list[i].next; - - /* insert_at_head(list, i) - */ - list[i].prev = heap->nrRegions; - list[i].next = list[heap->nrRegions].next; - list[(unsigned)list[heap->nrRegions].next].prev = i; - list[heap->nrRegions].next = i; - } - - if ( 0 ) { - printGlobalLRU( heap, __FUNCTION__ ); - printLocalLRU( heap, __FUNCTION__ ); - } - } -} - - - - -/** - * Keep track of swapped out texture objects. - * - * \param t Texture object to be "swapped" out of its texture heap - */ - -void driSwapOutTextureObject( driTextureObject * t ) -{ - unsigned face; - - - if ( t->memBlock != NULL ) { - assert( t->heap != NULL ); - mmFreeMem( t->memBlock ); - t->memBlock = NULL; - - if (t->timestamp > t->heap->timestamp) - t->heap->timestamp = t->timestamp; - - t->heap->texture_swaps[0]++; - move_to_tail( t->heap->swapped_objects, t ); - t->heap = NULL; - } - else { - assert( t->heap == NULL ); - } - - - for ( face = 0 ; face < 6 ; face++ ) { - t->dirty_images[face] = ~0; - } -} - - - - -/** - * Destroy hardware state associated with texture \a t. Calls the - * \a destroy_texture_object method associated with the heap from which - * \a t was allocated. - * - * \param t Texture object to be destroyed - */ - -void driDestroyTextureObject( driTextureObject * t ) -{ - driTexHeap * heap; - - - if ( 0 ) { - fprintf( stderr, "[%s:%d] freeing %p (tObj = %p, DriverData = %p)\n", - __FILE__, __LINE__, - (void *)t, - (void *)((t != NULL) ? t->tObj : NULL), - (void *)((t != NULL && t->tObj != NULL) ? t->tObj->DriverData : NULL )); - } - - if ( t != NULL ) { - if ( t->memBlock ) { - heap = t->heap; - assert( heap != NULL ); - - heap->texture_swaps[0]++; - - mmFreeMem( t->memBlock ); - t->memBlock = NULL; - - if (t->timestamp > t->heap->timestamp) - t->heap->timestamp = t->timestamp; - - heap->destroy_texture_object( heap->driverContext, t ); - t->heap = NULL; - } - - if ( t->tObj != NULL ) { - assert( t->tObj->DriverData == t ); - t->tObj->DriverData = NULL; - } - - remove_from_list( t ); - FREE( t ); - } - - if ( 0 ) { - fprintf( stderr, "[%s:%d] done freeing %p\n", __FILE__, __LINE__, (void *)t ); - } -} - - - - -/** - * Update the local heap's representation of texture memory based on - * data in the SAREA. This is done each time it is detected that some other - * direct rendering client has held the lock. This pertains to both our local - * textures and the textures belonging to other clients. Keep track of other - * client's textures by pushing a placeholder texture onto the LRU list -- - * these are denoted by \a tObj being \a NULL. - * - * \param heap Heap whose state is to be updated - * \param offset Byte offset in the heap that has been stolen - * \param size Size, in bytes, of the stolen block - * \param in_use Non-zero if the block is pinned/reserved by the kernel - */ - -static void driTexturesGone( driTexHeap * heap, int offset, int size, - int in_use ) -{ - driTextureObject * t; - driTextureObject * tmp; - - - foreach_s ( t, tmp, & heap->texture_objects ) { - if ( (t->memBlock->ofs < (offset + size)) - && ((t->memBlock->ofs + t->memBlock->size) > offset) ) { - /* It overlaps - kick it out. If the texture object is just a - * place holder, then destroy it all together. Otherwise, mark - * it as being swapped out. - */ - - if ( t->tObj != NULL ) { - driSwapOutTextureObject( t ); - } - else { - driDestroyTextureObject( t ); - } - } - } - - - { - t = (driTextureObject *) CALLOC( heap->texture_object_size ); - if ( t == NULL ) return; - - t->memBlock = mmAllocMem( heap->memory_heap, size, 0, offset ); - if ( t->memBlock == NULL ) { - fprintf( stderr, "Couldn't alloc placeholder: heap %u sz %x ofs %x\n", heap->heapId, - (int)size, (int)offset ); - mmDumpMemInfo( heap->memory_heap ); - FREE(t); - return; - } - t->heap = heap; - if (in_use) - t->reserved = 1; - insert_at_head( & heap->texture_objects, t ); - } -} - - - - -/** - * Called by the client on lock contention to determine whether textures have - * been stolen. If another client has modified a region in which we have - * textures, then we need to figure out which of our textures have been - * removed and update our global LRU. - * - * \param heap Texture heap to be updated - */ - -void driAgeTextures( driTexHeap * heap ) -{ - drmTextureRegionPtr list = heap->global_regions; - unsigned sz = 1U << (heap->logGranularity); - unsigned i, nr = 0; - - - /* Have to go right round from the back to ensure stuff ends up - * LRU in the local list... Fix with a cursor pointer. - */ - - for (i = list[heap->nrRegions].prev ; - i != heap->nrRegions && nr < heap->nrRegions ; - i = list[i].prev, nr++) { - /* If switching texturing schemes, then the SAREA might not have been - * properly cleared, so we need to reset the global texture LRU. - */ - - if ( (i * sz) > heap->size ) { - nr = heap->nrRegions; - break; - } - - if (list[i].age > heap->local_age) - driTexturesGone( heap, i * sz, sz, list[i].in_use); - } - - /* Loop or uninitialized heap detected. Reset. - */ - - if (nr == heap->nrRegions) { - driTexturesGone( heap, 0, heap->size, 0); - resetGlobalLRU( heap ); - } - - if ( 0 ) { - printGlobalLRU( heap, __FUNCTION__ ); - printLocalLRU( heap, __FUNCTION__ ); - } - - heap->local_age = heap->global_age[0]; -} - - - - -#define INDEX_ARRAY_SIZE 6 /* I'm not aware of driver with more than 2 heaps */ - -/** - * Allocate memory from a texture heap to hold a texture object. This - * routine will attempt to allocate memory for the texture from the heaps - * specified by \c heap_array in order. That is, first it will try to - * allocate from \c heap_array[0], then \c heap_array[1], and so on. - * - * \param heap_array Array of pointers to texture heaps to use - * \param nr_heaps Number of heap pointer in \a heap_array - * \param t Texture object for which space is needed - * \return The ID of the heap from which memory was allocated, or -1 if - * memory could not be allocated. - * - * \bug The replacement policy implemented by this function is horrible. - */ - - -int -driAllocateTexture( driTexHeap * const * heap_array, unsigned nr_heaps, - driTextureObject * t ) -{ - driTexHeap * heap; - driTextureObject * temp; - driTextureObject * cursor; - unsigned id; - - - /* In case it already has texture space, initialize heap. This also - * prevents GCC from issuing a warning that heap might be used - * uninitialized. - */ - - heap = t->heap; - - - /* Run through each of the existing heaps and try to allocate a buffer - * to hold the texture. - */ - - for ( id = 0 ; (t->memBlock == NULL) && (id < nr_heaps) ; id++ ) { - heap = heap_array[ id ]; - if ( heap != NULL ) { - t->memBlock = mmAllocMem( heap->memory_heap, t->totalSize, - heap->alignmentShift, 0 ); - } - } - - - /* Kick textures out until the requested texture fits. - */ - - if ( t->memBlock == NULL ) { - unsigned index[INDEX_ARRAY_SIZE]; - unsigned nrGoodHeaps = 0; - - /* Trying to avoid dynamic memory allocation. If you have more - * heaps, increase INDEX_ARRAY_SIZE. I'm not aware of any - * drivers with more than 2 tex heaps. */ - assert( nr_heaps < INDEX_ARRAY_SIZE ); - - /* Sort large enough heaps by duty. Insertion sort should be - * fast enough for such a short array. */ - for ( id = 0 ; id < nr_heaps ; id++ ) { - heap = heap_array[ id ]; - - if ( heap != NULL && t->totalSize <= heap->size ) { - unsigned j; - - for ( j = 0 ; j < nrGoodHeaps; j++ ) { - if ( heap->duty > heap_array[ index[ j ] ]->duty ) - break; - } - - if ( j < nrGoodHeaps ) { - memmove( &index[ j+1 ], &index[ j ], - sizeof(index[ 0 ]) * (nrGoodHeaps - j) ); - } - - index[ j ] = id; - - nrGoodHeaps++; - } - } - - for ( id = 0 ; (t->memBlock == NULL) && (id < nrGoodHeaps) ; id++ ) { - heap = heap_array[ index[ id ] ]; - - for ( cursor = heap->texture_objects.prev, temp = cursor->prev; - cursor != &heap->texture_objects ; - cursor = temp, temp = cursor->prev ) { - - /* The the LRU element. If the texture is bound to one of - * the texture units, then we cannot kick it out. - */ - if ( cursor->bound || cursor->reserved ) { - continue; - } - - if ( cursor->memBlock ) - heap->duty -= cursor->memBlock->size; - - /* If this is a placeholder, there's no need to keep it */ - if (cursor->tObj) - driSwapOutTextureObject( cursor ); - else - driDestroyTextureObject( cursor ); - - t->memBlock = mmAllocMem( heap->memory_heap, t->totalSize, - heap->alignmentShift, 0 ); - - if (t->memBlock) - break; - } - } - - /* Rebalance duties. If a heap kicked more data than its duty, - * then all other heaps get that amount multiplied with their - * relative weight added to their duty. The negative duty is - * reset to 0. In the end all heaps have a duty >= 0. - * - * CAUTION: we must not change the heap pointer here, because it - * is used below to update the texture object. - */ - for ( id = 0 ; id < nr_heaps ; id++ ) - if ( heap_array[ id ] != NULL && heap_array[ id ]->duty < 0) { - int duty = -heap_array[ id ]->duty; - double weight = heap_array[ id ]->weight; - unsigned j; - - for ( j = 0 ; j < nr_heaps ; j++ ) - if ( j != id && heap_array[ j ] != NULL ) { - heap_array[ j ]->duty += (double) duty * - heap_array[ j ]->weight / weight; - } - - heap_array[ id ]->duty = 0; - } - } - - - if ( t->memBlock != NULL ) { - /* id and heap->heapId may or may not be the same value here. - */ - - assert( heap != NULL ); - assert( (t->heap == NULL) || (t->heap == heap) ); - - t->heap = heap; - return heap->heapId; - } - else { - assert( t->heap == NULL ); - - fprintf( stderr, "[%s:%d] unable to allocate texture\n", - __FUNCTION__, __LINE__ ); - return -1; - } -} - - - - - - -/** - * Set the location where the texture-swap counter is stored. - */ - -void -driSetTextureSwapCounterLocation( driTexHeap * heap, unsigned * counter ) -{ - heap->texture_swaps = (counter == NULL) ? & dummy_swap_counter : counter; -} - - - - -/** - * Create a new heap for texture data. - * - * \param heap_id Device-dependent heap identifier. This value - * will returned by driAllocateTexture when memory - * is allocated from this heap. - * \param context Device-dependent driver context. This is - * supplied as the first parameter to the - * \c destroy_tex_obj function. - * \param size Size, in bytes, of the texture region - * \param alignmentShift Alignment requirement for textures. If textures - * must be allocated on a 4096 byte boundry, this - * would be 12. - * \param nr_regions Number of regions into which this texture space - * should be partitioned - * \param global_regions Array of \c drmTextureRegion structures in the SAREA - * \param global_age Pointer to the global texture age in the SAREA - * \param swapped_objects Pointer to the list of texture objects that are - * not in texture memory (i.e., have been swapped - * out). - * \param texture_object_size Size, in bytes, of a device-dependent texture - * object - * \param destroy_tex_obj Function used to destroy a device-dependent - * texture object - * - * \sa driDestroyTextureHeap - */ - -driTexHeap * -driCreateTextureHeap( unsigned heap_id, void * context, unsigned size, - unsigned alignmentShift, unsigned nr_regions, - drmTextureRegionPtr global_regions, unsigned * global_age, - driTextureObject * swapped_objects, - unsigned texture_object_size, - destroy_texture_object_t * destroy_tex_obj - ) -{ - driTexHeap * heap; - unsigned l; - - - if ( 0 ) - fprintf( stderr, "%s( %u, %p, %u, %u, %u )\n", - __FUNCTION__, - heap_id, (void *)context, size, alignmentShift, nr_regions ); - - heap = (driTexHeap *) CALLOC( sizeof( driTexHeap ) ); - if ( heap != NULL ) { - l = driLog2( (size - 1) / nr_regions ); - if ( l < alignmentShift ) - { - l = alignmentShift; - } - - heap->logGranularity = l; - heap->size = size & ~((1L << l) - 1); - - heap->memory_heap = mmInit( 0, heap->size ); - if ( heap->memory_heap != NULL ) { - heap->heapId = heap_id; - heap->driverContext = context; - - heap->alignmentShift = alignmentShift; - heap->nrRegions = nr_regions; - heap->global_regions = global_regions; - heap->global_age = global_age; - heap->swapped_objects = swapped_objects; - heap->texture_object_size = texture_object_size; - heap->destroy_texture_object = destroy_tex_obj; - - /* Force global heap init */ - if (heap->global_age[0] == 0) - heap->local_age = ~0; - else - heap->local_age = 0; - - make_empty_list( & heap->texture_objects ); - driSetTextureSwapCounterLocation( heap, NULL ); - - heap->weight = heap->size; - heap->duty = 0; - } - else { - FREE( heap ); - heap = NULL; - } - } - - - if ( 0 ) - fprintf( stderr, "%s returning %p\n", __FUNCTION__, (void *)heap ); - - return heap; -} - - - - -/** Destroys a texture heap - * - * \param heap Texture heap to be destroyed - */ - -void -driDestroyTextureHeap( driTexHeap * heap ) -{ - driTextureObject * t; - driTextureObject * temp; - - - if ( heap != NULL ) { - foreach_s( t, temp, & heap->texture_objects ) { - driDestroyTextureObject( t ); - } - foreach_s( t, temp, heap->swapped_objects ) { - driDestroyTextureObject( t ); - } - - mmDestroy( heap->memory_heap ); - FREE( heap ); - } -} - - - - -/****************************************************************************/ -/** - * Determine how many texels (including all mipmap levels) would be required - * for a texture map of size \f$2^^\c base_size_log2\f$ would require. - * - * \param base_size_log2 \f$log_2\f$ of the size of a side of the texture - * \param dimensions Number of dimensions of the texture. Either 2 or 3. - * \param faces Number of faces of the texture. Either 1 or 6 (for cube maps). - * \return Number of texels - */ - -static unsigned -texels_this_map_size( int base_size_log2, unsigned dimensions, unsigned faces ) -{ - unsigned texels; - - - assert( (faces == 1) || (faces == 6) ); - assert( (dimensions == 2) || (dimensions == 3) ); - - texels = 0; - if ( base_size_log2 >= 0 ) { - texels = (1U << (dimensions * base_size_log2)); - - /* See http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg03636.html - * for the complete explaination of why this formulation is used. - * Basically, the smaller mipmap levels sum to 0.333 the size of the - * level 0 map. The total size is therefore the size of the map - * multipled by 1.333. The +2 is there to round up. - */ - - texels = (texels * 4 * faces + 2) / 3; - } - - return texels; -} - - - - -struct maps_per_heap { - unsigned c[32]; -}; - -static void -fill_in_maximums( driTexHeap * const * heaps, unsigned nr_heaps, - unsigned max_bytes_per_texel, unsigned max_size, - unsigned mipmaps_at_once, unsigned dimensions, - unsigned faces, struct maps_per_heap * max_textures ) -{ - unsigned heap; - unsigned log2_size; - unsigned mask; - - - /* Determine how many textures of each size can be stored in each - * texture heap. - */ - - for ( heap = 0 ; heap < nr_heaps ; heap++ ) { - if ( heaps[ heap ] == NULL ) { - (void) memset( max_textures[ heap ].c, 0, - sizeof( max_textures[ heap ].c ) ); - continue; - } - - mask = (1U << heaps[ heap ]->logGranularity) - 1; - - if ( 0 ) { - fprintf( stderr, "[%s:%d] heap[%u] = %u bytes, mask = 0x%08x\n", - __FILE__, __LINE__, - heap, heaps[ heap ]->size, mask ); - } - - for ( log2_size = max_size ; log2_size > 0 ; log2_size-- ) { - unsigned total; - - - /* Determine the total number of bytes required by a texture of - * size log2_size. - */ - - total = texels_this_map_size( log2_size, dimensions, faces ) - - texels_this_map_size( log2_size - mipmaps_at_once, - dimensions, faces ); - total *= max_bytes_per_texel; - total = (total + mask) & ~mask; - - /* The number of textures of a given size that will fit in a heap - * is equal to the size of the heap divided by the size of the - * texture. - */ - - max_textures[ heap ].c[ log2_size ] = heaps[ heap ]->size / total; - - if ( 0 ) { - fprintf( stderr, "[%s:%d] max_textures[%u].c[%02u] " - "= 0x%08x / 0x%08x " - "= %u (%u)\n", - __FILE__, __LINE__, - heap, log2_size, - heaps[ heap ]->size, total, - heaps[ heap ]->size / total, - max_textures[ heap ].c[ log2_size ] ); - } - } - } -} - - -static unsigned -get_max_size( unsigned nr_heaps, - unsigned texture_units, - unsigned max_size, - int all_textures_one_heap, - struct maps_per_heap * max_textures ) -{ - unsigned heap; - unsigned log2_size; - - - /* Determine the largest texture size such that a texture of that size - * can be bound to each texture unit at the same time. Some hardware - * may require that all textures be in the same texture heap for - * multitexturing. - */ - - for ( log2_size = max_size ; log2_size > 0 ; log2_size-- ) { - unsigned total = 0; - - for ( heap = 0 ; heap < nr_heaps ; heap++ ) - { - total += max_textures[ heap ].c[ log2_size ]; - - if ( 0 ) { - fprintf( stderr, "[%s:%d] max_textures[%u].c[%02u] = %u, " - "total = %u\n", __FILE__, __LINE__, heap, log2_size, - max_textures[ heap ].c[ log2_size ], total ); - } - - if ( (max_textures[ heap ].c[ log2_size ] >= texture_units) - || (!all_textures_one_heap && (total >= texture_units)) ) { - /* The number of mipmap levels is the log-base-2 of the - * maximum texture size plus 1. If the maximum texture size - * is 1x1, the log-base-2 is 0 and 1 mipmap level (the base - * level) is available. - */ - - return log2_size + 1; - } - } - } - - /* This should NEVER happen. It should always be possible to have at - * *least* a 1x1 texture in memory! - */ - assert( log2_size != 0 ); - return 0; -} - -#define SET_MAX(f,v) \ - do { if ( max_sizes[v] != 0 ) { limits-> f = max_sizes[v]; } } while( 0 ) - -#define SET_MAX_RECT(f,v) \ - do { if ( max_sizes[v] != 0 ) { limits-> f = 1 << (max_sizes[v] - 1); } } while( 0 ) - - -/** - * Given the amount of texture memory, the number of texture units, and the - * maximum size of a texel, calculate the maximum texture size the driver can - * advertise. - * - * \param heaps Texture heaps for this card - * \param nr_heap Number of texture heaps - * \param limits OpenGL contants. MaxTextureUnits must be set. - * \param max_bytes_per_texel Maximum size of a single texel, in bytes - * \param max_2D_size \f$\log_2\f$ of the maximum 2D texture size (i.e., - * 1024x1024 textures, this would be 10) - * \param max_3D_size \f$\log_2\f$ of the maximum 3D texture size (i.e., - * 1024x1024x1024 textures, this would be 10) - * \param max_cube_size \f$\log_2\f$ of the maximum cube texture size (i.e., - * 1024x1024 textures, this would be 10) - * \param max_rect_size \f$\log_2\f$ of the maximum texture rectangle size - * (i.e., 1024x1024 textures, this would be 10). This is a power-of-2 - * even though texture rectangles need not be a power-of-2. - * \param mipmaps_at_once Total number of mipmaps that can be used - * at one time. For most hardware this will be \f$\c max_size + 1\f$. - * For hardware that does not support mipmapping, this will be 1. - * \param all_textures_one_heap True if the hardware requires that all - * textures be in a single texture heap for multitexturing. - * \param allow_larger_textures 0 conservative, 1 calculate limits - * so at least one worst-case texture can fit, 2 just use hw limits. - */ - -void -driCalculateMaxTextureLevels( driTexHeap * const * heaps, - unsigned nr_heaps, - struct gl_constants * limits, - unsigned max_bytes_per_texel, - unsigned max_2D_size, - unsigned max_3D_size, - unsigned max_cube_size, - unsigned max_rect_size, - unsigned mipmaps_at_once, - int all_textures_one_heap, - int allow_larger_textures ) -{ - struct maps_per_heap max_textures[8]; - unsigned i; - const unsigned dimensions[4] = { 2, 3, 2, 2 }; - const unsigned faces[4] = { 1, 1, 6, 1 }; - unsigned max_sizes[4]; - unsigned mipmaps[4]; - - - max_sizes[0] = max_2D_size; - max_sizes[1] = max_3D_size; - max_sizes[2] = max_cube_size; - max_sizes[3] = max_rect_size; - - mipmaps[0] = mipmaps_at_once; - mipmaps[1] = mipmaps_at_once; - mipmaps[2] = mipmaps_at_once; - mipmaps[3] = 1; - - - /* Calculate the maximum number of texture levels in two passes. The - * first pass determines how many textures of each power-of-two size - * (including all mipmap levels for that size) can fit in each texture - * heap. The second pass finds the largest texture size that allows - * a texture of that size to be bound to every texture unit. - */ - - for ( i = 0 ; i < 4 ; i++ ) { - if ( (allow_larger_textures != 2) && (max_sizes[ i ] != 0) ) { - fill_in_maximums( heaps, nr_heaps, max_bytes_per_texel, - max_sizes[ i ], mipmaps[ i ], - dimensions[ i ], faces[ i ], - max_textures ); - - max_sizes[ i ] = get_max_size( nr_heaps, - allow_larger_textures == 1 ? - 1 : limits->MaxTextureUnits, - max_sizes[ i ], - all_textures_one_heap, - max_textures ); - } - else if (max_sizes[ i ] != 0) { - max_sizes[ i ] += 1; - } - } - - SET_MAX( MaxTextureLevels, 0 ); - SET_MAX( Max3DTextureLevels, 1 ); - SET_MAX( MaxCubeTextureLevels, 2 ); - SET_MAX_RECT( MaxTextureRectSize, 3 ); -} - - - - -/** - * Perform initial binding of default textures objects on a per unit, per - * texture target basis. - * - * \param ctx Current OpenGL context - * \param swapped List of swapped-out textures - * \param targets Bit-mask of value texture targets - */ - -void driInitTextureObjects( struct gl_context *ctx, driTextureObject * swapped, - GLuint targets ) -{ - struct gl_texture_object *texObj; - GLuint tmp = ctx->Texture.CurrentUnit; - unsigned i; - - - for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) { - ctx->Texture.CurrentUnit = i; - - if ( (targets & DRI_TEXMGR_DO_TEXTURE_1D) != 0 ) { - texObj = ctx->Texture.Unit[i].CurrentTex[TEXTURE_1D_INDEX]; - ctx->Driver.BindTexture( ctx, GL_TEXTURE_1D, texObj ); - move_to_tail( swapped, (driTextureObject *) texObj->DriverData ); - } - - if ( (targets & DRI_TEXMGR_DO_TEXTURE_2D) != 0 ) { - texObj = ctx->Texture.Unit[i].CurrentTex[TEXTURE_2D_INDEX]; - ctx->Driver.BindTexture( ctx, GL_TEXTURE_2D, texObj ); - move_to_tail( swapped, (driTextureObject *) texObj->DriverData ); - } - - if ( (targets & DRI_TEXMGR_DO_TEXTURE_3D) != 0 ) { - texObj = ctx->Texture.Unit[i].CurrentTex[TEXTURE_3D_INDEX]; - ctx->Driver.BindTexture( ctx, GL_TEXTURE_3D, texObj ); - move_to_tail( swapped, (driTextureObject *) texObj->DriverData ); - } - - if ( (targets & DRI_TEXMGR_DO_TEXTURE_CUBE) != 0 ) { - texObj = ctx->Texture.Unit[i].CurrentTex[TEXTURE_CUBE_INDEX]; - ctx->Driver.BindTexture( ctx, GL_TEXTURE_CUBE_MAP_ARB, texObj ); - move_to_tail( swapped, (driTextureObject *) texObj->DriverData ); - } - - if ( (targets & DRI_TEXMGR_DO_TEXTURE_RECT) != 0 ) { - texObj = ctx->Texture.Unit[i].CurrentTex[TEXTURE_RECT_INDEX]; - ctx->Driver.BindTexture( ctx, GL_TEXTURE_RECTANGLE_NV, texObj ); - move_to_tail( swapped, (driTextureObject *) texObj->DriverData ); - } - } - - ctx->Texture.CurrentUnit = tmp; -} - - - - -/** - * Verify that the specified texture is in the specificed heap. - * - * \param tex Texture to be tested. - * \param heap Texture memory heap to be tested. - * \return True if the texture is in the heap, false otherwise. - */ - -static GLboolean -check_in_heap( const driTextureObject * tex, const driTexHeap * heap ) -{ -#if 1 - return tex->heap == heap; -#else - driTextureObject * curr; - - foreach( curr, & heap->texture_objects ) { - if ( curr == tex ) { - break; - } - } - - return curr == tex; -#endif -} - - - -/****************************************************************************/ -/** - * Validate the consistency of a set of texture heaps. - * Original version by Keith Whitwell in r200/r200_sanity.c. - */ - -GLboolean -driValidateTextureHeaps( driTexHeap * const * texture_heaps, - unsigned nr_heaps, const driTextureObject * swapped ) -{ - driTextureObject *t; - unsigned i; - - for ( i = 0 ; i < nr_heaps ; i++ ) { - int last_end = 0; - unsigned textures_in_heap = 0; - unsigned blocks_in_mempool = 0; - const driTexHeap * heap = texture_heaps[i]; - const struct mem_block *p = heap->memory_heap; - - /* Check each texture object has a MemBlock, and is linked into - * the correct heap. - * - * Check the texobj base address corresponds to the MemBlock - * range. Check the texobj size (recalculate?) fits within - * the MemBlock. - * - * Count the number of texobj's using this heap. - */ - - foreach ( t, &heap->texture_objects ) { - if ( !check_in_heap( t, heap ) ) { - fprintf( stderr, "%s memory block for texture object @ %p not " - "found in heap #%d\n", - __FUNCTION__, (void *)t, i ); - return GL_FALSE; - } - - - if ( t->totalSize > t->memBlock->size ) { - fprintf( stderr, "%s: Memory block for texture object @ %p is " - "only %u bytes, but %u are required\n", - __FUNCTION__, (void *)t, t->totalSize, t->memBlock->size ); - return GL_FALSE; - } - - textures_in_heap++; - } - - /* Validate the contents of the heap: - * - Ordering - * - Overlaps - * - Bounds - */ - - while ( p != NULL ) { - if (p->reserved) { - fprintf( stderr, "%s: Block (%08x,%x), is reserved?!\n", - __FUNCTION__, p->ofs, p->size ); - return GL_FALSE; - } - - if (p->ofs != last_end) { - fprintf( stderr, "%s: blocks_in_mempool = %d, last_end = %d, p->ofs = %d\n", - __FUNCTION__, blocks_in_mempool, last_end, p->ofs ); - return GL_FALSE; - } - - if (!p->reserved && !p->free) { - blocks_in_mempool++; - } - - last_end = p->ofs + p->size; - p = p->next; - } - - if (textures_in_heap != blocks_in_mempool) { - fprintf( stderr, "%s: Different number of textures objects (%u) and " - "inuse memory blocks (%u)\n", - __FUNCTION__, textures_in_heap, blocks_in_mempool ); - return GL_FALSE; - } - -#if 0 - fprintf( stderr, "%s: textures_in_heap = %u\n", - __FUNCTION__, textures_in_heap ); -#endif - } - - - /* Check swapped texobj's have zero memblocks - */ - i = 0; - foreach ( t, swapped ) { - if ( t->memBlock != NULL ) { - fprintf( stderr, "%s: Swapped texobj %p has non-NULL memblock %p\n", - __FUNCTION__, (void *)t, (void *)t->memBlock ); - return GL_FALSE; - } - i++; - } - -#if 0 - fprintf( stderr, "%s: swapped texture count = %u\n", __FUNCTION__, i ); -#endif - - return GL_TRUE; -} - - - - -/****************************************************************************/ -/** - * Compute which mipmap levels that really need to be sent to the hardware. - * This depends on the base image size, GL_TEXTURE_MIN_LOD, - * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL. - */ - -void -driCalculateTextureFirstLastLevel( driTextureObject * t ) -{ - struct gl_texture_object * const tObj = t->tObj; - const struct gl_texture_image * const baseImage = - tObj->Image[0][tObj->BaseLevel]; - - /* These must be signed values. MinLod and MaxLod can be negative numbers, - * and having firstLevel and lastLevel as signed prevents the need for - * extra sign checks. - */ - int firstLevel; - int lastLevel; - - /* Yes, this looks overly complicated, but it's all needed. - */ - - switch (tObj->Target) { - case GL_TEXTURE_1D: - case GL_TEXTURE_2D: - case GL_TEXTURE_3D: - case GL_TEXTURE_CUBE_MAP: - if (tObj->Sampler.MinFilter == GL_NEAREST || - tObj->Sampler.MinFilter == GL_LINEAR) { - /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL. - */ - - firstLevel = lastLevel = tObj->BaseLevel; - } - else { - firstLevel = tObj->BaseLevel + (GLint)(tObj->Sampler.MinLod + 0.5); - firstLevel = MAX2(firstLevel, tObj->BaseLevel); - firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2); - lastLevel = tObj->BaseLevel + (GLint)(tObj->Sampler.MaxLod + 0.5); - lastLevel = MAX2(lastLevel, t->tObj->BaseLevel); - lastLevel = MIN2(lastLevel, t->tObj->BaseLevel + baseImage->MaxLog2); - lastLevel = MIN2(lastLevel, t->tObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ - } - break; - case GL_TEXTURE_RECTANGLE_NV: - case GL_TEXTURE_4D_SGIS: - firstLevel = lastLevel = 0; - break; - default: - return; - } - - /* save these values */ - t->firstLevel = firstLevel; - t->lastLevel = lastLevel; -} - - - - -/** - * \name DRI texture formats. These vars are initialized to either the - * big- or little-endian Mesa formats. - */ -/*@{*/ -gl_format _dri_texformat_rgba8888 = MESA_FORMAT_NONE; -gl_format _dri_texformat_argb8888 = MESA_FORMAT_NONE; -gl_format _dri_texformat_rgb565 = MESA_FORMAT_NONE; -gl_format _dri_texformat_argb4444 = MESA_FORMAT_NONE; -gl_format _dri_texformat_argb1555 = MESA_FORMAT_NONE; -gl_format _dri_texformat_al88 = MESA_FORMAT_NONE; -gl_format _dri_texformat_a8 = MESA_FORMAT_A8; -gl_format _dri_texformat_i8 = MESA_FORMAT_I8; -gl_format _dri_texformat_l8 = MESA_FORMAT_L8; -/*@}*/ - - -/** - * Initialize _dri_texformat_* vars according to whether we're on - * a big or little endian system. - */ -void -driInitTextureFormats(void) -{ - if (_mesa_little_endian()) { - _dri_texformat_rgba8888 = MESA_FORMAT_RGBA8888; - _dri_texformat_argb8888 = MESA_FORMAT_ARGB8888; - _dri_texformat_rgb565 = MESA_FORMAT_RGB565; - _dri_texformat_argb4444 = MESA_FORMAT_ARGB4444; - _dri_texformat_argb1555 = MESA_FORMAT_ARGB1555; - _dri_texformat_al88 = MESA_FORMAT_AL88; - } - else { - _dri_texformat_rgba8888 = MESA_FORMAT_RGBA8888_REV; - _dri_texformat_argb8888 = MESA_FORMAT_ARGB8888_REV; - _dri_texformat_rgb565 = MESA_FORMAT_RGB565_REV; - _dri_texformat_argb4444 = MESA_FORMAT_ARGB4444_REV; - _dri_texformat_argb1555 = MESA_FORMAT_ARGB1555_REV; - _dri_texformat_al88 = MESA_FORMAT_AL88_REV; - } -} diff --git a/mesalib/src/mesa/drivers/dri/common/texmem.h b/mesalib/src/mesa/drivers/dri/common/texmem.h deleted file mode 100644 index 3815c4107..000000000 --- a/mesalib/src/mesa/drivers/dri/common/texmem.h +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright 2000-2001 VA Linux Systems, Inc. - * (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 - * Keith Whitwell - * Kevin E. Martin - * Gareth Hughes - */ - -/** \file texmem.h - * Public interface to the DRI texture memory management routines. - * - * \sa texmem.c - */ - -#ifndef DRI_TEXMEM_H -#define DRI_TEXMEM_H - -#include "main/mtypes.h" -#include "main/formats.h" -#include "main/mm.h" -#include "xf86drm.h" - -struct dri_tex_heap; -typedef struct dri_tex_heap driTexHeap; - -struct dri_texture_object; -typedef struct dri_texture_object driTextureObject; - - -/** - * Base texture object type. Each driver will extend this type with its own - * private data members. - */ - -struct dri_texture_object { - struct dri_texture_object * next; - struct dri_texture_object * prev; - - driTexHeap * heap; /**< Texture heap currently stored in */ - struct gl_texture_object * tObj;/**< Pointer to Mesa texture object - * If NULL, this texture object is a - * "placeholder" object representing - * texture memory in use by another context. - * A placeholder should have a heap and a memBlock. - */ - struct mem_block *memBlock; /**< Memory block containing texture */ - - unsigned reserved; /**< Cannot be swapped out by user contexts. */ - - unsigned bound; /**< Bitmask indicating which tex units - * this texture object is bound to. - * Bit 0 = unit 0, Bit 1 = unit 1, etc - */ - - unsigned totalSize; /**< Total size of the texture, - * including all mipmap levels - */ - - unsigned dirty_images[6]; /**< Flags for whether or not images - * need to be uploaded to local or - * AGP texture space. One flag set - * for each cube face for cubic - * textures. Bit zero corresponds to - * the base-level, which may or may - * not be the level zero mipmap. - */ - - unsigned timestamp; /**< Timestamp used to - * synchronize with 3d engine - * in hardware where textures - * are uploaded directly to - * the framebuffer. - */ - - unsigned firstLevel; /**< Image in \c tObj->Image[0] that - * corresponds to the base-level of - * this texture object. - */ - - unsigned lastLevel; /**< Last image in \c tObj->Image[0] - * used by the - * current LOD settings of - * this texture object. This - * value must be greater than - * or equal to \c firstLevel. - */ -}; - - -typedef void (destroy_texture_object_t)( void * driverContext, - driTextureObject * t ); - -/** - * Client-private representation of texture memory state. - * - * Clients will place one or more of these structs in their driver - * context struct to manage one or more global texture heaps. - */ - -struct dri_tex_heap { - - /** Client-supplied heap identifier - */ - unsigned heapId; - - /** Pointer to the client's private context - */ - void *driverContext; - - /** Total size of the heap, in bytes - */ - unsigned size; - - /** \brief \f$log_2\f$ of size of single heap region - * - * Each context takes memory from the global texture heap in - * \f$2^{logGranularity}\f$ byte blocks. The value of - * \a logGranularity is based on the amount of memory represented - * by the heap and the maximum number of regions in the SAREA. Given - * \a b bytes of texture memory an \a n regions in the SAREA, - * \a logGranularity will be \f$\lfloor\log_2( b / n )\rfloor\f$. - */ - unsigned logGranularity; - - /** \brief Required alignment of allocations in this heap - * - * The alignment shift is supplied to \a mmAllocMem when memory is - * allocated from this heap. The value of \a alignmentShift will - * typically reflect some require of the hardware. This value has - * \b no \b relation to \a logGranularity. \a alignmentShift is a - * per-context value. - * - * \sa mmAllocMem - */ - unsigned alignmentShift; - - /** Number of elements in global list (the SAREA). - */ - unsigned nrRegions; - - /** Pointer to SAREA \a driTexRegion array - */ - drmTextureRegionPtr global_regions; - - /** Pointer to the texture state age (generation number) in the SAREA - */ - unsigned * global_age; - - /** Local age (generation number) of texture state - */ - unsigned local_age; - - /** Memory heap used to manage texture memory represented by - * this texture heap. - */ - struct mem_block * memory_heap; - - /** List of objects that we currently believe to be in texture - * memory. - */ - driTextureObject texture_objects; - - /** Pointer to the list of texture objects that are not in - * texture memory. - */ - driTextureObject * swapped_objects; - - /** Size of the driver-speicific texture object. - */ - unsigned texture_object_size; - - - /** - * \brief Function to destroy driver-specific texture object data. - * - * This function is supplied by the driver so that the texture manager - * can release all resources associated with a texture object. This - * function should only release driver-specific data. That is, - * \a driDestroyTextureObject will release the texture memory - * associated with the texture object, it will release the memory - * for the texture object itself, and it will unlink the texture - * object from the texture object lists. - * - * \param driverContext Pointer to the driver supplied context - * \param t Texture object that is to be destroyed - * \sa driDestroyTextureObject - */ - - destroy_texture_object_t * destroy_texture_object; - - - /** - */ - unsigned * texture_swaps; - - /** - * Timestamp used to synchronize with 3d engine in hardware - * where textures are uploaded directly to the - * framebuffer. - */ - unsigned timestamp; - - /** \brief Kick/upload weight - * - * When not enough free space is available this weight - * influences the choice of the heap from which textures are - * kicked. By default the weight is equal to the heap size. - */ - double weight; - - /** \brief Kick/upload duty - * - * The heap with the highest duty will be chosen for kicking - * textures if not enough free space is available. The duty is - * reduced by the amount of data kicked. Rebalancing of - * negative duties takes the weights into account. - */ - int duty; -}; - - - - -/** - * Called by the client on lock contention to determine whether textures have - * been stolen. If another client has modified a region in which we have - * textures, then we need to figure out which of our textures have been - * removed and update our global LRU. - * - * \param heap Texture heap to be updated - * \hideinitializer - */ - -#define DRI_AGE_TEXTURES( heap ) \ - do { \ - if ( ((heap) != NULL) \ - && ((heap)->local_age != (heap)->global_age[0]) ) \ - driAgeTextures( heap ); \ - } while( 0 ) - - - - -/* This should be called whenever there has been contention on the hardware - * lock. driAgeTextures should not be called directly. Instead, clients - * should use DRI_AGE_TEXTURES, above. - */ - -void driAgeTextures( driTexHeap * heap ); - -void driUpdateTextureLRU( driTextureObject * t ); -void driSwapOutTextureObject( driTextureObject * t ); -void driDestroyTextureObject( driTextureObject * t ); -int driAllocateTexture( driTexHeap * const * heap_array, unsigned nr_heaps, - driTextureObject * t ); - -GLboolean driIsTextureResident( struct gl_context * ctx, - struct gl_texture_object * texObj ); - -driTexHeap * driCreateTextureHeap( unsigned heap_id, void * context, - unsigned size, unsigned alignmentShift, unsigned nr_regions, - drmTextureRegionPtr global_regions, unsigned * global_age, - driTextureObject * swapped_objects, unsigned texture_object_size, - destroy_texture_object_t * destroy_tex_obj ); -void driDestroyTextureHeap( driTexHeap * heap ); - -void -driCalculateMaxTextureLevels( driTexHeap * const * heaps, - unsigned nr_heaps, - struct gl_constants * limits, - unsigned max_bytes_per_texel, - unsigned max_2D_size, - unsigned max_3D_size, - unsigned max_cube_size, - unsigned max_rect_size, - unsigned mipmaps_at_once, - int all_textures_one_heap, - int allow_larger_textures ); - -void -driSetTextureSwapCounterLocation( driTexHeap * heap, unsigned * counter ); - -#define DRI_TEXMGR_DO_TEXTURE_1D 0x0001 -#define DRI_TEXMGR_DO_TEXTURE_2D 0x0002 -#define DRI_TEXMGR_DO_TEXTURE_3D 0x0004 -#define DRI_TEXMGR_DO_TEXTURE_CUBE 0x0008 -#define DRI_TEXMGR_DO_TEXTURE_RECT 0x0010 - -void driInitTextureObjects( struct gl_context *ctx, driTextureObject * swapped, - GLuint targets ); - -GLboolean driValidateTextureHeaps( driTexHeap * const * texture_heaps, - unsigned nr_heaps, const driTextureObject * swapped ); - -extern void driCalculateTextureFirstLastLevel( driTextureObject * t ); - - -extern gl_format _dri_texformat_rgba8888; -extern gl_format _dri_texformat_argb8888; -extern gl_format _dri_texformat_rgb565; -extern gl_format _dri_texformat_argb4444; -extern gl_format _dri_texformat_argb1555; -extern gl_format _dri_texformat_al88; -extern gl_format _dri_texformat_a8; -extern gl_format _dri_texformat_ci8; -extern gl_format _dri_texformat_i8; -extern gl_format _dri_texformat_l8; - -extern void driInitTextureFormats( void ); - -#endif /* DRI_TEXMEM_H */ diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index 54156d34a..d8656a784 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -137,124 +137,6 @@ driGetRendererString( char * buffer, const char * hardware_name, } -/** - * Utility function used by drivers to test the verions of other components. - * - * \param driver_name Name of the driver. Used in error messages. - * \param driActual Actual DRI version supplied __driCreateNewScreen. - * \param driExpected Minimum DRI version required by the driver. - * \param ddxActual Actual DDX version supplied __driCreateNewScreen. - * \param ddxExpected Minimum DDX minor and range of DDX major version required by the driver. - * \param drmActual Actual DRM version supplied __driCreateNewScreen. - * \param drmExpected Minimum DRM version required by the driver. - * - * \returns \c GL_TRUE if all version requirements are met. Otherwise, - * \c GL_FALSE is returned. - * - * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2 - * - * \todo - * Now that the old \c driCheckDriDdxDrmVersions function is gone, this - * function and \c driCheckDriDdxDrmVersions2 should be renamed. - */ -GLboolean -driCheckDriDdxDrmVersions3(const char * driver_name, - const __DRIversion * driActual, - const __DRIversion * driExpected, - const __DRIversion * ddxActual, - const __DRIutilversion2 * ddxExpected, - const __DRIversion * drmActual, - const __DRIversion * drmExpected) -{ - static const char format[] = "%s DRI driver expected %s version %d.%d.x " - "but got version %d.%d.%d\n"; - static const char format2[] = "%s DRI driver expected %s version %d-%d.%d.x " - "but got version %d.%d.%d\n"; - - - /* Check the DRI version */ - if ( (driActual->major != driExpected->major) - || (driActual->minor < driExpected->minor) ) { - fprintf(stderr, format, driver_name, "DRI", - driExpected->major, driExpected->minor, - driActual->major, driActual->minor, driActual->patch); - return GL_FALSE; - } - - /* Check that the DDX driver version is compatible */ - if ( (ddxActual->major < ddxExpected->major_min) - || (ddxActual->major > ddxExpected->major_max) - || (ddxActual->minor < ddxExpected->minor) ) { - fprintf(stderr, format2, driver_name, "DDX", - ddxExpected->major_min, ddxExpected->major_max, ddxExpected->minor, - ddxActual->major, ddxActual->minor, ddxActual->patch); - return GL_FALSE; - } - - /* Check that the DRM driver version is compatible */ - if ( (drmActual->major != drmExpected->major) - || (drmActual->minor < drmExpected->minor) ) { - fprintf(stderr, format, driver_name, "DRM", - drmExpected->major, drmExpected->minor, - drmActual->major, drmActual->minor, drmActual->patch); - return GL_FALSE; - } - - return GL_TRUE; -} - -GLboolean -driCheckDriDdxDrmVersions2(const char * driver_name, - const __DRIversion * driActual, - const __DRIversion * driExpected, - const __DRIversion * ddxActual, - const __DRIversion * ddxExpected, - const __DRIversion * drmActual, - const __DRIversion * drmExpected) -{ - __DRIutilversion2 ddx_expected; - ddx_expected.major_min = ddxExpected->major; - ddx_expected.major_max = ddxExpected->major; - ddx_expected.minor = ddxExpected->minor; - ddx_expected.patch = ddxExpected->patch; - return driCheckDriDdxDrmVersions3(driver_name, driActual, - driExpected, ddxActual, & ddx_expected, - drmActual, drmExpected); -} - -GLboolean driClipRectToFramebuffer( const struct gl_framebuffer *buffer, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ) -{ - /* left clipping */ - if (*x < buffer->_Xmin) { - *width -= (buffer->_Xmin - *x); - *x = buffer->_Xmin; - } - - /* right clipping */ - if (*x + *width > buffer->_Xmax) - *width -= (*x + *width - buffer->_Xmax - 1); - - if (*width <= 0) - return GL_FALSE; - - /* bottom clipping */ - if (*y < buffer->_Ymin) { - *height -= (buffer->_Ymin - *y); - *y = buffer->_Ymin; - } - - /* top clipping */ - if (*y + *height > buffer->_Ymax) - *height -= (*y + *height - buffer->_Ymax - 1); - - if (*height <= 0) - return GL_FALSE; - - return GL_TRUE; -} - /** * Creates a set of \c struct gl_config that a driver will expose. * diff --git a/mesalib/src/mesa/drivers/dri/common/utils.h b/mesalib/src/mesa/drivers/dri/common/utils.h index 100d0dd51..c2302de5d 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.h +++ b/mesalib/src/mesa/drivers/dri/common/utils.h @@ -39,17 +39,6 @@ struct dri_debug_control { unsigned flag; }; -/** - * Used to store a version which includes a major range instead of a single - * major version number. - */ -struct __DRIutilversionRec2 { - int major_min; /** min allowed Major version number. */ - int major_max; /** max allowed Major version number. */ - int minor; /**< Minor version number. */ - int patch; /**< Patch-level. */ -}; - extern void __driUtilMessage(const char *f, ...); @@ -59,20 +48,6 @@ extern unsigned driParseDebugString( const char * debug, extern unsigned driGetRendererString( char * buffer, const char * hardware_name, GLuint agp_mode ); -extern GLboolean driCheckDriDdxDrmVersions2(const char * driver_name, - const __DRIversion * driActual, const __DRIversion * driExpected, - const __DRIversion * ddxActual, const __DRIversion * ddxExpected, - const __DRIversion * drmActual, const __DRIversion * drmExpected); - -extern GLboolean driCheckDriDdxDrmVersions3(const char * driver_name, - const __DRIversion * driActual, const __DRIversion * driExpected, - const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected, - const __DRIversion * drmActual, const __DRIversion * drmExpected); - -extern GLboolean driClipRectToFramebuffer( const struct gl_framebuffer *buffer, - GLint *x, GLint *y, - GLsizei *width, GLsizei *height ); - struct __DRIconfigRec { struct gl_config modes; }; diff --git a/mesalib/src/mesa/drivers/dri/common/vblank.c b/mesalib/src/mesa/drivers/dri/common/vblank.c deleted file mode 100644 index 3b8136844..000000000 --- a/mesalib/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/mesalib/src/mesa/drivers/dri/common/vblank.h b/mesalib/src/mesa/drivers/dri/common/vblank.h deleted file mode 100644 index c46f4ccc3..000000000 --- a/mesalib/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/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po index 4ea82f901..933a05c04 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po @@ -7,10 +7,11 @@ msgid "" msgstr "" "Project-Id-Version: Mesa 6.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-04-11 23:19+0200\n" +"POT-Creation-Date: 2011-08-30 11:40+0200\n" "PO-Revision-Date: 2005-04-11 01:34+0200\n" "Last-Translator: Felix Kuehling \n" "Language-Team: German \n" +"Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -32,148 +33,148 @@ msgstr "Zeige Performanceboxen" msgid "Image Quality" msgstr "Bildqualität" -#: t_options.h:77 +#: t_options.h:82 msgid "Texture color depth" msgstr "Texturfarbtiefe" -#: t_options.h:78 +#: t_options.h:83 msgid "Prefer frame buffer color depth" msgstr "Bevorzuge Farbtiefe des Framebuffers" -#: t_options.h:79 +#: t_options.h:84 msgid "Prefer 32 bits per texel" msgstr "Bevorzuge 32 bits pro Texel" -#: t_options.h:80 +#: t_options.h:85 msgid "Prefer 16 bits per texel" msgstr "Bevorzuge 16 bits pro Texel" -#: t_options.h:81 +#: t_options.h:86 msgid "Force 16 bits per texel" msgstr "Erzwinge 16 bits pro Texel" -#: t_options.h:87 +#: t_options.h:92 msgid "Initial maximum value for anisotropic texture filtering" msgstr "Initialer Maximalwert für anisotropische Texturfilterung" -#: t_options.h:92 +#: t_options.h:97 msgid "Forbid negative texture LOD bias" msgstr "Verbiete negative Textur-Detailgradverschiebung" -#: t_options.h:97 +#: t_options.h:102 msgid "" "Enable S3TC texture compression even if software support is not available" msgstr "" "Aktiviere S3TC Texturkomprimierung auch wenn die nötige " "Softwareunterstützung fehlt" -#: t_options.h:104 +#: t_options.h:109 msgid "Initial color reduction method" msgstr "Initiale Farbreduktionsmethode" -#: t_options.h:105 +#: t_options.h:110 msgid "Round colors" msgstr "Farben runden" -#: t_options.h:106 +#: t_options.h:111 msgid "Dither colors" msgstr "Farben rastern" -#: t_options.h:114 +#: t_options.h:119 msgid "Color rounding method" msgstr "Farbrundungsmethode" -#: t_options.h:115 +#: t_options.h:120 msgid "Round color components downward" msgstr "Farbkomponenten abrunden" -#: t_options.h:116 +#: t_options.h:121 msgid "Round to nearest color" msgstr "Zur ähnlichsten Farbe runden" -#: t_options.h:125 +#: t_options.h:130 msgid "Color dithering method" msgstr "Farbrasterungsmethode" -#: t_options.h:126 +#: t_options.h:131 msgid "Horizontal error diffusion" msgstr "Horizontale Fehlerstreuung" -#: t_options.h:127 +#: t_options.h:132 msgid "Horizontal error diffusion, reset error at line start" msgstr "Horizontale Fehlerstreuung, Fehler am Zeilenanfang zurücksetzen" -#: t_options.h:128 +#: t_options.h:133 msgid "Ordered 2D color dithering" msgstr "Geordnete 2D Farbrasterung" -#: t_options.h:134 +#: t_options.h:139 msgid "Floating point depth buffer" msgstr "Fließkomma z-Puffer" -#: t_options.h:140 +#: t_options.h:145 msgid "Performance" msgstr "Leistung" -#: t_options.h:148 +#: t_options.h:153 msgid "TCL mode (Transformation, Clipping, Lighting)" msgstr "TCL-Modus (Transformation, Clipping, Licht)" -#: t_options.h:149 +#: t_options.h:154 msgid "Use software TCL pipeline" msgstr "Benutze die Software-TCL-Pipeline" -#: t_options.h:150 +#: t_options.h:155 msgid "Use hardware TCL as first TCL pipeline stage" msgstr "Benutze Hardware TCL als erste Stufe der TCL-Pipeline" -#: t_options.h:151 +#: t_options.h:156 msgid "Bypass the TCL pipeline" msgstr "Umgehe die TCL-Pipeline" -#: t_options.h:152 +#: t_options.h:157 msgid "" "Bypass the TCL pipeline with state-based machine code generated on-the-fly" msgstr "" "Umgehe die TCL-Pipeline mit zur Laufzeit erzeugtem, zustandsbasiertem " "Maschinencode" -#: t_options.h:161 +#: t_options.h:166 msgid "Method to limit rendering latency" msgstr "Methode zur Begrenzung der Bildverzögerung" -#: t_options.h:162 +#: t_options.h:167 msgid "Busy waiting for the graphics hardware" msgstr "Aktives Warten auf die Grafikhardware" -#: t_options.h:163 +#: t_options.h:168 msgid "Sleep for brief intervals while waiting for the graphics hardware" msgstr "Kurze Schlafintervalle beim Warten auf die Grafikhardware" -#: t_options.h:164 +#: t_options.h:169 msgid "Let the graphics hardware emit a software interrupt and sleep" msgstr "" "Die Grafikhardware eine Softwareunterbrechnung erzeugen lassen und schlafen" -#: t_options.h:174 +#: t_options.h:179 msgid "Synchronization with vertical refresh (swap intervals)" msgstr "Synchronisation mit der vertikalen Bildwiederholung" -#: t_options.h:175 +#: t_options.h:180 msgid "Never synchronize with vertical refresh, ignore application's choice" msgstr "" "Niemals mit der Bildwiederholung synchronisieren, Anweisungen der Anwendung " "ignorieren" -#: t_options.h:176 +#: t_options.h:181 msgid "Initial swap interval 0, obey application's choice" msgstr "Initiales Bildinterval 0, Anweisungen der Anwendung gehorchen" -#: t_options.h:177 +#: t_options.h:182 msgid "Initial swap interval 1, obey application's choice" msgstr "Initiales Bildinterval 1, Anweisungen der Anwendung gehorchen" -#: t_options.h:178 +#: t_options.h:183 msgid "" "Always synchronize with vertical refresh, application chooses the minimum " "swap interval" @@ -181,60 +182,100 @@ msgstr "" "Immer mit der Bildwiederholung synchronisieren, Anwendung wählt das minimale " "Bildintervall" -#: t_options.h:186 +#: t_options.h:191 msgid "Use HyperZ to boost performance" msgstr "HyperZ zur Leistungssteigerung verwenden" -#: t_options.h:191 +#: t_options.h:196 +msgid "A post-processing filter to cel-shade the output" +msgstr "Nachbearbeitungsfilter für Cell Shading" + +#: t_options.h:201 +msgid "A post-processing filter to remove the red channel" +msgstr "Nachbearbeitungsfilter zum Entfernen des Rotkanals" + +#: t_options.h:206 +msgid "A post-processing filter to remove the green channel" +msgstr "Nachbearbeitungsfilter zum Entfernen des Grünkanals" + +#: t_options.h:211 +msgid "A post-processing filter to remove the blue channel" +msgstr "Nachbearbeitungsfilter zum Entfernen des Blaukanals" + +#: t_options.h:216 +msgid "" +"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for " +"default quality" +msgstr "Morphologische Kantenglättung (Anti-Aliasing) basierend auf " +"Jimenez\' MLAA. 0 für deaktiviert, 8 für Standardqualität" + +#: t_options.h:221 +msgid "" +"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for " +"default quality. Color version, usable with 2d GL apps" +msgstr "Morphologische Kantenglättung (Anti-Aliasing) basierend auf " +"Jimenez\' MLAA. 0 für deaktiviert, 8 für Standardqualität. " +"Farbversion, für 2D-Anwendungen" + +#: t_options.h:226 msgid "Number of texture units used" msgstr "Anzahl der benutzten Textureinheiten" -#: t_options.h:196 +#: t_options.h:231 msgid "Support larger textures not guaranteed to fit into graphics memory" -msgstr "Unterstütze grosse Texturen die evtl. nicht in den Grafikspeicher passen" +msgstr "" +"Unterstütze grosse Texturen die evtl. nicht in den Grafikspeicher passen" -#: t_options.h:197 +#: t_options.h:232 msgid "No" msgstr "Nein" -#: t_options.h:198 +#: t_options.h:233 msgid "At least 1 texture must fit under worst-case assumptions" msgstr "Mindestens 1 Textur muss auch im schlechtesten Fall Platz haben" -#: t_options.h:199 +#: t_options.h:234 msgid "Announce hardware limits" msgstr "Benutze Hardware-Limits" -#: t_options.h:205 +#: t_options.h:240 msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering" msgstr "" "Texturfilterqualität versus -geschwindigkeit, auch bekannt als „brilineare“ " "Texturfilterung" -#: t_options.h:213 +#: t_options.h:248 msgid "Used types of texture memory" msgstr "Benutzte Arten von Texturspeicher" -#: t_options.h:214 +#: t_options.h:249 msgid "All available memory" msgstr "Aller verfügbarer Speicher" -#: t_options.h:215 +#: t_options.h:250 msgid "Only card memory (if available)" msgstr "Nur Grafikspeicher (falls verfügbar)" -#: t_options.h:216 +#: t_options.h:251 msgid "Only GART (AGP/PCIE) memory (if available)" msgstr "Nur GART-Speicher (AGP/PCIE) (falls verfügbar)" -#: t_options.h:224 +#: t_options.h:259 msgid "Features that are not hardware-accelerated" msgstr "Funktionalität, die nicht hardwarebeschleunigt ist" -#: t_options.h:228 +#: t_options.h:263 msgid "Enable extension GL_ARB_vertex_program" msgstr "Erweiterung GL_ARB_vertex_program aktivieren" -#: t_options.h:233 +#: t_options.h:268 msgid "Enable extension GL_NV_vertex_program" msgstr "Erweiterung GL_NV_vertex_program aktivieren" + +#: t_options.h:273 +msgid "Enable flushing batchbuffer after each draw call" +msgstr "Aktiviere sofortige Leerung des Stapelpuffers nach jedem Zeichenaufruf" + +#: t_options.h:278 +msgid "Enable flushing GPU caches with each draw call" +msgstr "Aktiviere sofortige Leerung der GPU-Zwischenspeicher mit jedem Zeichenaufruf" -- cgit v1.2.3