internal/dri_interface.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
00003  * (C) Copyright IBM Corporation 2004
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the "Software"),
00008  * to deal in the Software without restriction, including without limitation
00009  * on the rights to use, copy, modify, merge, publish, distribute, sub
00010  * license, and/or sell copies of the Software, and to permit persons to whom
00011  * the Software is furnished to do so, subject to the following conditions:
00012  *
00013  * The above copyright notice and this permission notice (including the next
00014  * paragraph) shall be included in all copies or substantial portions of the
00015  * Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
00020  * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
00021  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
00022  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
00023  * USE OR OTHER DEALINGS IN THE SOFTWARE.
00024  */
00025 
00026 /**
00027  * \file dri_interface.h
00028  *
00029  * This file contains all the types and functions that define the interface
00030  * between a DRI driver and driver loader.  Currently, the most common driver
00031  * loader is the XFree86 libGL.so.  However, other loaders do exist, and in
00032  * the future the server-side libglx.a will also be a loader.
00033  * 
00034  * \author Kevin E. Martin <kevin@precisioninsight.com>
00035  * \author Ian Romanick <idr@us.ibm.com>
00036  */
00037 
00038 #ifndef DRI_INTERFACE_H
00039 #define DRI_INTERFACE_H
00040 
00041 #include <GL/internal/glcore.h>
00042 #include <drm.h>
00043 
00044 /**
00045  * \name DRI interface structures
00046  *
00047  * The following structures define the interface between the GLX client
00048  * side library and the DRI (direct rendering infrastructure).
00049  */
00050 /*@{*/
00051 typedef struct __DRIdisplayRec  __DRIdisplay;
00052 typedef struct __DRIscreenRec   __DRIscreen;
00053 typedef struct __DRIcontextRec  __DRIcontext;
00054 typedef struct __DRIdrawableRec __DRIdrawable;
00055 typedef struct __DRIdriverRec   __DRIdriver;
00056 typedef struct __DRIframebufferRec __DRIframebuffer;
00057 typedef struct __DRIversionRec     __DRIversion;
00058 typedef struct __DRIinterfaceMethodsRec  __DRIinterfaceMethods;
00059 typedef unsigned long __DRIid;
00060 typedef void __DRInativeDisplay;
00061 /*@}*/
00062 
00063 
00064 /**
00065  * \name Functions provided by the driver loader.
00066  */
00067 /*@{*/
00068 /**
00069  * Type of a pointer to \c glXGetScreenDriver, as returned by
00070  * \c glXGetProcAddress.  This function is used to get the name of the DRI
00071  * driver for the specified screen of the specified display.  The driver
00072  * name is typically used with \c glXGetDriverConfig.
00073  *
00074  * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig
00075  */
00076 typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum);
00077 
00078 /**
00079  * Type of a pointer to \c glXGetDriverConfig, as returned by
00080  * \c glXGetProcAddress.  This function is used to get the XML document
00081  * describing the configuration options available for the specified driver.
00082  *
00083  * \sa glXGetDriverConfig, glXGetProcAddress, glXGetScreenDriver
00084  */
00085 typedef const char * (* PFNGLXGETDRIVERCONFIGPROC) (const char *driverName);
00086 
00087 /**
00088  * Type of a pointer to \c glxEnableExtension, as returned by
00089  * \c __DRIinterfaceMethods::getProcAddress.  This function is used to enable
00090  * a GLX extension on the specified screen.
00091  */
00092 typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name );
00093 /*@}*/
00094 
00095 
00096 /**
00097  * \name Functions and data provided by the driver.
00098  */
00099 /*@{*/
00100 
00101 typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn,
00102     __DRIscreen *psc, const __GLcontextModes * modes,
00103     const __DRIversion * ddx_version, const __DRIversion * dri_version,
00104     const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
00105     void * pSAREA, int fd, int internal_api_version,
00106     const __DRIinterfaceMethods * interface,
00107     __GLcontextModes ** driver_modes);
00108 typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
00109 extern CREATENEWSCREENFUNC __driCreateNewScreen_20050727;
00110 
00111 
00112 /**
00113  * XML document describing the configuration options supported by the
00114  * driver.
00115  */
00116 extern const char __driConfigOptions[];
00117 
00118 /*@}*/
00119 
00120 
00121 /**
00122  * Stored version of some component (i.e., server-side DRI module, kernel-side
00123  * DRM, etc.).
00124  * 
00125  * \todo
00126  * There are several data structures that explicitly store a major version,
00127  * minor version, and patch level.  These structures should be modified to
00128  * have a \c __DRIversionRec instead.
00129  */
00130 struct __DRIversionRec {
00131     int    major;        /**< Major version number. */
00132     int    minor;        /**< Minor version number. */
00133     int    patch;        /**< Patch-level. */
00134 };
00135 
00136 
00137 typedef void (*__DRIfuncPtr)(void);
00138 
00139 struct __DRIinterfaceMethodsRec {
00140     /**
00141      * Get pointer to named function.
00142      */
00143     __DRIfuncPtr (*getProcAddress)( const char * proc_name );
00144 
00145     /**
00146      * Create a list of \c __GLcontextModes structures.
00147      */
00148     __GLcontextModes * (*createContextModes)(unsigned count,
00149         size_t minimum_bytes_per_struct);
00150 
00151     /**
00152      * Destroy a list of \c __GLcontextModes structures.
00153      *
00154      * \todo
00155      * Determine if the drivers actually need to call this.
00156      */
00157     void (*destroyContextModes)( __GLcontextModes * modes );
00158 
00159     /**
00160      * Get the \c __DRIscreen for a given display and screen number.
00161      */
00162     __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum);
00163 
00164 
00165     /**
00166      * \name Client/server protocol functions.
00167      *
00168      * These functions implement the DRI client/server protocol for
00169      * context and drawable operations.  Platforms that do not implement
00170      * the wire protocol (e.g., EGL) will implement glorified no-op functions.
00171      */
00172     /*@{*/
00173     /**
00174      * Determine if the specified window ID still exists.
00175      * 
00176      * \note
00177      * Implementations may assume that the driver will only pass an ID into
00178      * this function that actually corresponds to a window.  On
00179      * implementations where windows can only be destroyed by the DRI driver
00180      * (e.g., EGL), this function is allowed to always return \c GL_TRUE.
00181      */
00182     GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw);
00183 
00184     /**
00185      * Create the server-side portion of the GL context.
00186      */
00187     GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum,
00188         int configID, void * contextID, drm_context_t * hw_context );
00189 
00190     /**
00191      * Destroy the server-side portion of the GL context.
00192      */
00193     GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum,
00194         __DRIid context );
00195 
00196     /**
00197      * Create the server-side portion of the drawable.
00198      */
00199     GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen,
00200         __DRIid drawable, drm_drawable_t * hHWDrawable );
00201 
00202     /**
00203      * Destroy the server-side portion of the drawable.
00204      */
00205     GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen,
00206         __DRIid drawable );
00207 
00208     /**
00209      * This function is used to get information about the position, size, and
00210      * clip rects of a drawable.
00211      */
00212     GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn,
00213         __DRIid draw, unsigned int * index, unsigned int * stamp,
00214         int * x, int * y, int * width, int * height,
00215         int * numClipRects, drm_clip_rect_t ** pClipRects,
00216         int * backX, int * backY,
00217         int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
00218     /*@}*/
00219 
00220 
00221     /**
00222      * \name Timing related functions.
00223      */
00224     /*@{*/
00225     /**
00226      * Get the 64-bit unadjusted system time (UST).
00227      */
00228     int (*getUST)(int64_t * ust);
00229 
00230     /**
00231      * Get the media stream counter (MSC) rate.
00232      * 
00233      * Matching the definition in GLX_OML_sync_control, this function returns
00234      * the rate of the "media stream counter".  In practical terms, this is
00235      * the frame refresh rate of the display.
00236      */
00237     GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable,
00238         int32_t * numerator, int32_t * denominator);
00239     /*@}*/
00240 };
00241 
00242    
00243 /**
00244  * Framebuffer information record.  Used by libGL to communicate information
00245  * about the framebuffer to the driver's \c __driCreateNewScreen function.
00246  * 
00247  * In XFree86, most of this information is derrived from data returned by
00248  * calling \c XF86DRIGetDeviceInfo.
00249  *
00250  * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
00251  *     __driUtilCreateNewScreen CallCreateNewScreen
00252  *
00253  * \bug This structure could be better named.
00254  */
00255 struct __DRIframebufferRec {
00256     unsigned char *base;    /**< Framebuffer base address in the CPU's
00257                              * address space.  This value is calculated by
00258                              * calling \c drmMap on the framebuffer handle
00259                              * returned by \c XF86DRIGetDeviceInfo (or a
00260                              * similar function).
00261                              */
00262     int size;               /**< Framebuffer size, in bytes. */
00263     int stride;             /**< Number of bytes from one line to the next. */
00264     int width;              /**< Pixel width of the framebuffer. */
00265     int height;             /**< Pixel height of the framebuffer. */
00266     int dev_priv_size;      /**< Size of the driver's dev-priv structure. */
00267     void *dev_priv;         /**< Pointer to the driver's dev-priv structure. */
00268 };
00269 
00270 
00271 /**
00272  * Screen dependent methods.  This structure is initialized during the
00273  * \c __DRIdisplayRec::createScreen call.
00274  */
00275 struct __DRIscreenRec {
00276     /**
00277      * Method to destroy the private DRI screen data.
00278      */
00279     void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate);
00280 
00281     /**
00282      * Method to create the private DRI drawable data and initialize the
00283      * drawable dependent methods.
00284      */
00285     void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
00286                                __DRIid draw, __DRIdrawable *pdraw,
00287                                int renderType, const int *attrs);
00288 
00289     /**
00290      * Method to return a pointer to the DRI drawable data.
00291      */
00292     __DRIdrawable *(*getDrawable)(__DRInativeDisplay *dpy, __DRIid draw,
00293                                   void *drawablePrivate);
00294 
00295     /**
00296      * Opaque pointer to private per screen direct rendering data.  \c NULL
00297      * if direct rendering is not supported on this screen.  Never
00298      * dereferenced in libGL.
00299      */
00300     void *private;
00301 
00302     /**
00303      * Get the number of vertical refreshes since some point in time before
00304      * this function was first called (i.e., system start up).
00305      * 
00306      * \since Internal API version 20030317.
00307      */
00308     int (*getMSC)( void *screenPrivate, int64_t *msc );
00309 
00310     /**
00311      * Opaque pointer that points back to the containing 
00312      * \c __GLXscreenConfigs.  This data structure is shared with DRI drivers
00313      * but \c __GLXscreenConfigs is not. However, they are needed by some GLX
00314      * functions called by DRI drivers.
00315      *
00316      * \since Internal API version 20030813.
00317      */
00318     void *screenConfigs;
00319 
00320     /**
00321      * Functions associated with MESA_allocate_memory.
00322      *
00323      * \since Internal API version 20030815.
00324      */
00325     /*@{*/
00326     void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size,
00327                             GLfloat readfreq, GLfloat writefreq,
00328                             GLfloat priority);
00329    
00330     void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer);
00331    
00332     GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer);
00333     /*@}*/
00334 
00335     /**
00336      * Method to create the private DRI context data and initialize the
00337      * context dependent methods.
00338      *
00339      * \since Internal API version 20031201.
00340      */
00341     void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
00342                                int render_type,
00343                                void *sharedPrivate, __DRIcontext *pctx);
00344 };
00345 
00346 /**
00347  * Context dependent methods.  This structure is initialized during the
00348  * \c __DRIscreenRec::createContext call.
00349  */
00350 struct __DRIcontextRec {
00351     /**
00352      * Method to destroy the private DRI context data.
00353      */
00354     void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate);
00355 
00356     /**
00357      * Opaque pointer to private per context direct rendering data.
00358      * \c NULL if direct rendering is not supported on the display or
00359      * screen used to create this context.  Never dereferenced in libGL.
00360      */
00361     void *private;
00362 
00363     /**
00364      * Pointer to the mode used to create this context.
00365      *
00366      * \since Internal API version 20040317.
00367      */
00368     const __GLcontextModes * mode;
00369 
00370     /**
00371      * Method to bind a DRI drawable to a DRI graphics context.
00372      *
00373      * \since Internal API version 20050727.
00374      */
00375     GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
00376                          __DRIid read, __DRIcontext *ctx);
00377 
00378     /**
00379      * Method to unbind a DRI drawable from a DRI graphics context.
00380      *
00381      * \since Internal API version 20050727.
00382      */
00383     GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
00384                            __DRIid read, __DRIcontext *ctx);
00385 };
00386 
00387 /**
00388  * Drawable dependent methods.  This structure is initialized during the
00389  * \c __DRIscreenRec::createDrawable call.  \c createDrawable is not called
00390  * by libGL at this time.  It's currently used via the dri_util.c utility code
00391  * instead.
00392  */
00393 struct __DRIdrawableRec {
00394     /**
00395      * Method to destroy the private DRI drawable data.
00396      */
00397     void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate);
00398 
00399     /**
00400      * Method to swap the front and back buffers.
00401      */
00402     void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate);
00403 
00404     /**
00405      * Opaque pointer to private per drawable direct rendering data.
00406      * \c NULL if direct rendering is not supported on the display or
00407      * screen used to create this drawable.  Never dereferenced in libGL.
00408      */
00409     void *private;
00410 
00411     /**
00412      * Get the number of completed swap buffers for this drawable.
00413      *
00414      * \since Internal API version 20030317.
00415      */
00416     int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc );
00417 
00418     /**
00419      * Wait for the SBC to be greater than or equal target_sbc.
00420      *
00421      * \since Internal API version 20030317.
00422      */
00423     int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv,
00424                        int64_t target_sbc,
00425                        int64_t * msc, int64_t * sbc );
00426 
00427     /**
00428      * Wait for the MSC to equal target_msc, or, if that has already passed,
00429      * the next time (MSC % divisor) is equal to remainder.  If divisor is
00430      * zero, the function will return as soon as MSC is greater than or equal
00431      * to target_msc.
00432      * 
00433      * \since Internal API version 20030317.
00434      */
00435     int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv,
00436                        int64_t target_msc, int64_t divisor, int64_t remainder,
00437                        int64_t * msc, int64_t * sbc );
00438 
00439     /**
00440      * Like \c swapBuffers, but does NOT have an implicit \c glFlush.  Once
00441      * rendering is complete, waits until MSC is equal to target_msc, or
00442      * if that has already passed, waits until (MSC % divisor) is equal
00443      * to remainder.  If divisor is zero, the swap will happen as soon as
00444      * MSC is greater than or equal to target_msc.
00445      * 
00446      * \since Internal API version 20030317.
00447      */
00448     int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate,
00449                               int64_t target_msc,
00450                               int64_t divisor, int64_t remainder);
00451 
00452     /**
00453      * Enable or disable frame usage tracking.
00454      * 
00455      * \since Internal API version 20030317.
00456      */
00457     int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable);
00458 
00459     /**
00460      * Retrieve frame usage information.
00461      * 
00462      * \since Internal API version 20030317.
00463      */
00464     int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate,
00465                               int64_t * sbc, int64_t * missedFrames,
00466                               float * lastMissedUsage, float * usage );
00467 
00468     /**
00469      * Used by drivers that implement the GLX_SGI_swap_control or
00470      * GLX_MESA_swap_control extension.
00471      *
00472      * \since Internal API version 20030317.
00473      */
00474     unsigned swap_interval;
00475 };
00476 
00477 #endif

Generated on Sun Jul 29 04:01:04 2012 for TerraLib - Development Source by  doxygen 1.5.3