Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dri_interface.h 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /*
  2. * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
  3. * (C) Copyright IBM Corporation 2004
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * on the rights to use, copy, modify, merge, publish, distribute, sub
  10. * license, and/or sell copies of the Software, and to permit persons to whom
  11. * the Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the next
  14. * paragraph) shall be included in all copies or substantial portions of the
  15. * Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  20. * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  21. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  23. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. /**
  26. * \file dri_interface.h
  27. *
  28. * This file contains all the types and functions that define the interface
  29. * between a DRI driver and driver loader. Currently, the most common driver
  30. * loader is the XFree86 libGL.so. However, other loaders do exist, and in
  31. * the future the server-side libglx.a will also be a loader.
  32. *
  33. * \author Kevin E. Martin <kevin@precisioninsight.com>
  34. * \author Ian Romanick <idr@us.ibm.com>
  35. */
  36. #ifndef DRI_INTERFACE_H
  37. #define DRI_INTERFACE_H
  38. #if 0 /*ndef DRI_NEW_INTERFACE_ONLY*/
  39. # include <X11/X.h>
  40. # include <GL/glx.h>
  41. # include "GL/glxint.h"
  42. #endif
  43. #include <GL/internal/glcore.h>
  44. #include <xf86drm.h>
  45. #include <drm.h>
  46. /**
  47. * \name DRI interface structures
  48. *
  49. * The following structures define the interface between the GLX client
  50. * side library and the DRI (direct rendering infrastructure).
  51. */
  52. /*@{*/
  53. typedef struct __DRIdisplayRec __DRIdisplay;
  54. typedef struct __DRIscreenRec __DRIscreen;
  55. typedef struct __DRIcontextRec __DRIcontext;
  56. typedef struct __DRIdrawableRec __DRIdrawable;
  57. typedef struct __DRIdriverRec __DRIdriver;
  58. typedef struct __DRIframebufferRec __DRIframebuffer;
  59. typedef struct __DRIversionRec __DRIversion;
  60. typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods;
  61. typedef unsigned long __DRIid;
  62. typedef void __DRInativeDisplay;
  63. /*@}*/
  64. /**
  65. * \name Functions provided by the driver loader.
  66. */
  67. /*@{*/
  68. /**
  69. * Type of a pointer to \c glXGetScreenDriver, as returned by
  70. * \c glXGetProcAddress. This function is used to get the name of the DRI
  71. * driver for the specified screen of the specified display. The driver
  72. * name is typically used with \c glXGetDriverConfig.
  73. *
  74. * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig
  75. */
  76. typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum);
  77. /**
  78. * Type of a pointer to \c glXGetDriverConfig, as returned by
  79. * \c glXGetProcAddress. This function is used to get the XML document
  80. * describing the configuration options available for the specified driver.
  81. *
  82. * \sa glXGetDriverConfig, glXGetProcAddress, glXGetScreenDriver
  83. */
  84. typedef const char * (* PFNGLXGETDRIVERCONFIGPROC) (const char *driverName);
  85. /**
  86. * Type of a pointer to \c glxEnableExtension, as returned by
  87. * \c __DRIinterfaceMethods::getProcAddress. This function is used to enable
  88. * a GLX extension on the specified screen.
  89. */
  90. typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name );
  91. /*@}*/
  92. /**
  93. * \name Functions and data provided by the driver.
  94. */
  95. /*@{*/
  96. typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn,
  97. __DRIscreen *psc, const __GLcontextModes * modes,
  98. const __DRIversion * ddx_version, const __DRIversion * dri_version,
  99. const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
  100. void * pSAREA, int fd, int internal_api_version,
  101. const __DRIinterfaceMethods * interface,
  102. __GLcontextModes ** driver_modes);
  103. typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
  104. extern CREATENEWSCREENFUNC __driCreateNewScreen_20050725;
  105. /**
  106. * XML document describing the configuration options supported by the
  107. * driver.
  108. */
  109. extern const char __driConfigOptions[];
  110. /*@}*/
  111. /**
  112. * Stored version of some component (i.e., server-side DRI module, kernel-side
  113. * DRM, etc.).
  114. *
  115. * \todo
  116. * There are several data structures that explicitly store a major version,
  117. * minor version, and patch level. These structures should be modified to
  118. * have a \c __DRIversionRec instead.
  119. */
  120. struct __DRIversionRec {
  121. int major; /**< Major version number. */
  122. int minor; /**< Minor version number. */
  123. int patch; /**< Patch-level. */
  124. };
  125. typedef void (*__DRIfuncPtr)(void);
  126. struct __DRIinterfaceMethodsRec {
  127. /**
  128. * Get pointer to named function.
  129. */
  130. __DRIfuncPtr (*getProcAddress)( const char * proc_name );
  131. /**
  132. * Create a list of \c __GLcontextModes structures.
  133. */
  134. __GLcontextModes * (*createContextModes)(unsigned count,
  135. size_t minimum_bytes_per_struct);
  136. /**
  137. * Destroy a list of \c __GLcontextModes structures.
  138. *
  139. * \todo
  140. * Determine if the drivers actually need to call this.
  141. */
  142. void (*destroyContextModes)( __GLcontextModes * modes );
  143. /**
  144. * Get the \c __DRIscreen for a given display and screen number.
  145. */
  146. __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum);
  147. /**
  148. * \name Client/server protocol functions.
  149. *
  150. * These functions implement the DRI client/server protocol for
  151. * context and drawable operations. Platforms that do not implement
  152. * the wire protocol (e.g., EGL) will implement glorified no-op functions.
  153. */
  154. /*@{*/
  155. /**
  156. * Determine if the specified window ID still exists.
  157. *
  158. * \note
  159. * Implementations may assume that the driver will only pass an ID into
  160. * this function that actually corresponds to a window. On
  161. * implementations where windows can only be destroyed by the DRI driver
  162. * (e.g., EGL), this function is allowed to always return \c GL_TRUE.
  163. */
  164. GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw);
  165. /**
  166. * Create the server-side portion of the GL context.
  167. */
  168. GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum,
  169. int configID, void * contextID, drm_context_t * hw_context );
  170. /**
  171. * Destroy the server-side portion of the GL context.
  172. */
  173. GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum,
  174. __DRIid context );
  175. /**
  176. * Create the server-side portion of the drawable.
  177. */
  178. GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen,
  179. __DRIid drawable, drm_drawable_t * hHWDrawable );
  180. /**
  181. * Destroy the server-side portion of the drawable.
  182. */
  183. GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen,
  184. __DRIid drawable );
  185. /**
  186. * This function is used to get information about the position, size, and
  187. * clip rects of a drawable.
  188. */
  189. GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn,
  190. __DRIid draw, unsigned int * index, unsigned int * stamp,
  191. int * x, int * y, int * width, int * height,
  192. int * numClipRects, drm_clip_rect_t ** pClipRects,
  193. int * backX, int * backY,
  194. int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
  195. /*@}*/
  196. /**
  197. * \name Timing related functions.
  198. */
  199. /*@{*/
  200. /**
  201. * Get the 64-bit unadjusted system time (UST).
  202. */
  203. int (*getUST)(int64_t * ust);
  204. /**
  205. * Get the media stream counter (MSC) rate.
  206. *
  207. * Matching the definition in GLX_OML_sync_control, this function returns
  208. * the rate of the "media stream counter". In practical terms, this is
  209. * the frame refresh rate of the display.
  210. */
  211. GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable,
  212. int32_t * numerator, int32_t * denominator);
  213. /*@}*/
  214. };
  215. /**
  216. * Framebuffer information record. Used by libGL to communicate information
  217. * about the framebuffer to the driver's \c __driCreateNewScreen function.
  218. *
  219. * In XFree86, most of this information is derrived from data returned by
  220. * calling \c XF86DRIGetDeviceInfo.
  221. *
  222. * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
  223. * __driUtilCreateNewScreen CallCreateNewScreen
  224. *
  225. * \bug This structure could be better named.
  226. */
  227. struct __DRIframebufferRec {
  228. unsigned char *base; /**< Framebuffer base address in the CPU's
  229. * address space. This value is calculated by
  230. * calling \c drmMap on the framebuffer handle
  231. * returned by \c XF86DRIGetDeviceInfo (or a
  232. * similar function).
  233. */
  234. int size; /**< Framebuffer size, in bytes. */
  235. int stride; /**< Number of bytes from one line to the next. */
  236. int width; /**< Pixel width of the framebuffer. */
  237. int height; /**< Pixel height of the framebuffer. */
  238. int dev_priv_size; /**< Size of the driver's dev-priv structure. */
  239. void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
  240. };
  241. /**
  242. * Screen dependent methods. This structure is initialized during the
  243. * \c __DRIdisplayRec::createScreen call.
  244. */
  245. struct __DRIscreenRec {
  246. /**
  247. * Method to destroy the private DRI screen data.
  248. */
  249. void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate);
  250. /**
  251. * Method to create the private DRI drawable data and initialize the
  252. * drawable dependent methods.
  253. */
  254. void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
  255. __DRIid draw, __DRIdrawable *pdraw,
  256. int renderType, const int *attrs);
  257. /**
  258. * Method to return a pointer to the DRI drawable data.
  259. */
  260. __DRIdrawable *(*getDrawable)(__DRInativeDisplay *dpy, __DRIid draw,
  261. void *drawablePrivate);
  262. /**
  263. * Opaque pointer to private per screen direct rendering data. \c NULL
  264. * if direct rendering is not supported on this screen. Never
  265. * dereferenced in libGL.
  266. */
  267. void *private;
  268. /**
  269. * Get the number of vertical refreshes since some point in time before
  270. * this function was first called (i.e., system start up).
  271. *
  272. * \since Internal API version 20030317.
  273. */
  274. int (*getMSC)( void *screenPrivate, int64_t *msc );
  275. /**
  276. * Opaque pointer that points back to the containing
  277. * \c __GLXscreenConfigs. This data structure is shared with DRI drivers
  278. * but \c __GLXscreenConfigs is not. However, they are needed by some GLX
  279. * functions called by DRI drivers.
  280. *
  281. * \since Internal API version 20030813.
  282. */
  283. void *screenConfigs;
  284. /**
  285. * Functions associated with MESA_allocate_memory.
  286. *
  287. * \since Internal API version 20030815.
  288. */
  289. /*@{*/
  290. void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size,
  291. GLfloat readfreq, GLfloat writefreq,
  292. GLfloat priority);
  293. void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer);
  294. GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer);
  295. /*@}*/
  296. /**
  297. * Method to create the private DRI context data and initialize the
  298. * context dependent methods.
  299. *
  300. * \since Internal API version 20031201.
  301. */
  302. void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
  303. int render_type,
  304. void *sharedPrivate, __DRIcontext *pctx);
  305. };
  306. /**
  307. * Context dependent methods. This structure is initialized during the
  308. * \c __DRIscreenRec::createContext call.
  309. */
  310. struct __DRIcontextRec {
  311. /**
  312. * Method to destroy the private DRI context data.
  313. */
  314. void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate);
  315. /**
  316. * Opaque pointer to private per context direct rendering data.
  317. * \c NULL if direct rendering is not supported on the display or
  318. * screen used to create this context. Never dereferenced in libGL.
  319. */
  320. void *private;
  321. /**
  322. * Pointer to the mode used to create this context.
  323. *
  324. * \since Internal API version 20040317.
  325. */
  326. const __GLcontextModes * mode;
  327. /**
  328. * Method to bind a DRI drawable to a DRI graphics context.
  329. *
  330. * \since Internal API version 20050725.
  331. */
  332. GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
  333. __DRIid read, __DRIcontext *ctx);
  334. /**
  335. * Method to unbind a DRI drawable from a DRI graphics context.
  336. *
  337. * \since Internal API version 20050725.
  338. */
  339. GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
  340. __DRIid read, __DRIcontext *ctx);
  341. };
  342. /**
  343. * Drawable dependent methods. This structure is initialized during the
  344. * \c __DRIscreenRec::createDrawable call. \c createDrawable is not called
  345. * by libGL at this time. It's currently used via the dri_util.c utility code
  346. * instead.
  347. */
  348. struct __DRIdrawableRec {
  349. /**
  350. * Method to destroy the private DRI drawable data.
  351. */
  352. void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate);
  353. /**
  354. * Method to swap the front and back buffers.
  355. */
  356. void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate);
  357. /**
  358. * Opaque pointer to private per drawable direct rendering data.
  359. * \c NULL if direct rendering is not supported on the display or
  360. * screen used to create this drawable. Never dereferenced in libGL.
  361. */
  362. void *private;
  363. /**
  364. * Get the number of completed swap buffers for this drawable.
  365. *
  366. * \since Internal API version 20030317.
  367. */
  368. int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc );
  369. /**
  370. * Wait for the SBC to be greater than or equal target_sbc.
  371. *
  372. * \since Internal API version 20030317.
  373. */
  374. int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv,
  375. int64_t target_sbc,
  376. int64_t * msc, int64_t * sbc );
  377. /**
  378. * Wait for the MSC to equal target_msc, or, if that has already passed,
  379. * the next time (MSC % divisor) is equal to remainder. If divisor is
  380. * zero, the function will return as soon as MSC is greater than or equal
  381. * to target_msc.
  382. *
  383. * \since Internal API version 20030317.
  384. */
  385. int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv,
  386. int64_t target_msc, int64_t divisor, int64_t remainder,
  387. int64_t * msc, int64_t * sbc );
  388. /**
  389. * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once
  390. * rendering is complete, waits until MSC is equal to target_msc, or
  391. * if that has already passed, waits until (MSC % divisor) is equal
  392. * to remainder. If divisor is zero, the swap will happen as soon as
  393. * MSC is greater than or equal to target_msc.
  394. *
  395. * \since Internal API version 20030317.
  396. */
  397. int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate,
  398. int64_t target_msc,
  399. int64_t divisor, int64_t remainder);
  400. /**
  401. * Enable or disable frame usage tracking.
  402. *
  403. * \since Internal API version 20030317.
  404. */
  405. int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable);
  406. /**
  407. * Retrieve frame usage information.
  408. *
  409. * \since Internal API version 20030317.
  410. */
  411. int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate,
  412. int64_t * sbc, int64_t * missedFrames,
  413. float * lastMissedUsage, float * usage );
  414. /**
  415. * Used by drivers that implement the GLX_SGI_swap_control or
  416. * GLX_MESA_swap_control extension.
  417. *
  418. * \since Internal API version 20030317.
  419. */
  420. unsigned swap_interval;
  421. };
  422. #endif