X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fcommon%2Fdri_util.h;h=900f04853a73498d6a388572429ad9ae95b86094;hb=bdf13dc8324c391b7d34f8bdaea72c4452ab7edb;hp=316afa6285982b999468716d62195907c0e8f14c;hpb=8e6c22136f416b72fef269939f673aa7e55a5d07;p=mesa.git diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 316afa62859..900f04853a7 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -44,24 +44,25 @@ * \author Brian Paul */ +/** + * The following structs are shared between DRISW and DRI2, the DRISW structs + * are essentially base classes of the DRI2 structs. DRISW needs to compile on + * platforms without DRM, so keep the structs opaque to DRM. + */ + #ifndef _DRI_UTIL_H_ #define _DRI_UTIL_H_ #include -#include -#include -#include -#include "xmlconfig.h" -#include "main/glheader.h" +#include #include "main/mtypes.h" -#include "GL/internal/dri_interface.h" - -#define GLX_BAD_CONTEXT 5 +#include "xmlconfig.h" /** * Extensions. */ extern const __DRIcoreExtension driCoreExtension; +extern const __DRIswrastExtension driSWRastExtension; extern const __DRIdri2Extension driDRI2Extension; extern const __DRI2configQueryExtension dri2ConfigQueryExtension; @@ -78,88 +79,39 @@ extern const __DRI2configQueryExtension dri2ConfigQueryExtension; struct __DriverAPIRec { const __DRIconfig **(*InitScreen) (__DRIscreen * priv); - /** - * Screen destruction callback - */ void (*DestroyScreen)(__DRIscreen *driScrnPriv); - /** - * Context creation callback - */ GLboolean (*CreateContext)(gl_api api, - const struct gl_config *glVis, - __DRIcontext *driContextPriv, + const struct gl_config *glVis, + __DRIcontext *driContextPriv, + unsigned major_version, + unsigned minor_version, + uint32_t flags, + unsigned *error, void *sharedContextPrivate); - /** - * Context destruction callback - */ void (*DestroyContext)(__DRIcontext *driContextPriv); - /** - * Buffer (drawable) creation callback - */ GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, __DRIdrawable *driDrawPriv, const struct gl_config *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); - - /** - * 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); __DRIbuffer *(*AllocateBuffer) (__DRIscreen *screenPrivate, - unsigned int attachment, - unsigned int format, - int width, int height); + unsigned int attachment, + unsigned int format, + int width, int height); + void (*ReleaseBuffer) (__DRIscreen *screenPrivate, __DRIbuffer *buffer); }; @@ -167,130 +119,54 @@ extern const struct __DriverAPIRec driDriverAPI; /** - * Per-drawable private DRI driver information. + * Per-screen private 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. - * - * \note This behavior will change with GLX 1.3. - */ - 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, - * 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; - +struct __DRIscreenRec { /** - * \name Drawable - * - * Drawable information used in software fallbacks. + * Current screen's number */ - /*@{*/ - int x; - int y; - int w; - int h; - int numClipRects; - drm_clip_rect_t *pClipRects; - /*@}*/ + int myNum; /** - * \name Back and depthbuffer - * - * Information about the back and depthbuffer where different from above. + * File descriptor returned when the kernel device driver is opened. + * + * Used to: + * - authenticate client to kernel + * - map the frame buffer, SAREA, etc. + * - close the kernel device driver */ - /*@{*/ - int backX; - int backY; - int backClipRectType; - int numBackClipRects; - drm_clip_rect_t *pBackClipRects; - /*@}*/ + int fd; /** - * \name Vertical blank tracking information - * Used for waiting on vertical blank events. + * DRM (kernel module) version information. */ - /*@{*/ - unsigned int vblSeq; - unsigned int vblFlags; - /*@}*/ + __DRIversion drm_version; /** - * \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; + * Device-dependent private information (not stored in the SAREA). + * + * This pointer is never touched by the DRI layer. */ - /*@{*/ - int64_t vblank_base; - int64_t msc_base; - /*@}*/ + void *driverPrivate; - /** - * Pointer to context to which this drawable is currently bound. - */ - __DRIcontext *driContextPriv; + void *loaderPrivate; - /** - * Pointer to screen on which this drawable was created. - */ - __DRIscreen *driScreenPriv; + const __DRIextension **extensions; - /** - * Controls swap interval as used by GLX_SGI_swap_control and - * GLX_MESA_swap_control. - */ - unsigned int swap_interval; + const __DRIswrastLoaderExtension *swrast_loader; struct { - unsigned int stamp; - drm_clip_rect_t clipRect; + /* Flag to indicate that this is a DRI2 screen. Many of the above + * fields will not be valid or initializaed in that case. */ + __DRIdri2LoaderExtension *loader; + __DRIimageLookupExtension *image; + __DRIuseInvalidateExtension *useInvalidate; } dri2; + + driOptionCache optionInfo; + driOptionCache optionCache; + + unsigned int api_mask; }; /** @@ -298,14 +174,14 @@ struct __DRIdrawableRec { */ struct __DRIcontextRec { /** - * Kernel context handle used to access the device lock. + * Device driver's private context data. This structure is opaque. */ - drm_context_t hHWContext; + void *driverPrivate; /** - * Device driver's private context data. This structure is opaque. + * The loaders's private context data. This structure is opaque. */ - void *driverPrivate; + void *loaderPrivate; /** * Pointer to drawable currently bound to this context for drawing. @@ -322,11 +198,6 @@ struct __DRIcontextRec { */ __DRIscreen *driScreenPriv; - /** - * The loaders's private context data. This structure is opaque. - */ - void *loaderPrivate; - struct { int draw_stamp; int read_stamp; @@ -334,125 +205,65 @@ struct __DRIcontextRec { }; /** - * Per-screen private driver information. + * Per-drawable private DRI driver information. */ -struct __DRIscreenRec { - /** - * Current screen's number - */ - int myNum; - +struct __DRIdrawableRec { /** - * Callback functions into the hardware-specific DRI driver code. + * Driver's private drawable information. + * + * This structure is opaque. */ - struct __DriverAPIRec DriverAPI; + void *driverPrivate; - const __DRIextension **extensions; /** - * DDX / 2D driver version information. + * Private data from the loader. We just hold on to it and pass + * it back when calling into loader provided functions. */ - __DRIversion ddx_version; + void *loaderPrivate; /** - * DRI X extension version information. + * Pointer to context to which this drawable is currently bound. */ - __DRIversion dri_version; + __DRIcontext *driContextPriv; /** - * DRM (kernel module) version information. + * Pointer to screen on which this drawable was created. */ - __DRIversion drm_version; + __DRIscreen *driScreenPriv; /** - * ID used when the client sets the drawable lock. + * Reference count for number of context's currently bound to this + * drawable. * - * 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. - * - * Used to: - * - authenticate client to kernel - * - map the frame buffer, SAREA, etc. - * - close the kernel device driver - */ - int fd; - - /** - * SAREA pointer + * Once it reaches zero, the drawable can be destroyed. * - * 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. + * \note This behavior will change with GLX 1.3. */ - /*@{*/ - unsigned char *pFB; - int fbSize; - int fbOrigin; - int fbStride; - int fbWidth; - int fbHeight; - int fbBPP; - /*@}*/ + int refcount; /** - * \name Device-dependent private information (stored in the SAREA). + * Last value of the stamp. * - * This data is accessed by the client driver only. + * 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. */ - /*@{*/ - void *pDevPriv; - int devPrivSize; - /*@}*/ + unsigned int lastStamp; + + int w, h; /** - * Device-dependent private information (not stored in the SAREA). - * - * This pointer is never touched by the DRI layer. + * Drawable timestamp. Increased when the loader calls invalidate. */ -#ifdef __cplusplus - void *priv; -#else - 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; + unsigned int stamp; } dri2; - - /* The lock actually in use, old sarea or DRI2 */ - drmLock *lock; - - driOptionCache optionInfo; - driOptionCache optionCache; - unsigned int api_mask; - void *loaderPrivate; }; -extern float -driCalculateSwapUsage( __DRIdrawable *dPriv, - int64_t last_swap_ust, int64_t current_ust ); - extern void dri2InvalidateDrawable(__DRIdrawable *drawable); +extern void +driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv); + #endif /* _DRI_UTIL_H_ */