Clone of mesa.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

dri_interface.h 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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. #ifndef 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 unsigned long __DRIid;
  61. typedef void __DRInativeDisplay;
  62. /*@}*/
  63. /**
  64. * \name Functions provided by the driver loader.
  65. */
  66. /*@{*/
  67. extern __DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn);
  68. /**
  69. * Type of a pointer to \c __glXGetInternalVersion, as returned by
  70. * \c glXGetProcAddress.
  71. *
  72. * \sa __glXGetInternalVersion, glXGetProcAddress
  73. */
  74. typedef int (* PFNGLXGETINTERNALVERSIONPROC) ( void );
  75. /**
  76. * Type of a pointer to \c __glXWindowExists, as returned by
  77. * \c glXGetProcAddress.
  78. *
  79. * \sa __glXWindowExists, glXGetProcAddress
  80. */
  81. typedef GLboolean (* PFNGLXWINDOWEXISTSPROC) (__DRInativeDisplay *dpy, __DRIid draw);
  82. /**
  83. * Type of a pointer to \c __glXGetUST, as returned by \c glXGetProcAddress.
  84. *
  85. * \sa __glXGetUST, glXGetProcAddress
  86. */
  87. typedef int (* PFNGLXGETUSTPROC) ( int64_t * ust );
  88. /**
  89. * Type of pointer to \c __glXCreateContextModes, as returned by
  90. * \c glXGetProcAddress.
  91. *
  92. * \sa _gl_context_modes_create, glXGetProcAddress
  93. */
  94. typedef __GLcontextModes * (* PFNGLXCREATECONTEXTMODES) ( unsigned count,
  95. size_t minimum_bytes_per_struct );
  96. /**
  97. * Type of a pointer to \c glXGetScreenDriver, as returned by
  98. * \c glXGetProcAddress. This function is used to get the name of the DRI
  99. * driver for the specified screen of the specified display. The driver
  100. * name is typically used with \c glXGetDriverConfig.
  101. *
  102. * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig
  103. */
  104. typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum);
  105. /**
  106. * Type of a pointer to \c glXGetDriverConfig, as returned by
  107. * \c glXGetProcAddress. This function is used to get the XML document
  108. * describing the configuration options available for the specified driver.
  109. *
  110. * \sa glXGetDriverConfig, glXGetProcAddress, glXGetScreenDriver
  111. */
  112. typedef const char * (* PFNGLXGETDRIVERCONFIGPROC) (const char *driverName);
  113. /**
  114. * Type of a pointer to \c __glXScrEnableExtension, as returned by
  115. * \c glXGetProcAddress. This function is used to enable a GLX extension
  116. * on the specified screen.
  117. *
  118. * \sa __glXScrEnableExtension, glXGetProcAddress
  119. */
  120. typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name );
  121. /**
  122. * Type of a pointer to \c __glXGetDrawableInfo, as returned by
  123. * \c glXGetProcAddress. This function is used to get information about the
  124. * position, size, and clip rects of a drawable.
  125. *
  126. * \sa __glXGetDrawableInfo, glXGetProcAddress
  127. */
  128. typedef GLboolean (* PFNGLXGETDRAWABLEINFOPROC) ( __DRInativeDisplay *dpy, int scrn,
  129. __DRIid draw, unsigned int * index, unsigned int * stamp,
  130. int * x, int * y, int * width, int * height,
  131. int * numClipRects, drm_clip_rect_t ** pClipRects,
  132. int * backX, int * backY,
  133. int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
  134. /* Test for the xf86dri.h header file */
  135. #ifndef _XF86DRI_H_
  136. extern GLboolean XF86DRIDestroyContext( __DRInativeDisplay *dpy, int screen,
  137. __DRIid context_id );
  138. extern GLboolean XF86DRICreateDrawable( __DRInativeDisplay *dpy, int screen,
  139. __DRIid drawable, drm_drawable_t *hHWDrawable );
  140. extern GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay *dpy, int screen,
  141. __DRIid drawable);
  142. #endif
  143. /*@}*/
  144. /**
  145. * \name Functions and data provided by the driver.
  146. */
  147. /*@{*/
  148. typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn,
  149. __DRIscreen *psc, const __GLcontextModes * modes,
  150. const __DRIversion * ddx_version, const __DRIversion * dri_version,
  151. const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
  152. void * pSAREA, int fd, int internal_api_version,
  153. __GLcontextModes ** driver_modes);
  154. typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
  155. extern CREATENEWSCREENFUNC __driCreateNewScreen;
  156. #ifndef DRI_NEW_INTERFACE_ONLY
  157. extern void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
  158. int numConfigs, __GLXvisualConfig *config);
  159. #endif /* DRI_NEW_INTERFACE_ONLY */
  160. /**
  161. * XML document describing the configuration options supported by the
  162. * driver.
  163. */
  164. extern const char __driConfigOptions[];
  165. /*@}*/
  166. /**
  167. * Stored version of some component (i.e., server-side DRI module, kernel-side
  168. * DRM, etc.).
  169. *
  170. * \todo
  171. * There are several data structures that explicitly store a major version,
  172. * minor version, and patch level. These structures should be modified to
  173. * have a \c __DRIversionRec instead.
  174. */
  175. struct __DRIversionRec {
  176. int major; /**< Major version number. */
  177. int minor; /**< Minor version number. */
  178. int patch; /**< Patch-level. */
  179. };
  180. /**
  181. * Framebuffer information record. Used by libGL to communicate information
  182. * about the framebuffer to the driver's \c __driCreateNewScreen function.
  183. *
  184. * In XFree86, most of this information is derrived from data returned by
  185. * calling \c XF86DRIGetDeviceInfo.
  186. *
  187. * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
  188. * __driUtilCreateNewScreen CallCreateNewScreen
  189. *
  190. * \bug This structure could be better named.
  191. */
  192. struct __DRIframebufferRec {
  193. unsigned char *base; /**< Framebuffer base address in the CPU's
  194. * address space. This value is calculated by
  195. * calling \c drmMap on the framebuffer handle
  196. * returned by \c XF86DRIGetDeviceInfo (or a
  197. * similar function).
  198. */
  199. int size; /**< Framebuffer size, in bytes. */
  200. int stride; /**< Number of bytes from one line to the next. */
  201. int width; /**< Pixel width of the framebuffer. */
  202. int height; /**< Pixel height of the framebuffer. */
  203. int dev_priv_size; /**< Size of the driver's dev-priv structure. */
  204. void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
  205. };
  206. /**
  207. * Screen dependent methods. This structure is initialized during the
  208. * \c __DRIdisplayRec::createScreen call.
  209. */
  210. struct __DRIscreenRec {
  211. /**
  212. * Method to destroy the private DRI screen data.
  213. */
  214. void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate);
  215. /**
  216. * Method to create the private DRI context data and initialize the
  217. * context dependent methods.
  218. *
  219. * \sa __DRIscreenRec::createNewContext driCreateContext
  220. * driCreateNewContext
  221. *
  222. * \deprecated
  223. * This function has been replaced by \c __DRIscreenRec::createNewContext.
  224. * New drivers will continue to export this method, but it will eventually
  225. * (in the next XFree86 major relearse) go away.
  226. */
  227. #ifndef DRI_NEW_INTERFACE_ONLY
  228. void *(*createContext)(Display *dpy, XVisualInfo *vis, void *sharedPrivate,
  229. __DRIcontext *pctx);
  230. #else
  231. void * createContext;
  232. #endif /* DRI_NEW_INTERFACE_ONLY */
  233. /**
  234. * Method to create the private DRI drawable data and initialize the
  235. * drawable dependent methods.
  236. */
  237. void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
  238. __DRIid draw, __DRIdrawable *pdraw,
  239. int renderType, const int *attrs);
  240. /**
  241. * Method to return a pointer to the DRI drawable data.
  242. */
  243. __DRIdrawable *(*getDrawable)(__DRInativeDisplay *dpy, __DRIid draw,
  244. void *drawablePrivate);
  245. /**
  246. * Opaque pointer to private per screen direct rendering data. \c NULL
  247. * if direct rendering is not supported on this screen. Never
  248. * dereferenced in libGL.
  249. */
  250. void *private;
  251. /**
  252. * Get the number of vertical refreshes since some point in time before
  253. * this function was first called (i.e., system start up).
  254. *
  255. * \since Internal API version 20030317.
  256. */
  257. int (*getMSC)( void *screenPrivate, int64_t *msc );
  258. /**
  259. * Opaque pointer that points back to the containing
  260. * \c __GLXscreenConfigs. This data structure is shared with DRI drivers
  261. * but \c __GLXscreenConfigs is not. However, they are needed by some GLX
  262. * functions called by DRI drivers.
  263. *
  264. * \since Internal API version 20030813.
  265. */
  266. void *screenConfigs;
  267. /**
  268. * Functions associated with MESA_allocate_memory.
  269. *
  270. * \since Internal API version 20030815.
  271. */
  272. /*@{*/
  273. void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size,
  274. GLfloat readfreq, GLfloat writefreq,
  275. GLfloat priority);
  276. void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer);
  277. GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer);
  278. /*@}*/
  279. /**
  280. * Method to create the private DRI context data and initialize the
  281. * context dependent methods.
  282. *
  283. * \since Internal API version 20031201.
  284. */
  285. void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
  286. int render_type,
  287. void *sharedPrivate, __DRIcontext *pctx);
  288. };
  289. /**
  290. * Context dependent methods. This structure is initialized during the
  291. * \c __DRIscreenRec::createContext call.
  292. */
  293. struct __DRIcontextRec {
  294. /**
  295. * Method to destroy the private DRI context data.
  296. */
  297. void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate);
  298. /**
  299. * Method to bind a DRI drawable to a DRI graphics context.
  300. *
  301. * \deprecated Replaced by bindContext3.
  302. */
  303. #ifndef DRI_NEW_INTERFACE_ONLY
  304. Bool (*bindContext)(Display *dpy, int scrn, GLXDrawable draw,
  305. GLXContext gc);
  306. #else
  307. void *bindContext;
  308. #endif /* DRI_NEW_INTERFACE_ONLY */
  309. /**
  310. * Method to unbind a DRI drawable to a DRI graphics context.
  311. *
  312. * \deprecated Replaced by unbindContext3.
  313. */
  314. #ifndef DRI_NEW_INTERFACE_ONLY
  315. Bool (*unbindContext)(Display *dpy, int scrn, GLXDrawable draw,
  316. GLXContext gc, int will_rebind);
  317. #else
  318. void *unbindContext;
  319. #endif /* DRI_NEW_INTERFACE_ONLY */
  320. /**
  321. * Opaque pointer to private per context direct rendering data.
  322. * \c NULL if direct rendering is not supported on the display or
  323. * screen used to create this context. Never dereferenced in libGL.
  324. */
  325. void *private;
  326. /**
  327. * Method to bind a DRI drawable to a DRI graphics context.
  328. *
  329. * \since Internal API version 20030606.
  330. * \deprecated Replaced by bindContext3.
  331. */
  332. #ifndef DRI_NEW_INTERFACE_ONLY
  333. Bool (*bindContext2)(Display *dpy, int scrn, GLXDrawable draw,
  334. GLXDrawable read, GLXContext gc);
  335. #else
  336. void *bindContext2;
  337. #endif /* DRI_NEW_INTERFACE_ONLY */
  338. /**
  339. * Method to unbind a DRI drawable from a DRI graphics context.
  340. *
  341. * \since Internal API version 20030606.
  342. * \deprecated Replaced by unbindContext3.
  343. */
  344. #ifndef DRI_NEW_INTERFACE_ONLY
  345. Bool (*unbindContext2)(Display *dpy, int scrn, GLXDrawable draw,
  346. GLXDrawable read, GLXContext gc);
  347. #else
  348. void *unbindContext2;
  349. #endif /* DRI_NEW_INTERFACE_ONLY */
  350. /**
  351. * Pointer to the mode used to create this context.
  352. *
  353. * \since Internal API version 20040317.
  354. */
  355. const __GLcontextModes * mode;
  356. /**
  357. * Method to bind a DRI drawable to a DRI graphics context.
  358. *
  359. * \since Internal API version 20040415.
  360. */
  361. GLboolean (*bindContext3)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
  362. __DRIid read, __DRIcontext *ctx);
  363. /**
  364. * Method to unbind a DRI drawable from a DRI graphics context.
  365. *
  366. * \since Internal API version 20040415.
  367. */
  368. GLboolean (*unbindContext3)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
  369. __DRIid read, __DRIcontext *ctx);
  370. };
  371. /**
  372. * Drawable dependent methods. This structure is initialized during the
  373. * \c __DRIscreenRec::createDrawable call. \c createDrawable is not called
  374. * by libGL at this time. It's currently used via the dri_util.c utility code
  375. * instead.
  376. */
  377. struct __DRIdrawableRec {
  378. /**
  379. * Method to destroy the private DRI drawable data.
  380. */
  381. void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate);
  382. /**
  383. * Method to swap the front and back buffers.
  384. */
  385. void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate);
  386. /**
  387. * Opaque pointer to private per drawable direct rendering data.
  388. * \c NULL if direct rendering is not supported on the display or
  389. * screen used to create this drawable. Never dereferenced in libGL.
  390. */
  391. void *private;
  392. /**
  393. * Get the number of completed swap buffers for this drawable.
  394. *
  395. * \since Internal API version 20030317.
  396. */
  397. int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc );
  398. /**
  399. * Wait for the SBC to be greater than or equal target_sbc.
  400. *
  401. * \since Internal API version 20030317.
  402. */
  403. int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv,
  404. int64_t target_sbc,
  405. int64_t * msc, int64_t * sbc );
  406. /**
  407. * Wait for the MSC to equal target_msc, or, if that has already passed,
  408. * the next time (MSC % divisor) is equal to remainder. If divisor is
  409. * zero, the function will return as soon as MSC is greater than or equal
  410. * to target_msc.
  411. *
  412. * \since Internal API version 20030317.
  413. */
  414. int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv,
  415. int64_t target_msc, int64_t divisor, int64_t remainder,
  416. int64_t * msc, int64_t * sbc );
  417. /**
  418. * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once
  419. * rendering is complete, waits until MSC is equal to target_msc, or
  420. * if that has already passed, waits until (MSC % divisor) is equal
  421. * to remainder. If divisor is zero, the swap will happen as soon as
  422. * MSC is greater than or equal to target_msc.
  423. *
  424. * \since Internal API version 20030317.
  425. */
  426. int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate,
  427. int64_t target_msc,
  428. int64_t divisor, int64_t remainder);
  429. /**
  430. * Enable or disable frame usage tracking.
  431. *
  432. * \since Internal API version 20030317.
  433. */
  434. int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable);
  435. /**
  436. * Retrieve frame usage information.
  437. *
  438. * \since Internal API version 20030317.
  439. */
  440. int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate,
  441. int64_t * sbc, int64_t * missedFrames,
  442. float * lastMissedUsage, float * usage );
  443. /**
  444. * Used by drivers that implement the GLX_SGI_swap_control or
  445. * GLX_MESA_swap_control extension.
  446. *
  447. * \since Internal API version 20030317.
  448. */
  449. unsigned swap_interval;
  450. };
  451. #endif