📄 dri_util.h
字号:
/* $XFree86: xc/lib/GL/dri/dri_util.h,v 1.1 2002/02/22 21:32:52 dawes Exp $ *//** * \file dri_util.h * DRI utility functions definitions. * * This module acts as glue between GLX and the actual hardware driver. A DRI * driver doesn't really \e have to use any of this - it's optional. But, some * useful stuff is done here that otherwise would have to be duplicated in most * drivers. * * Basically, these utility functions take care of some of the dirty details of * screen initialization, context creation, context binding, DRM setup, etc. * * These functions are compiled into each DRI driver so libGL.so knows nothing * about them. * * \sa dri_util.c. * * \author Kevin E. Martin <kevin@precisioninsight.com> * \author Brian Paul <brian@precisioninsight.com> *//* * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. * 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 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 PRECISION INSIGHT AND/OR ITS 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. */#ifndef _DRI_UTIL_H_#define _DRI_UTIL_H_#include <GL/gl.h>#include <drm.h>#include <drm_sarea.h>#include <xf86drm.h>#include "glheader.h"#include "GL/internal/glcore.h"#include "GL/internal/dri_interface.h"#include "GL/internal/dri_sarea.h"#define GLX_BAD_CONTEXT 5typedef struct __DRIswapInfoRec __DRIswapInfo;/* Typedefs to avoid rewriting the world. */typedef struct __DRIscreenRec __DRIscreenPrivate;typedef struct __DRIdrawableRec __DRIdrawablePrivate;typedef struct __DRIcontextRec __DRIcontextPrivate;/** * Extensions. */extern const __DRIlegacyExtension driLegacyExtension;extern const __DRIcoreExtension driCoreExtension;extern const __DRIextension driReadDrawableExtension;extern const __DRIcopySubBufferExtension driCopySubBufferExtension;extern const __DRIswapControlExtension driSwapControlExtension;extern const __DRIframeTrackingExtension driFrameTrackingExtension;extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;/** * 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)/** * Driver callback functions. * * Each DRI driver must have one of these structures with all the pointers set * to appropriate functions within the driver. * * When glXCreateContext() is called, for example, it'll call a helper function * dri_util.c which in turn will jump through the \a CreateContext pointer in * this structure. */struct __DriverAPIRec { const __DRIconfig **(*InitScreen) (__DRIscreen * priv); /** * Screen destruction callback */ void (*DestroyScreen)(__DRIscreen *driScrnPriv); /** * Context creation callback */ GLboolean (*CreateContext)(const __GLcontextModes *glVis, __DRIcontext *driContextPriv, void *sharedContextPrivate); /** * Context destruction callback */ void (*DestroyContext)(__DRIcontext *driContextPriv); /** * Buffer (drawable) creation callback */ GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, __DRIdrawable *driDrawPriv, const __GLcontextModes *glVis, GLboolean pixmapBuffer); /** * Buffer (drawable) destruction callback */ void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); /** * Buffer swapping callback */ void (*SwapBuffers)(__DRIdrawable *driDrawPriv); /** * Context activation callback */ GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, __DRIdrawable *driDrawPriv, __DRIdrawable *driReadPriv); /** * 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 points */ const __DRIconfig **(*InitScreen2) (__DRIscreen * priv); void (*HandleDrawableConfig)(__DRIdrawable *dPriv, __DRIcontext *pcp, __DRIDrawableConfigEvent *event); void (*HandleBufferAttach)(__DRIdrawable *dPriv, __DRIcontext *pcp, __DRIBufferAttachEvent *ba);};extern const struct __DriverAPIRec driDriverAPI;struct __DRIswapInfoRec { /** * Number of swapBuffers operations that have been *completed*. */ u_int64_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. */ u_int64_t swap_missed_count; /** * Amount of time used by the last swap that missed its deadline. This * is calculated as (__glXGetUST() - swap_ust) / (swap_interval * * time_for_single_vrefresh)). If the actual value of swap_interval is * 0, then 1 is used instead. If swap_missed_count is non-zero, this * should be greater-than 1.0. */ float swap_missed_usage;};/** * Per-drawable private DRI driver information. */struct __DRIdrawableRec { /** * Kernel drawable handle */ drm_drawable_t hHWDrawable; /** * Driver's private drawable information. * * This structure is opaque. */ void *driverPrivate; /** * Private data from the loader. We just hold on to it and pass * it back when calling into loader provided functions. */ void *loaderPrivate; /** * Reference count for number of context's currently bound to this * drawable. * * Once it reaches zero, the drawable can be destroyed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -